0

I'm trying to make a slideshow from some pictures along with an existing mp3 (copied). Picture dimensions differ, but I want the video output to be 16:9 aspect ratio and 3840x2160. I also want a watermark. It is important that pictures are not stretched.

I tried this code...

ffmpeg -y -framerate 1/1.5 -i "pics/%03d.jpg" -i audio.mp3 -c:v libx264 -r 24 -preset veryfast -tune stillimage -c:a copy -pix_fmt yuv420p -aspect 16:9 -filter_complex "scale=iw*min(3840/iw\,2160/ih):ih*min(3840/iw\,2160/ih),pad=3840:2160:(3840-iw)/2:(2160-ih)/2, movie=watermark.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" vid.mkv

But it is giving me this error:

[AVFilterGraph @ 0x2d21480] Too many inputs specified for the "movie" filter. Error initializing complex filters. Invalid argument

I am able to successfully make a slideshow with pictures, audio, and watermark; however, I am unable to factor in the aspect ratio without having pictures getting stretched.

If it makes a difference, the output video will be uploaded to YouTube.

Pamela
  • 507
  • 6
  • 23

1 Answers1

2

You can remove the aspect flag. Since your filter output is 3840x2160, which is 16:9, you don't need it. Your scale filter works for me with images of varying ratios.

Here's a full command for you to try:

ffmpeg -y -framerate 2/3 -i "pics/%03d.jpg" -i audio.mp3 -loop 1 -i watermark.png
-filter_complex
 "[0:v]scale=iw*min(3840/iw\,2160/ih):ih*min(3840/iw\,2160/ih),
 pad=3840:2160:(3840-iw)/2:(2160-ih)/2[ss];
 [ss][2:v] overlay=main_w-overlay_w-10:main_h-overlay_h-10:shortest=1[out]"
 -map "[out]" -map 1:a
 -c:v libx264 -r 24 -preset veryfast -tune stillimage -pix_fmt yuv420p
 -c:a copy
vid.mkv
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Thanks, but for some reason the console displays `frame= 3 fps=0.0 q=0.0 size= 1kB time=00:00:00.00 bitrate=N/A speed=` in an endless loop. I don't know if it makes a difference that some of my pictures have widths/heights not divisible by 2 (e.g. 1327x177)? – Pamela Jan 16 '16 at 14:04
  • When I try almost the same thing but with -vf and without the final out label, the video saves with only the audio (no pictures/watermark): `ffmpeg -y -framerate 2/3 -i "pics/%03d.jpg" -i audio.mp3 -i watermark.png -vf "[0:v]scale=iw*min(3840/iw\,2160/ih):ih*min(3840/iw\,2160/ih), pad=3840:2160:(3840-iw)/2:(2160-ih)/2[ss]; [ss][2:v] overlay=main_w-overlay_w-10:main_h-overlay_h-10[out]" -map 1:a -c:v libx264 -r 24 -preset veryfast -tune stillimage -pix_fmt yuv420p -c:a copy vid.mkv` – Pamela Jan 16 '16 at 14:09
  • 1
    `vf` is for a single video input only, but the overlay takes in two inputs. The odd dimension is also not an issue since the frames sent to the encoder is the padded 3840x2160 stream. Might one of your images be corrupt? Run my command with `-report` added and paste the contents of the generated logfile. – Gyan Jan 16 '16 at 14:33
  • Report results were too big to post in my question, so I have them on [jsfiddle](https://jsfiddle.net/w0kLgdc7/). Please note there were two lines which I deleted instances of. These are indicated by ********* – Pamela Jan 16 '16 at 15:01
  • Thanks. Is there any difference in using `-framerate 2/3` vs. `-framerate 1/1.5`? – Pamela Jan 16 '16 at 15:48
  • 1
    No. Just my convention. – Gyan Jan 16 '16 at 15:49