Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mp3 + image to flv 2

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
Hi,

Im looking for a commandprompt method to convert 1 mp3 file and 1 or more image files into a single flv file...

i use mencoder to convert most video files to flv...

this does not work for mp3 tho, so i guess the steps would be:

convert the 1 or more images to a video
add the mp3 as audio to this file
convert the whole thing to flv

having some problems finding the right software and methods tho.

can anyone help me?

thanks!






I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
...and this has what exactly to do with Linux servers?

Anyway, from the top of my head, have your files named sequentially. i.e. img00000.png, img000001.png ... etc. Get ffmpeg. Use: ffmpeg -r 1 -i img%05d.png -i some_music.mp3 -y -f flv -r 5 -s 352x240 some_output.flv. The first -r denotes the rate at which the image files are read in (fps). A value of 1 plays 1 image every 1 second, 0.5 plays 1 image every 2 seconds etc. Adjust to fit audio.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Thank you, i will try this.

this has to do with linux server because it is running on a linux server, the files to be converted will be uploaded, and the command will be called from php's exec or system

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Iv been trying this out however it seems the image is added to the file but the audio is not. any idea's?

exec("/usr/local/bin/ffmpeg -r 1 -i audiofile.mp3 -i image.png -y -f flv -r 0.1 -s 444x250 output.flv");

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
i tried the code in the command prompt with just audio and got this:

Code:
root@premium1 [/home/thomas/public_html/mp3flv/tmp]# /usr/local/bin/ffmpeg -r 1 -i /home/thomas/public_html/mp3flv/tmp/aud46fa38bc1e1c2.mp3 -y -f flv -r 0.1 -s 444x250 /home/thomas/public_html/mp3flv/tmp/t_aud46fa38bc1e1c2.flv              FFmpeg version SVN-r7986, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --enable-shared
  libavutil version: 49.3.0
  libavcodec version: 51.33.0
  libavformat version: 51.10.0
  built on Feb 16 2007 00:58:35, gcc: 3.4.6 20060404 (Red Hat 3.4.6-3)
Input #0, mp3, from '/home/thomas/public_html/mp3flv/tmp/aud46fa38bc1e1c2.mp3':
  Duration: 00:00:49.6, start: 0.000000, bitrate: 128 kb/s
  Stream #0.0: Audio: mp3, 44100 Hz, stereo, 128 kb/s
Output file does not contain any stream

output: none



with both audio and an image i got this:

Code:
root@premium1 [/home/thomas/public_html/mp3flv/tmp]# /usr/local/bin/ffmpeg -r 1 -i /home/thomas/public_html/mp3flv/tmp/aud46fa38bc1e1c2.mp3 -i /home/thomas/public_html/mp3flv/tmp/aud46fa38bc1e1c2.png -y -f flv -r 0.1 -s 444x250 /home/thomas/public_html/mp3flv/tmp/t_aud46fa38bc1e1c2.flv
FFmpeg version SVN-r7986, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --enable-shared
  libavutil version: 49.3.0
  libavcodec version: 51.33.0
  libavformat version: 51.10.0
  built on Feb 16 2007 00:58:35, gcc: 3.4.6 20060404 (Red Hat 3.4.6-3)
Input #0, mp3, from '/home/thomas/public_html/mp3flv/tmp/aud46fa38bc1e1c2.mp3':
  Duration: 00:00:49.6, start: 0.000000, bitrate: 128 kb/s
  Stream #0.0: Audio: mp3, 44100 Hz, stereo, 128 kb/s
Input #1, image2, from '/home/thomas/public_html/mp3flv/tmp/aud46fa38bc1e1c2.png':
  Duration: 00:00:01.0, start: 0.000000, bitrate: N/A
  Stream #1.0: Video: png, rgb24, 444x250,  1.00 fps(r)
Output #0, flv, to '/home/thomas/public_html/mp3flv/tmp/t_aud46fa38bc1e1c2.flv':
  Stream #0.0: Video: flv, yuv420p, 444x250, q=2-31, 200 kb/s,  0.10 fps(c)
Stream mapping:
  Stream #1.0 -> #0.0
Press [q] to stop encoding
Compiler did not align stack variables. Libavcodec has been miscompiled
and may be very slow or crash. This is not a bug in libavcodec,
but in the compiler. Do not report crashes to FFmpeg developers.
frame=    1 q=4.3 Lsize=      23kB time=10.0 bitrate=  18.8kbits/s
video:23kB audio:0kB global headers:0kB muxing overhead 0.870834%

