[FFmpeg-user] Problems with combined seeking

MK pikim at web.de
Thu Apr 9 22:56:01 EEST 2020


I'm trying to fix some issues with frame accurate cutting in VidCutter,
see my fork at https://github.com/pikim/vidcutter.

With input seeking the cuts aren't frame accurate, with output seeking
the processing takes very long. Therefore I wanted to use combined
seeking. The overall idea is to copy an entire segment if the cut
position is a keyframe and if not, to re-encode until the next keyframe.

A clip is the portion of the movie between advertisements, each clip
consists of a start, a middle and an end segment. start and end segments
may be copied or re-encoded, depending on the desired timestamps and the
keyframe positions.

The example clip shall start at 181.46 and end at 1741.52.

There are keyframes at the following positions:
163.88, 173.88, 183.88, ..., 1736.44, 1741.44, 1749.68

The resulting ffmpeg calls for the 3 segments of this clip are:
/usr/bin/ffmpeg -v info -ss 163.88 -i movie.avi -ss 17.58 -t 2.42 -c:v
libx264 -tune film -preset ultrafast -x264-params crf=18 -qp 0 -flags
+cgop -c:a copy -c:s copy -map 0:0 -map 0:1 -avoid_negative_ts 1 -y
/usr/bin/ffmpeg -v error -ss 173.88 -i movie.avi -ss 10.0 -t 1557.56 -c
copy -map 0:0 -map 0:1 -avoid_negative_ts 1 -y
/usr/bin/ffmpeg -v info -ss 1736.44 -i movie.avi -ss 5.0 -t 0.08 -c:v
libx264 -tune film -preset ultrafast -x264-params crf=18 -qp 0 -flags
+cgop -c:a copy -c:s copy -map 0:0 -map 0:1 -avoid_negative_ts 1 -y

With my first H264 test file this worked perfectly well. With further
test files I have the problem that two frames at the
start-middle-segment border are missing and two frames at the
middle-end-segment border are doubled.

Manual calculation of the timestamps show that the program logic is be
correct. Am I using some argument in an incorrect way?

Best regards,

More information about the ffmpeg-user mailing list