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
Related
I am using FFmpeg to speed up a video and add a watermark. The watermark is a percentage of the video size.
To speed up I am using
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4
And to add a watermark, I am using
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=5:H-h-5" -c:a copy output.mp4
Both work well on their own. I am trying to combine them into a single command. There are many questions/answers regarding similar problems that I could find, however they seem to either be outdated or I just can't get them to work.
To combine filters I have read to just add a comma, but that doesn't seem to work:
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=5:H-h-5,[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4
The command will run without errors, and add the watermark, but the audio/video filter is not being applied.
How can I do it?
Combined command:
ffmpeg -i input.mp4 -i watermark.png -filter_complex "[1][0]scale2ref=w=oh*mdar:h=ih*0.1[logo][video];[video][logo]overlay=5:H-h-5,setpts=0.5*PTS;[0:a]atempo=2.0" output.mp4
Connect linear filters with a comma. Connect filterchains with a semicolon. See FFmpeg Filtering Intro.
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.
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.
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
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