Opened 6 years ago

Closed 6 years ago

#7044 closed defect (fixed)

hls duration incorrect with split filter

Reported by: ronag Owned by: Steven Liu
Priority: normal Component: avformat
Version: git-master Keywords: hls
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I'm trying to encode two video streams into an HLS file (fill & alpha). However, when I use the split filter (which I need for this) the segment durations in the manifest file becomes x2 (30s) vs the actual duration (15s).

ffmpeg -i M7HGQ8gA7Sf09Z.qt -c:v libx264 -g:v 100 -filter_complex:v "[0:v]fps=fps=25,split=2" -f hls -hls_time 4 -hls_flags single_file test.m3u8 -y && cat test.m3u8
ffmpeg version git-2018-02-26-f4709f1 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-f4709f1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libmp3lame --enable-libwebp --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      56.  7.101 / 56.  7.101
  libavcodec     58. 13.100 / 58. 13.100
  libavformat    58. 10.100 / 58. 10.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 12.100 /  7. 12.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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'M7HGQ8gA7Sf09Z.qt':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2018-02-03T19:48:37.000000Z
  Duration: 00:00:14.98, start: 0.000000, bitrate: 33223 kb/s
    Stream #0:0(eng): Video: png (png  / 0x20676E70), rgba(pc), 1280x720 [SAR 2834:2834 DAR 16:9], 33217 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
    Metadata:
      creation_time   : 2018-02-03T19:48:37.000000Z
      handler_name    : Gestor de datos de alias Apple
      encoder         : PNG
      timecode        : 00:00:00;00
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2018-02-03T19:49:39.000000Z
      handler_name    : Gestor de datos de alias Apple
      timecode        : 00:00:00;00
Stream mapping:
  Stream #0:0 (png) -> fps
  split:output0 -> Stream #0:0 (libx264)
  split:output1 -> Stream #0:1 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x7fc570802200] using SAR=1/1
[libx264 @ 0x7fc570802200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fc570802200] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0x7fc570802200] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 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=100 keyint_min=10 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
[libx264 @ 0x7fc570803a00] using SAR=1/1
[libx264 @ 0x7fc570803a00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7fc570803a00] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0x7fc570803a00] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 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=100 keyint_min=10 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
[hls @ 0x7fc57080b400] More than a single video stream present, expect issues decoding it.
[hls @ 0x7fc57080b400] Opening 'test.ts' for writing
Output #0, hls, to 'test.m3u8':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    encoder         : Lavf58.10.100
    Stream #0:0: Video: h264 (libx264), yuv444p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc58.13.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Video: h264 (libx264), yuv444p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc58.13.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[hls @ 0x7fc57080b400] Opening 'test.m3u8.tmp' for writing2 bitrate=N/A speed=0.961x    
