VideoHelp Forum




+ Reply to Thread
Results 1 to 7 of 7
  1. Hi

    I am newbie and appreciate all the help i can get in understanding better . I would like to split a .mp4 video at exactly b-frames and i know i need to use -ss option in ffmpeg and specify exact time at which i need the splitting to happen.

    I also used the ffprobe to see the frames for a given video . But i donot know which time parameter (dts/pts ) to be considered while giving it as a value to -ss flag in ffmpeg .

    for eg :

    [FRAME]
    media_type=video
    stream_index=0
    key_frame=1
    pkt_pts=2000
    pkt_pts_time=0.083333
    pkt_dts=2000
    pkt_dts_time=0.083333
    best_effort_timestamp=2000
    best_effort_timestamp_time=0.083333
    pkt_duration=N/A
    pkt_duration_time=N/A
    pkt_pos=3891678
    pkt_size=797
    width=320
    height=240
    pix_fmt=yuv420p
    sample_aspect_ratio=4:3
    pict_type=I
    coded_picture_number=0
    display_picture_number=0
    interlaced_frame=0
    top_field_first=0
    repeat_pict=0
    [/FRAME]

    Also, how do i display the above time in hh::mm:s format as the time given in the above frame is a very small value ?

    Thanks in Advance for teaching me!
    Quote Quote  
  2. Originally Posted by db2t4 View Post
    I would like to split a .mp4 video at exactly b-frames and i know i need to use -ss option in ffmpeg and specify exact time at which i need the splitting to happen.
    It's not possible to be precise or exact with splitting and stream copy when using long GOP formats . Cuts must be on GOP boundaries (ie. preceding the next IDR frame). If you enter the wrong value, ffmpeg will jump to the nearest keyframe anyways . You cannot interrupt a GOP, because frames can rely on data from other frames (each frame isn't necessarily independent, unlike intra-only or I-frame formats)

    If you meant split and re-encode then it can be precise if you use -ss as an input option (preceding the -i ) , then it would use the normal display timestamp. In your example, frame zero is both the coded and display frame zero, so it's the very first frame. So you wouldn't need to enter -ss because it's the very start
    Quote Quote  
  3. @ poisondeathray : Thank you, how about i pick a b-frame somewhere in the middle , i am not clear about which timestamp to use for splitting and re-encoding. Also if you could tell me what does best_effort_timestamp indicate here?


    [FRAME]
    media_type=video
    stream_index=0
    key_frame=0
    pkt_pts=39000
    pkt_pts_time=1.625000
    pkt_dts=40000
    pkt_dts_time=1.666667
    best_effort_timestamp=40000
    best_effort_timestamp_time=1.666667
    pkt_duration=1000
    pkt_duration_time=0.041667
    pkt_pos=3916119
    pkt_size=156
    width=320
    height=240
    pix_fmt=yuv420p
    sample_aspect_ratio=4:3
    pict_type=B
    coded_picture_number=39
    display_picture_number=0
    interlaced_frame=0
    top_field_first=0
    repeat_pict=0
    [/FRAME]
    Quote Quote  
  4. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    You can use an AVISynth script to display the frames and times. I use Potplayer because it allows step forward and backward but any player that will allow this and honor Avisynth will work.

    Script is thus

    Code:
    DirectShowSource(("C:\Users\Bud\Desktop\Various test Formats\both.mp4"), Pixel_Type="yuy2").Crop(0,0,-0,-0)
    Subtitle("C:\Users\Bud\Desktop\Various test Formats\both.mp4", x=640, y=200, font="Arial", size=24, text_color=$ff0000, align=3)
    ShowFrameNumber(scroll=true, x=10, y=27, font="Arial", size=24, text_color=$ff0000)
    ShowTime(x=72, y=44, font="Arial", size=24, text_color=$ff0000)
    ShowSMPTE(fps=30, x=68, y=61, font="Arial", size=24, text_color=$ff0000)
    Results in Click image for larger version

Name:	ScreenHunter_200 Oct. 25 22.37.jpg
Views:	434
Size:	85.7 KB
ID:	39051
    Quote Quote  
  5. AviSynth+FFMS2 can display the frame type (I/B/P) as well.
    Code:
    FFmpegSource(<path>) 
    ScriptClip(Last, """Subtitle("[ "+Chr(FFPICT_TYPE)+" ]", size=(Height*56.0/720), align=2)""", after_frame=true)
    But (as others have said) you can't split on B-frames without re-encoding -- or smart rendering, which is limited re-encoding.
    Quote Quote  
  6. Originally Posted by db2t4 View Post
    @ poisondeathray : Thank you, how about i pick a b-frame somewhere in the middle , i am not clear about which timestamp to use for splitting and re-encoding. Also if you could tell me what does best_effort_timestamp indicate here?


    [FRAME]
    media_type=video
    stream_index=0
    key_frame=0
    pkt_pts=39000
    pkt_pts_time=1.625000
    pkt_dts=40000
    pkt_dts_time=1.666667
    best_effort_timestamp=40000
    best_effort_timestamp_time=1.666667
    pkt_duration=1000
    pkt_duration_time=0.041667
    pkt_pos=3916119
    pkt_size=156
    width=320
    height=240
    pix_fmt=yuv420p
    sample_aspect_ratio=4:3
    pict_type=B
    coded_picture_number=39
    display_picture_number=0
    interlaced_frame=0
    top_field_first=0
    repeat_pict=0
    [/FRAME]



    "split at b-frame" is ambiguous, because each frame has a duration - did you want to include or exclude the frame? (cut before the frame to include, or cut after the frame to exclude)

    Assuming you want to include, in your example, that frame starts at 1.625 (you would convert to hh:mms.ms notation, so -ss 00:00:01.625)

    DTS/PTS calculations have been revised several times for ffmpeg /libav over time, and typically "best effort" is the fall back calculation when the video timestamps do not increase normally or show a zero value beyond the 1st frame. In the past , they just took the DTS value, but now I'm not sure how it's calculated they keep on revising it.

    rr42's ffms2 suggestion is actually more reliable than using ffmpeg CLI , because it indexes the video. There is a helper function ffinfo() that overlays the CFR/VFR time and frame type
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!