Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#9101 closed defect (invalid)

Issue with creating hls m3u8 playlist with .m4s

Reported by: Den Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
I’m trying to create hls m3u8 playlist with .m4s files instead of .ts. It needs for streaming h265 video from live RTSP camera. I’m trying to add hls_flags delete_segments+append_list to remove the end of file + add segments to the m3u8 file but look like ffmpeg skips this option. Also m3u8 creates only after stopping ffmpeg command, but should during the process.
How to reproduce:

ffmpeg -use_wallclock_as_timestamps 1 \
      -loglevel warning \
      -fflags nobuffer \
      -rtsp_transport tcp  \
      -i rtsp://username:password@192.168.2.252:554/Streaming/Channels/101 \
      -c:v libx264 -b:v 1500k \
      -c:a aac \
      -b:a 64k \
      -ar 44100 \
      -af aresample=async=1000 \
      -g 48 \
      -keyint_min 48 \
      -sc_threshold 0 \
      -use_localtime 1 \
      -hls_time 2 \
      -hls_list_size 2 \
      -hls_flags delete_segments+append_list \
      -c:v libx264 -b:v 1500k \
      -hls_playlist_type vod \
      -hls_segment_type fmp4 \
      -hls_base_url ‘/api/v3/cameras/5d4442faa34dbe188129ccbe/live?token=[TOKEN]&file=’ \
      -hls_segment_filename 5d4442faa34dbe188129ccbe-%s.ts \
      5d4442faa34dbe188129ccbe.m3u8

Expected behaviour:

  1. It creates 5d4442faa34dbe188129ccbe.m3u8 when starting process
  2. Creates 5d4442faa34dbe188129ccbe.m3u8 without #EXT-X-ENDLIST
  3. Should have only 2 segments filenames

What I have in result:

  1. It creates 5d4442faa34dbe188129ccbe.m3u8 only after force stop process (control + C)
  2. Creates 5d4442faa34dbe188129ccbe.m3u8 with #EXT-X-ENDLIST in the end of file
  3. The file has all m4s segments filenames

Here is content of 5d4442faa34dbe188129ccbe.m3u8:

#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-MAP:URI=“init.mp4”
#EXT-X-DISCONTINUITY
#EXTINF:3.840000,
5d4442faa34dbe188129ccbe-1613079721.m4s
#EXTINF:1.920000,
5d4442faa34dbe188129ccbe-1613079728.m4s
#EXTINF:1.920000,
5d4442faa34dbe188129ccbe-1613079729.m4s
#EXTINF:1.920000,
5d4442faa34dbe188129ccbe-1613079731.m4s
#EXTINF:1.920000,
5d4442faa34dbe188129ccbe-1613079733.m4s
#EXTINF:1.920000,
5d4442faa34dbe188129ccbe-1613079735.m4s
#EXTINF:0.880000,
5d4442faa34dbe188129ccbe-1613079737.m4s
#EXT-X-ENDLIST

ffmpeg version:

ffmpeg -version
ffmpeg version N-97685-gde7b690300 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
configuration: --enable-libx264 --enable-libfdk-aac --enable-gpl --enable-nonfree --enable-shared --enable-pic --enable-openssl
libavutil      56. 43.100 / 56. 43.100
libavcodec     58. 83.100 / 58. 83.100
libavformat    58. 43.100 / 58. 43.100
libavdevice    58.  9.103 / 58.  9.103
libavfilter     7. 80.100 /  7. 80.100
libswscale      5.  6.101 /  5.  6.101
libswresample   3.  6.100 /  3.  6.100
libpostproc    55.  6.100 / 55.  6.100

Attachments (3)

m4s-issue.gif (504.5 KB ) - added by Den 3 years ago.
How is hls m4s works with rtsp stream
ts-works.gif (161.2 KB ) - added by Den 3 years ago.
How is hls ts works with rtsp stream
cat-m3u8-result.gif (147.1 KB ) - added by Den 3 years ago.
ts m3u8 file result

Download all attachments as: .zip

Change History (7)

comment:1 by Carl Eugen Hoyos, 3 years ago

