audio - Concat videos with ffmpeg does not work

24
2013-08
  • BrainStone

    I'm currently trying to concat 3 Videos which don't have a audio stream and adding a audio file in the same step.

    I created this command which should do the work:

    ffmpeg -y -r 30 -i data\intro.mp4 -vcodec ppm -f image2pipe -i data\render.ppm -i data\outro.mp4 -i "data\I could be the one.mp3" -c:v libx264 -crf 18 -preset slow -pix_fmt yuv420p -c:a copy -filter_complex "[0:0] [1:0] [2:0] concat=n=3:v=1:a=0 [v]" -map [v] -map 3:0 -shortest -metadata title="Development of BrainStoneMod" -metadata description="This is the development of the BrainStoneMod starting from 08th April, 2013" -metadata author="The_BrainStone" -metadata copyright="2013" -metadata year="2013" -metadata composer="" -metadata TBPM="" -metadata TDAT="" gource.mp4
    

    It is indeed a long command but it satisfied my needs until I wanted to embend the actual video in between a intro and a outro.

    I'm getting this log:

    ffmpeg version N-51639-g7775992 Copyright (c) 2000-2013 the FFmpeg developers
      built on Apr  5 2013 22:24:22 with gcc 4.8.0 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
    e --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrn
    b --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libr
    tmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheo
    ra --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li
    bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena
    ble-zlib
      libavutil      52. 25.100 / 52. 25.100
      libavcodec     55.  2.100 / 55.  2.100
      libavformat    55.  1.100 / 55.  1.100
      libavdevice    55.  0.100 / 55.  0.100
      libavfilter     3. 49.100 /  3. 49.100
      libswscale      2.  2.100 /  2.  2.100
      libswresample   0. 17.102 /  0. 17.102
      libpostproc    52.  2.100 / 52.  2.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'data\intro.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf55.1.100
      Duration: 00:00:04.00, start: 0.000000, bitrate: 42 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720
    [SAR 1:1 DAR 16:9], 38 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
        Metadata:
          handler_name    : VideoHandler
    [image2pipe @ 027f0a80] Stream #0: not enough frames to estimate rate; consider
    increasing probesize
    Input #1, image2pipe, from 'data\render.ppm':
      Duration: N/A, bitrate: N/A
        Stream #1:0: Video: ppm, rgb24, 1280x720, 25 tbr, 25 tbn, 25 tbc
    Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'data\outro.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf55.1.100
      Duration: 00:00:04.00, start: 0.000000, bitrate: 42 kb/s
        Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720
    [SAR 1:1 DAR 16:9], 38 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc
        Metadata:
          handler_name    : VideoHandler
    [mp3 @ 02757020] max_analyze_duration 5000000 reached at 5015510 microseconds
    [mp3 @ 02757020] Estimating duration from bitrate, this may be inaccurate
    Input #3, mp3, from 'data\I could be the one.mp3':
      Metadata:
        TBPM            : 140
        TDAT            : 0000
        composer        : Kevin Als
      Duration: 00:03:55.91, start: 0.000000, bitrate: 320 kb/s
        Stream #3:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
    [Parsed_concat_0 @ 028b20e0] Input link in1:v0 parameters (size 1280x720, SAR 0:
    1) do not match the corresponding output link in0:v0 parameters (1280x720, SAR 1
    :1)
    [Parsed_concat_0 @ 028b20e0] Failed to configure output pad on Parsed_concat_0
    

    What should I do?

    By the way: This is the command I used before and worked out great:

    ffmpeg -y -r 30 -i "data\I could be the one.mp3" -vcodec ppm -f image2pipe -i data\render.ppm -c:v libx264 -crf 18 -preset slow -pix_fmt yuv420p -c:a copy -map 1:0 -map 0:0 -shortest -metadata title="Development of BrainStoneMod" -metadata description="This is the development of the BrainStoneMod starting from 08th April, 2013" -metadata author="The_BrainStone" -metadata copyright="2013" -metadata year="2013" -metadata composer="" -metadata TBPM="" -metadata TDAT="" gource.mp4
    

    Any ideas?

  • Answers
  • BrainStone

    Well i solved it by splitting it into two commands:

    ffmpeg -y -r 30 -i data\intro.mp4 -r 30 -i data\outro.mp4 -r 30 -vcodec ppm -f image2pipe -i data\render.ppm -filter_complex "[0:0] [2:0] [1:0] concat=n=3:v=1:a=0:unsafe=1 [v]" -c:v libx264 -preset ultrafast -map [v] data\tmp.mp4
    ffmpeg -y -r 30 -i data\tmp.mp4 -i "data\I could be the one.mp3" -c:v libx264 -crf 18 -preset slow -pix_fmt yuv420p -c:a copy -map 0:0 -map 1:0 -shortest -metadata title="Development of BrainStoneMod" -metadata description="This is the development of the BrainStoneMod starting from 08th April, 2013" -metadata author="The_BrainStone" -metadata copyright="2013" -metadata year="2013" -metadata composer="" -metadata TBPM="" -metadata TDAT="" gource.mp4
    

    But still, isn't there a possibility to do this in one???


  • Related Question

    audio - ffmpeg hangs when creating a video
  • FearUs

    I am trying to insert an audio channel with a video:

    1. first of all I extract the audio from the original video for processing:

      ffmpeg -i lotr.mp4 lotr.wav

    2. I then extract all frames for later processing too:

      ffmpeg -i lotr.mp4 -f image2 %d.jpg

    3. When done processing audio and video streams, I try to create the video

      ffmpeg -f image2 -r 15 -i %d.jpg new.mp4

    4. then merge with the audio:

      ffmpeg -i new.mp4 -i lotr.wav -map 0:0 -map 1:0 new_w_audio.mp4

    Result: CPU activity = 100%, the process hangs and never returns. PS: I even tried it without modifying the images or the audio (so just trying to unpack then repack the video) but still the same output

    FFmpeg version SVN-r26400, Copyright (c) 2000-2011 the FFmpeg developers
      built on Jan 18 2011 04:07:05 with gcc 4.4.2
      configuration: --enable-gpl --enable-version3 --enable-libgsm --enable-libvorb
    is --enable-libtheora --enable-libspeex --enable-libmp3lame --enable-libopenjpeg
     --enable-libschroedinger --enable-libopencore_amrwb --enable-libopencore_amrnb
    --enable-libvpx --disable-decoder=libvpx --arch=x86 --enable-runtime-cpudetect -
    -enable-libxvid --enable-libx264 --enable-librtmp --extra-libs='-lrtmp -lpolarss
    l -lws2_32 -lwinmm' --target-os=mingw32 --enable-avisynth --enable-w32threads --
    cross-prefix=i686-mingw32- --cc='ccache i686-mingw32-gcc' --enable-memalign-hack
    
      libavutil     50.36. 0 / 50.36. 0
      libavcore      0.16. 1 /  0.16. 1
      libavcodec    52.108. 0 / 52.108. 0
      libavformat   52.93. 0 / 52.93. 0
      libavdevice   52. 2. 3 / 52. 2. 3
      libavfilter    1.74. 0 /  1.74. 0
      libswscale     0.12. 0 /  0.12. 0
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'new.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        creation_time   : 1970-01-01 00:00:00
        encoder         : Lavf52.93.0
      Duration: 00:00:29.66, start: 0.000000, bitrate: 193 kb/s
        Stream #0.0(und): Video: mpeg4, yuv420p, 200x134 [PAR 1:1 DAR 100:67], 192 k
    b/s, 15 fps, 15 tbr, 15 tbn, 15 tbc
        Metadata:
          creation_time   : 1970-01-01 00:00:00
    [wav @ 01fed010] max_analyze_duration reached
    Input #1, wav, from 'lotr.wav':
      Duration: 00:00:29.90, bitrate: 176 kb/s
        Stream #1.0: Audio: pcm_s16le, 11025 Hz, 1 channels, s16, 176 kb/s
    File 'new_w_audio.mp4' already exists. Overwrite ? [y/N] y
    [buffer @ 01b03820] w:200 h:134 pixfmt:yuv420p
    Output #0, mp4, to 'new_w_audio.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        creation_time   : 1970-01-01 00:00:00
        encoder         : Lavf52.93.0
        Stream #0.0(und): Video: mpeg4, yuv420p, 200x134 [PAR 1:1 DAR 100:67], q=2-3
    1, 200 kb/s, 15 tbn, 15 tbc
        Metadata:
          creation_time   : 1970-01-01 00:00:00
        Stream #0.1: Audio: aac, 11025 Hz, 1 channels, s16, 64 kb/s
    Stream mapping:
      Stream #0.0 -> #0.0
      Stream #1.0 -> #0.1
    Press [q] to stop encoding
    

  • Related Answers
  • S.gfx

    Could be several things. A hang in general with video editing happens a lot when dealing with uncompressed video codecs. Not sure if I read up there that original video is in yuv420p codec. It maybe gets hanged trying to handle a lot of memory or when compressing directly the images to mp4. One thing I can think of is converting first to avi, ie, outputting to an avi but forcing a lossless codec like camtasia / camstudio (I think ffmpeg supports it) , so it is not so "heavy", and then do a second operation to convert to mp4. Other matter is... -r15 ? You surely know better which fps is having the original video, but it uses to be 24fps or so, isn't it?

    Also... You might force as well the output codec, not just the format. MP4 works pretty well with .h264 codec, which gives a lot of quality and incredible small size. If I remember well ffmpeg also supports it. (you might want to try this first of all...)

    Edit: Remember -codecs gives you the list of codecs, in command line. You can of course, for example in Win console, ffmpeg -codecs > codecs.txt for easier reading, searching etc. Healthy to do also with -formats, etc.

  • soandos

    Try updating to the latest version of ffmpeg.