[FFmpeg-trac] #7798(undetermined:new): hls muxer often generates segments shorter than -hls_time
FFmpeg
trac at avcodec.org
Sun Mar 17 05:11:15 EET 2019
#7798: hls muxer often generates segments shorter than -hls_time
-------------------------------------+-------------------------------------
Reporter: JoshuaWalsh | Owner:
Type: defect | Status: new
Priority: normal | Component:
| undetermined
Version: git-master | Resolution:
Keywords: hls | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Comment (by stevenliu):
Replying to [comment:11 JoshuaWalsh]:
> Tried using Git master in my original post, but I haven't had access to
my work PC since then so wasn't set up to build from source.
>
> I want segment duration >= 5s, it doesn't need to be 5s exactly. I don't
want to force GOP and I don't want to disable scenecut.
>
>
> If the packet pts - the start of the segment pts is large than
hls_time, and the packet flags is key, then close current file and open
new file for the next segment
>
> I don't understand how this can produce segments shorter than -hls_time,
since packet pts - start of segment pts will be less than hls_time.
>
> With your second example:
>
> kppkppppppppkpppppppkpppkppkppp
>
> First segment is
> kppkpppppppp
> That makes sense. Remaining data is:
> kpppppppkpppkppkppp
> But to produce a second segment of 1.6s length:
> kppppppp
> would require splitting while packet pts - seg start pts < hls_time, no?
If respecting hls_time, second segment should be
> kpppppppkpppkppkppp (2.4s again)
No, the end_pts is compute by (segment numbers * hls_time), maybe this is
not good, but this is allowed by users pass several years.
because the keyframe position is not standard, if you want hlsenc split at
5, you should try hls_flags split_by_time
>
> I'm happy to try to write a patch, but I'm not a C/C++ developer so it's
difficult for me to get my head around ffmpeg's internals.
{{{
liuqideMacBook-Pro:dash liuqi$ mkdir output; ffmpeg -i
~/Movies/Test/bbb_sunflower_1080p_30fps_normal.mp4 -c:v libx264 -f hls
-hls_time 5 -hls_flags split_by_time -hls_list_size 0 -preset veryfast -t
60 -an output/output.m3u8
mkdir: output: File exists
ffmpeg version N-92522-g370b8bd847 Copyright (c) 2000-2018 the FFmpeg
developers
built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
configuration: --enable-fontconfig --enable-gpl --enable-libass
--enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-
libspeex --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-
version3 --enable-nonfree --enable-videotoolbox --enable-libxml2
libavutil 56. 24.101 / 56. 24.101
libavcodec 58. 40.100 / 58. 40.100
libavformat 58. 23.100 / 58. 23.100
libavdevice 58. 6.100 / 58. 6.100
libavfilter 7. 46.100 / 7. 46.100
libswscale 5. 4.100 / 5. 4.100
libswresample 3. 4.100 / 3. 4.100
libpostproc 55. 4.100 / 55. 4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'/Users/liuqi/Movies/Test/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) (avc1 / 0x31637661), yuv420p,
1920x1080 [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,
fltp, 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))
Press [q] to stop, [?] for help
[libx264 @ 0x7fb098807600] using SAR=1/1
[libx264 @ 0x7fb098807600] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX
[libx264 @ 0x7fb098807600] profile High, level 4.0
[libx264 @ 0x7fb098807600] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC
codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options:
cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=2 psy=1
psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6
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=1 keyint=250 keyint_min=25
scenecut=40 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=1 crf=23.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x7fb098805600] Opening 'output/output0.ts' for writing
Output #0, hls, to 'output/output.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.23.100
Stream #0:0(und): Video: h264 (libx264), yuv420p, 1920x1080 [SAR 1:1
DAR 16:9], q=-1--1, 30 fps, 90k tbn, 30 tbc (default)
Metadata:
creation_time : 2013-12-16T17:44:39.000000Z
handler_name : GPAC ISO Video Handler
encoder : Lavc58.40.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[hls @ 0x7fb098805600] Opening 'output/output1.ts' for writing/A dup=2
drop=0 speed=1.87x
[hls @ 0x7fb098805600] Cannot use rename on non file protocol, this may
lead to races and temporary partial files
[hls @ 0x7fb098805600] Opening 'output/output2.ts' for writing/A dup=2
drop=0 speed=1.69x
[hls @ 0x7fb098805600] Opening 'output/output3.ts' for writing/A dup=2
drop=0 speed=1.58x
[hls @ 0x7fb098805600] Opening 'output/output4.ts' for writing/A dup=2
drop=0 speed=1.55x
[hls @ 0x7fb098805600] Opening 'output/output5.ts' for writing/A dup=2
drop=0 speed=1.64x
[hls @ 0x7fb098805600] Opening 'output/output6.ts' for writing/A dup=2
drop=0 speed=1.65x
[hls @ 0x7fb098805600] Opening 'output/output7.ts' for writing/A dup=2
drop=0 speed=1.58x
[hls @ 0x7fb098805600] Opening 'output/output8.ts' for writing/A dup=2
drop=0 speed=1.54x
[hls @ 0x7fb098805600] Opening 'output/output9.ts' for writing/A dup=2
drop=0 speed=1.52x
[hls @ 0x7fb098805600] Opening 'output/output10.ts' for writingA dup=2
drop=0 speed=1.54x
[hls @ 0x7fb098805600] Opening 'output/output11.ts' for writingA dup=2
drop=0 speed=1.52x
frame= 1800 fps= 46 q=-1.0 Lsize=N/A time=00:00:59.93 bitrate=N/A dup=2
drop=0 speed=1.54x
video:17525kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: unknown
[libx264 @ 0x7fb098807600] frame I:12 Avg QP:15.83 size:227217
[libx264 @ 0x7fb098807600] frame P:487 Avg QP:22.42 size: 25400
[libx264 @ 0x7fb098807600] frame B:1301 Avg QP:25.88 size: 2190
[libx264 @ 0x7fb098807600] consecutive B-frames: 2.1% 3.4% 3.3% 91.1%
[libx264 @ 0x7fb098807600] mb I I16..4: 38.3% 14.1% 47.6%
[libx264 @ 0x7fb098807600] mb P I16..4: 3.6% 1.7% 0.2% P16..4: 29.7%
11.6% 6.7% 0.0% 0.0% skip:46.5%
[libx264 @ 0x7fb098807600] mb B I16..4: 0.3% 0.1% 0.0% B16..8: 5.4%
1.3% 0.2% direct: 2.0% skip:90.8% L0:36.9% L1:45.3% BI:17.8%
[libx264 @ 0x7fb098807600] 8x8 transform intra:25.3% inter:46.9%
[libx264 @ 0x7fb098807600] coded y,uvDC,uvAC intra: 28.5% 39.2% 17.2%
inter: 4.7% 5.3% 0.6%
[libx264 @ 0x7fb098807600] i16 v,h,dc,p: 68% 19% 9% 4%
[libx264 @ 0x7fb098807600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 21% 29% 3%
5% 5% 5% 4% 5%
[libx264 @ 0x7fb098807600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 12% 11% 8%
9% 10% 8% 13% 9%
[libx264 @ 0x7fb098807600] i8c dc,h,v,p: 63% 18% 15% 5%
[libx264 @ 0x7fb098807600] Weighted P-Frames: Y:3.3% UV:3.3%
[libx264 @ 0x7fb098807600] kb/s:2392.71
liuqideMacBook-Pro:dash liuqi$ cat output/output.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:5.000000,
output0.ts
#EXTINF:5.000000,
output1.ts
#EXTINF:5.000000,
output2.ts
#EXTINF:4.933333,
output3.ts
#EXTINF:4.966667,
output4.ts
#EXTINF:5.000000,
output5.ts
#EXTINF:5.066667,
output6.ts
#EXTINF:4.966667,
output7.ts
#EXTINF:5.066667,
output8.ts
#EXTINF:5.000000,
output9.ts
#EXTINF:4.900000,
output10.ts
#EXTINF:5.100000,
output11.ts
#EXT-X-ENDLIST
liuqideMacBook-Pro:dash liuqi$
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7798#comment:12>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list