[hls @ 0x7fc57080b400] Opening 'test.m3u8.tmp' for writing6 bitrate=N/A speed=1.32x    
[hls @ 0x7fc57080b400] Opening 'test.m3u8.tmp' for writing4 bitrate=N/A speed=1.55x    
[hls @ 0x7fc57080b400] Opening 'test.m3u8.tmp' for writing8 bitrate=N/A speed=1.55x    
frame=  375 fps= 42 q=-1.0 Lq=-1.0 size=N/A time=00:00:14.92 bitrate=N/A speed=1.68x    
video:1430kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7fc570802200] frame I:4     Avg QP: 9.58  size:  9548
[libx264 @ 0x7fc570802200] frame P:211   Avg QP:16.21  size:  2499
[libx264 @ 0x7fc570802200] frame B:160   Avg QP:24.70  size:  1038
[libx264 @ 0x7fc570802200] consecutive B-frames: 25.1% 51.2%  8.8% 14.9%
[libx264 @ 0x7fc570802200] mb I  I16..4: 86.8%  0.0% 13.2%
[libx264 @ 0x7fc570802200] mb P  I16..4:  5.0%  0.0%  0.6%  P16..4:  8.2%  3.0%  0.9%  0.0%  0.0%    skip:82.2%
[libx264 @ 0x7fc570802200] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 13.9%  1.9%  0.1%  direct: 0.1%  skip:83.9%  L0:46.5% L1:50.5% BI: 3.0%
[libx264 @ 0x7fc570802200] coded y,u,v intra: 5.3% 2.4% 2.6% inter: 0.8% 0.2% 0.2%
[libx264 @ 0x7fc570802200] i16 v,h,dc,p: 88%  9%  3%  0%
[libx264 @ 0x7fc570802200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 11% 53%  3%  4%  4%  4%  3%  2%
[libx264 @ 0x7fc570802200] Weighted P-Frames: Y:8.1% UV:0.0%
[libx264 @ 0x7fc570802200] ref P L0: 75.6%  3.9% 15.0%  5.4%  0.1%
[libx264 @ 0x7fc570802200] ref B L0: 86.0% 13.6%  0.4%
[libx264 @ 0x7fc570802200] ref B L1: 99.9%  0.1%
[libx264 @ 0x7fc570802200] kb/s:390.14
[libx264 @ 0x7fc570803a00] frame I:4     Avg QP: 9.58  size:  9548
[libx264 @ 0x7fc570803a00] frame P:211   Avg QP:16.21  size:  2499
[libx264 @ 0x7fc570803a00] frame B:160   Avg QP:24.70  size:  1038
[libx264 @ 0x7fc570803a00] consecutive B-frames: 25.1% 51.2%  8.8% 14.9%
[libx264 @ 0x7fc570803a00] mb I  I16..4: 86.8%  0.0% 13.2%
[libx264 @ 0x7fc570803a00] mb P  I16..4:  5.0%  0.0%  0.6%  P16..4:  8.2%  3.0%  0.9%  0.0%  0.0%    skip:82.2%
[libx264 @ 0x7fc570803a00] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 13.9%  1.9%  0.1%  direct: 0.1%  skip:83.9%  L0:46.5% L1:50.5% BI: 3.0%
[libx264 @ 0x7fc570803a00] coded y,u,v intra: 5.3% 2.4% 2.6% inter: 0.8% 0.2% 0.2%
[libx264 @ 0x7fc570803a00] i16 v,h,dc,p: 88%  9%  3%  0%
[libx264 @ 0x7fc570803a00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 11% 53%  3%  4%  4%  4%  3%  2%
[libx264 @ 0x7fc570803a00] Weighted P-Frames: Y:8.1% UV:0.0%
[libx264 @ 0x7fc570803a00] ref P L0: 75.6%  3.9% 15.0%  5.4%  0.1%
[libx264 @ 0x7fc570803a00] ref B L0: 86.0% 13.6%  0.4%
[libx264 @ 0x7fc570803a00] ref B L1: 99.9%  0.1%
[libx264 @ 0x7fc570803a00] kb/s:390.14
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:8
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:8.000000,
#EXT-X-BYTERANGE:585432@0
test.ts
#EXTINF:8.000000,
#EXT-X-BYTERANGE:134984@585432
test.ts
#EXTINF:8.000000,
#EXT-X-BYTERANGE:337648@720416
test.ts
#EXTINF:6.000000,
#EXT-X-BYTERANGE:533920@1058064
test.ts
#EXT-X-ENDLIST

However, without the split everything is correct:

Roberts-MBP-2:Desktop ronagy$ ffmpeg -i M7HGQ8gA7Sf09Z.qt -c:v libx264 -g:v 100 -filter_complex:v "[0:v]fps=fps=25" -f hls -hls_time 4 -hls_flags single_file test.m3u8 -y && cat test.m3u8
ffmpeg version git-2018-02-26-f4709f1 Copyright (c) 2000-2018 the FFmpeg developers
  built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/HEAD-f4709f1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-gpl --enable-ffplay --enable-libmp3lame --enable-libwebp --enable-libx264 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma
  libavutil      56.  7.101 / 56.  7.101
  libavcodec     58. 13.100 / 58. 13.100
  libavformat    58. 10.100 / 58. 10.100
  libavdevice    58.  2.100 / 58.  2.100
  libavfilter     7. 12.100 /  7. 12.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
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'M7HGQ8gA7Sf09Z.qt':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    creation_time   : 2018-02-03T19:48:37.000000Z
  Duration: 00:00:14.98, start: 0.000000, bitrate: 33223 kb/s
    Stream #0:0(eng): Video: png (png  / 0x20676E70), rgba(pc), 1280x720 [SAR 2834:2834 DAR 16:9], 33217 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default)
    Metadata:
      creation_time   : 2018-02-03T19:48:37.000000Z
      handler_name    : Gestor de datos de alias Apple
      encoder         : PNG
      timecode        : 00:00:00;00
    Stream #0:1(eng): Data: none (tmcd / 0x64636D74), 0 kb/s (default)
    Metadata:
      creation_time   : 2018-02-03T19:49:39.000000Z
      handler_name    : Gestor de datos de alias Apple
      timecode        : 00:00:00;00
Stream mapping:
  Stream #0:0 (png) -> fps
  fps -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x7f8335804200] using SAR=1/1
[libx264 @ 0x7f8335804200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f8335804200] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 @ 0x7f8335804200] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 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=100 keyint_min=10 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
[hls @ 0x7f8335818c00] Opening 'test.ts' for writing
Output #0, hls, to 'test.m3u8':
  Metadata:
    major_brand     : qt  
    minor_version   : 537199360
    compatible_brands: qt  
    encoder         : Lavf58.10.100
    Stream #0:0: Video: h264 (libx264), yuv444p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc58.13.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[hls @ 0x7f8335818c00] Opening 'test.m3u8.tmp' for writingte=N/A speed=1.69x     