output: 1 frame flv with image but no audio

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
I think you've got the inputs wrong. The frame rate option -r, must come before the image input and not the audio input. Also, you should have the second -r = 1. From you command example, the resulting video would only play for 1/10 of a second for every input frame.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
ok, changed it to:

/usr/local/bin/ffmpeg -i audio.mp3 -r 1 -i image.png -y -f flv -r 1 -s 444x250 output.flv

but still the same result, 1 frame video with no audio.

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
OK. I messed around a bit and found this to work better.

Code:
ffmpeg -loop_input -t 30 -i image.png -i audiowav.mp3 -y -f flv -r 1 -s 352x240 test.flv

In this example, my audio is 30 seconds long. So i ask ffmpeg to loop my input image (-loop_input) for 30 seconds (-t 30).

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
I'm going to ask a tangent question, don't want to sidetrack the OP's thread...

If one wanted to make a slideshow with, say, 10 images over 2 minutes, would this solution still be appropriate? How?

D.E.R. Management - IT Project Management Consulting
 
Have your images named in sequential order. i.e. pic0001.png pic0002.png ... pic0010.png. 10 images over 120s = 12s/image = 1/12 fps.

As per my initial command:
Code:
ffmpeg -r 1:12 -i pic%04d.png -i some_music.mp3 -y -f flv -r 1 -s 352x240 some_output.flv

For me however, the first image always plays too fast (plays only for 1 second). Don't know why yet. May inquire over at the ffmpeg user forum.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
COOL!

zeland, that nomenclature is new to me

Code:
ffmpeg -r 1:12 -i pic%04d.png

"%04d" looks like string formatting speak, but is that usage specific to a particular shell or is that something that ffmpeg has as a unique parameter parsing capability?



D.E.R. Management - IT Project Management Consulting
 
Yup, %04d is formating placeholder just like what is used in C /PHP programing printf() function. I've used this nomenclature for as long as I've used ffmpeg. Other video editing application like MJPEG Tools png2yuv use it too. It would seem silly if not down right tedious to type in 40,000++ image names to form a 30 minute video.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Hi Zeland,

Now the video clip is longer than 1 frame but still no sound, im starting to think there is something wrong with the software on the server that processes the sound part :/

any ideas?








I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Can you post the command used and the full output of ffmpeg?

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Code:
/usr/local/bin/ffmpeg -loop_input -t 30 -i tmp/image.png -i tmp/audio.mp3 -y -f flv -r 1 -s 444x250 video.flv

FFmpeg version SVN-r7986, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --enable-shared
  libavutil version: 49.3.0
  libavcodec version: 51.33.0
  libavformat version: 51.10.0
  built on Feb 16 2007 00:58:35, gcc: 3.4.6 20060404 (Red Hat 3.4.6-3)

Input #0, image2, from 'tmp/image.png':
  Duration: 00:00:00.0, start: 0.000000, bitrate: N/A
  Stream #0.0: Video: png, rgb24, 444x250, 25.00 fps(r)

Input #1, mp3, from 'tmp/audio.mp3':
  Duration: 00:00:49.6, start: 0.000000, bitrate: 128 kb/s
  Stream #1.0: Audio: mp3, 44100 Hz, stereo, 128 kb/s

Output #0, flv, to 'video.flv':
  Stream #0.0: Video: flv, yuv420p, 444x250, q=2-31, 200 kb/s,  1.00 fps(c)

Stream mapping:
  Stream #0.0 -> #0.0

Press [q] to stop encoding 

Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec, but in the compiler. Do not report crashes to FFmpeg developers.

frame=   30 q=2.0 Lsize=     124kB time=30.0 bitrate=  33.9kbits/s

so whats wrong with the libav... does it matter... and how do i fix it :)



I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
i missed this bit on the end:
Code:
video:124kB audio:0kB global headers:0kB muxing overhead 0.526869%

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Notice my output line, it has 2 streams, Stream #0.0: Video & Stream #0.1: Audio. Yours only has video. This explains why your output doesn't have sound. It could be that your libavcodec/ffmpeg might be stuffed. Try downloading the latest SVN and recompile ffmpeg.

Code:
$ ffmpeg -loop_input -t 30 -i img0001.png -i audio.mp3 -y -f flv -r 1 -s 352x240 video.flv
FFmpeg version SVN-r9849, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/usr --enable-libmp3lame --enable-libogg --enable-libvorbis --enable-libxvid --enable-libx264 --enable-liba52 --enable-libfaac --enable-libfaadbin --enable-pp --enable-gpl --enable-pthreads --enable-static --enable-shared --enable-swscaler
  libavutil version: 49.4.1
  libavcodec version: 51.40.4
  libavformat version: 51.12.1
  built on Aug  1 2007 18:51:21, gcc: 4.1.2 20070502 (Red Hat 4.1.2-12)
