Using -ss as input option together with -c:v copy might not be accurate since ffmpeg is forced to only use/split on i-frames. Though it will—if possible—adjust the start time of the stream to a negative value to compensate for that. Basically, if you specify "second 157" and there is no key frame until second 159, it will include two seconds of audio (with no video) at the start, then will start from the first key frame. So be careful when splitting and doing codec copy.
To avoid this, I’ve tried first finding the timestamps of the frames needed for -ss and -to by building a tile of all nearby frames. I’ve generated the tiles using
ffmpeg -i "INPUT.mkv" -ss 09:55 -t 3 -vf "drawtext=fontfile=I\:Misc\\~Software\\~OS\\I386\\arial.ttf: fontsize=60: text='F%{n}(%{pict_type})@%{pts:hms}': x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1,scale=320:-1,tile=layout=12x10" tiles%03d.png
and according to them the needed keyframe should be starting from 00:09:56.012, and the last needed frame should be at 00:10:00.224. However, the fragment created when cutting with these timestamps
ffmpeg -i "INPUT.mkv" -map 0:0 -map 0:4 -map 0:5 -map 0:6 -ss 09:56.012 -to 00:10:00.224 -vcodec copy -acodec copy J01.mkv
starts at a non-key frame (sound only) and ends at a wrong place as well. In contrast, cutting the same fragment in Avidemux works fine even with Video- and Audio-output settings set to Copy (IIUC, no re-encoding and start from a no-key frame). Displayed timestamps in Avidemux are also different (-ss 09:56.346 -to 10:00.558 v.s. -ss 09:56.012 -to 10:00.224).
I’ve also tried cutting by pkt_dts_time (http://stackoverflow.com/questions/14005110/), but that didn’t work either.
p.s. Another similar procedure to what I am trying to do (to abovementioned Avidemux) is when in Sony Vegas you zoom in into the timeline until you can step from one frame to another, then set the first frame after scene change (which is also a keyframe) as the starting point and the last frame of the same scene (after which comes the next keyframe that is not needed) as the endpoint and then render. Something like this can also be done in Avidemux while also copying the video and audio streams.
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 219
تاريخ: جمعه
24 ارديبهشت
1395 ساعت: 5:41