views:

1267

answers:

2

Hi :)

How can I add sound from a mp3-file to a flv file that has no audio? (With ffmpeg)

When I use

ffmpeg -i video.flv -i audio.mp3 -acodec copy -vcodec copy -ab 128k -ar 44100 output.flv

I get this output:

FFmpeg version SVN-r12758, Copyright (c) 2000-2008 Fabrice Bellard, et al.
  configuration: --enable-shared --prefix=/usr
  libavutil version: 49.6.0
  libavcodec version: 51.54.0
  libavformat version: 52.13.0
  libavdevice version: 52.0.0
  built on Apr  7 2008 09:00:42, gcc: 4.1.2 20070626 (Red Hat 4.1.2-14)
[flv @ 0x2b72415e00c0]Could not find codec parameters (Audio: 0x0000)
Input #0, flv, from 'video.flv':
  Duration: 00:00:03.2, start: 0.000000, bitrate: N/A
    Stream #0.0: Video: flv, yuv420p, 468x312, 1000.00 tb(r)
    Stream #0.1: Audio: 0x0000
mdb:511, lastbuf:0 skipping granule 0
mdb:511, lastbuf:0 skipping granule 0
mdb:511, lastbuf:0 skipping granule 1
mdb:511, lastbuf:0 skipping granule 1
Input #1, mp3, from 'audio.mp3':
  Duration: 00:01:00.9, start: 0.000000, bitrate: 128 kb/s
    Stream #1.0: Audio: mp3, 44100 Hz, stereo, 128 kb/s
Output #0, flv, to 'output.flv':
    Stream #0.0: Video: flv, yuv420p, 468x312, q=2-31, 1000.00 tb(c)
    Stream #0.1: Audio: 0x0000
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
[flv @ 0x2b72415e00c0]sample rate not set
Could not write header for output file #0 (incorrect codec parameters ?)

A: 

This might work, haven't tried recently:

ffmpeg -i video.flv -i audio.mp3 -acodec copy -vcodec copy out.flv
David
Hmmm it says "Could not find codec parameters (Audio: 0x0000)" Seems not to work with flvs that have no audio at all.. :(
Past the ffmpeg output error message to your question.
Stu Thompson
The mp3's sample rate will need to be 44100, 22050, or 11025hz.
David
Still does not work... added more detailed info in my question.
+1  A: 

You need to add "-map 0:0 -map 1:0" to tell it to get the video from the flv and the audio from the mp3. ffmpeg was trying to use the audio channel from the flv, which rather than not having one at all had an invalid one, instead of using the mp3.

David