[FFmpeg-user] h264_mp4toannexb unable to split h264_qsv-encoded files?

Hugo Garbez h.garbez at kol.to
Fri Mar 3 16:21:43 EET 2017


2017-03-02 17:39 GMT+01:00 Carl Eugen Hoyos <ceffmpeg at gmail.com>:
> 2017-03-02 17:11 GMT+01:00 Hugo Garbez <h.garbez at kol.to>:
>
>> I'm using FFmpeg 3.2.4 on Debian 8.7, and I have some problems
>> with h264_qsv and HLS.
>
> Please test current FFmpeg git head, provide command lines including
> complete, uncut console output and short input sample files.

I tried the FFmpeg git version but I got the same problem. I can’t
spilt my file with "-hls_time 5".

Download the file :
$ curl http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4 -o input.mp4

With h264_qsv :

$ ffmpeg -i input.mp4 -codec:v h264_qsv -look_ahead 0 w240.mp4
ffmpeg version N-83731-g16abc10 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --toolchain=hardened --enable-shared --enable-libmfx
--enable-gpl --disable-doc --disable-libtesseract --disable-stripping
--disable-decoder=libschroedinger --enable-avresample
--enable-avisynth --disable-gnutls --disable-ladspa --disable-libass
--disable-libbluray --enable-libbs2b --disable-libcaca
--disable-libcdio --disable-libflite --enable-libfontconfig
--enable-libfreetype --enable-libfribidi --enable-libgme
--disable-libgsm --enable-libmodplug --enable-libmp3lame
--enable-libopenjpeg --enable-libopus --disable-libpulse
--enable-librubberband --enable-libschroedinger --enable-libshine
--enable-libsnappy --enable-libsoxr --enable-libspeex --disable-libssh
--enable-libtheora --enable-libtwolame --enable-libvorbis
--enable-libvpx --disable-libwavpack --enable-libwebp --enable-libx265
--disable-libxvid --disable-libzmq --enable-libzvbi --disable-opengl
--disable-sdl2 --disable-x11grab --disable-libdc1394
--disable-libiec61883 --enable-openal --enable-frei0r
--disable-libopencv --enable-libx264 --disable-chromaprint
  libavutil      55. 47.101 / 55. 47.101
  libavcodec     57. 82.100 / 57. 82.100
  libavformat    57. 66.103 / 57. 66.103
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    creation_time   : 2010-02-09T01:55:39.000000Z
  Duration: 00:01:00.10, start: 0.000000, bitrate: 733 kb/s
    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz,
stereo, fltp, 65 kb/s (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360, 612
kb/s, 23.96 fps, 24 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Video Media Handler
    Stream #0:2(eng): Data: none (rtp  / 0x20707472), 45 kb/s
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : hint media handler
    Stream #0:3(eng): Data: none (rtp  / 0x20707472), 5 kb/s
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : hint media handler
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> h264 (h264_qsv))
  Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[h264_qsv @ 0x5609d8b19b80] Encoder will work with partial HW acceleration
Output #0, mp4, to 'w240.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    encoder         : Lavf57.66.103
    Stream #0:0(eng): Video: h264 (h264_qsv) ([33][0][0][0] / 0x0021),
nv12, 640x360, q=2-31, 1000 kb/s, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Video Media Handler
      encoder         : Lavc57.82.100 h264_qsv
    Side data:
      cpb: bitrate max/min/avg: 0/0/1000000 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 22050
Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Sound Media Handler
      encoder         : Lavc57.82.100 aac
frame= 1442 fps=267 q=-0.0 Lsize=    8035kB time=00:01:00.13
bitrate=1094.4kbits/s dup=2 drop=0 speed=11.1x
video:7096kB audio:899kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.495575%
[aac @ 0x5609d8b1aa20] Qavg: 35057.434

Then HLS :

$ ffmpeg -y -threads 1 -i w240.mp4 -codec copy -map 0 -bsf:v
h264_mp4toannexb -hls_time 5 -hls_init_time 1 -hls_list_size 0
hls/w240.m3u8
ffmpeg version N-83731-g16abc10 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --toolchain=hardened --enable-shared --enable-libmfx
--enable-gpl --disable-doc --disable-libtesseract --disable-stripping
--disable-decoder=libschroedinger --enable-avresample
--enable-avisynth --disable-gnutls --disable-ladspa --disable-libass
--disable-libbluray --enable-libbs2b --disable-libcaca
--disable-libcdio --disable-libflite --enable-libfontconfig
--enable-libfreetype --enable-libfribidi --enable-libgme
--disable-libgsm --enable-libmodplug --enable-libmp3lame
--enable-libopenjpeg --enable-libopus --disable-libpulse
--enable-librubberband --enable-libschroedinger --enable-libshine
--enable-libsnappy --enable-libsoxr --enable-libspeex --disable-libssh
--enable-libtheora --enable-libtwolame --enable-libvorbis
--enable-libvpx --disable-libwavpack --enable-libwebp --enable-libx265
--disable-libxvid --disable-libzmq --enable-libzvbi --disable-opengl
--disable-sdl2 --disable-x11grab --disable-libdc1394
--disable-libiec61883 --enable-openal --enable-frei0r
--disable-libopencv --enable-libx264 --disable-chromaprint
  libavutil      55. 47.101 / 55. 47.101
  libavcodec     57. 82.100 / 57. 82.100
  libavformat    57. 66.103 / 57. 66.103
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'w240.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.66.103
  Duration: 00:01:00.19, start: 0.000000, bitrate: 1093 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