Component: ffmpegundetermined

Are you reporting an issue with rtsp input or with hls output?

Please test current FFmpeg git head and post a simplified command line you tested together with the complete, uncut console output to make this a valid ticket.

comment:2 by Steven Liu, 3 years ago

Resolution: wontfix
Status: newclosed

Yes, because you are using hls_playlist_type argument and "EVENT or VOD playlists imply sliding window (hls_list_size) cannot be used"

reference documentation said: https://ffmpeg.org/ffmpeg-formats.html#Options-6

hls_playlist_type event
Emit #EXT-X-PLAYLIST-TYPE:EVENT in the m3u8 header. Forces hls_list_size to 0; the playlist can only be appended to.

hls_playlist_type vod
Emit #EXT-X-PLAYLIST-TYPE:VOD in the m3u8 header. Forces hls_list_size to 0; the playlist must not change.

you should not use hls_playlist_type, it will ok.

liuqideMacBook-Pro:build liuqi$  ./ffmpeg -use_wallclock_as_timestamps 1 -re -f lavfi -i testsrc=s=176x144 -c:v libx264 -b:v 1500k -g 48 -r:v 24 -sc_threshold 0 -keyint_min 48 -use_localtime 1 -hls_time 2 -hls_list_size 2  -hls_flags delete_segments+append_list -hls_segment_type fmp4 -hls_segment_filename 5d4442faa34dbe188129ccbe-%s.m4s -t 6 5d4442faa34dbe188129ccbe.m3u8
ffmpeg version N-101068-gedc45d1bd5 Copyright (c) 2000-2021 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 --samples=/Users/liuqi/multimedia/fate-suite/ --enable-libopencv
  libavutil      56. 65.100 / 56. 65.100
  libavcodec     58.122.100 / 58.122.100
  libavformat    58. 67.100 / 58. 67.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7.106.100 /  7.106.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, lavfi, from 'testsrc=s=176x144':
  Duration: N/A, start: 1613131174.520000, bitrate: N/A
  Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 176x144 [SAR 1:1 DAR 11:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7fd9ca82d400] using SAR=1/1
[libx264 @ 0x7fd9ca82d400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fd9ca82d400] profile High 4:4:4 Predictive, level 1.3, 4:4:4 8-bit
[libx264 @ 0x7fd9ca82d400] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=4 threads=4 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=48 keyint_min=25 scenecut=0 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x7fd9c9003e00] Opening 'init.mp4' for writing
Output #0, hls, to '5d4442faa34dbe188129ccbe.m3u8':
  Metadata:
    encoder         : Lavf58.67.100
  Stream #0:0: Video: h264, yuv444p(tv, progressive), 176x144 [SAR 1:1 DAR 11:9], q=2-31, 1500 kb/s, 24 fps, 12288 tbn
    Metadata:
      encoder         : Lavc58.122.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/1500000 buffer size: 0 vbv_delay: N/A
