ffmpegmp4concatenationmp4box

Concat mp4 files with a command line tool


I am blocked trying to do something, and I'm ready to make a donation if somebody can help me:

I try to concat http://s.serero.free.fr/rolex.mp4 video and http://s.serero.free.fr/video.mp4 video in one output mp4 file and I tried during a big time without results.

I want to concat http://s.serero.free.fr/rolex.mp4 + http://s.serero.free.fr/video.mp4 or http://s.serero.free.fr/video.mp4 + http://s.serero.free.fr/rolex.mp4.

I tried with ffmpeg command line software and with mp4box command line software, I think that I don't have the good method.

I tried to transform http://s.serero.free.fr/video.mp4 in the same format of http://s.serero.free.fr/rolex.mp4 (and vice versa):

I transformed http://s.serero.free.fr/rolex.mp4 with the same frame rate of http://s.serero.free.fr/video.mp4

I transformed http://s.serero.free.fr/rolex.mp4 with the same video bitrate of http://s.serero.free.fr/video.mp4

I transformed http://s.serero.free.fr/rolex.mp4 with the same video audio bitrate of http://s.serero.free.fr/video.mp4

Can somebody help me?

Explain to me what is wrong in my strategy?


Solution

  • Your input parameters vary, so you have to make them similar before concatenation.

    This example will make video.mp4 more like rolex.mp4 then concat them:

    ffmpeg -i rolex.mp4 -i video.mp4 -filter_complex \
    "[1:v]pad=1280:720:(ow-iw)/2:0,fps=25,format=yuv420p[v1]; \
     [0:v][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a]" \
    -map "[v]" -map "[a]" output.mp4
    

    You don't actually need to declare fps or format because, as the concat filter documentation states:

    All corresponding streams must have the same parameters in all segments; the filtering system will automatically select a common pixel format for video streams, and a common sample format, sample rate and channel layout for audio streams, but other settings, such as resolution, must be converted explicitly by the user.

    ...but doing so will allow you to manually choose the "common" settings instead of relying on the filter automatically doing so and potentially selecting a setting you don't want.