640x360 [SAR 1:1 DAR 16:9], 967 kb/s, 24 fps, 24 tbr, 12288 tbn, 48
tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz,
stereo, fltp, 122 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, hls, to 'hls/w240.m3u8':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.66.103
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
640x360 [SAR 1:1 DAR 16:9], q=2-31, 967 kb/s, 24 fps, 24 tbr, 90k tbn,
24 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz,
stereo, fltp, 122 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1442 fps=0.0 q=-1.0 Lsize=N/A time=00:01:00.09 bitrate=N/A
speed= 204x
video:7096kB audio:899kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown

$ cat hls/w240.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.416667,
w2400.ts
#EXTINF:10.416667,
w2401.ts
#EXTINF:10.416667,
w2402.ts
#EXTINF:10.416667,
w2403.ts
#EXTINF:10.416667,
w2404.ts
#EXTINF:8.000000,
w2405.ts
#EXT-X-ENDLIST

With libx264 :

$ ffmpeg -i input.mp4 -codec:v libx264 w240.mp4
ffmpeg version N-83731-g16abc10 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --toolchain=hardened --enable-shared --enable-libmfx
--enable-gpl --disable-doc --disable-libtesseract --disable-stripping
--disable-decoder=libschroedinger --enable-avresample
--enable-avisynth --disable-gnutls --disable-ladspa --disable-libass
--disable-libbluray --enable-libbs2b --disable-libcaca
--disable-libcdio --disable-libflite --enable-libfontconfig
--enable-libfreetype --enable-libfribidi --enable-libgme
--disable-libgsm --enable-libmodplug --enable-libmp3lame
--enable-libopenjpeg --enable-libopus --disable-libpulse
--enable-librubberband --enable-libschroedinger --enable-libshine
--enable-libsnappy --enable-libsoxr --enable-libspeex --disable-libssh
--enable-libtheora --enable-libtwolame --enable-libvorbis
--enable-libvpx --disable-libwavpack --enable-libwebp --enable-libx265
--disable-libxvid --disable-libzmq --enable-libzvbi --disable-opengl
--disable-sdl2 --disable-x11grab --disable-libdc1394
--disable-libiec61883 --enable-openal --enable-frei0r
--disable-libopencv --enable-libx264 --disable-chromaprint
  libavutil      55. 47.101 / 55. 47.101
  libavcodec     57. 82.100 / 57. 82.100
  libavformat    57. 66.103 / 57. 66.103
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    creation_time   : 2010-02-09T01:55:39.000000Z
  Duration: 00:01:00.10, start: 0.000000, bitrate: 733 kb/s
    Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz,
stereo, fltp, 65 kb/s (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Sound Media Handler
    Stream #0:1(eng): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709), 640x360, 612
kb/s, 23.96 fps, 24 tbr, 600 tbn, 1200 tbc (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Video Media Handler
    Stream #0:2(eng): Data: none (rtp  / 0x20707472), 45 kb/s
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : hint media handler
    Stream #0:3(eng): Data: none (rtp  / 0x20707472), 5 kb/s
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : hint media handler
Stream mapping:
  Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x55a37e308840] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x55a37e308840] profile High, level 3.0
[libx264 @ 0x55a37e308840] 264 - core 142 r2431 a5831aa - H.264/MPEG-4
AVC codec - Copyleft 2003-2014 - 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=12 lookahead_threads=2 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=24 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf
mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40
aq=1:1.00
Output #0, mp4, to 'w240.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 1
    compatible_brands: mp42avc1
    encoder         : Lavf57.66.103
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 640x360, q=-1--1, 24 fps, 12288 tbn, 24 tbc (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Video Media Handler
      encoder         : Lavc57.82.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) ([64][0][0][0] / 0x0040), 22050
Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2010-02-09T01:55:39.000000Z
      handler_name    : Apple Sound Media Handler
      encoder         : Lavc57.82.100 aac
