[FFmpeg-user] How to split and then concatenate a video file?

Stefano Sabatini stefasab at gmail.com
Thu Feb 21 22:35:36 CET 2013


On date Wednesday 2013-02-20 15:37:24 +0100, Žygimantas Bruzgys wrote:
> On Wed, Feb 20, 2013 at 3:17 PM, Žygimantas Bruzgys <un1x0nly at gmail.com> wrote:
> > On Wed, Feb 20, 2013 at 2:16 PM, Stefano Sabatini <stefasab at gmail.com> wrote:
> >>> zybru at hp-6530b-bs:~/Desktop$ ffmpeg -i small.mp4 -f segment -vcodec
> >>> h264 -acodec mp3 -segment_time 2 -map 0 out%03d.mp4
> >>
> >> Did you try with -reset_timestamps 1?
> >
> > Let me try it now! (just fyi, I've recompiled ffmpeg today from git head)
> 
> 
> What I've else noticed today is that:
> 
> - if you demux the video and segment it with '-f segment' with output
> format .h264;
> - concatenate all h264s to a single h264;
> - mux h264 with audio back to mp4 file
> 
> despite couple of errors during concatenation, everything works
> smoothly and as it should. This makes me draw a conclusion that there
> is some kind of a bug in segmenting (or concatenating) mp4 containers.
> 
> The output was a bit big, so I put it on gist:
> https://gist.github.com/anonymous/52d77ac231c1240ec551

Bug confirmed.

ffmpeg -f lavfi -i testsrc=n=2 -f segment -codec:v h264 -bf:v 0 -segment_time 2 -map 0 -reset_timestamps 1 -segment_list test.cat -t 60 test-%03d.mp4
ffmpeg -f concat -i test.cat -c copy -y test-joined.mp4
ffprobe -show_entries packet=pts_time test-joined.mp4  -of compact 
[...]
packet|pts_time=9.840000
packet|pts_time=9.880000
packet|pts_time=9.920000
packet|pts_time=9.960000
packet|pts_time=10.242031
packet|pts_time=10.282031
packet|pts_time=10.322031
[...]

The bug seems located in the concat code.


More information about the ffmpeg-user mailing list