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!
+ Reply to Thread
Results 1 to 7 of 7
-
-
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 -
@ 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] -
Read about segment http://www.ffmpeg.org/ffmpeg-formats.html#segment_002c-stream_005fsegment_002c-ssegment - perhaps it will be useful for you.
-
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)
-
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)
-
"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
Similar Threads
-
Can ffmpeg use frame numbers to cut a video?
By yetanotherlogin in forum EditingReplies: 4Last Post: 26th Jan 2015, 05:12 -
A little confused on ffmpeg syntax with regards to the "-q" parameter.
By Iced Coffee in forum Video ConversionReplies: 4Last Post: 21st Jan 2013, 01:04 -
merge multiple mp4(h264) video the time frame get reduce by 10%
By redsunbird in forum Video ConversionReplies: 2Last Post: 15th Dec 2012, 03:32 -
FFmpeg video split frame missing
By mrahmet in forum EditingReplies: 2Last Post: 5th Dec 2012, 01:40 -
GPU encoding considered not ready for prime time
By jman98 in forum Newbie / General discussionsReplies: 18Last Post: 15th May 2012, 06:33