Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Compression Techniques Unable to add audio to video

  • Unable to add audio to video

    Posted by Zafar Yousafi on July 1, 2012 at 11:11 am

    Hi, I am trying to add audio to a video(with no video) using command
    ffmpeg -y -i 0001.mp4 -i audio.mp3 -map 0:0 -map 1:
    0 -c copy withaudio.mp4

    but received following error
    ffmpeg version N-34318-g8475ec1, Copyright (c) 2000-2011 the FFmpeg developers
    built on Oct 31 2011 17:50:05 with gcc 4.6.1
    configuration: --enable-gpl --enable-version3 --enable-runtime-cpudetect --ena
    ble-avisynth --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-
    libopencore-amrwb --enable-libfreetype --enable-libgsm --enable-libmp3lame --ena
    ble-libopenjpeg --enable-librtmp --enable-libschroedinger --enable-libspeex --en
    able-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
    --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib

    libavutil 51. 22. 0 / 51. 22. 0
    libavcodec 53. 26. 0 / 53. 26. 0
    libavformat 53. 18. 0 / 53. 18. 0
    libavdevice 53. 4. 0 / 53. 4. 0
    libavfilter 2. 45. 3 / 2. 45. 3
    libswscale 2. 1. 0 / 2. 1. 0
    libpostproc 51. 2. 0 / 51. 2. 0
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '0001.mp4':
    Metadata:
    major_brand : mp42
    minor_version : 0
    compatible_brands: isom
    encoder : Machete 3.8
    Duration: 00:02:27.09, start: 0.000000, bitrate: 98 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x460 [
    SAR 23:24 DAR 4:3], 61 kb/s, 25 fps, 25 tbr, 600 tbn, 50 tbc
    Metadata:
    handler_name : Machete Video Handler
    Stream #0:1(eng): Audio: mp3 (mp4a / 0x6134706D), 8000 Hz, 1 channels, s16,
    30 kb/s
    Metadata:
    handler_name :
    [mp3 @ 01D66800] max_analyze_duration 5000000 reached at 5040000
    Input #1, mp3, from 'audio.mp3':
    Duration: 00:06:30.16, start: 0.000000, bitrate: 29 kb/s
    Stream #1:0: Audio: mp3, 8000 Hz, mono, s16, 24 kb/s
    [mp4 @ 01D60060] track 1: muxing mp3 at 8000hz is not supported
    Output #0, mp4, to 'withaudio.mp4':
    Metadata:
    major_brand : mp42
    minor_version : 0
    compatible_brands: isom
    encoder : Lavf53.18.0
    Stream #0:0(eng): Video: h264 (![0][0][0] / 0x0021), yuv420p, 640x460 [SAR 2
    3:24 DAR 4:3], q=2-31, 61 kb/s, 25 tbn, 25 tbc
    Metadata:
    handler_name : Machete Video Handler
    Stream #0:1: Audio: mp3 (i[0][0][0] / 0x0069), 8000 Hz, mono, 24 kb/s
    Stream mapping:
    Stream #0.0 -> #0.0 (copy)
    Stream #1.0 -> #0.1 (copy)
    Could not write header for output file #0 (incorrect codec parameters ?)


    Please help

    Zafar Yousafi replied 14 years ago 2 Members · 4 Replies
  • 4 Replies
  • Reuben Martin

    July 2, 2012 at 2:05 am

    It tells you in the terminal output: [mp4 @ 01D60060] track 1: muxing mp3 at 8000hz is not supported

    You will need to re-sample and re-encode the audio in order to mux it into an mp4 file.

  • Zafar Yousafi

    July 3, 2012 at 6:12 am

    you are right. But how can I reencode my audio without loosing quality. when I try to remux with default settings, audio becomes garbled.

  • Reuben Martin

    July 3, 2012 at 1:50 pm

    ffmpeg -y -i 0001.mp4 -i audio.mp3 -map 0:0 -map 1:0 -c:v copy -c:a libmp3lame -ar 44100 -aq 0 withaudio.mp4

  • Zafar Yousafi

    July 8, 2012 at 9:50 am

    Thanx. It help me a lot

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy