Body: <p>video1.mp4 1280×720, with a green area</p>
  <p>video2.mp4 1280×720</p>
  <p>I need to reduce video2.mp4 to 640x480 and insert what fits into the green area of video1.mp4</p>
  <p>I went through all the options that I found on the Internet, but they don't work in my case.</p>
  <p>An example that reduces, but the chromakey does not work:</p>
  <p><code>ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex &quot;[0]colorkey=0x00b200:0.02:0.03[v0];[1]scale=800:640[v1];[v0][v1]overlay[out]&quot; -codec:v libx264 -crf 23 -preset slow -map &quot;[out]&quot; -map 0:a result.mp4</code></p>
  <p>Please tell me how to fix it.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-21T06:22:02.967Z
Comments.Text: try to increase similarity `0.02` to `0.2` and, maybe, reverse `[v1][v0]overlay`?
Comments.UserDisplayName: Баяр Гончикжапов
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-21T10:15:14.070Z
Comments.Text: "similarity 0.02 to 0.2", - it didn't help. If reverse [v1][v0]overlay then the chromakey is triggered, but the output video is cropped to size 640x480.
Comments.UserDisplayName: Jhon Abrams
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-12-22T04:50:40.823Z
Comments.Text: tested by this way `ffmpeg -i "switch.mp4" -i "input 1.mp4" -filter_complex "
  [0]colorkey=#5fc502:0.1:0[v0];
  [1]scale=640:480,pad=1280:720:-1:-1[v1];
  [v1][v0]overlay
  " -c:v h264_nvenc -cq 23 -c:a copy -t 5 /tmp/output.mkv`
Comments.UserDisplayName: Баяр Гончикжапов
Tags: <ffmpeg><chromakey><scale>
Title: FFMPEG - scale and chromakey not working together?
UserDisplayName: Jhon Abrams
ThreadText: # FFMPEG - scale and chromakey not working together?
  
  (Asked by: username_0 on 2023-12-20)
  
  video1.mp4 1280×720, with a green area
  
  video2.mp4 1280×720
  
  I need to reduce video2.mp4 to 640x480 and insert what fits into the green area of video1.mp4
  
  I went through all the options that I found on the Internet, but they don't work in my case.
  
  An example that reduces, but the chromakey does not work:
  
  `ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0]colorkey=0x00b200:0.02:0.03[v0];[1]scale=800:640[v1];[v0][v1]overlay[out]" -codec:v libx264 -crf 23 -preset slow -map "[out]" -map 0:a result.mp4`
  
  Please tell me how to fix it.
  
  **Tags:** ffmpeg, chromakey, scale
  
  > **Comments:**
  > **username_1**: try to increase similarity `0.02` to `0.2` and, maybe, reverse `[v1][v0]overlay`?  
  > **username_0**: "similarity 0.02 to 0.2", - it didn't help. If reverse [v1][v0]overlay then the chromakey is triggered, but the output video is cropped to size 640x480.  
  > **username_1**: tested by this way `ffmpeg -i "switch.mp4" -i "input 1.mp4" -filter_complex " [0]colorkey=#5fc502:0.1:0[v0]; [1]scale=640:480,pad=1280:720:-1:-1[v1]; [v1][v0]overlay " -c:v h264_nvenc -cq 23 -c:a copy -t 5 /tmp/output.mkv`  
  
  ---
  
  ## 0 answers
  
  