avconv video from single jpg and ogg

2

1

I have a long ogg sounds file that I want to put on youtube, I don't have a video so want to display a single jpg for the duration for the ogg. I've seen:

 avconv -i "sound file.ogg" -i cog.jpg out.avi

I have adjusted the jpg to be 640 x 480 but I get the following warnings:

 Incompatible pixel format 'yuvj420p' for codec 'mpeg4', auto-selecting format 'yuv420p'

 Incompatible sample format 's16' for codec 'ac3', auto-selecting format 'flt'
 [ac3 @ 0x18ae340] invalid bit rate

And it bombs out on:

 Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height

Any ideas on what parameters I could use to make this work?

pluke

Posted 2013-03-24T21:07:35.133

Reputation: 213

Answers

6

Without seeing the full command line output this boils down to guessing, but it seems avconv selects the AC3 encoder for audio here, which isn't a useful default.

Try specifying the encoders you want to use. For YouTube, H.264 and AAC is recommended instead of MPEG-4 Part 2 video and AC3 audio.

avconv -loop 1 -i cog.jpg -i "sound file.ogg" \
-c:v libx264 -tune stillimage -pix_fmt yuv420p \
-c:a libfaac -q:a 100 \
-shortest \
out.mp4

You should add the -loop 1 option to force looping the image, and the -shortest option to stop encoding after there's no more audio. Instead of -shortest you can also specify -t 00:02:30 to stop after 2:30 minutes, which would be more accurate than -shortest.

The above should work with any recent versions. Please note that avconv is not from FFmpeg, but the Libav fork and thus entirely unrelated to the ffmpeg command.

slhck

Posted 2013-03-24T21:07:35.133

Reputation: 182 472

It bombs out on: Unknown encoder 'libfaac' replacing it with: libvo_aacenc seems to do the trick – pluke – 2013-04-09T11:08:14.413

1This one offers quite mediocre quality. Use -c:a aac -strict experimental -b:a 192k for the native Libav one which is a little bit better, or install FAAC before installing Libav—it should then link against FAAC properly. – slhck – 2013-04-09T15:11:52.057