I am having problems concating multiple videos and using a thumbnail.
I have tried the following:
ffmpeg -i "concat:GX014185.MP4|GX024185.MP4" -i ./scaled.png -filter_complex "overlay=main_w-overlay_w-5:main_h-overlay_h-5" output.MP4
This will put the thumbnail in the correct place, but will only concat the first video GX014185.MP4
Using
ffmpeg -i GX014185.MP4 -i GX024185.MP4 -i GX034185.MP4 -i GX044185.MP4 -i GX054185.MP4 -c copy ../$(date +%Y%m%d_%H%M%S)_merged.mp4
Does not support a thumbnail, though I wish it did as it is so fast.
How can I concat videos with thumbnails?
Answer
The concat protocol should not be used with MP4. This is a common mistake. You can use the concat filter instead:
ffmpeg -i GX014185.MP4 -i GX024185.MP4 -i GX034185.MP4 -i GX044185.MP4 -i GX054185.MP4 -i scaled.png -filter_complex "[0:v][0:a][1:v][1:a][2:v][2:a][3:v][3:a][4:v][4:a]concat=n=5:v=1:a=1[vv][a];[vv]overlay=main_w-overlay_w-5:main_h-overlay_h-5[v]" -map "[v]" -map "[a]" output.mp4
The concat filter is most useful with filtering since it requires the video to be re-encoded (all filters require re-encoding).
Because you have to re-encode, due to the overlay, this can take some time.
Alternatively you could use the concat demuxer. First make a text file named input.txt
:
file "GX014185.MP4"
file "GX024185.MP4"
file "GX034185.MP4"
file "GX044185.MP4"
file "GX054185.MP4"
Then run ffmpeg
:
ffmpeg -f concat -i input.txt -i scaled.png -filter_complex "overlay=main_w-overlay_w-5:main_h-overlay_h-5" output.mp4
The concat demuxer is useful to concatenate videos without needing to re-encode (when used with -c copy
), but it is also just as good when you need to re-encode (such as due to any filtering).
Because you have to re-encode, due to the overlay, this can take some time.
No comments:
Post a Comment