[FFmpeg-user] How to properly pasting same-size video parts together into one output?

Bo Berglund bo.berglund at gmail.com
Tue Jan 25 13:00:53 EET 2022


On Tue, 25 Jan 2022 15:30:06 +0500, Nikita Zlobin <nick87720z at gmail.com> wrote:

>So, there's another way - explicitly convert all to same format,
>unifying everything (with filters format, scale, setsar) for video.
>As it starts working - see, what could be omited from these extra
>options.

So I found a thread on StackOverflow:
https://stackoverflow.com/questions/7333232/how-to-concatenate-two-mp4-files-using-ffmpeg

And as the accepted reply is this where your suggestion is apparently used:

[quote]
I ended up using mpg as the intermediate format and it worked (NOTE this is a
dangerous example, -qscale 0 will re-encode the video...)

ffmpeg -i 1.mp4 -qscale 0 1.mpg
ffmpeg -i 2.mp4 -qscale 0 2.mpg
cat 1.mpg 2.mpg | ffmpeg -f mpeg -i - -qscale 0 -vcodec mpeg4 output.mp4
[/quote]

So I used this:
ffmpeg -hide_banner -i input1.mp4 -qscale 0 1.mpg
ffmpeg -hide_banner -i input2.mp4 -qscale 0 2.mpg
cat 1.mpg 2.mpg | ffmpeg -f mpeg -i - -qscale 0 -vcodec mpeg4 output.mp4

The resulting video plays well and at the cut position between them it keeps
audio sync.

So far so good, now the remaining problem I have is that the file size is blown
up considerably..

input1.mp4 =    98,302,009 bytes
input2.mp4 =    53,629,084 bytes
1.mpg is   =   930,535,424 bytes
2.mpg is   =   385,169,408 bytes
output.mp4 = 1,095,027,291 bytes

Is there a way to reduce the size of the final mp4 too?


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list