Herahadi An
Herahadi An

Reputation: 346

FFMPEG overlay video over image using movie filter resulting video with no sound

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

Upvotes: 0

Views: 1077

Answers (1)

pszemus
pszemus

Reputation: 393

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

Upvotes: 3

Related Questions