Opened 5 years ago

Last modified 3 years ago

#8636 open defect

Invalid byteranges in 1fps iframes-only HLS playlist

Reported by: Matt Patterson Owned by: Steven Liu
Priority: normal Component: avformat
Version: unspecified Keywords: hls
Cc: liuqi05@kuaishou.com Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Generating an HLS trick mode 1fps video (EXT-X-KEYFRAMES-ONLY) where all frames are IDR frames generates broken byteranges in the .m3u8.

The video itself is fine, it's just the .m3u8 playlist.

The playlist contains byteranges that look like this:

#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@0
iframes-g1.m4s
#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@1902
iframes-g1.m4s
#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@2391
iframes-g1.m4s
#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@2880
iframes-g1.m4s
#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@7849
iframes-g1.m4s

All the ranges are reported as being 0 bytes long.

I've tried this with several videos and with different h.264 encoders (libx264 and videotoolbox) with the same results.

This example uses a 20-second extract from the 1080p render of Tears of Steel: https://mango.blender.org/download/, created with:

$ ffmpeg -t 20 -i tears_of_steel_1080p.mov -c copy tears-short.mp4

How to reproduce:

$ ffmpeg -threads 0 -report -i tears-short.mp4 \
  -map 0:v \
  -c:v libx264 -r 1 -g 1 \
  -an \
  -f hls -hls_playlist_type vod -hls_time 1 \
  -hls_flags single_file+iframes_only \
  -hls_segment_type fmp4 -hls_list_size 0 \
  iframes-g1.m3u8

ffmpeg started on 2020-04-27 at 09:59:46
Report written to "ffmpeg-20200427-095946.log"
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple clang version 11.0.0 (clang-1100.0.33.17)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'tears-short.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:20.04, start: 0.000000, bitrate: 3801 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 3603 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 191 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7fd08d00ce00] using SAR=1/1
[libx264 @ 0x7fd08d00ce00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fd08d00ce00] profile High, level 4.0
[libx264 @ 0x7fd08d00ce00] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=0 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=0 weightp=0 keyint=1 keyint_min=1 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x7fd08d009a00] Opening 'iframes-g1.m4s' for writing
Output #0, hls, to 'iframes-g1.m3u8':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
    Stream #0:0(eng): Video: h264 (libx264), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], q=-1--1, 1 fps, 16384 tbn, 1 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=   12 fps=0.0 q=12.0 size=N/A time=00:00:05.00 bitrate=N/A dup=0 drop=248 frame=   17 fps= 17 q=16.0 size=N/A time=00:00:10.00 bitrate=N/A dup=0 drop=341 frame=   20 fps= 13 q=17.0 size=N/A time=00:00:13.00 bitrate=N/A dup=0 drop=421 frame=   22 fps= 12 q=-1.0 Lsize=N/A time=00:00:22.00 bitrate=N/A dup=0 drop=459 speed=11.5x
video:1782kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7fd08d00ce00] frame I:22    Avg QP: 6.81  size: 82926
[libx264 @ 0x7fd08d00ce00] mb I  I16..4: 57.4% 27.9% 14.7%
[libx264 @ 0x7fd08d00ce00] 8x8 transform intra:27.9%
[libx264 @ 0x7fd08d00ce00] coded y,uvDC,uvAC intra: 40.9% 41.3% 34.8%
[libx264 @ 0x7fd08d00ce00] i16 v,h,dc,p: 93%  1%  3%  3%
[libx264 @ 0x7fd08d00ce00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 18% 12%  6%  6%  7%  7%  9%  9%
[libx264 @ 0x7fd08d00ce00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 19%  9%  6%  9%  8%  9%  6%  7%
[libx264 @ 0x7fd08d00ce00] i8c dc,h,v,p: 73% 10% 12%  5%
[libx264 @ 0x7fd08d00ce00] kb/s:663.41

Attachments (2)

ffmpeg-20200427-095946.log (137.8 KB ) - added by Matt Patterson 5 years ago.
ffmpeg report log
ffmpeg-20200427-141108.log (138.0 KB ) - added by Matt Patterson 5 years ago.
Report from running ffmpeg from HEAD

Download all attachments as: .zip

Change History (7)

by Matt Patterson, 5 years ago

Attachment: ffmpeg-20200427-095946.log added

ffmpeg report log

comment:1 by Carl Eugen Hoyos, 5 years ago

Component: undeterminedavformat
Keywords: hls added

Is the issue reproducible with current FFmpeg git head, the only version supported on this bug tracker?

comment:2 by Matt Patterson, 5 years ago

Yes, it is. In fact it's worse: byte offsets in the m3u8 are now all 0 too, as well as the lengths:

#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@0
iframes-g1-head.m4s
#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@0
iframes-g1-head.m4s
#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@0
iframes-g1-head.m4s
#EXTINF:1.000000,
#EXT-X-BYTERANGE:0@0
iframes-g1-head.m4s

I'll attach the report.

by Matt Patterson, 5 years ago

Attachment: ffmpeg-20200427-141108.log added

Report from running ffmpeg from HEAD

comment:3 by Steven Liu, 5 years ago

Cc: liuqi05@kuaishou.com added
Owner: set to Steven Liu
Status: newopen

comment:5 by Balling, 3 years ago

This got reverted so not fixed. 59032494e81a1a65c0b960aaae7ec4c2cc9db35a

Note: See TracTickets for help on using tickets.