Sunday, February 2, 2014

How to repeat a single frame and combine with an audio stream for upload to YouTube with ffmpeg

Yea it's 3am... but..

I just made a video for a local snow storm, it took me maybe 10-15 attempts to get a successful ffmpeg command string that would take a single jpeg frame and a separate audio stream and combine the two in a format that YouTube would accept as a video. This would be particularly useful for anyone trying to archive or share music on YouTube while just using an album cover or a single picture when you don't have a video to go with it:

In this case I had tried to record a video with my cellphone that crashed and corrupted the video requiring me to use the backup sound recorder inside windows 7. This left me with a wma2 audio file and no video stream, and of course YouTube doesn't want people to just upload audio so I had to figure a way to get around this.

C:\>ffmpeg.exe -loop 1 -r 2 -f image2 -i c:\001.jpg  -i rw1.wma -c:v libx264 -preset medium -tune stillimage -shortest -crf 18 -ab 192k  -pix_fmt yuv420p  -s 1920x1080 output.mkv

-preset medium, -crf 18 and -pix_fmt yuv420p are technically optional however if you don't know what these mean you should leave them or read up on exactly what they do.

Here is a sample video I created using this method: