[FFmpeg-user] stream copy frame accuracy
Henk D. Schoneveld
belcampo at zonnet.nl
Tue Jun 2 02:34:59 CEST 2015
On 01 Jun 2015, at 18:21, t <cadeparker at zoho.com> wrote:
>
> I know this might not be possible, but I'd at least appreciate understanding what's going on.
>
> I have a video with forced keyframes every 2 seconds. Ideally, I was hoping I'd be able to get frame-perfect slices without having to re-encode. For example:
>
> ffmpeg -ss 00:00:00 -i original.mp4 -t 2 -c copy slices_0.mp4
> ffmpeg -ss 00:00:02 -i original.mp4 -t 2 -c copy slices_1.mp4
> ffmpeg -ss 00:00:04 -i original.mp4 -t 2 -c copy slices_2.mp4
> …
Are you only interested in the video part ?
It might help to disable audio, because audio or video has a delay between them.
Another thing you could try is to choose the frame# you want. If the source is 25fps, select video frame 100. That equals 4 sec.
If the source is 29.97 things become difficult to be exactly at second points. The same occurs with 23.97 material. You’ll get rounding errors.
>
> This doesn't quite seem to work.
>
> Digging more into it, it looks like the first slice is frame-accurate, but everything after that has a slight offset (it might have other problems, but I'm just focusing on this for now). The first frame appears ok:
>
> # same output
> ffmpeg -ss 00:00:03 -i original.mp4 -vframes 1 o.png && md5 o.png
> ffmpeg -ss 00:00:00 -i slices_1.mp4 -vframes 1 1.png && md5 1.png
>
> But everything after that, is off:
>
> # not the same output
> ffmpeg -ss 00:00:04 -i original.mp4 -vframes 1 o.png && md5 o.png
> ffmpeg -ss 00:00:01 -i slices_1.mp4 -vframes 1 1.png && md5 1.png
>
> Whatever I do, I get the same result. If I look at the PTS for the original for frame 60, I get 2.002000 (instead of 2). But, even if I use this for my slice, I get the same offset.
>
> What's going on?
>
> (Probably not realted, but I'm also curious why the first frame of 0_slices.mp4 has an offset PST/DST, even though the original doesn't)
>
>
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
More information about the ffmpeg-user
mailing list