[hls @ 0x7fd9c9003e00] Opening '5d4442faa34dbe188129ccbe-1613131174.m4s' for writing.434x
[hls @ 0x7fd9c9003e00] Opening '5d4442faa34dbe188129ccbe.m3u8.tmp' for writing
[hls @ 0x7fd9c9003e00] Opening '5d4442faa34dbe188129ccbe-1613131178.m4s' for writing.642x
[hls @ 0x7fd9c9003e00] Opening '5d4442faa34dbe188129ccbe.m3u8.tmp' for writing
[hls @ 0x7fd9c9003e00] Opening '5d4442faa34dbe188129ccbe-1613131180.m4s' for writing
[hls @ 0x7fd9c9003e00] Opening '5d4442faa34dbe188129ccbe.m3u8.tmp' for writing
frame=  144 fps= 24 q=-1.0 Lsize=N/A time=00:00:05.91 bitrate=N/A dup=0 drop=4 speed=0.989x
video:165kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7fd9ca82d400] frame I:3     Avg QP: 3.99  size:  4777
[libx264 @ 0x7fd9ca82d400] frame P:115   Avg QP: 0.55  size:  1220
[libx264 @ 0x7fd9ca82d400] frame B:26    Avg QP: 1.45  size:   514
[libx264 @ 0x7fd9ca82d400] consecutive B-frames: 75.0%  0.0%  8.3% 16.7%
[libx264 @ 0x7fd9ca82d400] mb I  I16..4: 42.1%  6.4% 51.5%
[libx264 @ 0x7fd9ca82d400] mb P  I16..4:  0.2%  0.0%  0.2%  P16..4:  7.8%  9.2%  6.4%  0.0%  0.0%    skip:76.2%
[libx264 @ 0x7fd9ca82d400] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  2.7%  2.7%  1.6%  direct:13.2%  skip:79.8%  L0:44.7% L1:34.4% BI:20.9%
[libx264 @ 0x7fd9ca82d400] final ratefactor: -18.90
[libx264 @ 0x7fd9ca82d400] 8x8 transform intra:5.5% inter:19.7%
[libx264 @ 0x7fd9ca82d400] coded y,u,v intra: 25.0% 24.4% 23.8% inter: 13.2% 14.7% 13.7%
[libx264 @ 0x7fd9ca82d400] i16 v,h,dc,p: 96%  1%  3%  0%
[libx264 @ 0x7fd9ca82d400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 66% 13% 20%  0%  0%  0%  0%  0%  1%
[libx264 @ 0x7fd9ca82d400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 63% 15% 14%  2%  1%  2%  1%  2%  0%
[libx264 @ 0x7fd9ca82d400] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fd9ca82d400] ref P L0: 74.2% 12.9%  5.5%  7.4%
[libx264 @ 0x7fd9ca82d400] ref B L0: 91.5%  7.5%  1.0%
[libx264 @ 0x7fd9ca82d400] ref B L1: 98.2%  1.8%
[libx264 @ 0x7fd9ca82d400] kb/s:224.00
liuqideMacBook-Pro:build liuqi$ cat 5d4442faa34dbe188129ccbe.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init.mp4"
#EXTINF:2.000000,
5d4442faa34dbe188129ccbe-1613131178.m4s
#EXTINF:2.000000,
5d4442faa34dbe188129ccbe-1613131180.m4s
#EXT-X-ENDLIST
liuqideMacBook-Pro:build liuqi$  ./ffmpeg -use_wallclock_as_timestamps 1 -re -f lavfi -i testsrc=s=176x144 -c:v libx264 -b:v 1500k -g 48 -r:v 24 -sc_threshold 0 -keyint_min 48 -use_localtime 1 -hls_time 2 -hls_list_size 2  -hls_flags delete_segments+append_list -hls_segment_type fmp4 -hls_segment_filename 5d4442faa34dbe188129ccbe-%s.m4s -t 7 5d4442faa34dbe188129ccbe.m3u8
ffmpeg version N-101068-gedc45d1bd5 Copyright (c) 2000-2021 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 --samples=/Users/liuqi/multimedia/fate-suite/ --enable-libopencv
  libavutil      56. 65.100 / 56. 65.100
  libavcodec     58.122.100 / 58.122.100
  libavformat    58. 67.100 / 58. 67.100
  libavdevice    58. 11.103 / 58. 11.103
  libavfilter     7.106.100 /  7.106.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, lavfi, from 'testsrc=s=176x144':
  Duration: N/A, start: 1613131192.680000, bitrate: N/A
  Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 176x144 [SAR 1:1 DAR 11:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x7fb7f2003400] using SAR=1/1
[libx264 @ 0x7fb7f2003400] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x7fb7f2003400] profile High 4:4:4 Predictive, level 1.3, 4:4:4 8-bit
[libx264 @ 0x7fb7f2003400] 264 - core 148 r2694 3b70645 - H.264/MPEG-4 AVC codec - Copyleft 2003-2016 - 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=4 threads=4 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=48 keyint_min=25 scenecut=0 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
[hls @ 0x7fb7f2000000] Opening 'init.mp4' for writing
Output #0, hls, to '5d4442faa34dbe188129ccbe.m3u8':
  Metadata:
    encoder         : Lavf58.67.100
  Stream #0:0: Video: h264, yuv444p(tv, progressive), 176x144 [SAR 1:1 DAR 11:9], q=2-31, 1500 kb/s, 24 fps, 12288 tbn
    Metadata:
      encoder         : Lavc58.122.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/1500000 buffer size: 0 vbv_delay: N/A
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe-1613131192.m4s' for writing.434x
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe.m3u8.tmp' for writing
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe-1613131196.m4s' for writing.643x
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe.m3u8.tmp' for writing
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe-1613131198.m4s' for writing.695x
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe.m3u8.tmp' for writing
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe-1613131199.m4s' for writing
[hls @ 0x7fb7f2000000] Opening '5d4442faa34dbe188129ccbe.m3u8.tmp' for writing
frame=  168 fps= 24 q=-1.0 Lsize=N/A time=00:00:06.91 bitrate=N/A dup=0 drop=5 speed=0.992x
video:195kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7fb7f2003400] frame I:4     Avg QP: 3.04  size:  4938
[libx264 @ 0x7fb7f2003400] frame P:135   Avg QP: 0.48  size:  1217
[libx264 @ 0x7fb7f2003400] frame B:29    Avg QP: 1.47  size:   517
[libx264 @ 0x7fb7f2003400] consecutive B-frames: 76.2%  0.0%  7.1% 16.7%
[libx264 @ 0x7fb7f2003400] mb I  I16..4: 43.4%  5.1% 51.5%
[libx264 @ 0x7fb7f2003400] mb P  I16..4:  0.1%  0.0%  0.2%  P16..4:  7.6%  9.3%  6.4%  0.0%  0.0%    skip:76.3%
[libx264 @ 0x7fb7f2003400] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  2.7%  2.9%  1.7%  direct:13.0%  skip:79.8%  L0:45.8% L1:33.5% BI:20.7%
[libx264 @ 0x7fb7f2003400] final ratefactor: -19.15
[libx264 @ 0x7fb7f2003400] 8x8 transform intra:4.5% inter:20.0%
[libx264 @ 0x7fb7f2003400] coded y,u,v intra: 24.8% 24.2% 23.5% inter: 13.2% 14.8% 13.7%
[libx264 @ 0x7fb7f2003400] i16 v,h,dc,p: 95%  2%  3%  0%
[libx264 @ 0x7fb7f2003400] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 65% 12% 21%  0%  0%  0%  0%  0%  1%
[libx264 @ 0x7fb7f2003400] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 63% 15% 14%  2%  1%  2%  1%  2%  0%
[libx264 @ 0x7fb7f2003400] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7fb7f2003400] ref P L0: 74.5% 12.5%  5.7%  7.4%
[libx264 @ 0x7fb7f2003400] ref B L0: 90.0%  9.1%  0.9%
[libx264 @ 0x7fb7f2003400] ref B L1: 96.7%  3.3%
[libx264 @ 0x7fb7f2003400] kb/s:227.46
liuqideMacBook-Pro:build liuqi$ cat 5d4442faa34dbe188129ccbe.m3u8
#EXTM3U
#EXT-X-VERSION:7
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:5
#EXT-X-MAP:URI="init.mp4"
#EXTINF:2.000000,
5d4442faa34dbe188129ccbe-1613131198.m4s
#EXTINF:1.000000,
5d4442faa34dbe188129ccbe-1613131199.m4s
#EXT-X-ENDLIST
liuqideMacBook-Pro:build liuqi$
Last edited 3 years ago by Steven Liu (previous) (diff)

by Den, 3 years ago

Attachment: m4s-issue.gif added

How is hls m4s works with rtsp stream

by Den, 3 years ago

Attachment: ts-works.gif added

How is hls ts works with rtsp stream

by Den, 3 years ago

Attachment: cat-m3u8-result.gif added

ts m3u8 file result

comment:3 by Den, 3 years ago

Resolution: wontfixcompleted (art)

stevenliu, You are totally right, removed this option and all works as expected. You saved my time, thank you!

comment:4 by Carl Eugen Hoyos, 3 years ago

Resolution: completed (art)invalid
Note: See TracTickets for help on using tickets.