EDIT/UPDATE: current solution is to run this code on all files ffmpeg -i up.mp4 -vf scale=1920:1080 -crf 22 reUP.mp4
so resolution, but also frames per second match.
I used to be able to open CMD, type CD C:\Users\...
and then ffmpeg -f concat -safe 0 -i xmylist.txt -crf 22 -c copy x1.mp4
The recording are from same phone, some from front cam, some from back cam. I understand this could cause non-identical problems? but it worked fine until recently.
Now the output is corrupted with this log:
The individual video files play just fine, so does most of the concatted output, but some sections become like this and freeze:
You are concatenating two video files with different resolutions.
front.mp4
is 1920x1080rear.mp4
is 1280x720Reproducing the problem is not too difficult (you may place the code in a .bat
file):
rem Create tmplist.txt
echo file 'front.mp4' > tmplist.txt
echo file 'rear.mp4' >> tmplist.txt
rem Create video with resolution 192x108 for example (instead of 1920x1080)
ffmpeg -y -f lavfi -i testsrc=size=192x108:rate=25 -f lavfi -i sine=frequency=300 -acodec aac -ar 22050 -vcodec libx265 -crf 17 -pix_fmt yuv420p -t 3 front.mp4
rem Create video with resolution 128x72 for example (instead of 1280x720)
ffmpeg -y -f lavfi -i testsrc=size=128x72:rate=25 -f lavfi -i sine=frequency=400 -acodec aac -ar 22050 -vcodec libx265 -crf 17 -pix_fmt yuv420p -t 3 rear.mp4
rem Concatenate:
ffmpeg -y -f concat -safe 0 -i tmplist.txt -c copy tmp.mp4
Solution: Convert all the concatenated input videos to the same resolution.
Note:
I suppose the best solution is to convert the lower resolution to the higher, and then apply concat
:
ffmpeg -y -i rear.mp4 -vf scale=192:108,setsar=1 -vcodec libx265 -crf 22 -pix_fmt yuv420p resized_rear.mp4
ffmpeg -y -f concat -safe 0 -i tmplist.txt -c copy tmp2.mp4
Less recommended solution:
There is single solution, but it re-encode all the videos (reducing quality).
I don't know if there is a solution using a text file.
Example for concatenating two files - the second video is resized:
ffmpeg -y -i front.mp4 -i rear.mp4 -filter_complex "[1:v]scale=192:108,setsar=1[v1];[0:v][0:a][v1][1:a]concat=n=2:v=1:a=1[v][a]" -map "[v]" -map "[a]" -vcodec libx265 -crf 22 -pix_fmt yuv420p tmp_resized.mp4