audio - FFMPEG keeps converting without stopping

24
2013-08
  • Karim

    I have a web application that converts videos and splits them using FFMPEG. It was working fine until recently I noticed that the videos were taking much more time converting than they are supposed to. I ran the FFMPEG command and found that FFMPEG keeps converting after reaching the mark point.

    Here is the command that I ran:

    [root@myserver ~]# ffmpeg -y -ss 00:00:00.0 -t 00:01:00.0 -ar 44100 -i INPUT.wmv -qscale 5 -acodec libmp3lame -async 1 OUTPUT.flv
    

    And here is the result that I get:

    FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
    built on Jan 29 2012 23:55:02 with gcc 4.1.2 20080704 (Red Hat 4.1.2-51)
    configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --enable-avfilter --enable-avfilter-lavf --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
     libavutil     50.15. 1 / 50.15. 1
     libavcodec    52.72. 2 / 52.72. 2
     libavformat   52.64. 2 / 52.64. 2
     libavdevice   52. 2. 0 / 52. 2. 0
     libavfilter    1.19. 0 /  1.19. 0
     libswscale     0.11. 0 /  0.11. 0
     libpostproc   51. 2. 0 / 51. 2. 0
    [asf @ 0x1e7ae8b0]max_analyze_duration reached
    Input #0, asf, from 'INPUT.wmv':
      Metadata:
        WMFSDKVersion   : 12.0.7601.17514
        WMFSDKNeeded    : 0.0.0.0000
        IsVBR           : 0
      Duration: 04:01:40.81, start: 5.000000, bitrate: 245 kb/s
        Stream #0.0: Audio: wmapro, 44100 Hz, stereo, flt, 96 kb/s
        Stream #0.1: Video: vc1, yuv420p, 1364x768, 30.30 fps, 29.97 tbr, 1k tbn, 29.97 tbc
    Output #0, flv, to 'OUTPUT.flv':
    Metadata:
        encoder         : Lavf52.64.2
        Stream #0.0: Video: flv, yuv420p, 1364x768, q=2-31, 200 kb/s, 1k tbn, 29.97 tbc
        Stream #0.1: Audio: libmp3lame, 44100 Hz, stereo, s16, 64 kb/s
    Stream mapping:
      Stream #0.1 -> #0.0
      Stream #0.0 -> #0.1
    Press [q] to stop encoding
    Multiple frames in a packet from stream 0
    frame=   58 fps= 56 q=5.0 size=     873kB time=9.98 bitrate= 716.6kbits/s dup=0
    frame=   85 fps= 55 q=5.0 size=    1197kB time=16.95 bitrate= 578.2kbits/s dup=0
    frame=  114 fps= 55 q=5.0 size=    1515kB time=23.90 bitrate= 519.3kbits/s dup=0
    frame=  135 fps= 53 q=5.0 size=    1817kB time=29.21 bitrate= 509.7kbits/s dup=0
    frame=  155 fps= 50 q=5.0 size=    1985kB time=33.57 bitrate= 484.5kbits/s dup=0
    frame=  179 fps= 50 q=5.0 size=    2417kB time=39.42 bitrate= 502.3kbits/s dup=0
    frame=  203 fps= 50 q=5.0 size=    2596kB time=44.77 bitrate= 474.9kbits/s dup=0
    frame=  224 fps= 49 q=5.0 size=    2886kB time=49.08 bitrate= 481.7kbits/s dup=0
    frame=  253 fps= 50 q=5.0 size=    3385kB time=55.48 bitrate= 499.8kbits/s dup=0
    frame=  292 fps= 52 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  339 fps= 55 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  379 fps= 57 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  441 fps= 62 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  496 fps= 65 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  542 fps= 67 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  578 fps= 67 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  612 fps= 67 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  657 fps= 68 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  710 fps= 70 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  756 fps= 71 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  801 fps= 72 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  865 fps= 74 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  922 fps= 76 q=5.0 size=    3839kB time=59.90 bitrate= 525.0kbits/s dup=0
    frame=  968 fps= 76 q=5.0 Lsize=   13851kB time=60.06 bitrate=1889.3kbits/s dup=0 drop=2
    video:13330kB audio:469kB global headers:0kB muxing overhead 0.372018%
    Received signal 2: terminating.
    

    Note that I had to press Ctrl+C to terminate the process; otherwise it was going to keep running until it reached the end of the original video frames.

    The output video is supposed to be 1 minute long, but it's much longer, depending on how soon I press Ctrl+C; but after the 1 minute mark there is no video or audio, just a still image of the last frame of the 1 minute video.

  • Answers
  • slhck

    Thanks for providing the full output. Two things about your command:

    • Your FFmpeg version is terribly old. Please download a recent static build or compile it from source. There are thousands of things that have been fixed since then. If you're on a shared hosting server you might be able to run the static build from within the directories that you have execute privileges on, or you could ask your hosting provider to supply a non-ancient version of FFmpeg.

    • -t is an output option, meaning you have to specify it after -i and before the output filename.

    Try again with a recent build, and I'm sure it'll work.

    Note that -async is a deprecated option and doesn't seem to be necessary in your case.


  • Related Question

    ubuntu - FFMPEG Segfault Solutions
  • Brentley_11

    I'm trying to convert a bunch of movies into h.264 mp4's using FFMPEG. These movies are sourced from various portable camcorders such as the Flip Mino HD and the Kodak ZI8. One issue I'm having with video from the ZI8 is it seems to be causing FFMPEG to segfault.

    Here is my command:

    ffmpeg -i 'XmasSailor720p60fps.MOV' -threads 2 -acodec libfaac -ab 96kb -vcodec libx264 -vpre hq -b 500kb -s 484x272 XmasSailor.mp4
    

    Here is the output:

    FFmpeg version SVN-r20668, Copyright (c) 2000-2009 Fabrice Bellard, et al.
      built on Dec  2 2009 18:37:34 with gcc 4.2.4 (Ubuntu 4.2.4-1ubuntu4)
      configuration: --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared
      libavutil     50. 5. 1 / 50. 5. 1
      libavcodec    52.42. 0 / 52.42. 0
      libavformat   52.39. 2 / 52.39. 2
      libavdevice   52. 2. 0 / 52. 2. 0
      libswscale     0. 7. 2 /  0. 7. 2
      libpostproc   51. 2. 0 / 51. 2. 0
    
    Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 29.97 (30000/1001)
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'XmasSailor720p60fps.MOV':
      Duration: 00:00:05.37, start: 0.000000, bitrate: 12021 kb/s
        Stream #0.0(eng): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 11994 kb/s, 29.97 tbr, 90k tbn, 59.94 tbc
        Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 128 kb/s
      Metadata
        major_brand     : qt  
        minor_version   : 0
        compatible_brands: qt  
        comment         : KODAK Zi8 Pocket Video Camera
        comment-eng     : KODAK Zi8 Pocket Video Camera
    [libx264 @ 0x99e1020]using SAR=1/1
    [libx264 @ 0x99e1020]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
    [libx264 @ 0x99e1020]profile High, level 2.1
    Output #0, mp4, to 'XmasSailor.mp4':
        Stream #0.0(eng): Video: libx264, yuv420p, 484x272 [PAR 1:1 DAR 121:68], q=10-51, 500 kb/s, 30k tbn, 29.97 tbc
        Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16, 96 kb/s
      Metadata
        comment         : Encoded with the Statusfirm Video Transcoder
    Stream mapping:
      Stream #0.0 -> #0.0
      Stream #0.1 -> #0.1
    Press [q] to stop encoding
    [h264 @ 0x99de950]B picture before any references, skipping
    [h264 @ 0x99de950]decode_slice_header error
    [h264 @ 0x99de950]no frame!
    Error while decoding stream #0.0
    [h264 @ 0x99de950]B picture before any references, skipping
    [h264 @ 0x99de950]decode_slice_header error
    [h264 @ 0x99de950]no frame!
    Error while decoding stream #0.0
    frame=   20 fps=  0 q=13797729.0 size=       0kB time=0.66 bitrate=   0.6kbits/s    
    frame=   39 fps= 37 q=13797729.0 size=       0kB time=1.30 bitrate=   0.3kbits/s    
    frame=   48 fps= 30 q=33.0 size=      11kB time=0.10 bitrate= 903.0kbits/s    
    frame=   58 fps= 27 q=31.0 size=      22kB time=0.43 bitrate= 421.0kbits/s    
    frame=   67 fps= 25 q=29.0 size=      41kB time=0.73 bitrate= 462.6kbits/s    
    frame=   75 fps= 23 q=29.0 size=      59kB time=1.00 bitrate= 486.7kbits/s    
    frame=   83 fps= 22 q=29.0 size=      81kB time=1.27 bitrate= 521.9kbits/s    
    frame=   90 fps= 21 q=29.0 size=      97kB time=1.50 bitrate= 530.1kbits/s    
    frame=   98 fps= 20 q=29.0 size=     114kB time=1.77 bitrate= 526.9kbits/s    
    frame=  106 fps= 20 q=29.0 size=     134kB time=2.04 bitrate= 537.7kbits/s    
    frame=  114 fps= 19 q=29.0 size=     150kB time=2.30 bitrate= 533.7kbits/s    
    frame=  122 fps= 19 q=29.0 size=     172kB time=2.57 bitrate= 547.8kbits/s    
    frame=  130 fps= 19 q=29.0 size=     193kB time=2.84 bitrate= 557.5kbits/s    
    frame=  136 fps= 18 q=29.0 size=     211kB time=3.04 bitrate= 570.0kbits/s    
    frame=  144 fps= 18 q=29.0 size=     242kB time=3.30 bitrate= 599.5kbits/s    
    frame=  152 fps= 17 q=30.0 size=     261kB time=3.57 bitrate= 598.6kbits/s    
    frame=  157 fps= 15 q=-1.0 Lsize=     368kB time=5.21 bitrate= 579.3kbits/s    
    video:302kB audio:61kB global headers:0kB muxing overhead 1.416371%
    [libx264 @ 0x99e1020]frame I:1     Avg QP:27.22  size:  8720
    [libx264 @ 0x99e1020]frame P:48    Avg QP:25.15  size:  3759
    [libx264 @ 0x99e1020]frame B:108   Avg QP:30.10  size:  1105
    [libx264 @ 0x99e1020]consecutive B-frames:  0.6% 11.5% 28.8% 59.0%
    [libx264 @ 0x99e1020]mb I  I16..4: 28.5% 47.6% 23.9%
    [libx264 @ 0x99e1020]mb P  I16..4:  0.8%  1.3%  0.5%  P16..4: 50.6% 17.7% 13.1%  0.0%  0.0%    skip:15.9%
    [libx264 @ 0x99e1020]mb B  I16..4:  0.2%  0.3%  0.1%  B16..8: 44.0%  1.2%  2.6%  direct: 5.1%  skip:46.5%  L0:45.5% L1:51.0% BI: 3.5%
    [libx264 @ 0x99e1020]final ratefactor: 23.51
    [libx264 @ 0x99e1020]8x8 transform intra:49.9% inter:67.9%
    [libx264 @ 0x99e1020]direct mvs  spatial:98.1% temporal:1.9%
    [libx264 @ 0x99e1020]coded y,uvDC,uvAC intra: 54.7% 76.1% 41.4% inter: 17.1% 24.4% 7.8%
    [libx264 @ 0x99e1020]i16 v,h,dc,p: 18% 52%  5% 25%
    [libx264 @ 0x99e1020]i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 22%  9%  7% 10% 10%  9%  8% 13%
    [libx264 @ 0x99e1020]i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13% 18%  8%  8% 10% 13% 10%  9% 12%
    [libx264 @ 0x99e1020]Weighted P-Frames: Y:10.4%
    [libx264 @ 0x99e1020]ref P L0: 60.2% 15.3% 11.0%  7.6%  5.2%  0.7%
    [libx264 @ 0x99e1020]ref B L0: 72.6% 15.6% 11.8%
    [libx264 @ 0x99e1020]kb/s:471.17
    Segmentation fault
    

    I'm wondering if anyone else has ran into similar issues. I wasn't able to find anything helpful via Google.

    Another question I have is if anyone knows of a company that offers paid support for FFMPEG.

    Thank you for your time.


  • Related Answers
  • SleighBoy

    I just had a similar issue with libx264 encoding, and what I got from my examination of the matter were these points.

    1. Use gcc >= 4.2
    2. Make sure your ffmpeg is compiled against the same libx264 version

    By your output it is obvious you have #1 down, so check #2 like so (paths may need to be modified)

    ldd /usr/bin/ffmpeg | grep x264
    

    and then...

    cat /usr/include/x264.h | grep X264_BUILD
    

    (Source)

    For me, this checked out and I just had to not do 2-pass encoding. Try also not using the thread option, that will probably fix it. I had troubles on old Red Hat boxes, my Gentoo desktop had no trouble at all, I call that a win for from-source package managers!