14

I have an image. I have a transparent FLV. I want to use the image as a background to the transparent FLV and have it outputted as FLV.

This command works but the video is one frame long:

ffmpeg -i background.png -f flv -vcodec flv -b 1500k -vf "movie=test_videos/alpha.flv [logo]; [in][logo] overlay=0:0 [out]" -s 800x464 -y output.flv

I have tried to use the -t and -vframes parameters to no avail.

Does anyone have any tips?

Tim Scollick
  • 1,242
  • 1
  • 16
  • 17
  • There are some tricks that you can use to add an image on top of a video (watermark) but unfortunately I don't believe there exists anything in FFMpeg that allows you to do the reverse (chroma key/greenscreen/bluescreen). – Chris Haas Sep 07 '11 at 21:05
  • Well, I already have a transparent video working with an image, so I hope to prove you wrong, @Chris Haas. Thanks for the input. – Tim Scollick Sep 07 '11 at 21:26

2 Answers2

9

I apologize for my initial comment, my searching produced very little results initially.

Now looking at the documentation I see in fact that you should be able to do that. I don't have time to test this but I would try making two passes. The first pass should turn your PNG into a movie with a transparent background that's the same duration as your other movie. Something like:

ffmpeg -loop_input -f image2 -i background.png -r 25 -vframes 250 -an -vcodec png test.mov

I chose PNG for the video codec because according to this post it supports transparency in MOV containers.

Then you should hopefully just be able to pipe that movie into your original command where you had your image.

Community
  • 1
  • 1
Chris Haas
  • 53,986
  • 12
  • 141
  • 274
  • 3
    Brilliant, Chris. The complete solution that got me what I wanted was this command: ffmpeg -loop_input -f image2 -i background.png -r 25 -vframes 2500 -an -vcodec libx264 -b 1500k -vf "movie=test_videos/alpha.flv [logo]; [in][logo] overlay=0:0 [out]" -s 800x464 -y output.mov – Tim Scollick Sep 08 '11 at 14:34
  • 1
    Very great to hear! So basically it was just the `-loop_input` part that you needed to add to your original command, you didn't need to make two passes? – Chris Haas Sep 08 '11 at 14:43
  • I started with an flv (flv supports transparency OOTB) and added it as an overlay over the static image (using loop_input and -vframes to make it longer than one frame), which seems a bit counter-intuitive. However, using this method, there was no need to make two passes. Thank you so much for your help! – Tim Scollick Sep 08 '11 at 15:16
  • 3
    **Important TIP** to make the process **faster**: specify **4 or more THREADS** *(rule of thumb is 1 per CPU)* you put it first **`ffmpeg.exe -threads 4 -i back...`** . **Second tip**: if you are using `MP3` as the audio-track, and your target file extension is `.MP4` **specify `-acodec copy`** this way you'll save a lot of processing and you **can done within 10 seconds**. *You're welcome.* –  Apr 07 '15 at 21:43
  • -loop_input is deprecated. Here's an answer that works today: http://video.stackexchange.com/questions/14519/add-image-under-the-video-with-ffmepg – NeoTheThird Mar 01 '17 at 10:42
5

The complete solution that got me what I wanted was this command:

ffmpeg -loop_input -f image2 -i background.png -r 25 -vframes 2500 -an -vcodec libx264 -b 1500k -vf "movie=test_videos/alpha.flv [logo]; [in][logo] overlay=0:0 [out]" -s 800x464 -y output.mov
Tim Scollick
  • 1,242
  • 1
  • 16
  • 17