frame= 1442 fps=322 q=-1.0 Lsize=    5186kB time=00:01:00.13 bitrate=
706.4kbits/s dup=2 drop=0 speed=13.4x
video:4255kB audio:899kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.628625%
[libx264 @ 0x55a37e308840] frame I:9     Avg QP:18.97  size: 39793
[libx264 @ 0x55a37e308840] frame P:853   Avg QP:22.23  size:  4172
[libx264 @ 0x55a37e308840] frame B:580   Avg QP:28.03  size:   758
[libx264 @ 0x55a37e308840] consecutive B-frames: 43.6%  4.7% 10.6% 41.1%
[libx264 @ 0x55a37e308840] mb I  I16..4: 10.8% 22.3% 66.9%
[libx264 @ 0x55a37e308840] mb P  I16..4:  1.7%  3.9%  0.9%  P16..4:
34.2% 11.5%  5.8%  0.0%  0.0%    skip:42.0%
[libx264 @ 0x55a37e308840] mb B  I16..4:  0.1%  0.1%  0.1%  B16..8:
38.5%  5.6%  1.3%  direct: 1.0%  skip:53.5%  L0:48.5% L1:46.4% BI:
5.0%
[libx264 @ 0x55a37e308840] 8x8 transform intra:54.4% inter:41.4%
[libx264 @ 0x55a37e308840] coded y,uvDC,uvAC intra: 34.6% 43.6% 18.3%
inter: 11.2% 12.3% 1.6%
[libx264 @ 0x55a37e308840] i16 v,h,dc,p: 30% 37% 17% 16%
[libx264 @ 0x55a37e308840] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 37% 20% 32%
2%  2%  2%  2%  2%  2%
[libx264 @ 0x55a37e308840] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 16% 16%
7%  8%  8%  7%  7%  8%
[libx264 @ 0x55a37e308840] i8c dc,h,v,p: 60% 23% 12%  5%
[libx264 @ 0x55a37e308840] Weighted P-Frames: Y:3.9% UV:1.5%
[libx264 @ 0x55a37e308840] ref P L0: 81.3%  8.1%  8.8%  1.8%  0.0%
[libx264 @ 0x55a37e308840] ref B L0: 93.0%  6.6%  0.5%
[libx264 @ 0x55a37e308840] ref B L1: 95.1%  4.9%
[libx264 @ 0x55a37e308840] kb/s:580.05
[aac @ 0x55a37e309ce0] Qavg: 35057.434

Then HLS :

$ ffmpeg -y -threads 1 -i w240.mp4 -codec copy -map 0 -bsf:v
h264_mp4toannexb -hls_time 5 -hls_init_time 1 -hls_list_size 0
hls/w240.m3u8
ffmpeg version N-83731-g16abc10 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --toolchain=hardened --enable-shared --enable-libmfx
--enable-gpl --disable-doc --disable-libtesseract --disable-stripping
--disable-decoder=libschroedinger --enable-avresample
--enable-avisynth --disable-gnutls --disable-ladspa --disable-libass
--disable-libbluray --enable-libbs2b --disable-libcaca
--disable-libcdio --disable-libflite --enable-libfontconfig
--enable-libfreetype --enable-libfribidi --enable-libgme
--disable-libgsm --enable-libmodplug --enable-libmp3lame
--enable-libopenjpeg --enable-libopus --disable-libpulse
--enable-librubberband --enable-libschroedinger --enable-libshine
--enable-libsnappy --enable-libsoxr --enable-libspeex --disable-libssh
--enable-libtheora --enable-libtwolame --enable-libvorbis
--enable-libvpx --disable-libwavpack --enable-libwebp --enable-libx265
--disable-libxvid --disable-libzmq --enable-libzvbi --disable-opengl
--disable-sdl2 --disable-x11grab --disable-libdc1394
--disable-libiec61883 --enable-openal --enable-frei0r
--disable-libopencv --enable-libx264 --disable-chromaprint
  libavutil      55. 47.101 / 55. 47.101
  libavcodec     57. 82.100 / 57. 82.100
  libavformat    57. 66.103 / 57. 66.103
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 74.100 /  6. 74.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'w240.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.66.103
  Duration: 00:01:00.19, start: 0.000000, bitrate: 705 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
640x360, 580 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz,
stereo, fltp, 122 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Output #0, hls, to 'hls/w240.m3u8':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.66.103
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
640x360, q=2-31, 580 kb/s, 24 fps, 24 tbr, 90k tbn, 24 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz,
stereo, fltp, 122 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 1442 fps=0.0 q=-1.0 Lsize=N/A time=00:01:00.09 bitrate=N/A
speed= 143x
video:4255kB audio:899kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: unknown

$ cat hls/w240.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.416667,
w2400.ts
#EXTINF:1.458333,
w2401.ts
#EXTINF:3.875000,
w2402.ts
#EXTINF:7.291667,
w2403.ts
#EXTINF:8.958333,
w2404.ts
#EXTINF:10.416667,
w2405.ts
#EXTINF:5.291667,
w2406.ts
#EXTINF:8.375000,
w2407.ts
#EXTINF:4.000000,
w2408.ts
#EXT-X-ENDLIST

> Why are you not encoding and producing hls output in one
> command, why using two commands?

I use two commands because our back office needs that. I need to
encode my movie first, and then produce an HLS file.


More information about the ffmpeg-user mailing list