Body: <p>I would like to put a png file as a background to an h264 encoded mp4 video. I am just trying to replace the video's white background with a specific png background. They are both of the same size.</p>
  <p>Can this be done using ffmpeg?</p>
  <p>I have looked into using ffmpeg -filter_complex overlay but the background ended up covering the whole video. This is the command I tried:</p>
  <p><code>ffmpeg -loop 1 -i background.png -i video.mp4 -filter_complex 'overlay=10:main_h-overlay_h-10:shortest=1’ output.mp4</code></p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-17T21:44:08.007Z
Comments.Text: Welcome! Can you share the full ffmpeg command that you tried? What are you using to decide where to show the foreground and where to show the background? An alpha channel? A chroma or luma key?
Comments.UserDisplayName: Michael Liebman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-18T09:38:03.767Z
Comments.Text: Hi thanks for your reply @MichaelLiebman. I used the command below.
  
  `ffmpeg -loop 1 -i background.png -i video.mp4 -filter_complex 'overlay=10:main_h-overlay_h-10:shortest=1’ output.mp4`
  
  I am not too sure I understand the second part of your question. I am just trying to replace the video's white background with a specific png background.
Comments.UserDisplayName: Leon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-08-18T18:27:54.580Z
Comments.Text: That means you are trying to do a luma key. There's a [filter](https://ffmpeg.org/ffmpeg-filters.html#lumakey) for that.  I can't tell you specifically how to use it, but maybe that will give you more to search on in case someone else doesn't answer your question.
Comments.UserDisplayName: Michael Liebman
Tags: <ffmpeg><video>
Title: Putting a png background on h264 encoded mp4 video using ffmpeg
UserDisplayName: Leon
ThreadText: # Putting a png background on h264 encoded mp4 video using ffmpeg
  
  (Asked by: username_0 on 2022-08-17)
  
  I would like to put a png file as a background to an h264 encoded mp4 video. I am just trying to replace the video's white background with a specific png background. They are both of the same size.
  
  Can this be done using ffmpeg?
  
  I have looked into using ffmpeg -filter\_complex overlay but the background ended up covering the whole video. This is the command I tried:
  
  `ffmpeg -loop 1 -i background.png -i video.mp4 -filter_complex 'overlay=10:main_h-overlay_h-10:shortest=1’ output.mp4`
  
  **Tags:** ffmpeg, video
  
  > **Comments:**
  > **username_1**: Welcome! Can you share the full ffmpeg command that you tried? What are you using to decide where to show the foreground and where to show the background? An alpha channel? A chroma or luma key?  
  > **username_0**: Hi thanks for your reply @username_1. I used the command below.  `ffmpeg -loop 1 -i background.png -i video.mp4 -filter_complex 'overlay=10:main_h-overlay_h-10:shortest=1’ output.mp4`  I am not too sure I understand the second part of your question. I am just trying to replace the video's white background with a specific png background.  
  > **username_1**: That means you are trying to do a luma key. There's a [filter](https://ffmpeg.org/ffmpeg-filters.html#lumakey) for that.  I can't tell you specifically how to use it, but maybe that will give you more to search on in case someone else doesn't answer your question.  
  
  ---
  
  ## 0 answers
  
  