[FFmpeg-trac] #6868(ffmpeg:new): HLS segmenter doesn't cut properly with AVC Baseline level 3.0

FFmpeg trac at avcodec.org
Tue Nov 28 13:58:40 EET 2017


#6868: HLS segmenter doesn't cut properly with AVC Baseline level 3.0
------------------------------------+----------------------------------
             Reporter:  beloko      |                    Owner:
                 Type:  defect      |                   Status:  new
             Priority:  normal      |                Component:  ffmpeg
              Version:  git-master  |               Resolution:
             Keywords:  HLS         |               Blocked By:
             Blocking:              |  Reproduced by developer:  0
Analyzed by developer:  0           |
------------------------------------+----------------------------------

Comment (by beloko):

 My apologies for the inconvenience.

 The hlsenc.c file was properly up to date with your fix.
 But the hlsenc.o wasn't rebuilt by the compiler.
 This means FFMPEG was rebuild with the old library.

 So now congratulation ! It fixes the M3U8 playlist file.

 Here is the result :


 {{{
 C:\Users\Beloko\Desktop\FFMPEG>ffmpeg.exe -i
 "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4"
 -loglevel verbose -threads 0 -c:a libmp3lame -sn -vcodec libx264 -vprofile
 baseline -vlevel 3.0 -force_key_frames "expr:gte(t,n_forced*4)" -r 25 -g
 25 -f hls -hls_time 4 -hls_list_size 99999 -start_number 1
 -hls_segment_type mpegts -t 10
 "C:\Users\Beloko\Desktop\Big_Buck_Bunny.m3u8"
 ffmpeg version N-89288-g2ba6d7c-Reino Copyright (c) 2000-2017 the FFmpeg
 developers
   built with gcc 7.1.0 (GCC)
   configuration: --arch=x86 --target-os=mingw32 --cross-
 prefix=/home/beloko/FFMpeg_Builder/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-
 --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=Reino
 --enable-gray --enable-version3 --disable-debug --disable-doc --disable-
 htmlpages --disable-manpages --disable-podpages --disable-txtpages
 --disable-w32threads --enable-fontconfig --enable-gmp --enable-gnutls
 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
 --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme
 --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame
 --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb
 --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-
 libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-
 libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwebp --enable-libzimg --enable-libzvbi --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-
 cflags=-DCACA_STATIC --enable-gpl --enable-avisynth --enable-frei0r
 --enable-filter=frei0r --enable-librubberband --enable-libvidstab
 --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
 --enable-libmfx --enable-avresample --extra-cflags='-mtune=generic'
 --extra-cflags=-O3 --enable-static --disable-shared
 --prefix=/home/beloko/FFMpeg_Builder/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32
   libavutil      56.  3.100 / 56.  3.100
   libavcodec     58.  6.101 / 58.  6.101
   libavformat    58.  2.103 / 58.  2.103
   libavdevice    58.  0.100 / 58.  0.100
   libavfilter     7.  5.100 /  7.  5.100
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  0.101 /  5.  0.101
   libswresample   3.  0.101 /  3.  0.101
   libpostproc    55.  0.100 / 55.  0.100
 [h264 @ 07977e60] Reinit context to 1920x1088, pix_fmt: yuv420p
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 1
     compatible_brands: isomavc1
     creation_time   : 2013-12-16T17:44:39.000000Z
     title           : Big Buck Bunny, Sunflower version
     artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
     comment         : Creative Commons Attribution 3.0 -
 http://bbb3d.renderfarming.net
     genre           : Animation
     composer        : Sacha Goedegebure
   Duration: 00:10:34.53, start: 0.000000, bitrate: 3481 kb/s
     Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 /
 0x31637661), yuv420p(left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 2998
 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)
     Metadata:
       creation_time   : 2013-12-16T17:44:39.000000Z
       handler_name    : GPAC ISO Video Handler
     Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo,
 s16p, 160 kb/s (default)
     Metadata:
       creation_time   : 2013-12-16T17:44:42.000000Z
       handler_name    : GPAC ISO Audio Handler
     Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side),
 fltp, 320 kb/s (default)
     Metadata:
       creation_time   : 2013-12-16T17:44:42.000000Z
       handler_name    : GPAC ISO Audio Handler
     Side data:
       audio service type: main
 Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
   Stream #0:2 -> #0:1 (ac3 (native) -> mp3 (libmp3lame))
 Press [q] to stop, [?] for help
 [h264 @ 099bd400] Reinit context to 1920x1088, pix_fmt: yuv420p
 [graph 0 input from stream 0:0 @ 079999e0] w:1920 h:1080 pixfmt:yuv420p
 tb:1/30000 fr:30/1 sar:1/1 sws_param:flags=2
 [libx264 @ 0797b1c0] using SAR=1/1
 [libx264 @ 0797b1c0] frame MB size (120x68) > level limit (1620)
 [libx264 @ 0797b1c0] DPB size (1 frames, 8160 mbs) > level limit (0
 frames, 8100 mbs)
 [libx264 @ 0797b1c0] MB rate (204000) > level limit (40500)
 [libx264 @ 0797b1c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
 AVX FMA3 AVX2 LZCNT BMI2
 [libx264 @ 0797b1c0] profile Constrained Baseline, level 3.0
 [libx264 @ 0797b1c0] 264 - core 148 r2795M aaa9aa8 - H.264/MPEG-4 AVC
 codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options:
 cabac=0 ref=1 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1
 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0
 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=0 weightp=0 keyint=25
 keyint_min=2 scenecut=40 intra_refresh=0 rc_lookahead=25 rc=crf mbtree=1
 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
 *** 2 dup!
 Past duration 0.666664 too large
 Past duration 0.833321 too large
 Past duration 0.999992 too large
 [graph_1_in_0_2 @ 07999d60] tb:1/48000 samplefmt:fltp samplerate:48000
 chlayout:0x60f
 [format_out_0_1 @ 07999860] auto-inserting filter 'auto_resampler_0'
 between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
 [auto_resampler_0 @ 07999de0] ch:6 chl:5.1(side) fmt:fltp r:48000Hz ->
 ch:2 chl:stereo fmt:fltp r:48000Hz
 [hls @ 0796db80] Opening 'C:\Users\Beloko\Desktop\Big_Buck_Bunny1.ts' for
 writing
 [mpegts @ 0e550360] muxrate VBR, pcr every 2 pkts, sdt every 2147483647,
 pat/pmt every 2147483647 pkts
 Output #0, hls, to 'C:\Users\Beloko\Desktop\Big_Buck_Bunny.m3u8':
   Metadata:
     major_brand     : isom
     minor_version   : 1
     compatible_brands: isomavc1
     composer        : Sacha Goedegebure
     title           : Big Buck Bunny, Sunflower version
     artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
     comment         : Creative Commons Attribution 3.0 -
 http://bbb3d.renderfarming.net
     genre           : Animation
     encoder         : Lavf58.2.103
     Stream #0:0(und): Video: h264 (libx264), 1 reference frame,
 yuv420p(progressive, left), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps,
 90k tbn, 25 tbc (default)
     Metadata:
       creation_time   : 2013-12-16T17:44:39.000000Z
       handler_name    : GPAC ISO Video Handler
       encoder         : Lavc58.6.101 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
     Stream #0:1(und): Audio: mp3 (libmp3lame), 48000 Hz, stereo, fltp,
 delay 1105 (default)
     Metadata:
       creation_time   : 2013-12-16T17:44:42.000000Z
       handler_name    : GPAC ISO Audio Handler
       encoder         : Lavc58.6.101 libmp3lame
     Side data:
       audio service type: main
 *** dropping frame 13 from stream 0 at ts 11
 *** dropping frame 18 from stream 0 at ts 16
 *** dropping frame 23 from stream 0 at ts 21
 *** dropping frame 28 from stream 0 at ts 26
 *** dropping frame 33 from stream 0 at ts 31
 *** dropping frame 38 from stream 0 at ts 36
 *** dropping frame 43 from stream 0 at ts 41
 *** dropping frame 48 from stream 0 at ts 46
 *** dropping frame 53 from stream 0 at ts 51
 *** dropping frame 58 from stream 0 at ts 56
 *** dropping frame 63 from stream 0 at ts 61
 *** dropping frame 68 from stream 0 at ts 66
 *** dropping frame 73 from stream 0 at ts 7100:02.80 bitrate=N/A dup=2
 drop=12 speed=5.62x
 *** dropping frame 78 from stream 0 at ts 76
 *** dropping frame 83 from stream 0 at ts 81
 *** dropping frame 88 from stream 0 at ts 86
 *** dropping frame 93 from stream 0 at ts 91
 *** dropping frame 98 from stream 0 at ts 96
 *** dropping frame 103 from stream 0 at ts 101
 *** dropping frame 108 from stream 0 at ts 106
 *** dropping frame 113 from stream 0 at ts 111
 *** dropping frame 118 from stream 0 at ts 116
 *** dropping frame 123 from stream 0 at ts 121
 *** dropping frame 128 from stream 0 at ts 126
 *** dropping frame 133 from stream 0 at ts 131:05.20 bitrate=N/A dup=2
 drop=24 speed=5.21x
 *** dropping frame 138 from stream 0 at ts 136
 [hls @ 0796db80] Opening 'C:\Users\Beloko\Desktop\Big_Buck_Bunny2.ts' for
 writing
 [hls @ 0796db80] Opening 'C:\Users\Beloko\Desktop\Big_Buck_Bunny.m3u8.tmp'
 for writing
 [hls muxer @ 0796b6e0] EXT-X-MEDIA-SEQUENCE:1
 *** dropping frame 143 from stream 0 at ts 141
 *** dropping frame 148 from stream 0 at ts 146
 *** dropping frame 153 from stream 0 at ts 151
 *** dropping frame 158 from stream 0 at ts 156
 *** dropping frame 163 from stream 0 at ts 161
 *** dropping frame 168 from stream 0 at ts 166
 *** dropping frame 173 from stream 0 at ts 171:06.64 bitrate=N/A dup=2
 drop=32 speed=4.41x
 *** dropping frame 178 from stream 0 at ts 176
 *** dropping frame 183 from stream 0 at ts 181
 *** dropping frame 188 from stream 0 at ts 186
 *** dropping frame 193 from stream 0 at ts 191:07.20 bitrate=N/A dup=2
 drop=36 speed=3.59x
 *** dropping frame 198 from stream 0 at ts 196
 *** dropping frame 203 from stream 0 at ts 201
 *** dropping frame 208 from stream 0 at ts 206:08.08 bitrate=N/A dup=2
 drop=39 speed=2.99x
 *** dropping frame 213 from stream 0 at ts 211
 *** dropping frame 218 from stream 0 at ts 216:08.56 bitrate=N/A dup=2
 drop=41 speed=2.64x
 *** dropping frame 223 from stream 0 at ts 221
 *** dropping frame 228 from stream 0 at ts 226
 *** dropping frame 233 from stream 0 at ts 231:09.04 bitrate=N/A dup=2
 drop=44 speed=2.38x
 *** dropping frame 238 from stream 0 at ts 236
 [hls @ 0796db80] Opening 'C:\Users\Beloko\Desktop\Big_Buck_Bunny3.ts' for
 writing
 [hls @ 0796db80] Opening 'C:\Users\Beloko\Desktop\Big_Buck_Bunny.m3u8.tmp'
 for writing
 [hls muxer @ 0796b6e0] EXT-X-MEDIA-SEQUENCE:1
 *** dropping frame 243 from stream 0 at ts 241
 *** dropping frame 248 from stream 0 at ts 246:09.52 bitrate=N/A dup=2
 drop=47 speed= 2.2x
 No more output streams to write to, finishing.
 [hls @ 0796db80] Opening 'C:\Users\Beloko\Desktop\Big_Buck_Bunny.m3u8.tmp'
 for writing
 [hls muxer @ 0796b6e0] EXT-X-MEDIA-SEQUENCE:1
 frame=  250 fps= 51 q=-1.0 Lsize=N/A time=00:00:10.00 bitrate=N/A dup=2
 drop=48 speed=2.05x
 video:4054kB audio:157kB subtitle:0kB other streams:0kB global headers:0kB
 muxing overhead: unknown
 Input file #0
 (http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4):
   Input stream #0:0 (video): 307 packets read (3019729 bytes); 298 frames
 decoded;
   Input stream #0:1 (audio): 21 packets read (10080 bytes);
   Input stream #0:2 (audio): 316 packets read (404480 bytes); 316 frames
 decoded (485376 samples);
   Total: 644 packets (3434289 bytes) demuxed
 Output file #0 (C:\Users\Beloko\Desktop\Big_Buck_Bunny.m3u8):
   Output stream #0:0 (video): 250 frames encoded; 250 packets muxed
 (4151304 bytes);
   Output stream #0:1 (audio): 417 frames encoded (480000 samples); 418
 packets muxed (160512 bytes);
   Total: 668 packets (4311816 bytes) muxed
 [libx264 @ 0797b1c0] frame I:13    Avg QP:11.25  size: 65304
 [libx264 @ 0797b1c0] frame P:237   Avg QP:17.86  size: 13931
 [libx264 @ 0797b1c0] mb I  I16..4: 86.5%  0.0% 13.5%
 [libx264 @ 0797b1c0] mb P  I16..4: 14.9%  0.0%  0.7%  P16..4: 13.4%  2.7%
 1.1%  0.0%  0.0%    skip:67.3%
 [libx264 @ 0797b1c0] coded y,uvDC,uvAC intra: 5.1% 21.0% 6.9% inter: 4.7%
 9.2% 1.8%
 [libx264 @ 0797b1c0] i16 v,h,dc,p: 78% 14%  5%  3%
 [libx264 @ 0797b1c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 16% 28%  5%  6%
 4%  6%  3%  5%
 [libx264 @ 0797b1c0] i8c dc,h,v,p: 75% 13% 10%  1%
 [libx264 @ 0797b1c0] kb/s:3320.54

 C:\Users\Beloko\Desktop\FFMPEG>type
 "C:\Users\Beloko\Desktop\Big_Buck_Bunny.m3u8"
 #EXTM3U
 #EXT-X-VERSION:3
 #EXT-X-TARGETDURATION:4
 #EXT-X-MEDIA-SEQUENCE:1
 #EXTINF:4.000000,
 Big_Buck_Bunny1.ts
 #EXTINF:4.000000,
 Big_Buck_Bunny2.ts
 #EXTINF:2.000000,
 Big_Buck_Bunny3.ts
 #EXT-X-ENDLIST

 C:\Users\Beloko\Desktop\FFMPEG>ffprobe
 "C:\Users\Beloko\Desktop\Big_Buck_Bunny1.ts"
 ffprobe version N-88980-g5f1bb25-Reino Copyright (c) 2007-2017 the FFmpeg
 developers
   built with gcc 7.1.0 (GCC)
   configuration: --arch=x86 --target-os=mingw32 --cross-
 prefix=/home/beloko/FFMpeg_Builder/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-
 --pkg-config=pkg-config --pkg-config-flags=--static --extra-version=Reino
 --enable-gray --enable-version3 --disable-debug --disable-doc --disable-
 htmlpages --disable-manpages --disable-podpages --disable-txtpages
 --disable-w32threads --enable-fontconfig --enable-gmp --enable-gnutls
 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
 --enable-libflite --enable-libfreetype --enable-libfribidi --enable-libgme
 --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame
 --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb
 --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-
 libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-
 libtwolame --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
 --enable-libwebp --enable-libzimg --enable-libzvbi --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --extra-
 cflags=-DCACA_STATIC --enable-gpl --enable-avisynth --enable-frei0r
 --enable-filter=frei0r --enable-librubberband --enable-libvidstab
 --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid
 --enable-libmfx --enable-avresample --extra-cflags='-mtune=generic'
 --extra-cflags=-O3 --enable-static --disable-shared
 --prefix=/home/beloko/FFMpeg_Builder/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32
 --enable-nonfree --enable-decklink --enable-libfdk-aac
   libavutil      56.  0.100 / 56.  0.100
   libavcodec     58.  3.100 / 58.  3.100
   libavformat    58.  2.100 / 58.  2.100
   libavdevice    58.  0.100 / 58.  0.100
   libavfilter     7.  0.101 /  7.  0.101
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  0.101 /  5.  0.101
   libswresample   3.  0.101 /  3.  0.101
   libpostproc    55.  0.100 / 55.  0.100
 Input #0, mpegts, from 'C:\Users\Beloko\Desktop\Big_Buck_Bunny1.ts':
   Duration: 00:00:04.02, start: 1.400000, bitrate: 1112 kb/s
   Program 1
     Metadata:
       service_name    : Big Buck Bunny, Sunflower version
       service_provider: FFmpeg
     Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0]
 / 0x001B), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25
 tbr, 90k tbn, 50 tbc
     Stream #0:1[0x101](und): Audio: mp3 ([3][0][0][0] / 0x0003), 48000 Hz,
 stereo, s16p, 128 kb/s
 }}}

 I note the .TS isn't exactly 4s long with FFPROBE.
 But 4.02 seconds.

 But tested with an HLS adaptive bitrate.
 It doesn't affect the playback.
 And the Apple Mediastreamvalidator tool doesn't complain anymore with
 different #EXT-X-TARGETDURATION.

 Hope this fix will be merged with the master GIT for everyone.

--
Ticket URL: <https://trac.ffmpeg.org/ticket/6868#comment:10>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list