Input #0, image2, from 'img0001.png':
  Duration: 00:00:00.0, start: 0.000000, bitrate: N/A
  Stream #0.0: Video: png, rgb24, 352x240, 25.00 fps(r)
Input #1, mp3, from 'audio.mp3':
  Duration: 00:00:30.0, start: 0.000000, bitrate: 127 kb/s
  Stream #1.0: Audio: mp3, 44100 Hz, stereo, 128 kb/s
Output #0, flv, to 'video.flv':
  Stream #0.0: Video: flv, yuv420p, 352x240, q=2-31, 200 kb/s,  1.00 fps(c)
  Stream #0.1: Audio: libmp3lame, 44100 Hz, stereo, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #1.0 -> #0.1
Press [q] to stop encoding
frame=   30 fps=  3 q=2.0 Lsize=     263kB time=30.0 bitrate=  71.9kbits/s    
video:9kB audio:235kB global headers:0kB muxing overhead 7.664762%

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
reinstalled ffmpeg:

Code:
wget [URL unfurl="true"]http://ffmpeg.mplayerhq.hu/ffmpeg-export-snapshot.tar.bz2[/URL]
tar xfj ffmpeg-export-snapshot.tar.bz2
cd ffmpeg-export*
mkdir tmp
env TMPDIR=./tmp ./configure --enable-shared
make
make install
cd ..

wget [URL unfurl="true"]http://www.haque.net/software/ffmpeg/svn-snapshots/ffmpeg-svn-snapshot-latest.tar.bz2[/URL]
tar xfj ffmpeg-svn-snapshot-latest.tar.bz2
cd ffmpeg-svn
mkdir tmp
env TMPDIR=./tmp ./configure --enable-shared
make && make install
cd ..

wget [URL unfurl="true"]http://puzzle.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.1.tbz2[/URL]
tar xjf ffmpeg-php-0.5.1.tbz2
cd ffmpeg-php-0.5.1
phpize
./configure && make
make install
cd ..

but still getting this:


Code:
/usr/local/bin/ffmpeg -loop_input -t 30 -i tmp/image.png -i tmp/audio.mp3 -y -f flv -r 1 -s 444x250 video.flv

FFmpeg version SVN-r10597, Copyright (c) 2000-2007 Fabrice Bellard, et al.

  configuration: --enable-shared
  libavutil version: 49.5.0
  libavcodec version: 51.44.0
  libavformat version: 51.14.0
  built on Sep 27 2007 11:34:07, gcc: 3.4.6 20060404 (Red Hat 3.4.6-8)

Input #0, image2, from 'tmp/image.png':
  Duration: 00:00:00.0, start: 0.000000, bitrate: N/A
  Stream #0.0: Video: png, rgb24, 444x250, 25.00 fps(r)

Input #1, mp3, from 'tmp/audio.mp3':
  Duration: 00:00:49.6, bitrate: 128 kb/s
  Stream #1.0: Audio: mp3, 44100 Hz, stereo, 128 kb/s

Output #0, flv, to 'video.flv':
  Stream #0.0: Video: flv, yuv420p, 444x250, q=2-31, 200 kb/s,  1.00 fps(c)
Stream mapping:
  Stream #0.0 -> #0.0

Press [q] to stop encoding
Compiler did not align stack variables. Libavcodec has been miscompiled and may be very slow or crash. This is not a bug in libavcodec, but in the compiler. You may try recompiling using gcc >= 4.2. Do not report crashes to FFmpeg developers.

frame=   30 fps=  2 q=2.0 Lsize=     124kB time=30.0 bitrate=  33.9kbits/s video:124kB audio:0kB global headers:0kB muxing overhead 0.526731%


am i missing a config option??


I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
also interesting if i do audio first then the image, it still only loads the image, its like my audio is being ignored...

converting an avi/mpg with sound to an flv with sound works fine tho >.<

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Well, the first obvious thing to look at is that the error is asking you to compile ffmpeg using gcc >= 4.2. I've compiled mine under 4.1. What ver of gcc do you have?

Another thing that struck me is your ffmpeg build. The config line only states --enable-shared and nothing else. Can you encode a normal .wav file into an .mp3? You may want to passing the --enable-libmp3lame parameter during ./configure and recompile again.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top