I am an ffmpeg noob. I'm running the following command:

ffmpeg -i audio.mp3 -ar 44100 -f image2 -i logo.jpg -r 15 -b 1800 -s 640x480 foo.mov

Which successfully outputs a video with my recorded audio and an image on it.

When I try and upload this to Youtube it fails to process, regardless of the formats I try: .mov, .avi, .flv, .mp4

Is there some setting I'm missing in the above that would generate a format Youtube will accept? I've tried looking through the ffmpeg documentation but I'm in over my head.

-- UPDATE --

I did an experiment by putting a 2 second video with a 30 second mp3. When I uploaded to youtube, the resulting video was only 2 seconds long. So it may be that youtube looks only to the video track for the length, and since a picture is only a frame long or whatever, maybe that borks it.

link|improve this question
feedback

3 Answers

up vote 5 down vote accepted

Hallelujah! Here's what worked:

ffmpeg -i audio.mp3 -ar 44100 -f image2 -i logo.jpg -loop_input -shortest -r 15 -b 1800 -s 640x480 foo.mov

Specifically, the 'loop_input' command, which I assume will duplicate the image as frames or something. It will also then need the 'shortest' command to keep the file from growing and growing (this way it truncates it to the audio length).

I don't know what, if any, effect there is from 'r' (frame rate) or b (bit rate). Any ffmpeg geniuses, I welcome your input!

link|improve this answer
1  
Doesn't work for me. I get an one-frame movie. – Pavel Vlasov Aug 23 '11 at 22:46
what does the -b switch do? buffer? – pootzko Jan 18 at 13:24
feedback

A piece of code that works for me, from another forum:

ffmpeg -loop_input -r ntsc -i image.jpg -i song.mp3 -acodec copy -vcodec libx264 -vpre lossless_ultrafast -threads 0 -shortest output.mkv 
link|improve this answer
feedback

I took Pavel's code, that worked for me too, and shortened it by trimming needless options:

ffmpeg -loop_input -shortest -i <audio file> -i <image file> <output video file>

this is a general form that works with any image and audio file as input and produce a video file as output.

That said, since your video stream will be made of a single picture repeated indefinitely, you could set a low frame rate (that is the number of images that appears in a second) with -r. Note that not all output containers allow low frame rates. One that does is avi, so you might do:

ffmpeg -loop_input -shortest -r 0.1 -i <audio file> -i <image file> output.avi

this would create a video file with a frame rate of 0.1 (i.e. one image each 10 seconds) instead of the default of 25. This will affect file size but not video quality. Eventually, you can set the audio bitrate to get a better audio quality with -ab. This is the command I actually use to make this kind of videos for youtube:

ffmpeg -loop_input -shortest -r 0.1 -i <audio file> -i <image file> -ab 128k output.avi
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.