3

I tried this:

ffmpeg -i /sdcard/video/transcode/video.avi -map 0:0,0 -i /sdcard/video/transcode/first.mp3 -map 1:0,1  -i /sdcard/video/transcode/second.mp3 -map 2:0,2 -acodec copy -vcodec py /sdcard/video/transcode/Output.avi

to add two audio streams to one video file. But ffmpeg says the number of mappings should match the number of output streams. What is wrong here?


I'm trying to work with an Android build of FFmepg "ffmpeg for android beta". "Does not work" means that this uncommunicative Android build of FFmpeg just stops without giving any error message. The -codec copy option does not work with this build.

Now I tried the same set of files with the FFmpeg called command line tool that comes with Ubuntu 10. Something (can't say where it is from). The -codec copy option does not work with this FFmpeg too.

Here the complete output:

m30x:~/movie/Film$ ffmpeg -i input.avi -i first.mp3 -i second.mp3 -map 0 -map 1 -map 2 -acodec copy -vcodec copy output.avi
FFmpeg version SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.9-0ubuntu0.10.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Jun 12 2012 16:27:34, gcc: 4.4.3
[NULL @ 0x93cfd10]looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag

Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (30000/1) -> 25.00 (25/1)
Input #0, avi, from 'input.avi':
  Duration: 01:30:33.00, start: 0.000000, bitrate: 901 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 576x432, 25 tbr, 25 tbn, 30k tbc
Input #1, mp3, from 'first.mp3':
  Duration: 01:30:32.84, start: 0.000000, bitrate: 63 kb/s
    Stream #1.0: Audio: mp3, 22050 Hz, stereo, s16, 64 kb/s
Input #2, mp3, from 'second.mp3':
  Duration: 01:30:32.84, start: 0.000000, bitrate: 63 kb/s
    Stream #2.0: Audio: mp3, 22050 Hz, stereo, s16, 64 kb/s
Number of stream maps must match number of output streams

Merging only one audio stream with the video stream works with Ubuntu and Android version of FFmpeg. Here the complete output:

ffmpeg -i input.avi -i first.mp3 -map 0 -map 1 -acodec copy -vcodec copy output.avi
FFmpeg version SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.9-0ubuntu0.10.04.1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Jun 12 2012 16:27:34, gcc: 4.4.3
[NULL @ 0x9bfad10]looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag

Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (30000/1) -> 25.00 (25/1)
Input #0, avi, from 'input.avi':
  Duration: 01:30:33.00, start: 0.000000, bitrate: 901 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 576x432, 25 tbr, 25 tbn, 30k tbc
Input #1, mp3, from 'first.mp3':
  Duration: 01:30:32.84, start: 0.000000, bitrate: 63 kb/s
    Stream #1.0: Audio: mp3, 22050 Hz, stereo, s16, 64 kb/s
Output #0, avi, to 'output.avi':
    Stream #0.0: Video: mpeg4, yuv420p, 576x432, q=2-31, 90k tbn, 25 tbc
    Stream #0.1: Audio: libmp3lame, 22050 Hz, stereo, s16, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #1.0 -> #0.1
Press [q] to stop encoding
frame= 6157 fps=6156 q=-1.0 size=   31667kB time=246.28 bitrate=1053.3kbits/s   

Do you have an idea why it does not work with two audio streams?

By the way,

ffmpeg -i input_with_first_audio_stream.avi -i second.mp3 -acodec copy -vcodec copy output_two_audio_streams.avi -newaudio

works with both versions of ffmpeg that I use, but the first audio stream is played too fast (x10 or more), while the second audio stream is played correct.

Many thanks in advance and sorry for my unconventional question and outdated versions of ffmpeg. But I am a lamer and it is not so easy for me to compile from the source (especially for the Android version). I will try to compile an up to date version of ffmpeg with Ubuntu, but I don't have much free time.

3
  • Please include the complete ffmpeg console output.
    – llogan
    Nov 20, 2012 at 19:46
  • Sorry LordNeckbeard, I am using an android version of ffmpeg which does not output the complete console messages. The Video and mp3 files should consist of one Stream each. Nov 20, 2012 at 20:41
  • DID you get the solution of this answer?? Apr 17, 2015 at 5:31

2 Answers 2

6

See the -map and -codec options in the documentation. Example:

ffmpeg -i video.avi -i audio1.mp3 -i audio2.mp3 -map 0 -map 1 -map 2 -codec copy output

Also see:

3
  • Many thanks for your answer. I allready read the doc of the map option and the two first threads betören, but there is no example for what i want to do. Your code does not work either. I will try my set of files unser ubuntus ffmpeg and will Post the output. Nov 21, 2012 at 3:00
  • @tossinhausen You are most likely either using an outdated build, or you are not using FFmpeg. What Ubuntu now supplies is not from FFmpeg. "does not work" is not descriptive. Please at least provide the actual error messages or the complete console output.
    – llogan
    Nov 21, 2012 at 5:02
  • @TossinHausen Your ffmpeg is probably too old to support the syntax in my example. Either use a newer build or investigate the old and depreciated -newaudio option. For Ubuntu you can compile FFmpeg, use an already compiled static build, or Jon Severinsson's FFmpeg PPA if you want something recent.
    – llogan
    Nov 21, 2012 at 17:40
0

It really seems that there was used an outdatet version to compile the android version of ffmpeg found in the android market. As the output was reduced I was not able to find out which version. With Jon Severinsson's FFmpeg PPA which LordNeckbeard proposed everything works fine as described in the actual ffmpeg documentation. -newaudio worked in a second run but corrupted the first audio track. I will try to build an up to date version for android under ubuntu. I will do this when I find the time and report here in the forum. Many thanks for your help LordNeckbeard! tossin

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.