ffmpeg add scaled logo with two outputs - ffmpeg

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

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.

can we use -vf and -filter:a with -filter_complex

I want to combine some videos with some specific features like(video Speed, volume increase, resolution, rotation, framerate) of the final output of the video
We can do this process in 2 steps like
Combine video
ffmpeg -i test1.mp4 -i test2.mp4 -filter_complex [0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa] -map [outv] -map [outa] output.mp4
Then apply filters
ffmpeg -i output.mp4 -filter:a volume=1.0,atempo=1.0 -vf transpose=2,setpts=1/1.0*PTS,scale=3840X2160,fps=30 final.mp4
I can do it this way but is there any way to do it in 1 step
thank you
You have to apply the filters after concat.
ffmpeg -i test1.mp4 -i test2.mp4 -filter_complex [0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[v][a];[v]transpose=2,setpts=1/1.0*PTS,scale=3840X2160,fps=30[outv];[a]volume=1.0,atempo=1.0[outa] -map [outv] -map [outa] output.mp4

How do I combine two filter_complex?

I have these two filters that respectively, work just fine, but I can't seem to combine them.
Overlay with opacity
ffmpeg -i test.mp4 -i bar.png -filter_complex "[1:v]format=argb,geq=r='r(X,Y)':a='0.5*alpha(X,Y)'[zork]; [0:v][zork]overlay" -vcodec libx264 myresult.mp4
Overlay with left to right movement
ffmpeg -i test.mp4 -i bar.png -filter_complex "[0:v][1:v]overlay=x='if(lte(-w+(t)*100,100),-w+(t)*100,100)':y=0[out]" -map "[out]" -y out.mp4
End goal is to have my input picture with 0.5 opacity, and animated moving left to right.
Combined command:
ffmpeg -i test.mp4 -i bar.png -filter_complex "[1:v]format=argb,geq=r='r(X,Y)':a='0.5*alpha(X,Y)'[zork];[0:v][zork]overlay=x='if(lte(-w+(t)*100,100),-w+(t)*100,100)':y=0" output.mp4

concat 2 different image size multiple tracks videos

I try concat two videos (1.mkv has 640:360 image size, 2.mkv has 1280:720 image size), both videos have 2 video tracks and 0 audio tracks. I tried this code:
ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[0:v:1]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[v0][1:v:0][1:v:1]concat=n=2:v=2:a=0[v]" -map "[v]" -c:v "libvpx" 1+2.mkv
But I have wrong:
Filter pad has an unconnected output
Your filter labels need to be adjusted, and you need to change v=2 to v=1 in concat filter:
ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[1:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v1];[v0][v1]concat=n=2:v=1:a=0[v]" -map "[v]" -c:v libvpx 1+2.mkv
Since 2.mkv is already 1280x720 you can avoid processing that input:
ffmpeg -i 1.mkv -i 2.mkv -filter_complex "[0:v:0]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[v0];[v0][1:v]concat=n=2:v=1:a=0[v]" -map "[v]" -c:v libvpx 1+2.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

Resources