[MEncoder-users] Creating movie from audio and image file

Sebi Onofrei sebastian.onofrei at eyepartner.com
Tue Jul 8 08:38:33 CEST 2008


Hello all,

I'm trying to create a movie using ffmpeg and.or mencoder, from an image 
file (jpg / png) and an audio file.
I encountered problems and searched for answers but I was unable to find 
any that would help me in my problem, so I came to you to ask this directly.

Basically I have an audio file (mp3 / wav / ogg / whatever) and, for the 
entire length of this audio track, I want to create a movie (how it is 
encoded is not important for me) which will contain this audio track, 
and as video data - an image file (jpg / png / whaterver).
I tried to do this in one step, but I wasn't able to find any way to do 
this :( So here is what I did:

I succeeded in using mencoder to create a movie from the image file 
using the following command:

 >>> mencoder mf:///home/test/test.jpg -mf w=800:h=600:fps=25:type=jpg 
-ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o video.avi

The result (video.avi) file is a correct movie with only one frame (of 
course - that was expected)

Now, I tried to use ffmpeg to join my audio file with this one frame 
video file, into another output file, issuing the following command 
(which is incorrect, but I'm telling you what I've tried):

 >>> ffmpeg -y -i audio.mp3 -vn -acodec copy -i video.avi -an -vcodec 
copy -map 0:1 -map 1:0 -b 2500 result.avi


Now, I definitelly do something wrong as I cannot understand really well 
the -map option in order to get this right, but here is what I tried to do
- first input file (the audio file)
 -vn -- no video
 -acodec -- copy
- second input file (the video file created with mencoder)
 -an -- no audio
 -vcodec -- copy

now the -map options
-map 0:1 -map 1:0
 -map 0:1 -- I understood from documentation and other references that 
this means that input 0 (the audio file) is to be mapped to output 
stream 1(the audio)
 -map 1:0 -- mapping the video stream from input 2 (index 1) to the 
video stream in output file

Definitelly I do something wrong as ffmpeg reports this:
===
  libavutil version: 49.6.0
  libavcodec version: 51.56.0
  libavformat version: 52.13.0
  libavdevice version: 52.0.0
  built on Jun  1 2008 15:53:08, gcc: 4.1.2 20070626 (Red Hat 4.1.2-14)
Input #0, mp3, from 'audio.mp3':
  Duration: 00:08:02.61, start: 0.000000, bitrate: 320 kb/s
    Stream #0.0: Audio: mp3, 44100 Hz, stereo, 320 kb/s
Input #1, avi, from 'video.avi':
  Duration: 00:00:00.04, start: 0.000000, bitrate: 5445 kb/s
    Stream #1.0: Video: mpeg4, yuv420p, 800x600 [PAR 1:1 DAR 4:3], 25.00 
tb(r)
Output file does not contain any stream
===


Can I be forwarded to a more detailed documentation page or to the right 
direction about how to do this the right way?
What I want to do is similar to what movie maker from WinXP is doing - 
create a movie from an audio file and an image. The image should be the 
same for the entire length of the audio file. Of course, I would like to 
inform ffmpeg to add keyframes every X.XX seconds, etc... but these aer 
tweaks that I'll work on later, after I will see that the creation works 
in the beginning.


Note: I've sent this e-mail to both mencoder-users at mplayerhq.hu and 
ffmpeg-user at mplayerhq.hu as I've just registered myself with ffmpeg 
list, and I don't know if the message would arrive or not, and message 
arrival is priority for me.

Thank you for all your hard work and support.
With kind regards,
Sebi Onofrei



More information about the MEncoder-users mailing list