0

How to use FFmpeg video overlay function to add image logo to a MP4 video where overlay positions shall come from an external input.

Following is the command I am using to apply a logo to a video file

ffmpeg -i input.mp4 -i image.png -filter_complex \
       "[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" -c:a copy output.mp4

Say when the input is 1 the logo need to be placed on top left corner etc.

Does the overlay position can be changed on the fly based on input from the file?

Say for input file content given below

cat input.txt
1
2
3
4

I need to move the logo to other positions after the 20 sec duration is elapsed.

Is this is supported in FFmpeg command line? FFmpeg version is 2.6.2.

srv
  • 433
  • 9
  • 26
  • See [sendcmd](https://ffmpeg.org/ffmpeg-filters.html#sendcmd_002c-asendcmd) and [zmq](https://ffmpeg.org/ffmpeg-filters.html#zmq_002c-azmq) filters. See duplicate link above for sendcmd example. – llogan Jan 18 '19 at 18:47

1 Answers1

1

I don't think ffmpeg intelligent enough to read what's your file data format is. However, you can parse the file first, then apply filter_complex to move your image to desire location.

ffmpeg -i input.mp4 -i image.png -filter_complex \
       "[1:v] scale=100:100 [ovr1], [1:v] scale=200:200 [ovrl2], [0:v][ovr1] overlay=25:25:enable='between(t,0,20)' [temp1], [temp1][ovrl2] overlay=50:50:enable='between(t,20,40)'" output.mp4
Valdeir Psr
  • 702
  • 1
  • 7
  • 10