View Single Post
Old 27th July 2016, 14:27   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Quote:
One idea is to either sense (don't know how to do this) or at least mark the start of each GOP
Further to above:

Script to Create DBase where for each record(frame) there are 3 int fields, 0) frame status, 1) frameNo of prev I frame, 2) frameNo of Next I frame.
Code:
# https://forum.doom9.org/showthread.php?p=1775535#post1775535

Function DB_Write(string DB,int n,int type) {
    RT_DBaseSet(DB,n,Type,Glb_PrevIFrame,-1)
    GSCript("""
        if(Type==73) {                                      # I frame
            if(Glb_PrevIFrame>=0) {
                for(i=Glb_PrevIFrame,n-1) {
                    RT_DBaseSetField(DB,i,2,n)              # Set all previous GOP frames 'Next I frame field' to current frame n
                }
            }
            Global Glb_PrevIFrame=n                         # Remember current frame as previous I frame when at following frames
        }
    """)
    return 0
}

#Loadplugin("ffms2.dll")
Import("ffms2.avsi")           # May need path if not in current directory

FN="K:\TESTAVI\big_buck_bunny_720p_h264.mov"
FFmpegSource2(FN)

DB = "Meyer.DB"
DB=RT_GetFullPathName(DB)

SHOW =True
FORCE=true                              # Use ForceProcessAVI
Global Glb_PrevIFrame = -1              # Unset
RT_DbaseAlloc(DB,Framecount,"iii")      # FrameCount Records, 3 fields of type int,
                                        #  Field 0) CAPS character code of current frame(record), ie 'I'=73, 'P'=80, 'B'=66.
                                        #  Field 1) frame number(record) of previous I frame
                                        #  Field 2) frame number(record) of next I frame

SSS="""
    FrameType = FFPICT_TYPE                         # Have to use FFPICT_TYPE from main level script, not global.
    (Show&&!FORCE) ? RT_Subtitle("%d] %c Prev=%d ",current_frame,FrameType,Glb_PrevIFrame) : NOP
    DB_Write(DB,current_frame,FrameType)            # function as we want GScript
    return last
"""

ScriptClip(SSS,after_frame=true)

(FORCE)?ForceProcessAVI():NOP                      # From TWriteAVI, Fast creation of DBase (or RT_ForceProcess from RT_ v2.0)

Return Last

And DBase Viewer/Checker
Code:
#Loadplugin("ffms2.dll")
Import("ffms2.avsi")       # May need path if not in current directory

FN="K:\TESTAVI\big_buck_bunny_720p_h264.mov"
FFmpegSource2(FN)

DB="Meyer.DB"
DB=RT_GetFullPathName(DB)

SSS="""
    n=current_frame
    typ=RT_DBaseGetField(DB,n,0)
    prv=RT_DBaseGetField(DB,n,1)
    nxt=RT_DBaseGetField(DB,n,2)
    RT_Subtitle("%d] %c PrevI=%d NextI=%d",n,typ,prv,nxt)
    return last
"""

ScriptClip(SSS)
return last
I have not as yet downloaded your clip, so I used a mov that I do have.

EDIT: Req, RT_ Gscript (and TwriteAVI v2.0 if required).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 25th April 2017 at 16:45.
StainlessS is offline   Reply With Quote