0

I want to overlay srinked video on the top of single image. I use movie filter to do that. like this

ffmpeg.exe -loop 1 -i Coronavirus00000000.jpg -vf "movie=C\\:/\Users/\Toshiba/\Pictures/\test vcp/\shopi pro.mp4,scale=1180:-1[inner];[in][inner]overlay=70:70:shortest=1[out]" -y out.mp4

It's work. but the problem, the audio from video is removed. The final video out.mp4 has no sound, even though the original video has.

I have read answer on this threat FFMPEG overlaying video with image removes audio

That recommend to Change into ...[padded]overlay=0:0" -y ... Or add -map 0:a

But I don't understand how to implement that answer into movie filter

Herahadi An
  • 198
  • 14

1 Answers1

3

Please notice inputs/sources you have:

  1. an input image ("Coronavirus00000000.jpg")
  2. a movie source which by default selects a video stream

so you don't have any audio input stream selected/opened. To do so I'd recommend open every file as a standard ffmpeg input (-i <file>) and then configure a complex filtering graph that utilizes them.

In your example that would be:

ffmpeg -loop 1 -i Coronavirus00000000.jpg -i C\\:/\Users/\Toshiba/\Pictures/\test vcp/\shopi pro.mp4 -filter_complex "[1:v]scale=1180:-1[inner];[0:v][inner]overlay=70:70:shortest=1[out]" -map '[out]' -map 1:a -y out.mp4

where:

  • -i Coronavirus00000000.jpg opens your image file as input #0
  • -i C\\:/\Users/\Toshiba/\Pictures/\test vcp/\shopi pro.mp4 opens your video file with video and audio streams as input #1
  • [1:v]scale=1180:-1[inner] scales the input's #1 video stream
  • [0:v][inner]overlay=70:70:shortest=1[out] overlays the scaled video onto input's #0 video stream
  • -map '[out]' selects overlayed video stream (tagged as [out]) for output video stream
  • -map 1:a selects input's #1 audio stream for output audio stream
pszemus
  • 375
  • 2
  • 10
  • it gives me an error like this `[image2 @ 068446c0] Invalid stream specifier: '[out]'. Last message repeated 1 times Stream map ''[out]'' matches no streams. To ignore this, add a trailing '?' to the map.` – Herahadi An Feb 22 '21 at 22:20
  • it works, after i change the single quote of `-map '[out]'` to `-map "[out]"`. thank you very much. but could you explain in more details about this line `[0:v][inner]overlay=70:70:shortest=1[out]` why its use `[0:v]` while #0 is an image, not `[1:v]`? – Herahadi An Feb 22 '21 at 23:11
  • @HerahadiAn I assumed you want to overlay a video onto an image, so acording to [overlay filter documentation](https://ffmpeg.org/ffmpeg-filters.html#overlay-1): `It takes two inputs and has one output. The first input is the "main" video on which the second input is overlaid.` – pszemus Feb 23 '21 at 13:59