6

I need to add an overlay a video and I was wondering if there is an easy way to do this with FFMPEG.

I have a set of images (a banner and a portrait) which I would like to overlay at the bottom of my video for part of the duration of the video. For example, after about 5 seconds I would like the overlay to appear, and then about 5 seconds before the end of the video I would like to have the overlay go away.

Is this possible using FFMPEG command line options?

Adam
  • 3,014
  • 5
  • 33
  • 59
  • http://www.corbellconsulting.com/2010/07/using-ffmpeg-to-add-and-watermark-overlay-on-a-video-2/ – Eric Fortis Aug 14 '11 at 16:21
  • Sorry, I don't have much experience using FFMPEG. I read through the post, it looks like I would need to do a bunch of other stuff instead of just ffmpeg.exe -someoption right? Can you elaborate or clarify some of what this post is referring to for an inexperienced FFMPEG user. (Also note, I'm on Windows, not linux/mac os) – Adam Aug 14 '11 at 16:28

4 Answers4

4

With FFMpeg overlaying images using the command line by far the most powerful and elegant way to do this is with a tool called AVISynth.

Here is are some simple examples, one of which overlays one video on top of another (overlaying an image is a subset of this):
http://avisynth.org/mediawiki/Script_examples

You may wonder, what the heck kind of tool is this? This is how it works conceptually:

First, you create a simple text document with special commands, called a script. These commands make references to one or more videos and the filters you wish to run on them. Then, you run a video application, such as FFMPeg, and pass in the script file on the command line. This is when AviSynth takes action. It opens the videos you referenced in the script, runs the specified filters, and feeds the output to video application. The application, however, is not aware that AviSynth is working in the background. Instead, the application thinks that it is directly opening a filtered AVI file that resides on your hard drive.

What you are wanting is very simple with AVISynth, but it can scale to do videos like this site, where many photos, text, and effects are placed on videos. All videos on this ecard site are created with FFMpeg and AVISynth: http://www.hdgreetings.com

It may seem a little different, but once you get one simple script working, you instantly recognize this is one of the best video tools ever created. And it's free of course.

whitneyland
  • 10,632
  • 9
  • 60
  • 68
  • This looks very promising. Is AVISynth cross platform? – Adam Aug 14 '11 at 17:31
  • Cross platform support is still a work in progress, more info here: http://avisynth.org/mediawiki/AviSynth_v3. There are no alternatives that are really competitive with what it does. It's almost worst running a Windows server just for AVISynth, which many people do. – whitneyland Aug 14 '11 at 18:26
  • Just noticed in your comments you are already on Windows. Was your cross platform question a hard requirement or just finding out more information? – whitneyland Aug 14 '11 at 18:30
  • A little of both. Would like to be able to deploy to linux if possible. – Adam Aug 14 '11 at 21:35
  • I was reading through some of the docs on AVISynth.org and it looks like it only works on AVI's as the source? My videos are in MP4 format. Is this still a good (or potential) solution? – Adam Aug 18 '11 at 01:03
  • It works with MP4, and almost any other source. Are you using MPEG4 part2 or MPEG4 part 10? (http://en.wikipedia.org/wiki/MPEG-4_Part_2 or http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC) – whitneyland Aug 18 '11 at 04:56
  • AviSynth works quite well in Linux (using `wine`)... However, instead of using `DiredtShowSource()` you may need to use a different filter, such as *FFmpegSource2*... and encode with *Avidemux* + *avsproxy* (shipped with Avidemux) – Peter.O Jan 30 '12 at 09:19
0

ffmpeg doesn't allow that kind of picture manipulation. However, maybe you are in luck.

Since you'll have to decompress video anyway, you can use ffmpeg to create RAW images to disk, overlay images with some utility (simple c# app would do the trick), and use ffmpeg to create another video with desired (or same as source) parameters.

To do overlays, you can probably use GIMP: http://www.gimp.org/tutorials/Basic_Batch/ since it is a cross platform tool that can be used in a batch (command line) mode.

Daniel Mošmondor
  • 19,718
  • 12
  • 58
  • 99
  • FFMPEG can overlay images over video at any given video time. Please refer this post: https://stackoverflow.com/questions/42943805/ffmpeg-is-it-possible-to-overlay-multiple-images-over-a-video-at-specified-inte – Sunny Tambi Aug 22 '17 at 13:03
0

Depending on what platform you are using, you may be able to just play the video and then create like an X window with the image over the video. While you are playing the video you could use ffmpeg to record the X window with the video playing in the background and the your image in the foreground.

The is a a complete hack, but I'm throwing it out there.

Claire
  • 1
  • 1
-1

FFMPEG can overlay images over a video at any given video time.

ffmpeg -i video -i image1 -i image2 -i image3
 -filter_complex
    "[0][1]overlay=x=X:y=Y:enable='between(t,23,27)'[v1];
     [v1][2]overlay=x=X:y=Y:enable='between(t,44,61)'[v2];
     [v2][3]overlay=x=X:y=Y:enable='gt(t,112)'[v3]"
-map "[v3]" -map 0:a  out.mp4

Please check this post for more details: FFMPEG- Is it possible to overlay multiple images over a video at specified intervals?

Sunny Tambi
  • 2,393
  • 3
  • 23
  • 27