ffmpeg – Create Video From Single Image

How to use ffmpeg to create a YouTube video with audio and single image frame?

Make sure you have installed ffmpeg first!

I used this technique when I turned my audio podcasts into YouTube videos.

You can design your cover in Canva and somehow “glue” it to your audio.

To create a video from a single image and audio file, run this from the command line:

ffmpeg -loop 1 -i IMAGE.jpg -i AUDIO.wav -c:v libx264 -tune stillimage -c:a aac -b:a 192k -vf “scale=’iw-mod(iw,2)’:’ih-mod(ih,2)’,format=yuv420p” -shortest -movflags +faststart OUTPUT.mp4

Here’s how it looks like from the command line:

Simple, no?

Just replace IMAGE.jpg, AUDIO.wav and OUTPUT.mp4 with your actual file names.

Make sure to have no spaces in the file names, though.

The command line doesn’t like that very much.

You can quote the file names, e.g. “IMAGE.jpg”, but it’s best if you don’t use spaces in names at all.

Automating The Command

Let’s make this ffmpeg command easier and faster to re-use.

The best way is to create a quick batch script.

We can address 3 parts of the command:

  • IMAGE.jpeg – the name of your static single image
  • AUDIO.WAV – the name of your audio file (it can end with .mp3 as well)
  • OUTPUT.mp4 – the name of the final output video

Every time you create a new video, copy the script to your working folder.

And update the variables in the script.

Then run it.

From here, the script will have to:

Set The 3 Variables

SET IMAGE=”image.jpeg”

SET AUDIO=”audio.wav”

SET OUTPUT=”output.mp4″

Use The Variables In The Command

The next step is to update the command to use the variables we defined.

ffmpeg -loop 1 -i %IMAGE% -i %AUDIO% -c:v libx264 -tune stillimage -c:a aac -b:a 192k -vf “scale=’iw-mod(iw,2)’:’ih-mod(ih,2)’,format=yuv420p” -shortest -movflags +faststart %OUTPUT%

Putting it all together, here’s what a working version of SCRIPT.BAT looks like:

@echo off

SET IMAGE=”image.jpg”

SET AUDIO=”audio.wav”

SET OUTPUT=”output.mp4″

ffmpeg -loop 1 -i %IMAGE% -i %AUDIO% -c:v libx264 -tune stillimage -c:a aac -b:a 192k -vf “scale=’iw-mod(iw,2)’:’ih-mod(ih,2)’,format=yuv420p” -shortest -movflags +faststart %OUTPUT%

pause

When you double click script.bat, it will start putting your image and audio together.

Like this:

And when it’s done, it looks like this:

Success!

Let me know in the comments if you encounter problems with the script.

 

Leave a Reply

Your email address will not be published. Required fields are marked *