ffmpeg how to overlay with concat? - ffmpeg

ffmpeg \
-i main.avi\
-i mini.avi\
-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]; \
[0:v:1][0:a:0][1:v:1][1:a:0]concat=n=2:v=1:a=1[outvr][outar]" \
-map "[outv]" -map "[outa]" outputMain.mp4 \
-map "[outvr]" -map "[outar]" outputMini.mp4
Can I get just One output? The 2 videos are overlayed.
enter image description here

You want to use the overlay filter:
./ffmpeg -i main.avi -i mini.avi -filter_complex "[0:v][1:v]overlay=50:50[vout]" -map "[vout]" -map 0:a out.mp4
The values 50:50 are the offset from the top left (50px left; 50px right).
The overlay doesn't change the video resolution. So it's only working well, if the mini video has already a lower resolution than the main video.
If you wan to scale the mini video also down, use the following command:
./ffmpeg -i main.avi -i mini.avi -filter_complex "[1:v]scale=w=720:h=576[vmini];[0:v][vmini]overlay=50:50[vout]" -map "[vout]" -map 0:a out.mp4
The filter scale is used here to bring the mini video into the correct resolution you want for the overlay.

Related

How can I combine these two filters in ffmpeg

So Im trying to overlay a video on top of an image and then add text over the image in ffmpeg I found that Im able to do all these separately but when combining it gives me the error of
Cannot find a matching stream for unlabeled input pad 0 on filter Parsed_drawtext_2
The line of code:
ffmpeg -loop 1 -i overlay.png -re
-i overlay.mp4
-filter_complex "[1]scale=1660:934[inner];[0][inner]overlay=0:0:shortest=1[out];
drawtext=fontsize=40:fontfile=FreeSerif.ttf:textfile=text.txt:x=(w-text_w)/2:y=(h-text_h)/2:reload=1"
-map "[out]" -map 1:a -c:a copy -y -s 1280x800 output.mp4
Can anyone help me with this?
You almost got it. Only needs some re-arranging:
ffmpeg -loop 1 -i overlay.png
-i overlay.mp4
-filter_complex "[1]scale=1660:934[inner];[0][inner]overlay=0:0:shortest=1,scale=1280:800,drawtext=fontsize=40:fontfile=FreeSerif.ttf:textfile=text.txt:x=(w-text_w)/2:y=(h-text_h)/2:reload=1[out]"
-map "[out]" -map 1:a -c:a copy output.mp4
See FFmpeg filtering intro for a quick explanation of the syntax.

How to apply multiple cropped blurs?

I would like to apply multiple blurs into my video (with audio copied), each of them having different coordinates and durations. Here is what I have tried:
ffmpeg -i test.mp4 -filter_complex \
"[0:v]crop=w=100:h=100:x=20:y=40,boxblur=10:enable='between(t,5,8)'[c1];
[0:v]crop=w=100:h=100:x=40:y=60,boxblur=10:enable='between(t,10,13)'[c2];
[0:v][c1]overlay=x=20:y=40[v];
[0:v][c2]overlay=x=40:y=60[v]" \
-map "[v]" -movflags +faststart output.mp4
However, this results in a Filter overlay has an unconnected output error. I would like to know if there is any good way to solve this. Thanks for your attention.
The 2nd overlay should use the output of the first overlay as its base input.
ffmpeg -i test.mp4 -filter_complex \
"[0:v]crop=w=100:h=100:x=20:y=40,boxblur=10:enable='between(t,5,8)'[c1];
[0:v]crop=w=100:h=100:x=40:y=60,boxblur=10:enable='between(t,10,13)'[c2];
[0:v][c1]overlay=x=20:y=40:enable='between(t,5,8)'[v0];
[v0][c2]overlay=x=40:y=60:enable='between(t,10,13)'[v]" \
-map "[v]" -movflags +faststart output.mp4

ffmpeg add scaled logo with two outputs

I want to add a scaled logo with 2 outputs.
For 1 output this works for me:
-filter_complex '[1:v]scale=156:94,overlay=main_w-overlay_w-10:10'
But it does not work for 2 outputs in one ffmpeg command.
Use the split filter and -map option:
ffmpeg -i video.mp4 -i logo.png -filter_complex "[1:v]scale=156:94[logo];[0][logo]overlay=main_w-overlay_w-10:10,split=outputs=2[v1][v2]" -map "[v1]" output1.mp4 -map "[v2]" output2.mkv

chromakey: ffmpeg green color video removal

I am using ffmpeg on Mac to remove green background of video and add other background as image it is converting properly the video but auido is missing. I am using below command.
Am I doing anything wrong here?
ffmpeg -i bg.jpg -i input.mp4 -filter_complex "[1:v]colorkey=0x3BBD1E:0.3:0.2[ckout];[0:v][ckout]overlay[out]" -map "[out]" output.mp4
I solved it my own.
ffmpeg -i bg.jpg -i input.mp4 -filter_complex "[1:v]chromakey=0x3BBD1E:0.1:0.2[ckout];[0:v][ckout]overlay[o]" -map [o] -map 1:a output.mp4
we need to add flags for audio.
Once a map switch is added, only mapped streams are included. Add -map 1:a? -c:a copy

ffmpeg showwaves color

I'm trying to produce a video that has a lime green colored waveform overlayed on top of a background image. Unfortunately though, there is a grey color in the lines as you can see here:
How can I make the grey parts lime green as well?
And if possible, I would like to make the lines thicker as well.
Here is my ffmpeg command:
ffmpeg -i input.aac -i background.jpg -filter_complex "[0:a]aformat=sample_fmts=s16:sample_rates=4410:channel_layouts=mono,showwaves=size=300x200:mode=p2p:rate=10:colors=#68b847[fg];[1:v][fg]overlay=130:150,format=yuv420p[v]" -map "[v]" -map 0:a -c:v libx264 -r 10 -c:a copy -r 10 -movflags +faststart output.mp4
Try this
ffmpeg -i input.aac -i background.jpg -filter_complex "[0:a]aformat=channel_layouts=mono,showwaves=s=1920x1080:mode=p2p:r=30:colors=#68b847[v];[1:v][v]overlay=format=auto:x=(W-w)/2:y=(H-h)/2,format=yuv420p[outv]" -map "[outv]" -map 0:a -c:v libvpx-vp9 -c:a copy -shortest output.mp4

Resources