[FFmpeg-user] How to correctly split and then concatenate video (without reencoding)

Žygimantas Bruzgys un1x0nly at gmail.com
Mon Feb 11 16:37:58 CET 2013


Hey all,

I am trying to find a way how to split and then later concatenate
video so that no artefacts (glitches, pauses, cracks) would appear in
the resulting video. So far I have tried two methods for splitting
video:
1) ffmpeg -i video.mp4 -vcodec copy -acodec copy \
      -ss 00:00:00 -t 00:00:02 out01.mp4 \
      -ss 00:00:02 -t 00:00:04 out02.mp4 \
      -ss 00:00:04 -t 00:00:04 out03.mp4 ...
2) ffmpeg -i video mp4 -f segment -c copy -segment_time 2 -map 0 out%03d.mp4

Notice that I am trying to split video into segments so that durations
of each segment would be roughly 2 seconds.

After splitting I try to concatenate with:
  ffmpeg -f concat -i list.tmp -c copy joined.mp4
here 'list.tmp' contains all the segments (in an ascending order).

Results of each split-concat series are:
1) Smooth audio, but choppy video (frame drops) at splitting points,
see http://www.youtube.com/watch?v=wlVt4mYutqs
2) Cracks (pauses) at splitting points (both audio and video), however
none of the frames were lost (or dropped?). Increased duration of
overall video. ffprobe reported some STTS errors, VLC reported that
duration of is 8 seconds (probably headers were wrong), but after
performing:
  ffmpeg -i joined.mp4 -c copy fixed.mp4
VLC reported duration correctly. You can see the resulting video here:
http://www.youtube.com/watch?v=D-rTWzrnIwU

My remarks/questions:
1) Am I doing something wrong? What would be the the correct ffmpeg
usage for such use-case?
2) I think there might be a bug somewhere in '-f segment' module.
Could it be that way?

Regards,
Žygimantas


More information about the ffmpeg-user mailing list