chromakey: ffmpeg green color video removal - macos

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

Related

Combine filters for watermark and video speed using FFmpeg

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.

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.

ffmpeg - Add INTRO and Watermark

I need to add INTRO.mp4 at the beginning of video.mp4 and add watermark.png (bottom right corner)
How to do this using ffmpeg, because I'm lost?
log file
Copy and paste this command. It will work with any intro.mp4 and video.mp4 assuming they both have audio.
ffmpeg -i intro.mp4 -i video.mp4 -i watermark1.png -filter_complex "[0:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1,fps=30000/1001,format=yuv420p[intro];[1:v]scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:-1:-1,setsar=1,fps=30000/1001,format=yuv420p[video];[2]scale=96:-1[logo];[0:a]aformat=sample_rates=48000:channel_layouts=stereo[introa];[1:a]aformat=sample_rates=48000:channel_layouts=stereo[videoa];[intro][introa][video][videoa]concat=n=2:v=1:a=1[vid][a];[vid][logo]overlay=W-w-5:H-h-5[v]" -map "[v]" -map "[a]" -movflags +faststart output.mp4
See:
FFmpeg Filters Documentation
How to add watermark with ffmpeg?
How to concatenate videos in ffmpeg with different attributes?

ffmpeg mixing webm “Filter overlay has an unconnected output”

I want to mix multiple webm
Below is my command
But ffmpeg error
“Filter overlay has an unconnected output”
ffmpeg -i 1596618603934.webm -i 1596618618345.webm -filter_complex "nullsrc=size=1280x960[base];
[0:v]setpts=PTS-STARTPTS,scale=640*480[left];
[1:v]setpts=PTS-STARTPTS,scale=640*480[right];
[base][left]overlay=shortest=1[tmp1];
[tmp1][right] overlay=shortest=1:x=640[tmp2]" -c:v output.webm
If you provide a label for the final output of a filtergraph, then it has to be mapped. So, either do that -map '[tmp2]' or omit the label.
ffmpeg -i 1596618603934.webm -i 1596618618345.webm -filter_complex "nullsrc=size=1280x960[base];
[0:v]setpts=PTS-STARTPTS,scale=640*480[left];
[1:v]setpts=PTS-STARTPTS,scale=640*480[right];
[base][left]overlay=shortest=1[tmp1];
[tmp1][right] overlay=x=640" -c:v output.webm

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

Resources