2

I'm trying to use mencoder to make a video that has music playing over a single image. I'm using mf to add the image and I always get a video with about one second of audio with a reported length of 0:00. I've tried with a variety of mp3's and images from different sources and I tried using various codecs and options but I can't seem to get past this problem. Here's the basic command:

mencoder "mf://image.jpg" -o out.avi -ovc lavc -lavcopts vcodec=mjpeg -audiofile music.mp3 -oac copy

Does anyone know how to do this or why mencoder cuts the music to one second?

Tim
  • 51

2 Answers2

3

It's because the default FPS is set to 30, so mencoder expects 30 images per second -- you have to tell mencoder to use one image for whole record, so you have to set FPS to 1/"duration".

Add this options:

-fps 1/132.8 -ofps 30

where 132.8 is duration (in seconds) of your audio.

So result should look like this:

mencoder mf://image.jpg -o out.avi \
        -ovc lavc -lavcopts vcodec=mjpeg -audiofile music.mp3 \
        -oac copy -fps 1/132.8 -ofps 30
andrew.46
  • 39,359
1

I only have came with an alternative where you would provide the same image from a pipe:

for x in `seq 1 55`; do cat image.jpg; done | mencoder -o out.avi -fps 1 -ovc lavc -demuxer lavf -lavfdopts format=mjpeg -audiofile music.mp3 -oac copy -

where you would replace 55 with the number of seconds you wish (this would be the length of the song, as you wish).

But, as you can see, it's dumber than the simple and straight-to-the-point answer by Vojtech. Only advantage I got with this alternative of mine was a smaller resulting file size.