Newest 'libx264' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/libx264

Les articles publiés sur le site

  • FFMPEG creates incorrect Source duration

    4 août 2016, par Byron Whitlock

    When transcoding movies from an AVI to mp4 sometimes FFMPEG sets the "Source Duration" incorrectly.

    This messes up playback on IOS devices. Specifically, it causes the video to cut out at "Source duration" while the audio still plays.

    enter image description here

    FFMPEG output transcode doesn't' show anything odd at all. Looks normal, no errors or warnings.

    • Can I force FFMPEG to never add the "Source Duration" metadata?
    • How do I edit the track metadata shown by mediainfo? I tried Mp4box, and a few others, but I can't seem to figure out how to edit track level metadata.

    Thanks.

    Log is below.

    ffmpeg version N-77455-g4707497 Copyright (c) 2000-2015 the FFmpeg developers   built with gcc 5.2.0 (GCC)   configuration: --enable-gpl
        --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib   libavutil      55. 11.100 / 55. 11.100   libavcodec     57. 20.100 / 57. 20.100   libavformat    57. 20.100 / 57. 20.100   libavdevice    57.  0.100 / 57.  0.100   libavfilter     6. 21.101 / 
        6. 21.101   libswscale      4.  0.100 /  4.  0.100   libswresample   2.  0.101 /  2.  0.101   libpostproc    54.  0.100 / 54.  0.100 Input #0, avi, from 'E:\MEDIA\Central.Intelligence.2016.HC.HDRip.XviD.AC3-EVO\Central.Intelligence.2016.HC.HDRip.XviD.AC3-EVO.avi': Metadata:
            encoder         : VirtualDubMod 1.5.10.2 (build 2542/release)   Duration: 01:51:43.27, start: 0.000000, bitrate: 1765 kb/s
            Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x304 [SAR 1:1 DAR 45:19], 1563 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
            Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, fltp, 192 kb/s [libx264 @ 000000f3c80a0a80] using SAR=405/304 [libx264 @ 000000f3c80a0a80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2 [libx264 @ 000000f3c80a0a80] profile High, level 3.1 [libx264 @ 000000f3c80a0a80] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=1280 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'F:\STREAMS\Central.Intelligence.2016.HC.HDRip.XviD.AC3-EVO.avi.1280x720_1000kbps.TEMP.mp4': Metadata:
            encoder         : Lavf57.20.100
            Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 405:304 DAR 45:19], q=-1--1, 1280 kb/s, 23.98 fps, 10000k tbn, 23.98 tbc
            Metadata:
              encoder         : Lavc57.20.100 libx264
            Side data:
              unknown side data type 10 (24 bytes)
            Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 160 kb/s
            Metadata:
              encoder         : Lavc57.20.100 aac Stream mapping:   Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))   Stream #0:1 -> #0:1 (ac3 (native) -> aac (native)) Press [q] to stop, [?] for help [mpeg4 @ 000000f3c80ae220] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using the mpeg4_unpack_bframes bitstream filter without encoding but stream copy to fix it. 
    frame=   15 fps=0.0 q=0.0 size=       0kB time=00:00:01.18 bitrate=   0.3kbits/s dup=1 drop=0 speed=2.36x   
    --SNIP---
    frame=160704 fps= 16 q=30.0 size= 1180376kB time=01:51:43.08 bitrate=1442.6kbits/s dup=1 drop=0 speed=0.671x     
    [libx264 @ 0000001f60c5d900] frame I:1167  Avg QP:19.08  size: 44465
    [libx264 @ 0000001f60c5d900] frame P:63049 Avg QP:22.26  size: 12774
    [libx264 @ 0000001f60c5d900] frame B:110691 Avg QP:24.81  size:  2739
    [libx264 @ 0000001f60c5d900] consecutive B-frames:  6.0% 22.8% 18.3% 53.0%
    [libx264 @ 0000001f60c5d900] mb I  I16..4: 14.0% 76.1%  9.9%
    [libx264 @ 0000001f60c5d900] mb P  I16..4:  2.5%  6.6%  0.4%  P16..4: 44.5% 10.8%  5.2%  0.0%  0.0%    skip:30.0%
    [libx264 @ 0000001f60c5d900] mb B  I16..4:  0.1%  0.3%  0.0%  B16..8: 32.1%  1.6%  0.2%  direct: 0.9%  skip:64.9%  L0:37.9% L1:58.7% BI: 3.5%
    [libx264 @ 0000001f60c5d900] final ratefactor: 23.25
    [libx264 @ 0000001f60c5d900] 8x8 transform intra:70.8% inter:85.8%
    [libx264 @ 0000001f60c5d900] coded y,uvDC,uvAC intra: 47.1% 56.6% 19.5% inter: 10.7% 14.2% 0.4%
    [libx264 @ 0000001f60c5d900] i16 v,h,dc,p: 46% 20%  8% 26%
    [libx264 @ 0000001f60c5d900] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 17% 25%  5%  7%  7%  7%  6%  6%
    [libx264 @ 0000001f60c5d900] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 20% 12%  5% 10%  9%  8%  5%  4%
    [libx264 @ 0000001f60c5d900] i8c dc,h,v,p: 58% 18% 18%  6%
    [libx264 @ 0000001f60c5d900] Weighted P-Frames: Y:1.4% UV:0.8%
    [libx264 @ 0000001f60c5d900] ref P L0: 62.6% 12.9% 18.9%  5.6%  0.1%
    [libx264 @ 0000001f60c5d900] ref B L0: 87.6% 11.0%  1.4%
    [libx264 @ 0000001f60c5d900] ref B L1: 94.6%  5.4%
    [libx264 @ 0000001f60c5d900] kb/s:1272.59
    [aac @ 0000001f60b52180] Qavg: 954.859
    

    Edit

    This has something to do with data, when I run this command (cut at 10 minutes)

    ffmpeg.exe -i CI.mp4 -ss 00:00:00 -t 00:08:00 -vcodec copy  -map_metadata 0 -acodec copy CI2.mp4
    

    Mediainfo shows

    Duration                    : 9mn 49s
    Source duration             : 2mn 40s
    

    When I run this one (18 minutes)

    ffmpeg.exe -i CI.mp4 -ss 00:00:00 -t 00:18:00 -vcodec copy  -map_metadata 0 -acodec copy CI2.mp4
    

    Mediainfo shows

    Duration                    : 17mn 49s
    Source duration             : 3mn 30s
    

    How can I edit the metadata directly

  • ffmpeg mapping to mkv introduces "fake" delay relative to video

    1er août 2016, par JMor

    I need to map this x.264 clip into a matroska container using ffmpeg:

    ffmpeg -i f-0.mp4 -c copy f-0.mkv
    

    Here is the ffmpeg console output:

    ffmpeg -i f-0.mp4 -c copy f-0.mkv   
    ffmpeg version N-69672-g078be09 Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.9.2 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
      libavutil      54. 18.100 / 54. 18.100
      libavcodec     56. 21.102 / 56. 21.102
      libavformat    56. 19.100 / 56. 19.100
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5.  9.104 /  5.  9.104
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'f-0.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.19.100
      Duration: 00:02:08.06, start: 0.005333, bitrate: 5030 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4865 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 160 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
        Side data:
          unknown side data type 7 (4 bytes)
    Output #0, matroska, to 'f-0.mkv':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.19.100
        Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 4865 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 30k tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, stereo, 160 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
        Side data:
          unknown side data type 7 (4 bytes)
    Stream mapping:
      Stream #0:0 -> #0:0 (copy)
      Stream #0:1 -> #0:1 (copy)
    ...
    

    The result seems good, playing with well synchronized audio and video. However, MediaInfo shows a new item under Audio (that the original clip didn't have):

    Delay relative to video                  : 1mn 5s
    

    Here is the Mediainfo from the original f-0.mp4 file:

    Audio
      ID                                       : 2
      Format                                   : AC-3
      Format/Info                              : Audio Coding 3
      Mode extension                           : CM (complete main)
      Format settings, Endianness              : Big
      Codec ID                                 : ac-3
      Duration                                 : 2mn 8s
      Bit rate mode                            : Constant
      Bit rate                                 : 160 Kbps
      Channel(s)                               : 2 channels
      Channel positions                        : Front: L R
      Sampling rate                            : 48.0 KHz
      Bit depth                                : 16 bits
      Compression mode                         : Lossy
      Delay relative to video                  : 67ms
      Stream size                              : 2.44 MiB (3%)
    

    Mediainfo from the f-0.mkv output:

    Audio
      ID                                       : 2
      Format                                   : AC-3
      Format/Info                              : Audio Coding 3
      Mode extension                           : CM (complete main)
      Format settings, Endianness              : Big
      Codec ID                                 : A_AC3
      Duration                                 : 2mn 8s
      Bit rate mode                            : Constant
      Bit rate                                 : 160 Kbps
      Channel(s)                               : 2 channels
      Channel positions                        : Front: L R
      Sampling rate                            : 48.0 KHz
      Bit depth                                : 16 bits
      Compression mode                         : Lossy
      Delay relative to video                  : 1mn 5s
      Stream size                              : 2.44 MiB (3%)
      Default                                  : Yes
      Forced                                   : No
      HANDLER_NAME                             : SoundHandler
    

    There is no delay whatsoever and no reason to insert a delay.

    I am concerned that this information (Delay relative to video) be used by some players or other applications as a delay that should be corrected. Is there a way to prevent this from happening?

    Adding ffprobe output: f-0.mp4 clip

    ffprobe -show_entries stream=codec_type,duration,start_time -of compact f-0.mp4
        ffprobe version N-69672-g078be09 Copyright (c) 2007-2015 the FFmpeg developers
        built with gcc 4.9.2 (GCC)
        configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
        libavutil      54. 18.100 / 54. 18.100
        libavcodec     56. 21.102 / 56. 21.102
        libavformat    56. 19.100 / 56. 19.100
        libavdevice    56.  4.100 / 56.  4.100
        libavfilter     5.  9.104 /  5.  9.104
        libswscale      3.  1.101 /  3.  1.101
        libswresample   1.  1.100 /  1.  1.100
        libpostproc    53.  3.100 / 53.  3.100
      Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'f-0.mp4':
        Metadata:
          major_brand     : isom
          minor_version   : 512
          compatible_brands: isomiso2avc1mp41
          encoder         : Lavf56.19.100
        Duration: 00:02:08.06, start: 0.005333, bitrate: 5030 kb/s
          Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 4865 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
          Metadata:
            handler_name    : VideoHandler
          Stream #0:1(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 160 kb/s (default)
          Metadata:
            handler_name    : SoundHandler
          Side data:
            unknown side data type 7 (4 bytes)
      stream|codec_type=video|start_time=0.000000|duration=128.061267
      stream|codec_type=audio|start_time=-0.005333|duration=128.064000
    

    f-0.mkv clip:

    ffprobe version N-69672-g078be09 Copyright (c) 2007-2015 the FFmpeg developers
      built with gcc 4.9.2 (GCC)
      configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
      libavutil      54. 18.100 / 54. 18.100
      libavcodec     56. 21.102 / 56. 21.102
      libavformat    56. 19.100 / 56. 19.100
      libavdevice    56.  4.100 / 56.  4.100
      libavfilter     5.  9.104 /  5.  9.104
      libswscale      3.  1.101 /  3.  1.101
      libswresample   1.  1.100 /  1.  1.100
      libpostproc    53.  3.100 / 53.  3.100
    Input #0, matroska,webm, from 'f-0.mkv':
      Metadata:
        COMPATIBLE_BRANDS: isomiso2avc1mp41
        MAJOR_BRAND     : isom
        MINOR_VERSION   : 512
        ENCODER         : Lavf56.19.100
      Duration: 00:02:08.13, start: 0.061000, bitrate: 5026 kb/s
        Stream #0:0(und): Video: h264 (High), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 1k tbn, 59.94 tbc (default)
        Metadata:
          LANGUAGE        : und
          HANDLER_NAME    : VideoHandler
        Stream #0:1(und): Audio: ac3, 48000 Hz, stereo, fltp, 160 kb/s (default)
        Metadata:
          LANGUAGE        : und
          HANDLER_NAME    : SoundHandler
    stream|codec_type=video|start_time=0.066000|duration=N/A
    stream|codec_type=audio|start_time=0.061000|duration=N/A
    
  • Raspberry Pi Youtube Stream with ffmpeg : libx264 unknown

    21 juillet 2016, par tm011036

    I want to use my raspberry pi 3 for a youtube stream via an usb camera. Therefore, I compiled and installed the following tools:

    ffmpeg, libx264, libav-tools

    However, when running the following code i always get an error that the libx264 encoder is unknown:

    ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 
    -codec:v libx264 -b:v 700k -maxrate 700k -bufsize 700k -an -f 
    flv rtmp://a.rtmp.youtube.com/live2/MYYOUTUBECODE
    

    I installed x264 via clone and make install using this guideline. How can I check if this encoder was installed correctly? I am already stuck for 2 days on this problem - please help!

    Related hints (e.g. libavcodec-extra codec, type errors) regarding this problem unfortunately also didn't help further.

    Thank You.

    The entire console output is:

    ffmpeg version N-81043-ga49ed9e Copyright (c) 2000-2016 the FFmpeg developers
      built with gcc 4.9.2 (Raspbian 4.9.2-10)
      configuration: 
      libavutil      55. 28.100 / 55. 28.100
      libavcodec     57. 50.100 / 57. 50.100
      libavformat    57. 42.100 / 57. 42.100
      libavdevice    57.  0.102 / 57.  0.102
      libavfilter     6. 47.100 /  6. 47.100
      libswscale      4.  1.100 /  4.  1.100
      libswresample   2.  1.100 /  2.  1.100
    [video4linux2,v4l2 @ 0x24132f0] The driver changed the time per frame from 1/25 to 1/30
    Input #0, video4linux2,v4l2, from '/dev/video0':
    Duration: N/A, start: 161119.368327, bitrate: 147456 kb/s
    Stream #0:0: Video: rawvideo (YUY2 / 0x32595559), yuyv422, 640x480,     
    147456 kb/s, 30 fps, 30 tbr, 1000k tbn, 1000k tbc
    
    Unknown encoder 'libx264' 
    
  • How to build libx264 64bit library for android

    19 juillet 2016, par Pri1985

    I am unable to build libx264 code for android arm-64 bit architecture. Below is the command i tried.

    ./configure \
    --cross-prefix=arm-linux-androideabi- \
    --sysroot="$HOME/NDK/android-ndk-r10d/platforms/android-21/arch-arm64/" \
    --host=arm-linux \
    --enable-pic \
    --enable-static \
    --disable-cli
    

    Please advice. Thanks in advance.

  • Two processes of libx264 from ffmpeg

    14 juillet 2016, par Corentin

    I'm currently encountering a problem with ffmpeg (ffmpeg-2.7.2-64bit-static) on ubuntu. When I execute two processes of MP3 encoding at the same time, they complete successfully. But when I execute one process of MP4 encoding (from WMV), if I execute a simultaneous MP4 transcoding process, the first one stops with no reason and the second one completes successfully.

    I really need to transcode at least two files in MP4 simultaneously, would you know what could be the issue?

    Here are the commands:

    ffmpeg -copyts -start_at_zero -ss 00:00:00.0 -t 00:00:23.0 -i 'in1.wmv' -codec:v 'h264' 'out1.mp4'
    

    then:

    ffmpeg -copyts -start_at_zero -ss 00:00:00.0 -t 00:00:23.0 -i 'in2.wmv' -codec:v 'h264' 'out2.mp4'
    

    Thank you very much, Best regards,