[hls @ 0x7f8335818c00] Opening 'test.m3u8.tmp' for writingte=N/A speed=2.13x    
[hls @ 0x7f8335818c00] Opening 'test.m3u8.tmp' for writingte=N/A speed=2.69x    
[hls @ 0x7f8335818c00] Opening 'test.m3u8.tmp' for writingte=N/A speed=2.76x    
frame=  375 fps= 75 q=-1.0 Lsize=N/A time=00:00:14.92 bitrate=N/A speed=2.99x    
video:715kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7f8335804200] frame I:4     Avg QP: 9.58  size:  9548
[libx264 @ 0x7f8335804200] frame P:211   Avg QP:16.21  size:  2499
[libx264 @ 0x7f8335804200] frame B:160   Avg QP:24.70  size:  1038
[libx264 @ 0x7f8335804200] consecutive B-frames: 25.1% 51.2%  8.8% 14.9%
[libx264 @ 0x7f8335804200] mb I  I16..4: 86.8%  0.0% 13.2%
[libx264 @ 0x7f8335804200] mb P  I16..4:  5.0%  0.0%  0.6%  P16..4:  8.2%  3.0%  0.9%  0.0%  0.0%    skip:82.2%
[libx264 @ 0x7f8335804200] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8: 13.9%  1.9%  0.1%  direct: 0.1%  skip:83.9%  L0:46.5% L1:50.5% BI: 3.0%
[libx264 @ 0x7f8335804200] coded y,u,v intra: 5.3% 2.4% 2.6% inter: 0.8% 0.2% 0.2%
[libx264 @ 0x7f8335804200] i16 v,h,dc,p: 88%  9%  3%  0%
[libx264 @ 0x7f8335804200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 11% 53%  3%  4%  4%  4%  3%  2%
[libx264 @ 0x7f8335804200] Weighted P-Frames: Y:8.1% UV:0.0%
[libx264 @ 0x7f8335804200] ref P L0: 75.6%  3.9% 15.0%  5.4%  0.1%
[libx264 @ 0x7f8335804200] ref B L0: 86.0% 13.6%  0.4%
[libx264 @ 0x7f8335804200] ref B L1: 99.9%  0.1%
[libx264 @ 0x7f8335804200] kb/s:390.14
#EXTM3U
#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:4.000000,
#EXT-X-BYTERANGE:293092@0
test.ts
#EXTINF:4.000000,
#EXT-X-BYTERANGE:67680@293092
test.ts
#EXTINF:4.000000,
#EXT-X-BYTERANGE:168824@360772
test.ts
#EXTINF:3.000000,
#EXT-X-BYTERANGE:266960@529596
test.ts
#EXT-X-ENDLIST

This is what I want to achieve:

ffmpeg -i M7HGQ8gA7Sf09Z.qt -c:v libx264 -g:v 100 -filter_complex:v "[0:v]fps=fps=25,split=2[f1][f2];[f2]alphaextract[a1]" -map f1 -map a1 -f hls -hls_time 4 -hls_flags single_file test.m3u8 -y && cat test.m3u8

Change History (9)

comment:1 by ronag, 6 years ago

Notice the difference in EXT-X-TARGETDURATION and EXTINF between the runs depending on whether we have 1 or 2 video streams.

Last edited 6 years ago by ronag (previous) (diff)

comment:2 by ronag, 6 years ago

Component: undeterminedavformat
Version: unspecifiedgit-master

comment:3 by Carl Eugen Hoyos, 6 years ago

Keywords: hls added

comment:4 by Steven Liu, 6 years ago

Owner: set to Steven Liu
Status: newopen

comment:5 by Steven Liu, 6 years ago

comment:6 by ronag, 6 years ago

Yep, that fixed it

comment:7 by Steven Liu, 6 years ago

Resolution: fixed
Status: openclosed

comment:8 by Steven Liu, 6 years ago

Resolution: fixed
Status: openclosed

comment:9 by Steven Liu, 6 years ago

Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.