Discussion:
[FFmpeg-user] Creating movie from audio and image file
Sebi Onofrei
2008-07-08 06:38:33 UTC
Permalink
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
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
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
Benoit Fouet
2008-07-08 13:18:14 UTC
Permalink
Hi,
Post by Sebi Onofrei
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
I succeeded in using mencoder to create a movie from the image file
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
ffmpeg -y -i audio.mp3 -vn -acodec copy -i video.avi -an -vcodec
copy -map 0:1 -map 1:0 -b 2500 result.avi
try the following:
ffmpeg -i test.jpg -i audio.mp3 [your_options_here] output_file.mp4/nut/...
--
Benoit Fouet
Purple Labs S.A.
www.purplelabs.com
Sebi Onofrei
2008-07-08 13:27:20 UTC
Permalink
Post by Benoit Fouet
Hi,
Post by Sebi Onofrei
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
I succeeded in using mencoder to create a movie from the image file
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
ffmpeg -y -i audio.mp3 -vn -acodec copy -i video.avi -an -vcodec
copy -map 0:1 -map 1:0 -b 2500 result.avi
ffmpeg -i test.jpg -i audio.mp3 [your_options_here] output_file.mp4/nut/...
Hello,

I'm still working on this, and finally I will not need mencoder with
this process too, as currently I'm doing something like this:

ffmpeg -y -b 2500k -r 30 -i image.jpg -i audio.mp3 -map 0:0 -map 1:0
-vsync 1 -acodec ac3 -ab 384k -vcodec mpeg4 -s 800x600 result2.avi


Now, the output is a big file which has only one frame and the entire
audio. Is there any way to "extend" the image to be visible for the
entire audio stream length? Is possible something like that? Or the only
way to do this would be to generate audio_length_in_seconds * frame_rate
images and use them as input ?


Thank you

Seby
Benoit Fouet
2008-07-08 13:33:47 UTC
Permalink
Hi,
Post by Sebi Onofrei
Post by Benoit Fouet
Hi,
Post by Sebi Onofrei
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
I succeeded in using mencoder to create a movie from the image file
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
ffmpeg -y -i audio.mp3 -vn -acodec copy -i video.avi -an -vcodec
copy -map 0:1 -map 1:0 -b 2500 result.avi
ffmpeg -i test.jpg -i audio.mp3 [your_options_here] output_file.mp4/nut/...
Hello,
I'm still working on this, and finally I will not need mencoder with
ffmpeg -y -b 2500k -r 30 -i image.jpg -i audio.mp3 -map 0:0 -map 1:0
-vsync 1 -acodec ac3 -ab 384k -vcodec mpeg4 -s 800x600 result2.avi
I don't think you need neither the map options at all, nor the sync one,
nor the framerate one
(and if you don't care about output file format, don't use avi)
also, try to pay attention to where you place options in your command
line, that should be:
ffmpeg -i image.jpg -i audio.mp3 -y -b 2500k -acodec ac3 -ab 384k
-vcodec mpeg4 -s svga result.mp4
Post by Sebi Onofrei
Now, the output is a big file which has only one frame and the entire
audio. Is there any way to "extend" the image to be visible for the
entire audio stream length? Is possible something like that? Or the only
way to do this would be to generate audio_length_in_seconds * frame_rate
images and use them as input ?
see -loop_input and -r options
--
Benoit Fouet
Purple Labs S.A.
www.purplelabs.com
Sebi Onofrei
2008-07-08 14:38:41 UTC
Permalink
Post by Benoit Fouet
Hi,
Post by Sebi Onofrei
Post by Benoit Fouet
Hi,
Post by Sebi Onofrei
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
I succeeded in using mencoder to create a movie from the image file
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
ffmpeg -y -i audio.mp3 -vn -acodec copy -i video.avi -an -vcodec
copy -map 0:1 -map 1:0 -b 2500 result.avi
ffmpeg -i test.jpg -i audio.mp3 [your_options_here] output_file.mp4/nut/...
Hello,
I'm still working on this, and finally I will not need mencoder with
ffmpeg -y -b 2500k -r 30 -i image.jpg -i audio.mp3 -map 0:0 -map 1:0
-vsync 1 -acodec ac3 -ab 384k -vcodec mpeg4 -s 800x600 result2.avi
I don't think you need neither the map options at all, nor the sync one,
nor the framerate one
(and if you don't care about output file format, don't use avi)
also, try to pay attention to where you place options in your command
ffmpeg -i image.jpg -i audio.mp3 -y -b 2500k -acodec ac3 -ab 384k
-vcodec mpeg4 -s svga result.mp4
Post by Sebi Onofrei
Now, the output is a big file which has only one frame and the entire
audio. Is there any way to "extend" the image to be visible for the
entire audio stream length? Is possible something like that? Or the only
way to do this would be to generate audio_length_in_seconds * frame_rate
images and use them as input ?
see -loop_input and -r options
Hello,

Thanks for the -loop_input hint. This saved me :)

The command I used at the end is this one (in case anyone else meets
this problem)

?ffmpeg -loop_input -vframes 14490 -i imagine.jpg -i audio.mp3 -y -r 30
-b 2500k -acodec ac3 -ab 384k -vcodec mpeg4 result.mp4

-vframes 14490 is the quick computed number of frames that should be
looped in order to have a continuous image for the entire audio.mp3 file
which in my case was 8 minutes and ~3 seconds ( (8m x 60s + 3s)
x 30fps = 14490 vf )


Thank you a lot for your time.
With kind regards,
Seby Onofrei
Benoit Fouet
2008-07-08 14:41:51 UTC
Permalink
Hi,

Sebi Onofrei wrote:
[...]
Post by Sebi Onofrei
The command I used at the end is this one (in case anyone else meets
this problem)
?ffmpeg -loop_input -vframes 14490 -i imagine.jpg -i audio.mp3 -y -r 30
-b 2500k -acodec ac3 -ab 384k -vcodec mpeg4 result.mp4
-vframes 14490 is the quick computed number of frames that should be
looped in order to have a continuous image for the entire audio.mp3 file
which in my case was 8 minutes and ~3 seconds ( (8m x 60s + 3s)
x 30fps = 14490 vf )
you don't need to specify -vframes.
--
Benoit Fouet
Purple Labs S.A.
www.purplelabs.com
Sebi Onofrei
2008-07-08 17:09:49 UTC
Permalink
Post by Benoit Fouet
Hi,
[...]
Post by Sebi Onofrei
The command I used at the end is this one (in case anyone else meets
this problem)
?ffmpeg -loop_input -vframes 14490 -i imagine.jpg -i audio.mp3 -y -r 30
-b 2500k -acodec ac3 -ab 384k -vcodec mpeg4 result.mp4
-vframes 14490 is the quick computed number of frames that should be
looped in order to have a continuous image for the entire audio.mp3 file
which in my case was 8 minutes and ~3 seconds ( (8m x 60s + 3s)
x 30fps = 14490 vf )
you don't need to specify -vframes.
True, I don't need to specify that :) Thank you a lot !

With kind regards,
Sebi Onofrei

Continue reading on narkive:
Loading...