[FFmpeg-user] How to concat two videos with same size but different source?

Bo Berglund bo.berglund at gmail.com
Fri Oct 14 20:24:40 EEST 2022

On Tue, 11 Oct 2022 13:52:14 +0200, pehache <pehache.7 at gmail.com> wrote:

>Le 08/10/2022 à 10:31, Bo Berglund a écrit :
>> I have two mp4 videos both at 480p resolution, which I want to concat.
>> They are together about 80 minutes long.
>> When I do this using the common way with this command:
>> ffmpeg -f concat -safe 0 -i join.txt -c copy joinedfile.mp4
>> using a file specifying the video sections to concatenate the result plays very
>> poorly and has many artifacts.
>> And at the border between the two videos the output video becomes unplayable.
>> So I tried to re-encode using this command instead:
>> ffmpeg -hide_banner -i video.1.mp4 -i video.2.mp4 \
>> -filter_complex "[0:v] [0:a] [1:v] [1:a] concat=n=2:v=1:a=1 [v] [a]" \
>> -map "[v]" -map "[a]" video.mp4
>> This command was started before bedtime yesterday and had not finished this
>> morning 8 hours later...
>> The video output file size was about 1.5 GB when I interrupted the process.
>> The two videos are 101 and 238 MB in size respectively. They are downloaded
>> videos from the Internet.
>> What ffmpeg command can I use to concatenate these two files in a safe way?
>First I advice reading this: https://trac.ffmpeg.org/wiki/Concatenate

Been there and tried that, in fact my main concat script uses the first approach
to create the list file and supplies that to ffmpeg. But that script is always
dealing with a number of clips from one and the same downloaded video...

>Second, when you have commands that do not give the expected results, it 
>can often help to show the messages they print in the terminal.

The unexpected result is not an ffmpeg error or such just that the second half
of the output does not play properly while the first does...

What I am writing about here is basically this:
I have several sources for the same video content (news shows) and I have two
Linux machines running the same downloads but using different sources.
Sometimes both of the resulting files have flaws but in different locations so I
can clip OK sections from both and want to concatenate these to a final "good"

The download script used on both machines is the same and the actual download
command is built like this:

CMD="ffmpeg -hide_banner -referer \"${VIDEOURL} -i \"${M3U8URL}\" -vf
scale=w=-4:h=480 -c:v libx264 -preset fast -crf 26 -c:a aac -t ${CAPTURETIME}

(Of course the variables used here are filled in properly when the CMD string is

I figured that since I force a scale setting of 480p and use of libx264 and aac
for video and audio I would get the same basic content in both...
Are these not setting the "codec"?

Is this a flawed assumption?

If it is then I need probably to translate each snippet to something entirely
different like ts before concatenate with re-encode using libx264 and aac?

And that would increase the needed processing time a lot.

Bo Berglund
Developer in Sweden

More information about the ffmpeg-user mailing list