1

So I am trying to combine a .mp3 and a image and add text then turn it into a .mp4 with ffmpeg, what would the command for this be.

I tried: ffmpeg -i audio.mp3 -i background.jpg -filter_complex "[0:v][1:v]overlay=10:10,drawtext=text='Hello World'" -c:a copy -movflags +faststart output.mp4

But it gave me this error: Stream specifier ':v' in filtergraph description [0:v][1:v]overlay=10:10,drawtext=text='Hello World' matches no streams.

Also how would I change the font of the text.

MrPigbot
  • 25
  • 1
  • 4

2 Answers2

2

No need to use overlay. Just use the image as the input to the drawtext filter:

ffmpeg -i audio.mp3 -loop 1 -framerate 10 -i background.jpg -filter_complex "[1:v]drawtext=text='Hello World':fontfile=/path/to/your/font.ttf:fontsize=24:fontcolor=white:x=10:y=10,format=yuv420p[v]" -map "[v]" -map 0:a -c:a copy -movflags +faststart -shortest output.mp4

Other changes:

  • The image must be looped, so the -loop 1 input option was added. Because it loops indefinitely the -shortest output option was also added so the file stops when the audio stops.
  • Added -framerate 10 to set image frame rate. Default is 25. Using a lower fps than 10 risks causing problems with some players.
  • Select font with fontfile option.
  • See How to position drawtext text for examples for x and y positions.
  • Added the format filter to set yuv420p pixel format for compatibility.
  • Consider changing -c:a copy to -c:a aac for compatibility.
llogan
  • 57,139
  • 15
  • 118
  • 145
0

I'm not familiar with ffmpeg but I think you should do this in the following order:

  1. Convert mp3 into mp4
  2. Add image
  3. Add text

Mp3 is a audio format thats why I think you can't add text (so it appears like a video). Of course you can edit the ID3-Tags.

it-person
  • 30
  • 3