Opened 4 months ago

Closed 4 months ago

#6915 closed defect (worksforme)

DASH audio segments duration doesn't match exactly with video segments duration.

Reported by: beloko Owned by: stevenliu
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

I tried to produce an HLS fMP4 stream through DASH segmenter. Using its new parameter -hls_playlist 1. Also I set segments duration to 4 seconds. Using the -force_key_frames "expr:gte(t,n_forced*4)" parameter and the -min_seg_duration 4000000 parameter.

Here is my command line processed :

ffmpeg.exe -i "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" -loglevel verbose -threads 0 -c:a libfdk_aac -sn -c:v libx264 -x264opts scenecut=-1 -force_key_frames "expr:gte(t,n_forced*4)" -r 25 -min_seg_duration 4000000 -window_size 99999 -t 30 -hls_playlist 1 "C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd"
ffmpeg version N-89478-g2e391a5-Reino Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.1.0 (GCC)
  configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/beloko/FFMpeg_Builder/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-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-x86_64/x86_64-w64-mingw32 --enable-nonfree --enable-decklink --enable-libfdk-aac
  libavutil      56.  5.100 / 56.  5.100
  libavcodec     58.  6.103 / 58.  6.103
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  7.100 /  7.  7.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 @ 0000025fc6d6fe60] 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) -> aac (libfdk_aac))
Press [q] to stop, [?] for help
[h264 @ 0000025fc6d5a800] Reinit context to 1920x1088, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 0000025fc77caf00] w:1920 h:1080 pixfmt:yuv420p tb:1/30000 fr:30/1 sar:1/1 sws_param:flags=2
[libx264 @ 0000025fc77d7ea0] using SAR=1/1
[libx264 @ 0000025fc77d7ea0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0000025fc77d7ea0] profile High, level 4.0
[libx264 @ 0000025fc77d7ea0] 264 - core 148 r2795M aaa9aa8 - 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=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=-2 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=250 keyint_min=25 scenecut=0 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
*** 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 @ 0000025fc77d7d40] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x60f
[format_out_0_1 @ 0000025fcb10ee40] auto-inserting filter 'auto_resampler_0' between the filter 'Parsed_anull_0' and the filter 'format_out_0_1'
[auto_resampler_0 @ 0000025fc77d5ba0] ch:6 chl:5.1(side) fmt:fltp r:48000Hz -> ch:6 chl:5.1 fmt:s16 r:48000Hz
[dash @ 0000025fc744d8c0] No bit rate set for stream 0
[dash @ 0000025fc744d8c0] Opening 'init-stream0.m4s' for writing
[mp4 @ 0000025fdd592300] Empty MOOV enabled; disabling automatic bitstream filtering
[dash @ 0000025fc744d8c0] Representation 0 init segment will be written to: init-stream0.m4s
[dash @ 0000025fc744d8c0] Opening 'init-stream1.m4s' for writing
[mp4 @ 0000025fdd5d4b80] Empty MOOV enabled; disabling automatic bitstream filtering
[dash @ 0000025fc744d8c0] Representation 1 init segment will be written to: init-stream1.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
Bandwidth info not available, set audio and video bitrates
[dash @ 0000025fc744d8c0] Manifest written to: C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd
Output #0, dash, to 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd':
  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.3.100
    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, 12800 tbn, 25 tbc (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:39.000000Z
      handler_name    : GPAC ISO Video Handler
      encoder         : Lavc58.6.103 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (libfdk_aac), 48000 Hz, 5.1, s16, delay 2048, 488 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.6.103 libfdk_aac
    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 6100:02.38 bitrate=N/A dup=2 drop=10 speed=4.76x
*** dropping frame 68 from stream 0 at ts 66
*** dropping frame 73 from stream 0 at ts 71
*** 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:04.77 bitrate=N/A dup=2 drop=21 speed=4.75x
*** 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
*** dropping frame 138 from stream 0 at ts 136
*** 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
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00001.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 2 written to: chunk-stream0-00001.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00001.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 2 written to: chunk-stream1-00001.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
*** dropping frame 158 from stream 0 at ts 156:06.22 bitrate=N/A dup=2 drop=29 speed=4.07x
*** 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
*** dropping frame 178 from stream 0 at ts 176:06.69 bitrate=N/A dup=2 drop=33 speed= 3.3x
*** 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
*** dropping frame 198 from stream 0 at ts 196
*** dropping frame 203 from stream 0 at ts 201:07.65 bitrate=N/A dup=2 drop=38 speed=2.98x
*** dropping frame 208 from stream 0 at ts 206
*** dropping frame 213 from stream 0 at ts 211:08.14 bitrate=N/A dup=2 drop=40 speed=2.65x
*** dropping frame 218 from stream 0 at ts 216
*** dropping frame 223 from stream 0 at ts 221:08.61 bitrate=N/A dup=2 drop=42 speed=2.39x
*** dropping frame 228 from stream 0 at ts 226
*** dropping frame 233 from stream 0 at ts 231
*** dropping frame 238 from stream 0 at ts 236:09.17 bitrate=N/A dup=2 drop=45 speed=2.23x
*** dropping frame 243 from stream 0 at ts 241
*** dropping frame 248 from stream 0 at ts 246
*** dropping frame 253 from stream 0 at ts 251:09.62 bitrate=N/A dup=2 drop=48 speed=2.09x
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00002.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 3 written to: chunk-stream0-00002.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00002.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 3 written to: chunk-stream1-00002.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
*** dropping frame 258 from stream 0 at ts 256
*** dropping frame 263 from stream 0 at ts 261
*** dropping frame 268 from stream 0 at ts 266:10.53 bitrate=N/A dup=2 drop=51 speed=2.03x
*** dropping frame 273 from stream 0 at ts 271
*** dropping frame 278 from stream 0 at ts 276
*** dropping frame 283 from stream 0 at ts 281:11.02 bitrate=N/A dup=2 drop=54 speed=1.92x
*** dropping frame 288 from stream 0 at ts 286
*** dropping frame 293 from stream 0 at ts 291
*** dropping frame 298 from stream 0 at ts 296:11.49 bitrate=N/A dup=2 drop=57 speed=1.84x
*** dropping frame 303 from stream 0 at ts 301
*** dropping frame 308 from stream 0 at ts 306
*** dropping frame 313 from stream 0 at ts 311:12.45 bitrate=N/A dup=2 drop=60 speed=1.83x
*** dropping frame 318 from stream 0 at ts 316
*** dropping frame 323 from stream 0 at ts 321
*** dropping frame 328 from stream 0 at ts 326:12.94 bitrate=N/A dup=2 drop=63 speed=1.75x
*** dropping frame 333 from stream 0 at ts 331
*** dropping frame 338 from stream 0 at ts 336
*** dropping frame 343 from stream 0 at ts 341
*** dropping frame 348 from stream 0 at ts 346:13.41 bitrate=N/A dup=2 drop=67 speed= 1.7x
*** dropping frame 353 from stream 0 at ts 351
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00003.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 4 written to: chunk-stream0-00003.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00003.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 4 written to: chunk-stream1-00003.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
*** dropping frame 358 from stream 0 at ts 356:14.10 bitrate=N/A dup=2 drop=69 speed=1.68x
*** dropping frame 363 from stream 0 at ts 361
*** dropping frame 368 from stream 0 at ts 366
*** dropping frame 373 from stream 0 at ts 371
*** dropping frame 378 from stream 0 at ts 376:14.86 bitrate=N/A dup=2 drop=73 speed=1.67x
*** dropping frame 383 from stream 0 at ts 381
*** dropping frame 388 from stream 0 at ts 386
*** dropping frame 393 from stream 0 at ts 391:15.33 bitrate=N/A dup=2 drop=76 speed=1.63x
*** dropping frame 398 from stream 0 at ts 396
*** dropping frame 403 from stream 0 at ts 401:15.82 bitrate=N/A dup=2 drop=78 speed=1.59x
*** dropping frame 408 from stream 0 at ts 406
*** dropping frame 413 from stream 0 at ts 411
*** dropping frame 418 from stream 0 at ts 416
*** dropping frame 423 from stream 0 at ts 421:16.78 bitrate=N/A dup=2 drop=82 speed= 1.6x
*** dropping frame 428 from stream 0 at ts 426
*** dropping frame 433 from stream 0 at ts 431
*** dropping frame 438 from stream 0 at ts 436
*** dropping frame 443 from stream 0 at ts 441
*** dropping frame 448 from stream 0 at ts 446:17.74 bitrate=N/A dup=2 drop=87 speed=1.62x
*** dropping frame 453 from stream 0 at ts 451
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00004.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 5 written to: chunk-stream0-00004.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00004.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 5 written to: chunk-stream1-00004.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
*** dropping frame 458 from stream 0 at ts 456
*** dropping frame 463 from stream 0 at ts 461
*** dropping frame 468 from stream 0 at ts 466:18.70 bitrate=N/A dup=2 drop=91 speed=1.61x
*** dropping frame 473 from stream 0 at ts 471
*** dropping frame 478 from stream 0 at ts 476
*** dropping frame 483 from stream 0 at ts 481
*** dropping frame 488 from stream 0 at ts 486
*** dropping frame 493 from stream 0 at ts 491:19.22 bitrate=N/A dup=2 drop=96 speed=1.58x
*** dropping frame 498 from stream 0 at ts 496
*** dropping frame 503 from stream 0 at ts 501:20.13 bitrate=N/A dup=2 drop=98 speed=1.58x
*** dropping frame 508 from stream 0 at ts 506
*** dropping frame 513 from stream 0 at ts 511
*** dropping frame 518 from stream 0 at ts 516
*** dropping frame 523 from stream 0 at ts 521
*** dropping frame 528 from stream 0 at ts 526:21.09 bitrate=N/A dup=2 drop=103 speed=1.58x
*** dropping frame 533 from stream 0 at ts 531
*** dropping frame 538 from stream 0 at ts 536
*** dropping frame 543 from stream 0 at ts 541
*** dropping frame 548 from stream 0 at ts 546
*** dropping frame 553 from stream 0 at ts 551:22.05 bitrate=N/A dup=2 drop=108 speed=1.58x
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00005.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 6 written to: chunk-stream0-00005.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00005.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 6 written to: chunk-stream1-00005.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
*** dropping frame 558 from stream 0 at ts 556
*** dropping frame 563 from stream 0 at ts 561
*** dropping frame 568 from stream 0 at ts 566
*** dropping frame 573 from stream 0 at ts 571
*** dropping frame 578 from stream 0 at ts 576:23.01 bitrate=N/A dup=2 drop=113 speed=1.59x
*** dropping frame 583 from stream 0 at ts 581
*** dropping frame 588 from stream 0 at ts 586
*** dropping frame 593 from stream 0 at ts 591
*** dropping frame 598 from stream 0 at ts 596
*** dropping frame 603 from stream 0 at ts 601
*** dropping frame 608 from stream 0 at ts 606
*** dropping frame 613 from stream 0 at ts 611:24.02 bitrate=N/A dup=2 drop=120 speed= 1.6x
*** dropping frame 618 from stream 0 at ts 616
*** dropping frame 623 from stream 0 at ts 621
*** dropping frame 628 from stream 0 at ts 626
*** dropping frame 633 from stream 0 at ts 631
*** dropping frame 638 from stream 0 at ts 636:25.42 bitrate=N/A dup=2 drop=125 speed=1.64x
*** dropping frame 643 from stream 0 at ts 641
*** dropping frame 648 from stream 0 at ts 646
*** dropping frame 653 from stream 0 at ts 651
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00006.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 7 written to: chunk-stream0-00006.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00006.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 7 written to: chunk-stream1-00006.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
*** dropping frame 658 from stream 0 at ts 656
*** dropping frame 663 from stream 0 at ts 661
*** dropping frame 668 from stream 0 at ts 666
*** dropping frame 673 from stream 0 at ts 671:26.47 bitrate=N/A dup=2 drop=132 speed=1.66x
*** dropping frame 678 from stream 0 at ts 676
*** dropping frame 683 from stream 0 at ts 681
*** dropping frame 688 from stream 0 at ts 686:27.34 bitrate=N/A dup=2 drop=135 speed=1.65x
*** dropping frame 693 from stream 0 at ts 691
*** dropping frame 698 from stream 0 at ts 696
*** dropping frame 703 from stream 0 at ts 701
*** dropping frame 708 from stream 0 at ts 706:27.94 bitrate=N/A dup=2 drop=139 speed=1.64x
*** dropping frame 713 from stream 0 at ts 711
*** dropping frame 718 from stream 0 at ts 716
*** dropping frame 723 from stream 0 at ts 721
*** dropping frame 728 from stream 0 at ts 726:28.77 bitrate=N/A dup=2 drop=143 speed=1.64x
*** dropping frame 733 from stream 0 at ts 731
*** dropping frame 738 from stream 0 at ts 736
*** dropping frame 743 from stream 0 at ts 741
*** dropping frame 748 from stream 0 at ts 746:29.73 bitrate=N/A dup=2 drop=147 speed=1.64x
No more output streams to write to, finishing.
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00007.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 8 written to: chunk-stream0-00007.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00007.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 8 written to: chunk-stream1-00007.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
[dash @ 0000025fc744d8c0] Opening 'chunk-stream0-00008.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 0 media segment 9 written to: chunk-stream0-00008.m4s
[dash @ 0000025fc744d8c0] Opening 'chunk-stream1-00008.m4s.tmp' for writing
[dash @ 0000025fc744d8c0] Representation 1 media segment 9 written to: chunk-stream1-00008.m4s
[dash @ 0000025fc744d8c0] Opening 'C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
frame=  750 fps= 39 q=-1.0 Lsize=N/A time=00:00:30.01 bitrate=N/A dup=2 drop=148 speed=1.54x
video:12174kB audio:1793kB 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): 909 packets read (11571340 bytes); 900 frames decoded;
  Input stream #0:1 (audio): 21 packets read (10080 bytes);
  Input stream #0:2 (audio): 939 packets read (1201920 bytes); 939 frames decoded (1442304 samples);
  Total: 1869 packets (12783340 bytes) demuxed
Output file #0 (C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd):
  Output stream #0:0 (video): 750 frames encoded; 750 packets muxed (12466439 bytes);
  Output stream #0:1 (audio): 1407 frames encoded (1440000 samples); 1409 packets muxed (1836311 bytes);
  Total: 2159 packets (14302750 bytes) muxed
[libx264 @ 0000025fc77d7ea0] frame I:8     Avg QP:14.94  size:240506
[libx264 @ 0000025fc77d7ea0] frame P:222   Avg QP:19.99  size: 37867
[libx264 @ 0000025fc77d7ea0] frame B:520   Avg QP:24.33  size:  4106
[libx264 @ 0000025fc77d7ea0] consecutive B-frames:  3.6%  8.5% 10.0% 77.9%
[libx264 @ 0000025fc77d7ea0] mb I  I16..4: 33.7% 45.8% 20.5%
[libx264 @ 0000025fc77d7ea0] mb P  I16..4:  3.1%  7.9%  0.9%  P16..4: 23.0%  8.3%  6.6%  0.0%  0.0%    skip:50.2%
[libx264 @ 0000025fc77d7ea0] mb B  I16..4:  0.5%  0.4%  0.0%  B16..8: 23.8%  1.4%  0.4%  direct: 1.4%  skip:72.1%  L0:45.5% L1:49.5% BI: 5.1%
[libx264 @ 0000025fc77d7ea0] 8x8 transform intra:59.2% inter:63.1%
[libx264 @ 0000025fc77d7ea0] coded y,uvDC,uvAC intra: 30.3% 42.8% 23.4% inter: 5.7% 7.4% 1.7%
[libx264 @ 0000025fc77d7ea0] i16 v,h,dc,p: 66% 19%  6%  9%
[libx264 @ 0000025fc77d7ea0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 14% 32%  3%  4%  4%  5%  4%  4%
[libx264 @ 0000025fc77d7ea0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 23% 15% 12%  7%  9%  9%  9%  8%  9%
[libx264 @ 0000025fc77d7ea0] i8c dc,h,v,p: 63% 19% 13%  6%
[libx264 @ 0000025fc77d7ea0] Weighted P-Frames: Y:8.6% UV:8.1%
[libx264 @ 0000025fc77d7ea0] ref P L0: 66.4% 12.6% 13.8%  7.2%  0.0%
[libx264 @ 0000025fc77d7ea0] ref B L0: 86.9% 10.8%  2.2%
[libx264 @ 0000025fc77d7ea0] ref B L1: 95.2%  4.8%
[libx264 @ 0000025fc77d7ea0] kb/s:3324.20

The DASH segmenter produce two separated streams.
First stream as video and second stream as audio.

Here is the HLS playlist content created for the video stream :

C:\Users\Beloko\Desktop\FFMPEG>type "C:\inetpub\wwwroot\fmp4_x264\media_0.m3u8"
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream0.m4s"
#EXTINF:4.000000,
chunk-stream0-00001.m4s
#EXTINF:4.000000,
chunk-stream0-00002.m4s
#EXTINF:4.000000,
chunk-stream0-00003.m4s
#EXTINF:4.000000,
chunk-stream0-00004.m4s
#EXTINF:4.000000,
chunk-stream0-00005.m4s
#EXTINF:4.000000,
chunk-stream0-00006.m4s
#EXTINF:4.000000,
chunk-stream0-00007.m4s
#EXTINF:2.000000,
chunk-stream0-00008.m4s
#EXT-X-ENDLIST

Segment duration is exactly 4 seconds for each .m4s files.
Verified with FFPROBE : its perfect.

But here is the HLS playlist content created for the audio stream :

C:\Users\Beloko\Desktop\FFMPEG>type "C:\inetpub\wwwroot\fmp4_x264\media_1.m3u8"
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:3.925333,
chunk-stream1-00001.m4s
#EXTINF:4.010667,
chunk-stream1-00002.m4s
#EXTINF:3.989333,
chunk-stream1-00003.m4s
#EXTINF:4.010667,
chunk-stream1-00004.m4s
#EXTINF:3.989333,
chunk-stream1-00005.m4s
#EXTINF:4.010667,
chunk-stream1-00006.m4s
#EXTINF:3.989333,
chunk-stream1-00007.m4s
#EXTINF:2.074667,
chunk-stream1-00008.m4s
#EXT-X-ENDLIST

Segments durations are around 4 seconds but not exactly 4 seconds.
Verified with FFPROBE : .m4s audio segments durations are longer or shorter than the expected 4 seconds.

To be compliant with the Apple mediastreamvalidator tool, video segments and audio segments should have the same duration. And the #EXT-X-TARGETDURATION tag should have the value 4 instead of 5.

Attachments (2)

master.m3u8 (292 bytes) - added by beloko 4 months ago.
HLS master playlist to mux video and audio tracks
apple.png (183.5 KB) - added by stevenliu 4 months ago.
HLS response

Download all attachments as: .zip

Change History (63)

comment:1 Changed 4 months ago by stevenliu

I'm not sure if the audio can 4.000000 indent, but about the EXT-X-TARGETDURATION, you should read and check the specification document.
https://www.rfc-editor.org/rfc/rfc8216.txt

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

comment:2 follow-up: Changed 4 months ago by beloko

I know the specification about the #EXT-X-TARGETDURATION since its first draft.

In this audio stream playlist some .m4s segments have a duration of 4.010667 seconds. So to be compliant with the specification #EXT-X-TARGETDURATION is rounded to the upper value 5. It's correct.

The issue is about playback and synchronisation for smooth streaming. With multiple video bitrate streams and audio tracks at adaptive bitrate, the video player switch automatically to different quality according to the bandwidth. When a video or an audio track isn't cut exactly at the same duration, sometimes spectator can detect a video freeze, a strange click noise in the audio rendering. Or the voice is a bit desynchronized with the mouth that's speaking.

The Apple mediastreamvalidator tool check the #EXT-X-TARGETDURATION is the same for all embed streams/tracks specified as a #EXT-X-STREAM-INF:. And returns this kind of error message if the longest segment duration is different between streams/tracks.

Error: Different target durations detected
--> Detail:  Target duration: 4 vs Target duration: 5
--> Source:  hdready/tears_of_steel_4k_2112_720p.m3u8
--> Compare: veryhigh/tears_of_steel_4k_1056_480p.m3u8

So to be square with the required specification all segment duration should be 4 seconds long exactly.

comment:3 in reply to: ↑ 2 Changed 4 months ago by stevenliu

Replying to beloko:

I know the specification about the #EXT-X-TARGETDURATION since its first draft.

In this audio stream playlist some .m4s segments have a duration of 4.010667 seconds. So to be compliant with the specification #EXT-X-TARGETDURATION is rounded to the upper value 5. It's correct.

The issue is about playback and synchronisation for smooth streaming. With multiple video bitrate streams and audio tracks at adaptive bitrate, the video player switch automatically to different quality according to the bandwidth. When a video or an audio track isn't cut exactly at the same duration, sometimes spectator can detect a video freeze, a strange click noise in the audio rendering. Or the voice is a bit desynchronized with the mouth that's speaking.

The Apple mediastreamvalidator tool check the #EXT-X-TARGETDURATION is the same for all embed streams/tracks specified as a #EXT-X-STREAM-INF:. And returns this kind of error message if the longest segment duration is different between streams/tracks.

Error: Different target durations detected
--> Detail:  Target duration: 4 vs Target duration: 5
--> Source:  hdready/tears_of_steel_4k_2112_720p.m3u8
--> Compare: veryhigh/tears_of_steel_4k_1056_480p.m3u8

So to be square with the required specification all segment duration should be 4 seconds long exactly.

No, That should be modify by one of the two space, specification, or mediastreamvalidator :D

whatever, maybe it cannot cut at 4s is a bug.

comment:4 Changed 4 months ago by beloko

Yes I'm agree with you that would be easier ;)

The mediastreamvalidator tool complements the RFC8216 to validate the HLS streams. However I already got some bugged result with the mediastreamvalidator tool. For example sometimes it detect a wrong pixel resolution.

Also the Apple developer website gives some additionals recommandations to broadcast properly any HLS streams. Not described in the Roger Pantos's RFC8216.


Because I was tired last night, I lately made a new HLS stream as sample today. My video source is the Tears of Steel 4K version.

Here is the FFMPEG command line :

ffmpeg.exe -i http://ftp.nluug.nl/pub/graphics/blender/demo/movies/ToS/tearsofsteel_4k.mov -loglevel verbose -threads 0 -c:a aac -sn -c:v libx264 -x264opts scenecut=-1 -force_key_frames "expr:gte(t,n_forced*4)" -r 25 -min_seg_duration 4000000 -window_size 99999 -t 60 -hls_playlist 1 "C:\inetpub\wwwroot\fmp4_x264\TOS.mpd"

DASH segmenter created two separated streams for video and audio tracks.
The video playlist is named : media_0.m3u8
And the audio playlist is named : media_1.m3u8

So to mux video and audio tracks I manually created a master.m3u8 file.

Here is the right content to use :

#EXTM3U
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-VERSION:6

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="media_1",NAME="media_1",LANGUAGE="en",URI="media_1.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=23106870,AVERAGE-BANDWIDTH=12649180,CODECS="avc1.640033,mp4a.40.2",RESOLUTION=3840x1714,AUDIO="media_1"
media_0.m3u8

Windows Edge browser or Safari browser give a good playback. Video and audio streams looks properly synchronised. No problem with seeking the duration bar.

But the mediastreamvalidator tool returns some errors to fix.

Here is the full report :

Belokos-Mac:~ beloko$ mediastreamvalidator http://192.168.1.3/fmp4_x264/master.m3u8
mediastreamvalidator: Version 1.2(170822)

[/fmp4_x264/master.m3u8] Started root playlist download
[media_0.m3u8] Started media playlist download
[media_1.m3u8] Started media playlist download
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
[media_1.m3u8] All media files delivered and have end tag, stopping
[media_0.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_0.m3u8
--------------------------------------------------------------------------------
Processed 15 out of 15 segments
Average segment duration: 4.000000
Total segment bitrates (all discontinuities): average: 12517.68 kb/s, max: 22974.29 kb/s
Playlist max bitrate: 23106.870000 kb/s
Audio Group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 15 of 15, duration: 60.000 sec, average: 12517.68 kb/s, max: 22974.29 kb/s
Track ID: 1
Video Codec: avc1
Video profile: High
Video level: 5.1
Video resolution: 3840x1714
Video average IDR interval: 4.000000, Standard deviation: 0.000000
Video frame rate: 25.000

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 15 out of 15 segments
Average segment duration: 4.000000
Total segment bitrates (all discontinuities): average: 131.50 kb/s, max: 132.58 kb/s
Rendition group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 15 of 15, duration: 60.000 sec, average: 131.50 kb/s, max: 132.58 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 44100 Hz
Audio channels: 2
Audio channel layout: Stereo (L R)

--------------------------------------------------------------------------------
MUST fix issues
--------------------------------------------------------------------------------

Error: Zero sample count
--> Detail:  Track ID 295
--> Source:  media_1.m3u8 - chunk-stream1-00015.m4s

Error: Different target durations detected
--> Detail:  Target duration: 5 vs Target duration: 4
--> Source:  media_1.m3u8
--> Compare: media_0.m3u8

I don't know what's the "zero sample count" error means for now in segment fifteen and what the "Track ID 295" is really.

But you can see the message about "different target durations detected" between media_0.m3u8 and media_1.m3u8. However the mediastreamvalidator tool detect an "Average segment duration: 4.000000" for the audio playlist media_1.m3u8.

This issue doesn't block to playback an HLS video stream. But I know Apple can refuse your apps to be published in its store because it contains invalid HLS streams. It happened to a person I know. His iPhone app was rejected because some HLS streams had a wrong bandwith peak (exceding 10%) setted in its master.m3u8 file.

Don't know if the Apple segmenter can cut audio streams at the exactly specified duration. Perhaps Apple segmenter can't do better.

Last edited 4 months ago by beloko (previous) (diff)

Changed 4 months ago by beloko

HLS master playlist to mux video and audio tracks

comment:5 Changed 4 months ago by beloko

Added my master.m3u8 file as attachment for anyone needing it. Because FFMPEG's DASH segmenter doesn't create this file properly yet.

comment:6 Changed 4 months ago by beloko

I encoded Tears of Steel as a full movie now. Its total duration is near 12 minutes and exactly 184 segments. This video lets detect more easily when video and audio tracks are desynchronized than Big Buck Bunny.

So I can play the full movie produced with FFMPEG and use the seek bar duration without desynchronization into Windows Edge and Safari web browsers.

After manually replacing the #EXT-X-TARGETDURATION 5 value by the 4 value in the audio playlist media_1.m3u8, the video always playback properly in web browsers.

And it fixes issue with the mediastreamvalidator tools.

Here is the full report :

Belokos-Mac:~ beloko$ mediastreamvalidator http://192.168.1.3/fmp4_x264/master.m3u8
mediastreamvalidator: Version 1.2(170822)

[/fmp4_x264/master.m3u8] Started root playlist download
[media_0.m3u8] Started media playlist download
[media_1.m3u8] Started media playlist download
[media_1.m3u8] parsed media segment count: 75, duration: 303.926
[media_1.m3u8] parsed media segment count: 150, duration: 603.928
[media_1.m3u8] All media files delivered and have end tag, stopping
[media_0.m3u8] parsed media segment count: 74, duration: 300.000
[media_0.m3u8] parsed media segment count: 149, duration: 600.000
[media_0.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_0.m3u8
--------------------------------------------------------------------------------
Processed 184 out of 184 segments
Average segment duration: 3.989130
Total segment bitrates (all discontinuities): average: 16353.10 kb/s, max: 46174.48 kb/s
Playlist max bitrate: 46312.470000 kb/s
Audio Group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 184 of 184, duration: 734.000 sec, average: 16353.10 kb/s, max: 46174.48 kb/s
Track ID: 1
Video Codec: avc1
Video profile: High
Video level: 5.1
Video resolution: 3840x1714
Video average IDR interval: 4.000000, Standard deviation: 0.000000
Video frame rate: 25.000

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 184 out of 184 segments
Average segment duration: 3.988784
Total segment bitrates (all discontinuities): average: 131.87 kb/s, max: 137.99 kb/s
Rendition group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 184 of 184, duration: 733.936 sec, average: 131.87 kb/s, max: 137.99 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 44100 Hz
Audio channels: 2
Audio channel layout: Stereo (L R)

Mediastreamvalidator doesn't complain anymore. But it doesn't respect the Roger Pantos RFC8216.


Then I decided to round all #EXTINF: values at 4 seconds as expected in the audio playlist media_1.m3u8. To get the same duration for all segments. And to accord their duration with all segments from he video playlist media_0.m3u8.

Video and audio playback synchronization is properly rendering into Safari and Windows Edge web browsers.

And the mediastreamvalidator doesn't complain. It find the same average segment duration of 3.989130 for video and audio playlist. That's perfect.

Here is the full report :

Belokos-Mac:~ beloko$ mediastreamvalidator http://192.168.1.3/fmp4_x264/master.m3u8
mediastreamvalidator: Version 1.2(170822)

[/fmp4_x264/master.m3u8] Started root playlist download
[media_0.m3u8] Started media playlist download
[media_1.m3u8] Started media playlist download
[media_1.m3u8] parsed media segment count: 74, duration: 300.000
[media_1.m3u8] parsed media segment count: 149, duration: 600.000
[media_1.m3u8] All media files delivered and have end tag, stopping
[media_0.m3u8] parsed media segment count: 74, duration: 300.000
[media_0.m3u8] parsed media segment count: 149, duration: 600.000
[media_0.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_0.m3u8
--------------------------------------------------------------------------------
Processed 184 out of 184 segments
Average segment duration: 3.989130
Total segment bitrates (all discontinuities): average: 16353.10 kb/s, max: 46174.48 kb/s
Playlist max bitrate: 46312.470000 kb/s
Audio Group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 184 of 184, duration: 734.000 sec, average: 16353.10 kb/s, max: 46174.48 kb/s
Track ID: 1
Video Codec: avc1
Video profile: High
Video level: 5.1
Video resolution: 3840x1714
Video average IDR interval: 4.000000, Standard deviation: 0.000000
Video frame rate: 25.000

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 184 out of 184 segments
Average segment duration: 3.989130
Total segment bitrates (all discontinuities): average: 131.86 kb/s, max: 137.78 kb/s
Rendition group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 184 of 184, duration: 734.000 sec, average: 131.86 kb/s, max: 137.78 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 44100 Hz
Audio channels: 2
Audio channel layout: Stereo (L R)


This tests mean, just fix the audio playlist is enough to be compliant with the Apple mediastreamvalidator tool and support the RFC8216. No need to cut the audio stream at exactly 4 seconds like we were supposing.

Last edited 4 months ago by beloko (previous) (diff)

comment:7 follow-up: Changed 4 months ago by j_karthic

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

comment:8 in reply to: ↑ 7 ; follow-up: Changed 4 months ago by stevenliu

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

comment:9 in reply to: ↑ 8 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

comment:10 in reply to: ↑ 9 ; follow-up: Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

comment:11 in reply to: ↑ 10 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

comment:12 in reply to: ↑ 11 ; follow-up: Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

comment:13 in reply to: ↑ 12 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

comment:14 in reply to: ↑ 13 ; follow-up: Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

comment:15 in reply to: ↑ 14 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

comment:16 in reply to: ↑ 15 ; follow-up: Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

comment:17 in reply to: ↑ 16 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

comment:18 in reply to: ↑ 17 ; follow-ups: Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

what will happen when just round the target duration ?i think the EXTINF will large than target duration

comment:19 in reply to: ↑ 18 ; follow-up: Changed 4 months ago by stevenliu

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

what will happen when just round the target duration ?i think the EXTINF will large than target duration

round up it is no problem, but round down will have different result for users understand,This is why implement an api to process it for round up.

comment:20 in reply to: ↑ 18 Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

what will happen when just round the target duration ?i think the EXTINF will large than target duration

Yes, that is correct. But as long it doesn't violate the spec, we should be fine with that. We will have to just follow the spec.

comment:21 in reply to: ↑ 19 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

what will happen when just round the target duration ?i think the EXTINF will large than target duration

round up it is no problem, but round down will have different result for users understand,This is why implement an api to process it for round up.

Well as long as it follows the spec, we need not worry. If the players were implemented as per the HLS spec then they should handle this case correctly.

comment:22 in reply to: ↑ 21 ; follow-up: Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

what will happen when just round the target duration ?i think the EXTINF will large than target duration

round up it is no problem, but round down will have different result for users understand,This is why implement an api to process it for round up.

Well as long as it follows the spec, we need not worry. If the players were implemented as per the HLS spec then they should handle this case correctly.

I will try to fix this problem

comment:23 Changed 4 months ago by stevenliu

  • Owner set to stevenliu
  • Status changed from new to open

comment:24 in reply to: ↑ 22 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

what will happen when just round the target duration ?i think the EXTINF will large than target duration

round up it is no problem, but round down will have different result for users understand,This is why implement an api to process it for round up.

Well as long as it follows the spec, we need not worry. If the players were implemented as per the HLS spec then they should handle this case correctly.

I will try to fix this problem

Oh! I am glad that we are on the same page. Thanks for your understanding.
Regarding the fix, I think fixing the target duration is good enough. For that I have already sent a patch. http://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/222745.html
It is theoretically not possible to get audio duration to exactly 4.00000 seconds. Because an AAC frame size is 1024 which is not a divisor of 4*48000 or 4*44100. So the audio segment can't be cut at exact 4.00000 seconds. Even the HLS spec is fine with that. In section 6.2.4. Providing Variant Streams, it mentions that the target duration of all variants to be same. No explicit mention for the EXTINF duration indirectly means that those durations need not be exactly same(as it is not possible theoretically).

      Each Media Playlist in each Variant Stream MUST have the same
      target duration.  The only exceptions are SUBTITLES Renditions and
      Media Playlists containing an EXT-X-I-FRAMES-ONLY tag, which MAY
      have different target durations if they have an EXT-X-PLAYLIST-
      TYPE of VOD.

comment:25 follow-up: Changed 4 months ago by beloko

My notes were for knowledge purposes about HLS playback with common and official video players. And used by Apple itself.

For sure the #EXT-X-TARGETDURATION cannot be rounded or forced to a lower value just to satisfy and dupe the Apple mediastreamvalidator tool result. But the #EXTINF value could be rounded to the nearest integer value when the duration doesn't exceed few small milliseconds.

#EXTINF:4.010667 could be rounded to #EXTINF:4.000000.
Or #EXTINF:3.989333 could be rounded to #EXTINF:4.000000.

Then the #EXT-X-TARGETDURATION can be set to 4 because the #EXTINF duration will never exceed 4.000000.

The difference in milliseconds between the real segment duration and the #EXTINF value setted in the audio playlist doesn't seems to affect HLS playback. Probably because the shortest duration of the preceding segment is compensated by the following segment. Which has a duration longer than 4 seconds. And so on until the #EXT-X-ENDLIST.

Should be interesting to see what's the Apple segmenter can produce for HLS audio streams. Perhaps it fakes the real #EXTINF segment duration value in the M3U8 playlist. Because I'm not sure it's possible to force the gop size or inject a keyframe to an audio stream.

Rounding the #EXTINF value to the nearest integer value could be a additional parameter in the command line.

Ex: -hls_max_segment_duration <int> E.......... round segments duration in HLS playlist if they not exceed few milliseconds

Then the -hls_max_segment_duration 2 parameter should be able to fix :

#EXTINF:4.010667 into #EXTINF:4.000000.
Because 0.010667 seconds is lower than 2 milliseconds

And #EXTINF:3.989333 into #EXTINF:4.000000
Because 4.000000 - 3.989333 = 0.010667 is lower than 2 milliseconds.

comment:26 in reply to: ↑ 24 Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

Replying to j_karthic:

Well, if we round the target duration to nearest integer as per the spec, part of the problem is resolved. Right now we are ceiling to the upper integer which is not according to HLS specifications.

4.3.3.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
   duration.  The EXTINF duration of each Media Segment in the Playlist
   file, when rounded to the nearest integer, MUST be less than or equal
   to the target duration; longer segments can trigger playback stalls
   or other errors.  It applies to the entire Playlist file.  Its format
   is:

   #EXT-X-TARGETDURATION:<s>

   where s is a decimal-integer indicating the target duration in
   seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.

So as per the spec, the EXT-X-TARGETDURATION should rounded to 4 instead of 5.

But when I submitted a patch for fixing such an issue in hlsenc, it was rejected by Steven. See thread http://ffmpeg.org/pipermail/ffmpeg-devel/2017-September/215630.html more details. During that time, I was not able to provide a concrete example with mediastreamvalidator like @beloko has done now. But I thought the spec was very clear about it without any room for confusion.

@stevenliu
If you have a change of mind after seeing these results, please let me know. Maybe I will send a new patch which fixes the target duration in dashenc, and we can take forward our discussions there.

The spec said "EXT-X-TARGETDURATION must > EXTINF", we have talk and you have sent twice patch about it. you can see the spec said "MUST be less than or equal to the target duration.", attention the MUST, MUST, MUST, we should don't care the tool, we should care the spec. If the tool different with the spec, that maybe apple's mistake, you should push apple.

I think you missing the important line "when rounded to the nearest integer" in the spec. I am also only talking about the spec. This is just a pure argument, about interpreting that English line. This is where I feel some other people in the ffmpeg community should also pitch in moderate a discussion, rather than leaving it as "Maintainer is always right".

Maintainer not always right, but can you give me the mean MUST be less than or equal to the target duration how should i understand it?

"when rounded to the nearest integer, MUST be less than or equal to the target duration" is in one sentence. That should be read in conjunction with the phrase "when rounded to the nearest integer". It means after rounding duration to the nearest integer, it MUST be less than or equal to the target duration.

how should i understand the target duration?
do you mean, when the EXTINF is 1.080000, the EXT-X-TARGETDURATION should equal to 1 ?

As per the spec, Yes.

I coding for hls from VERSION 1, from old VERSION, https://tools.ietf.org/html/draft-pantos-http-live-streaming-03
about the EXT-X-TARGETDURATION said:

3.2.1.  EXT-X-TARGETDURATION

   The EXT-X-TARGETDURATION tag specifies the maximum media file
   duration.  The EXTINF duration of each media file in the Playlist
   file MUST be less than or equal to the target duration.  This tag
   MUST appear once in the Playlist file.  Its format is:

   #EXT-X-TARGETDURATION:<s>

   where s is an integer indicating the target duration in seconds.

so, i always understand it to EXT-X-TARGETDURATION must large than EXTINF,
I have sent a Email to hls team of apple for check this description, maybe there have some misunderstanding words here.

In that version of HLS, floating point segment duration was not supported. The segment durations were already integers. Hence there is no question of rounding, when target duration was being defined.
But later when the floating point segment duration was supported in HLS, the definition for target duration was modified to specify "when rounded to nearest integer" to handle floating point segment durations.

Sorry for my poor English, but i think the when rounded to the nearest integer is description for The EXTINF duration of each Media Segment in the Playlist file,, because the they in one sentence, and the next sentence said longer segments can trigger playback stalls or other errors, so, the reason to make there have no longer segments can trigger playback stalls or other errors error, not use lrint.
When EXTINF is 1.080000, set the EXT-X-TARGETDURATION to 2.

Well, let me explain that entire sentence as a pseudo code.

The EXTINF duration of each Media Segment in the Playlist
file, when rounded to the nearest integer, MUST be less than or equal
to the target duration; longer segments can trigger playback stalls
or other errors.
for each media segment {
 if (round(EXTINF_duration) <= target_duration) { //when rounded to the nearest integer, MUST be less than or equal to the target duration
  Everything is fine here
 } else { // longer segments ...
  //Basically when (round(EXTINF_duration) > target_duration) 
  playback stalls or other errors can be triggered;
 }
}

longer segments can trigger playback stalls or other errors, is still part of the same sentence. This means longer after rounding to the nearest integer.

what will happen when just round the target duration ?i think the EXTINF will large than target duration

round up it is no problem, but round down will have different result for users understand,This is why implement an api to process it for round up.

Well as long as it follows the spec, we need not worry. If the players were implemented as per the HLS spec then they should handle this case correctly.

I will try to fix this problem

Oh! I am glad that we are on the same page. Thanks for your understanding.
Regarding the fix, I think fixing the target duration is good enough. For that I have already sent a patch. http://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/222745.html
It is theoretically not possible to get audio duration to exactly 4.00000 seconds. Because an AAC frame size is 1024 which is not a divisor of 4*48000 or 4*44100. So the audio segment can't be cut at exact 4.00000 seconds. Even the HLS spec is fine with that. In section 6.2.4. Providing Variant Streams, it mentions that the target duration of all variants to be same. No explicit mention for the EXTINF duration indirectly means that those durations need not be exactly same(as it is not possible theoretically).

      Each Media Playlist in each Variant Stream MUST have the same
      target duration.  The only exceptions are SUBTITLES Renditions and
      Media Playlists containing an EXT-X-I-FRAMES-ONLY tag, which MAY
      have different target durations if they have an EXT-X-PLAYLIST-
      TYPE of VOD.
MacBook:xxx StevenLiu$ ./ffmpeg -hide_banner -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 150 -r 100 -x264opts "scenecut=-1" -f dash -min_seg_duration 1000000 -window_size 99999 -t 5 -hls_playlist 1 output_Steven.mpd
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/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, 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) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f7fa5085200] using SAR=1/1
[libx264 @ 0x7f7fa5085200] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7f7fa5085200] profile High, level 5.1
[libx264 @ 0x7f7fa5085200] 264 - core 133 r2334M a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - 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=-2 threads=6 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=150 keyint_min=15 scenecut=0 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
[aac @ 0x7f7fa5086a00] Using a PCE to encode channel layout
[dash @ 0x7f7fa6087400] No bit rate set for stream 0
[dash @ 0x7f7fa6087400] Opening 'init-stream0.m4s' for writing
[dash @ 0x7f7fa6087400] Opening 'init-stream1.m4s' for writing
[dash @ 0x7f7fa6087400] Opening 'output_Steven.mpd.tmp' for writing
Bandwidth info not available, set audio and video bitrates
Output #0, dash, to 'output_Steven.mpd':
  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.3.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 100 fps, 12800 tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:39.000000Z
      handler_name    : GPAC ISO Video Handler
      encoder         : Lavc58.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC), 48000 Hz, 5.1(side), fltp, 394 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.8.100 aac
    Side data:
      audio service type: main
[dash @ 0x7f7fa6087400] Opening 'chunk-stream0-00001.m4s.tmp' for writingdrop=0 speed=0.532x
[dash @ 0x7f7fa6087400] Opening 'chunk-stream1-00001.m4s.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'chunk-stream0-00002.m4s.tmp' for writingdrop=0 speed=0.526x
[dash @ 0x7f7fa6087400] Opening 'chunk-stream1-00002.m4s.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'chunk-stream0-00003.m4s.tmp' for writingdrop=0 speed=0.455x
[dash @ 0x7f7fa6087400] Opening 'chunk-stream1-00003.m4s.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'chunk-stream0-00004.m4s.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'chunk-stream1-00004.m4s.tmp' for writing
[dash @ 0x7f7fa6087400] Opening 'output_Steven.mpd.tmp' for writing
frame=  500 fps= 41 q=-1.0 Lsize=N/A time=00:00:05.01 bitrate=N/A dup=354 drop=0 speed=0.41x
video:365kB audio:241kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7f7fa5085200] frame I:4     Avg QP:16.78  size: 20153
[libx264 @ 0x7f7fa5085200] frame P:150   Avg QP:20.52  size:  1625
[libx264 @ 0x7f7fa5085200] frame B:346   Avg QP:18.64  size:   141
[libx264 @ 0x7f7fa5085200] consecutive B-frames:  5.4%  5.2%  5.4% 84.0%
[libx264 @ 0x7f7fa5085200] mb I  I16..4: 92.8%  3.1%  4.1%
[libx264 @ 0x7f7fa5085200] mb P  I16..4:  6.0%  1.9%  0.1%  P16..4:  2.5%  0.2%  0.2%  0.0%  0.0%    skip:89.2%
[libx264 @ 0x7f7fa5085200] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  0.6%  0.0%  0.0%  direct: 0.2%  skip:99.0%  L0:33.2% L1:65.7% BI: 1.1%
[libx264 @ 0x7f7fa5085200] 8x8 transform intra:17.9% inter:71.0%
[libx264 @ 0x7f7fa5085200] coded y,uvDC,uvAC intra: 3.2% 11.7% 2.2% inter: 0.2% 0.7% 0.1%
[libx264 @ 0x7f7fa5085200] i16 v,h,dc,p: 83% 12%  3%  1%
[libx264 @ 0x7f7fa5085200] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 11% 62%  1%  2%  1%  2%  1%  1%
[libx264 @ 0x7f7fa5085200] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 22% 28%  4%  4%  4%  4%  3%  4%
[libx264 @ 0x7f7fa5085200] i8c dc,h,v,p: 77% 14%  9%  0%
[libx264 @ 0x7f7fa5085200] Weighted P-Frames: Y:22.7% UV:22.0%
[libx264 @ 0x7f7fa5085200] ref P L0: 83.9%  4.5%  9.7%  1.5%  0.4%
[libx264 @ 0x7f7fa5085200] ref B L0: 73.8% 24.9%  1.3%
[libx264 @ 0x7f7fa5085200] ref B L1: 97.2%  2.8%
[libx264 @ 0x7f7fa5085200] kb/s:597.11
[aac @ 0x7f7fa5086a00] Qavg: 190.813
MacBook:xxx StevenLiu$ mediastreamvalidator master.m3u8
mediastreamvalidator: Version 1.2(170822)

[master.m3u8] Started loading root playlist
[media_1.m3u8] Started loading media playlist
Can't deal with multiple sample timings per sample buffer
[media_1.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 4 out of 4 segments
Average segment duration: 1.250000
Total segment bitrates (all discontinuities): average: 397.05 kb/s, max: 405.60 kb/s
Playlist max bitrate: 394.000000 kb/s
Audio Group ID: AUDIO


Discontinuity: sequence: 0, parsed segment count: 4 of 4, duration: 5.000 sec, average: 397.05 kb/s, max: 405.60 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 48000 Hz
Audio channels: 0
Audio channel layout: (null)

--------------------------------------------------------------------------------
MUST fix issues
--------------------------------------------------------------------------------

Error: Playlist vs segment duration mismatch
--> Detail:  Segment duration 2.0053, Playlist duration: 1.4933
--> Source:  media_1.m3u8 - chunk-stream1-00003.m4s:73981@0

MacBook:xxx StevenLiu$ git diff
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5687530f2d..5368a2334c 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -358,7 +358,7 @@ static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext
             Segment *seg = os->segments[i];
             double duration = (double) seg->duration / timescale;
             if (target_duration <= duration)
-                target_duration = hls_get_int_from_double(duration);
+                target_duration = lrint(duration);
         }

         ff_hls_write_playlist_header(out_hls, 6, -1, target_duration,
MacBook:xxx StevenLiu$

I think the problem is not the EXTINF and the EXT-X-TARGETDURATION problem, the problem the playlist's target duration not same.

comment:27 in reply to: ↑ 25 Changed 4 months ago by j_karthic

Replying to beloko:

My notes were for knowledge purposes about HLS playback with common and official video players. And used by Apple itself.

For sure the #EXT-X-TARGETDURATION cannot be rounded or forced to a lower value just to satisfy and dupe the Apple mediastreamvalidator tool result. But the #EXTINF value could be rounded to the nearest integer value when the duration doesn't exceed few small milliseconds.

We are not rounding just to satisfy mediastreamvalidator. We are rounding because the spec says so.
I think the problem will be that we will need to define that "small". Then implementations will have their own definition of "small"

#EXTINF:4.010667 could be rounded to #EXTINF:4.000000.
Or #EXTINF:3.989333 could be rounded to #EXTINF:4.000000.

Then the #EXT-X-TARGETDURATION can be set to 4 because the #EXTINF duration will never exceed 4.000000.

The difference in milliseconds between the real segment duration and the #EXTINF value setted in the audio playlist doesn't seems to affect HLS playback. Probably because the shortest duration of the preceding segment is compensated by the following segment. Which has a duration longer than 4 seconds. And so on until the #EXT-X-ENDLIST.

That is correct. As long as the difference in duration is within the duration one audio frame then all player's should be OK with it, as long as the next segment compensates for it and maintains the average segment duration to be same as the target duration.

Should be interesting to see what's the Apple segmenter can produce for HLS audio streams. Perhaps it fakes the real #EXTINF segment duration value in the M3U8 playlist. Because I'm not sure it's possible to force the gop size or inject a keyframe to an audio stream.

There is no concept of gop or keyframe in an aac/mp3 audio stream. Technically all the aac/mp3 audio frames are key frames, meaning you could start decoding the audio from any frame.

Rounding the #EXTINF value to the nearest integer value could be a additional parameter in the command line.

Ex: -hls_max_segment_duration <int> E.......... round segments duration in HLS playlist if they not exceed few milliseconds

Then the -hls_max_segment_duration 2 parameter should be able to fix :

#EXTINF:4.010667 into #EXTINF:4.000000.
Because 0.010667 seconds is lower than 2 milliseconds

0.010667 is 10.677 milliseconds, much higher than 2 milliseconds:) Theoretically this number could be as high as 128 milliseconds for a 8kHz aac audio stream (1024/8000 = 0.128 seconds). And in some other audio formats where frame sizes of 2048 and 4096 etc., being used this number could go even higher. I think instead of giving that control to the user, we should just go by the hls spec and keep things simple.
Because there were issues in the past with EXTINF being rounded and players having difficulty in knowing the exact duration. That is the reason when floating point durations were added to the HLS standard. If we again round the floating point durations, then it will defeat the whole purpose.

And #EXTINF:3.989333 into #EXTINF:4.000000
Because 4.000000 - 3.989333 = 0.010667 is lower than 2 milliseconds.

comment:28 follow-ups: Changed 4 months ago by stevenliu

maybe the process way looks like bellow:

  1. check if there have video stream
  2. all the EXT-X-TARGETDURATION align to video playlist EXT-X-TARGETDURATION if there have video stream
  3. if no video stream, just use old way.

What do you think about it?

@beloko @j_karthic

comment:29 in reply to: ↑ 28 Changed 4 months ago by stevenliu

Replying to stevenliu:

maybe the process way looks like bellow:

  1. check if there have video stream
  2. all the EXT-X-TARGETDURATION align to video playlist EXT-X-TARGETDURATION if there have video stream
  3. if no video stream, just use old way.

Ah, this is not perfect, let me think about it detail.

What do you think about it?

@beloko @j_karthic

comment:30 in reply to: ↑ 28 Changed 4 months ago by j_karthic

Replying to stevenliu:

maybe the process way looks like bellow:

  1. check if there have video stream
  2. all the EXT-X-TARGETDURATION align to video playlist EXT-X-TARGETDURATION if there have video stream
  3. if no video stream, just use old way.

Anyways the old way is to use muxed AV streams in hlsenc where this is not at all an issue. Only one target duration is present for both audio and video stream, as there is only one media playlist.
The issue arises only in unmuxed AV streams. The HLS support for unmuxed AV streams was added very recently in both hlsenc and dashenc. So I propose that we use rounding of target duration in unmuxed streams, and leave the muxed stream in hlsenc as is, in order to not touch the existing behavior.
In that way the existing behavior in hlsenc is preserved and no active user gets affected. Any new user starting with unmuxed streams will get rounded target durations.

What do you think about it?

@beloko @j_karthic

Changed 4 months ago by stevenliu

HLS response

comment:31 follow-up: Changed 4 months ago by stevenliu

HLS Team have answered the question and about the 4.3.3.1. EXT-X-TARGETDURATION

I respect Roger Pantos's and HLS Team's specification.

Thanks for Apple and HLS Team's clearity explication

comment:32 follow-up: Changed 4 months ago by beloko

Each Media Playlist in each Variant Stream MUST have the same
target duration.  The only exceptions are SUBTITLES Renditions and
Media Playlists containing an EXT-X-I-FRAMES-ONLY tag, which MAY
have different target durations if they have an EXT-X-PLAYLIST-
TYPE of VOD.

Alternate audio tracks are define as #EXT-X-MEDIA:TYPE=AUDIO in the master playlist. So in theory audio segments "MUST" be exactly 4 seconds long. But as you say in practice an audio stream can't be cut at exactly 4 seconds long.

That's why I think rounding the #EXTINF value could be the best outcome to fix this issue and produce HLS streams with alternate audio tracks validated by the Apple mediastreamvalidator tool. And compliant with the RFC 8216.

When the segmenter generate the .m3u8 playlist it knows the expected segment duration via the -min_seg_duration 4000000 parameter. And it knows the real segment duration since it can currently write the exact value in the playlist.

IF( INT($expected_duration - $real_duration) <= $tolerated_milliseconds )
THEN $real_duration = ROUND($real_duration);
...
WRITE "#EXTINF:" + $real_duration;

But if this fix can create compatibility issues with some alternative HLS players; I can also accept the Steven's process : forcing the #EXT-X-TARGETDURATION in all alternate audio playlists to the same value as the #EXT-X-TARGETDURATION setted in the main video playlist.

In any case the fix isn't hurry. This issue could be delayed the time required to consider others ways.

Last edited 4 months ago by beloko (previous) (diff)

comment:33 in reply to: ↑ 31 ; follow-up: Changed 4 months ago by j_karthic

Replying to stevenliu:

HLS Team have answered the question and about the 4.3.3.1. EXT-X-TARGETDURATION

I respect Roger Pantos's and HLS Team's specification.

Thanks for Apple and HLS Team's clearity explication

Yes. That is clear. I am not contesting that. "You can have TARGETDURATION much higher than the EXTINF duration". The spec only says "round(EXTINF_duration) <= target_duration", which means for a EXTINF duration of 2.08 seconds, TARGETDURATION could be 2 second, 3 second, 5 second or 100 seconds. Any target durations greater than or equal to the rounded segment duration is valid.

comment:34 in reply to: ↑ 33 ; follow-up: Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to stevenliu:

HLS Team have answered the question and about the 4.3.3.1. EXT-X-TARGETDURATION

I respect Roger Pantos's and HLS Team's specification.

Thanks for Apple and HLS Team's clearity explication

Yes. That is clear. I am not contesting that. "You can have TARGETDURATION much higher than the EXTINF duration". The spec only says "round(EXTINF_duration) <= target_duration", which means for a EXTINF duration of 2.08 seconds, TARGETDURATION could be 2 second, 3 second, 5 second or 100 seconds. Any target durations greater than or equal to the rounded segment duration is valid.

I didn't say "You can have TARGETDURATION much higher than the EXTINF duration", just round up to looks like plus one.

comment:35 in reply to: ↑ 32 Changed 4 months ago by j_karthic

Replying to beloko:

Each Media Playlist in each Variant Stream MUST have the same
target duration.  The only exceptions are SUBTITLES Renditions and
Media Playlists containing an EXT-X-I-FRAMES-ONLY tag, which MAY
have different target durations if they have an EXT-X-PLAYLIST-
TYPE of VOD.

Alternate audio tracks are define as #EXT-X-MEDIA:TYPE=AUDIO in the master playlist. So in theory audio segments "MUST" be exactly 4 seconds long. But as you say in practice an audio stream can't be cut at exactly 4 seconds long.

That's why I think rounding the #EXTINF value could be the best outcome to fix this issue and produce HLS streams with alternate audio tracks validated by the Apple mediastreamvalidator tool. And compliant with the RFC 8216.

When the segmenter generate the .m3u8 playlist it knows the expected segment duration via the -min_seg_duration 4000000 parameter. And it knows the real segment duration since it can currently write the exact value in the playlist.

IF( INT($expected_duration - $real_duration) <= $tolerated_milliseconds )

The issue is to identify the right $tolerated_milliseconds. As I said this could be as high as 128 milliseconds for 8khz aac stream.

THEN $real_duration = ROUND($real_duration);
...
WRITE "#EXTINF:" + $real_duration;

But if this fix can create compatibility issues with some alternative HLS players; I can also accept the Steven's process : forcing the #EXT-X-TARGETDURATION in all alternate audio playlists to the same value as the #EXT-X-TARGETDURATION setted in the main video playlist.

In any case the fix isn't hurry. This issue could be delayed the time required to consider others ways.

I agree with you. We should consider other ways as well.

comment:36 in reply to: ↑ 34 Changed 4 months ago by j_karthic

Replying to stevenliu:

Replying to j_karthic:

Replying to stevenliu:

HLS Team have answered the question and about the 4.3.3.1. EXT-X-TARGETDURATION

I respect Roger Pantos's and HLS Team's specification.

Thanks for Apple and HLS Team's clearity explication

Yes. That is clear. I am not contesting that. "You can have TARGETDURATION much higher than the EXTINF duration". The spec only says "round(EXTINF_duration) <= target_duration", which means for a EXTINF duration of 2.08 seconds, TARGETDURATION could be 2 second, 3 second, 5 second or 100 seconds. Any target durations greater than or equal to the rounded segment duration is valid.

I didn't say "You can have TARGETDURATION much higher than the EXTINF duration", just round up to looks like plus one.

No, you didn't say it. Sorry for the misunderstanding. I meant, Roger Pantos has said that. In his own words "It is perfectly legal to have EXTINF duration that are less than EXT-X-TARGETDURATION. Much less, in fact." I just wrote it the other way.

Also he says "To be clear, the EXT-X-TARGETDURATION is the max (roughly) of EXTINF durations. Thats all." Again note the use of the word "roughly", which one can interpret as 1.08 is roughly 1.

comment:37 follow-up: Changed 4 months ago by beloko

Not sure Roger understood the question really or he forgot "Each Media Playlist in each Variant Stream MUST have the same target duration.". That's why the Apple mediastreamvalidator complains ;)

In my thinking, the $tolerated_milliseconds must be set in the command line by the user only if he wishes to round the #EXTINF value. It cannot be guessed automatically by FFMPEG, it's too hazardous.

comment:38 in reply to: ↑ 37 ; follow-up: Changed 4 months ago by j_karthic

Replying to beloko:

Not sure Roger understood the question really or he forgot "Each Media Playlist in each Variant Stream MUST have the same target duration.". That's why the Apple mediastreamvalidator complains ;)

I think, Roger was clear. Actually your original statement was

To be compliant with the Apple mediastreamvalidator tool, video segments and 
audio segments should have the same duration. And the #EXT-X-TARGETDURATION tag
should have the value 4 instead of 5

That is not completely true. video and audio segments need not have the same duration. They just need to have the same "target" duration. The word "target" was missing in your statement :)
Ofcourse you were right about the second part that #EXT-X-TARGETDURATION tag should have the value 4 instead of 5

comment:39 Changed 4 months ago by beloko

You're absolutely right.

Here is an interesting sample provided by Apple to study :
https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8

This HLS stream contain 8 video tracks and 3 variant audio tracks.

Here is the master.m3u8 content :

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-INDEPENDENT-SEGMENTS

#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=2218327,BANDWIDTH=2227464,CODECS="avc1.640020,mp4a.40.2",RESOLUTION=960x540,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v5/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=8144656,BANDWIDTH=8178040,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v9/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=6307144,BANDWIDTH=6453202,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v8/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=4775338,BANDWIDTH=5054232,CODECS="avc1.64002a,mp4a.40.2",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v7/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=3240596,BANDWIDTH=3289288,CODECS="avc1.640020,mp4a.40.2",RESOLUTION=1280x720,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v6/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=1292926,BANDWIDTH=1296989,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=768x432,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v4/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=914722,BANDWIDTH=922242,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=640x360,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v3/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=541239,BANDWIDTH=553010,CODECS="avc1.640015,mp4a.40.2",RESOLUTION=480x270,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud1",SUBTITLES="sub1"
v2/prog_index.m3u8

#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=2439704,BANDWIDTH=2448841,CODECS="avc1.640020,ac-3",RESOLUTION=960x540,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v5/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=8366033,BANDWIDTH=8399417,CODECS="avc1.64002a,ac-3",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v9/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=6528521,BANDWIDTH=6674579,CODECS="avc1.64002a,ac-3",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v8/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=4996715,BANDWIDTH=5275609,CODECS="avc1.64002a,ac-3",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v7/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=3461973,BANDWIDTH=3510665,CODECS="avc1.640020,ac-3",RESOLUTION=1280x720,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v6/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=1514303,BANDWIDTH=1518366,CODECS="avc1.64001e,ac-3",RESOLUTION=768x432,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v4/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=1136099,BANDWIDTH=1143619,CODECS="avc1.64001e,ac-3",RESOLUTION=640x360,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v3/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=762616,BANDWIDTH=774387,CODECS="avc1.640015,ac-3",RESOLUTION=480x270,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud2",SUBTITLES="sub1"
v2/prog_index.m3u8

#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=2247704,BANDWIDTH=2256841,CODECS="avc1.640020,ec-3",RESOLUTION=960x540,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v5/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=8174033,BANDWIDTH=8207417,CODECS="avc1.64002a,ec-3",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v9/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=6336521,BANDWIDTH=6482579,CODECS="avc1.64002a,ec-3",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v8/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=4804715,BANDWIDTH=5083609,CODECS="avc1.64002a,ec-3",RESOLUTION=1920x1080,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v7/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=3269973,BANDWIDTH=3318665,CODECS="avc1.640020,ec-3",RESOLUTION=1280x720,FRAME-RATE=60.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v6/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=1322303,BANDWIDTH=1326366,CODECS="avc1.64001e,ec-3",RESOLUTION=768x432,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v4/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=944099,BANDWIDTH=951619,CODECS="avc1.64001e,ec-3",RESOLUTION=640x360,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v3/prog_index.m3u8
#EXT-X-STREAM-INF:AVERAGE-BANDWIDTH=570616,BANDWIDTH=582387,CODECS="avc1.640015,ec-3",RESOLUTION=480x270,FRAME-RATE=30.000,CLOSED-CAPTIONS="cc1",AUDIO="aud3",SUBTITLES="sub1"
v2/prog_index.m3u8

#EXT-X-I-FRAME-STREAM-INF:AVERAGE-BANDWIDTH=182077,BANDWIDTH=186522,CODECS="avc1.64002a",RESOLUTION=1920x1080,URI="v7/iframe_index.m3u8"
#EXT-X-I-FRAME-STREAM-INF:AVERAGE-BANDWIDTH=129936,BANDWIDTH=133856,CODECS="avc1.640020",RESOLUTION=1280x720,URI="v6/iframe_index.m3u8"
#EXT-X-I-FRAME-STREAM-INF:AVERAGE-BANDWIDTH=94286,BANDWIDTH=98136,CODECS="avc1.640020",RESOLUTION=960x540,URI="v5/iframe_index.m3u8"
#EXT-X-I-FRAME-STREAM-INF:AVERAGE-BANDWIDTH=74767,BANDWIDTH=76704,CODECS="avc1.64001e",RESOLUTION=768x432,URI="v4/iframe_index.m3u8"
#EXT-X-I-FRAME-STREAM-INF:AVERAGE-BANDWIDTH=62251,BANDWIDTH=64078,CODECS="avc1.64001e",RESOLUTION=640x360,URI="v3/iframe_index.m3u8"
#EXT-X-I-FRAME-STREAM-INF:AVERAGE-BANDWIDTH=37866,BANDWIDTH=38728,CODECS="avc1.640015",RESOLUTION=480x270,URI="v2/iframe_index.m3u8"

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="2",URI="a1/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud2",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="6",URI="a2/prog_index.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aud3",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,CHANNELS="6",URI="a3/prog_index.m3u8"

#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID="cc1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,INSTREAM-ID="CC1"

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="sub1",LANGUAGE="en",NAME="English",AUTOSELECT=YES,DEFAULT=YES,FORCED=NO,URI="s1/en/prog_index.m3u8"

Now here is the first video playlist content :
https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/v5/prog_index.m3u8

#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXTINF:6.00000,	
#EXT-X-BITRATE:2060
fileSequence0.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2063
fileSequence1.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2056
fileSequence2.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2055
fileSequence3.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2056
fileSequence4.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2051
fileSequence5.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2055
fileSequence6.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2060
fileSequence7.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2050
fileSequence8.ts
...
#EXTINF:6.00000,	
#EXT-X-BITRATE:2063
fileSequence95.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2056
fileSequence96.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2048
fileSequence97.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2063
fileSequence98.ts
#EXTINF:6.00000,	
#EXT-X-BITRATE:2055
fileSequence99.ts
#EXT-X-ENDLIST

We can see the #EXT-X-TARGETDURATION value is 6 seconds.
And the #EXTINF value for each segment is exactly 6.00000.

Dashenc and Hlsenc segmenters can produce exactly the same result via FFMPEG.
That's perfect.

And now here is the first audio playlist content :
https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/a1/prog_index.m3u8

#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence0.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence1.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence2.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence3.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence4.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence5.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence6.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence7.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence8.aac
...
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence95.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence96.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence97.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence98.aac
#EXTINF:5.99467,	
#EXT-X-BITRATE:163
fileSequence99.aac
#EXTINF:0.57600,	
#EXT-X-BITRATE:164
fileSequence100.aac
#EXT-X-ENDLIST

We can see the #EXT-X-TARGETDURATION value is 6 seconds.
The same value as the video playlist.

And the #EXTINF value of each segment is always 5.99467.
This value is realy near of 6.000000 and always lower than 6.000000

So let's see the second audio playlist content :
https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/a2/prog_index.m3u8

#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence0.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence1.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence2.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence3.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence4.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence5.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence6.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence7.ac3
...
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence95.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence96.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence97.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence98.ac3
#EXTINF:5.98400,	
#EXT-X-BITRATE:384
fileSequence99.ac3
#EXTINF:1.60000,	
#EXT-X-BITRATE:384
fileSequence100.ac3
#EXT-X-ENDLIST

We can see the #EXT-X-TARGETDURATION value is 6 seconds.
The same value as the video playlist.
And the same value as the first audio playlist.

And the #EXTINF value of each segment is always 5.98400.
This value is realy near of 6.000000 and always lower than 6.000000.
But it's not the same duration as the segments in the first audio playlist.

This means to be absolutely compliant with the RFC 8216 the segmenter should be able to cut the audio stream few milliseconds before the expected segment duration. But I don't know if this is possible with Dashenc and/or Hlsenc. Their source code isn't easy for me.

comment:40 follow-up: Changed 4 months ago by stevenliu

If the two m3u8 list not MUST sequence align, i think this way can fix it.

MacBook:xxx StevenLiu$ rm -rf *.m4s *.m3u8;./ffmpeg -hide_banner -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 150 -r 100 -x264opts "scenecut=-1" -f dash -min_seg_duration 1000000 -window_size 99999 -t 5 -hls_playlist 1 output_Steven.mpd
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/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, 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) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f9441042000] using SAR=1/1
[libx264 @ 0x7f9441042000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7f9441042000] profile High, level 5.1
[libx264 @ 0x7f9441042000] 264 - core 133 r2334M a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - 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=-2 threads=6 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=150 keyint_min=15 scenecut=0 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
[aac @ 0x7f9441043800] Using a PCE to encode channel layout
[dash @ 0x7f944180dc00] No bit rate set for stream 0
[dash @ 0x7f944180dc00] Opening 'init-stream0.m4s' for writing
[dash @ 0x7f944180dc00] Opening 'init-stream1.m4s' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
Bandwidth info not available, set audio and video bitrates
Output #0, dash, to 'output_Steven.mpd':
  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.3.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 100 fps, 12800 tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:39.000000Z
      handler_name    : GPAC ISO Video Handler
      encoder         : Lavc58.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC), 48000 Hz, 5.1(side), fltp, 394 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.8.100 aac
    Side data:
      audio service type: main
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00001.m4s.tmp' for writingrop=0 speed=0.444x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00001.m4s.tmp' for writingdrop=0 speed=0.526x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00002.m4s.tmp' for writingdrop=0 speed=0.459x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00003.m4s.tmp' for writingdrop=0 speed=0.548x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00002.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00004.m4s.tmp' for writingdrop=0 speed=0.49x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00003.m4s.tmp' for writingdrop=0 speed=0.502x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00005.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00004.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00006.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
frame=  500 fps= 44 q=-1.0 Lsize=N/A time=00:00:05.01 bitrate=N/A dup=354 drop=0 speed=0.436x
video:365kB audio:241kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7f9441042000] frame I:4     Avg QP:16.78  size: 20153
[libx264 @ 0x7f9441042000] frame P:150   Avg QP:20.52  size:  1625
[libx264 @ 0x7f9441042000] frame B:346   Avg QP:18.64  size:   141
[libx264 @ 0x7f9441042000] consecutive B-frames:  5.4%  5.2%  5.4% 84.0%
[libx264 @ 0x7f9441042000] mb I  I16..4: 92.8%  3.1%  4.1%
[libx264 @ 0x7f9441042000] mb P  I16..4:  6.0%  1.9%  0.1%  P16..4:  2.5%  0.2%  0.2%  0.0%  0.0%    skip:89.2%
[libx264 @ 0x7f9441042000] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  0.6%  0.0%  0.0%  direct: 0.2%  skip:99.0%  L0:33.2% L1:65.7% BI: 1.1%
[libx264 @ 0x7f9441042000] 8x8 transform intra:17.9% inter:71.0%
[libx264 @ 0x7f9441042000] coded y,uvDC,uvAC intra: 3.2% 11.7% 2.2% inter: 0.2% 0.7% 0.1%
[libx264 @ 0x7f9441042000] i16 v,h,dc,p: 83% 12%  3%  1%
[libx264 @ 0x7f9441042000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 11% 62%  1%  2%  1%  2%  1%  1%
[libx264 @ 0x7f9441042000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 22% 28%  4%  4%  4%  4%  3%  4%
[libx264 @ 0x7f9441042000] i8c dc,h,v,p: 77% 14%  9%  0%
[libx264 @ 0x7f9441042000] Weighted P-Frames: Y:22.7% UV:22.0%
[libx264 @ 0x7f9441042000] ref P L0: 83.9%  4.5%  9.7%  1.5%  0.4%
[libx264 @ 0x7f9441042000] ref B L0: 73.8% 24.9%  1.3%
[libx264 @ 0x7f9441042000] ref B L1: 97.2%  2.8%
[libx264 @ 0x7f9441042000] kb/s:597.11
[aac @ 0x7f9441043800] Qavg: 190.813
MacBook:xxx StevenLiu$ cat media_0.m3u8 media_1.m3u8
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream0.m4s"
#EXTINF:1.500000,
chunk-stream0-00001.m4s
#EXTINF:1.500000,
chunk-stream0-00002.m4s
#EXTINF:1.500000,
chunk-stream0-00003.m4s
#EXTINF:0.500000,
chunk-stream0-00004.m4s
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:0.960000,
chunk-stream1-00001.m4s
#EXTINF:0.981333,
chunk-stream1-00002.m4s
#EXTINF:0.981333,
chunk-stream1-00003.m4s
#EXTINF:0.981333,
chunk-stream1-00004.m4s
#EXTINF:0.981333,
chunk-stream1-00005.m4s
#EXTINF:0.114667,
chunk-stream1-00006.m4s
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$
MacBook:xxx StevenLiu$ mediastreamvalidator master.m3u8
mediastreamvalidator: Version 1.2(170822)

[master.m3u8] Started loading root playlist
[media_1.m3u8] Started loading media playlist
Can't deal with multiple sample timings per sample buffer
[media_1.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 6 out of 6 segments
Average segment duration: 0.833333
Total segment bitrates (all discontinuities): average: 397.52 kb/s, max: 400.91 kb/s
Playlist max bitrate: 394.000000 kb/s
Audio Group ID: AUDIO


Discontinuity: sequence: 0, parsed segment count: 6 of 6, duration: 5.000 sec, average: 397.52 kb/s, max: 400.91 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 48000 Hz
Audio channels: 0
Audio channel layout: (null)

--------------------------------------------------------------------------------
MUST fix issues
--------------------------------------------------------------------------------

Error: Zero sample count
--> Detail:  Track ID 295
--> Source:  media_1.m3u8 - chunk-stream1-00006.m4s:6235@0

MacBook:xxx StevenLiu$ git diff
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5687530f2d..07dd2bef5f 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1168,6 +1168,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
     DASHContext *c = s->priv_data;
     AVStream *st = s->streams[pkt->stream_index];
     OutputStream *os = &c->streams[pkt->stream_index];
+    int get_split_time_point = 0;
     int ret;

     ret = update_stream_extradata(s, os, st->codecpar);
@@ -1195,10 +1196,17 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (os->first_pts == AV_NOPTS_VALUE)
         os->first_pts = pkt->pts;

-    if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
-        pkt->flags & AV_PKT_FLAG_KEY && os->packets_written &&
-        av_compare_ts(pkt->pts - os->start_pts, st->time_base,
-                      c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
+    if (c->has_video && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if ( av_compare_ts(pkt->pts + pkt->duration - os->start_pts, st->time_base, c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
+            get_split_time_point = 1;
+        }
+    } else {
+        if (av_compare_ts(pkt->pts - os->start_pts, st->time_base, c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
+            get_split_time_point = 1;
+        }
+    }
+    if ((!c->has_video || (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) || c->hls_playlist) &&
+        pkt->flags & AV_PKT_FLAG_KEY && os->packets_written && get_split_time_point) {
         int64_t prev_duration = c->last_duration;

         c->last_duration = av_rescale_q(pkt->pts - os->start_pts,
MacBook:xxx StevenLiu$

comment:41 in reply to: ↑ 40 Changed 4 months ago by stevenliu

Replying to stevenliu:

If the two m3u8 list not MUST sequence align, i think this way can fix it.

But i think this is not a perfect solution, i want set the EXT-X-TARGETDURATION higher value align maybe better,

if audio playlist EXT-X-TARGETDURATION > video playlist EXT-X-TARGETDURATION
the align to audio playlist EXT-X-TARGETDURATION

otherwise the align to video playlist EXT-X-TARGETDURATION

MacBook:xxx StevenLiu$ rm -rf *.m4s *.m3u8;./ffmpeg -hide_banner -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 150 -r 100 -x264opts "scenecut=-1" -f dash -min_seg_duration 1000000 -window_size 99999 -t 5 -hls_playlist 1 output_Steven.mpd
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/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, 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) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f9441042000] using SAR=1/1
[libx264 @ 0x7f9441042000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7f9441042000] profile High, level 5.1
[libx264 @ 0x7f9441042000] 264 - core 133 r2334M a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - 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=-2 threads=6 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=150 keyint_min=15 scenecut=0 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
[aac @ 0x7f9441043800] Using a PCE to encode channel layout
[dash @ 0x7f944180dc00] No bit rate set for stream 0
[dash @ 0x7f944180dc00] Opening 'init-stream0.m4s' for writing
[dash @ 0x7f944180dc00] Opening 'init-stream1.m4s' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
Bandwidth info not available, set audio and video bitrates
Output #0, dash, to 'output_Steven.mpd':
  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.3.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 100 fps, 12800 tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:39.000000Z
      handler_name    : GPAC ISO Video Handler
      encoder         : Lavc58.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC), 48000 Hz, 5.1(side), fltp, 394 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.8.100 aac
    Side data:
      audio service type: main
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00001.m4s.tmp' for writingrop=0 speed=0.444x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00001.m4s.tmp' for writingdrop=0 speed=0.526x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00002.m4s.tmp' for writingdrop=0 speed=0.459x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00003.m4s.tmp' for writingdrop=0 speed=0.548x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00002.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00004.m4s.tmp' for writingdrop=0 speed=0.49x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00003.m4s.tmp' for writingdrop=0 speed=0.502x
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00005.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream0-00004.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'chunk-stream1-00006.m4s.tmp' for writing
[dash @ 0x7f944180dc00] Opening 'output_Steven.mpd.tmp' for writing
frame=  500 fps= 44 q=-1.0 Lsize=N/A time=00:00:05.01 bitrate=N/A dup=354 drop=0 speed=0.436x
video:365kB audio:241kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7f9441042000] frame I:4     Avg QP:16.78  size: 20153
[libx264 @ 0x7f9441042000] frame P:150   Avg QP:20.52  size:  1625
[libx264 @ 0x7f9441042000] frame B:346   Avg QP:18.64  size:   141
[libx264 @ 0x7f9441042000] consecutive B-frames:  5.4%  5.2%  5.4% 84.0%
[libx264 @ 0x7f9441042000] mb I  I16..4: 92.8%  3.1%  4.1%
[libx264 @ 0x7f9441042000] mb P  I16..4:  6.0%  1.9%  0.1%  P16..4:  2.5%  0.2%  0.2%  0.0%  0.0%    skip:89.2%
[libx264 @ 0x7f9441042000] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  0.6%  0.0%  0.0%  direct: 0.2%  skip:99.0%  L0:33.2% L1:65.7% BI: 1.1%
[libx264 @ 0x7f9441042000] 8x8 transform intra:17.9% inter:71.0%
[libx264 @ 0x7f9441042000] coded y,uvDC,uvAC intra: 3.2% 11.7% 2.2% inter: 0.2% 0.7% 0.1%
[libx264 @ 0x7f9441042000] i16 v,h,dc,p: 83% 12%  3%  1%
[libx264 @ 0x7f9441042000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 11% 62%  1%  2%  1%  2%  1%  1%
[libx264 @ 0x7f9441042000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 22% 28%  4%  4%  4%  4%  3%  4%
[libx264 @ 0x7f9441042000] i8c dc,h,v,p: 77% 14%  9%  0%
[libx264 @ 0x7f9441042000] Weighted P-Frames: Y:22.7% UV:22.0%
[libx264 @ 0x7f9441042000] ref P L0: 83.9%  4.5%  9.7%  1.5%  0.4%
[libx264 @ 0x7f9441042000] ref B L0: 73.8% 24.9%  1.3%
[libx264 @ 0x7f9441042000] ref B L1: 97.2%  2.8%
[libx264 @ 0x7f9441042000] kb/s:597.11
[aac @ 0x7f9441043800] Qavg: 190.813
MacBook:xxx StevenLiu$ cat media_0.m3u8 media_1.m3u8
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream0.m4s"
#EXTINF:1.500000,
chunk-stream0-00001.m4s
#EXTINF:1.500000,
chunk-stream0-00002.m4s
#EXTINF:1.500000,
chunk-stream0-00003.m4s
#EXTINF:0.500000,
chunk-stream0-00004.m4s
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:0.960000,
chunk-stream1-00001.m4s
#EXTINF:0.981333,
chunk-stream1-00002.m4s
#EXTINF:0.981333,
chunk-stream1-00003.m4s
#EXTINF:0.981333,
chunk-stream1-00004.m4s
#EXTINF:0.981333,
chunk-stream1-00005.m4s
#EXTINF:0.114667,
chunk-stream1-00006.m4s
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$
MacBook:xxx StevenLiu$ mediastreamvalidator master.m3u8
mediastreamvalidator: Version 1.2(170822)

[master.m3u8] Started loading root playlist
[media_1.m3u8] Started loading media playlist
Can't deal with multiple sample timings per sample buffer
[media_1.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 6 out of 6 segments
Average segment duration: 0.833333
Total segment bitrates (all discontinuities): average: 397.52 kb/s, max: 400.91 kb/s
Playlist max bitrate: 394.000000 kb/s
Audio Group ID: AUDIO


Discontinuity: sequence: 0, parsed segment count: 6 of 6, duration: 5.000 sec, average: 397.52 kb/s, max: 400.91 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 48000 Hz
Audio channels: 0
Audio channel layout: (null)

--------------------------------------------------------------------------------
MUST fix issues
--------------------------------------------------------------------------------

Error: Zero sample count
--> Detail:  Track ID 295
--> Source:  media_1.m3u8 - chunk-stream1-00006.m4s:6235@0

MacBook:xxx StevenLiu$ git diff
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5687530f2d..07dd2bef5f 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1168,6 +1168,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
     DASHContext *c = s->priv_data;
     AVStream *st = s->streams[pkt->stream_index];
     OutputStream *os = &c->streams[pkt->stream_index];
+    int get_split_time_point = 0;
     int ret;

     ret = update_stream_extradata(s, os, st->codecpar);
@@ -1195,10 +1196,17 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
     if (os->first_pts == AV_NOPTS_VALUE)
         os->first_pts = pkt->pts;

-    if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
-        pkt->flags & AV_PKT_FLAG_KEY && os->packets_written &&
-        av_compare_ts(pkt->pts - os->start_pts, st->time_base,
-                      c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
+    if (c->has_video && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+        if ( av_compare_ts(pkt->pts + pkt->duration - os->start_pts, st->time_base, c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
+            get_split_time_point = 1;
+        }
+    } else {
+        if (av_compare_ts(pkt->pts - os->start_pts, st->time_base, c->min_seg_duration, AV_TIME_BASE_Q) >= 0) {
+            get_split_time_point = 1;
+        }
+    }
+    if ((!c->has_video || (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) || c->hls_playlist) &&
+        pkt->flags & AV_PKT_FLAG_KEY && os->packets_written && get_split_time_point) {
         int64_t prev_duration = c->last_duration;

         c->last_duration = av_rescale_q(pkt->pts - os->start_pts,
MacBook:xxx StevenLiu$

comment:42 in reply to: ↑ 38 Changed 4 months ago by stevenliu

Replying to j_karthic:

Replying to beloko:

Not sure Roger understood the question really or he forgot "Each Media Playlist in each Variant Stream MUST have the same target duration.". That's why the Apple mediastreamvalidator complains ;)

I think, Roger was clear. Actually your original statement was

To be compliant with the Apple mediastreamvalidator tool, video segments and 
audio segments should have the same duration. And the #EXT-X-TARGETDURATION tag
should have the value 4 instead of 5

That is not completely true. video and audio segments need not have the same duration. They just need to have the same "target" duration. The word "target" was missing in your statement :)
Ofcourse you were right about the second part that #EXT-X-TARGETDURATION tag should have the value 4 instead of 5

Yes, you are right, i have double check from Pantos:

2017-12-22 7:22 GMT+08:00 Roger Pantos <rpantos@apple.com>:
> If the longest EXTINF is 1.02 then you should set EXT-X-TARGETDURATION to 1.
Ok, i will modify that use lrint(EXTINF) to set the EXT-X-TARGETDURATION.

Thanks



Steven
>
> Roger
> Sent from my iPhone.
>
>> On Dec 21, 2017, at 2:53 PM, Steven Liu <lingjiujianke@gmail.com> wrote:
>>
>> 2017-12-22 0:51 GMT+08:00 Roger Pantos <rpantos@apple.com>:
>>> Hello Steven,
>>>
>>>> On Dec 20, 2017, at 11:19 PM, Steven Liu <lingjiujianke@gmail.com> wrote:
>>>>
>>>> Hi HLS Team,
>>>>
>>>>     This is a ffmpeg developer for hls, there have a problem about
>>>> user muxing hls,
>>>>
>>>>     I saw the specification said:
>>>>
>>>> 4.3.3.1.  EXT-X-TARGETDURATION
>>>>
>>>>  The EXT-X-TARGETDURATION tag specifies the maximum Media Segment
>>>>  duration.  The EXTINF duration of each Media Segment in the Playlist
>>>>  file, when rounded to the nearest integer, MUST be less than or equal
>>>>  to the target duration; longer segments can trigger playback stalls
>>>>  or other errors.  It applies to the entire Playlist file.  Its format
>>>>  is:
>>>>
>>>>  #EXT-X-TARGETDURATION:<s>
>>>>
>>>>  where s is a decimal-integer indicating the target duration in
>>>>  seconds.  The EXT-X-TARGETDURATION tag is REQUIRED.
>>>>
>>>>
>>>> i cannot sure if i misunderstand or that is a mistake, user use
>>>> mediastreamvalidator to check the hls file, When EXT-X-TARGETDURATION
>>>> value more than EXTINF, the mediastreamvalidator report warnng, the
>>>> detail infomation is linkto:
>>>> https://trac.ffmpeg.org/ticket/6915#comment:6
>>>
>>> I took a look at that link. There’s a lot there, so I’m not sure if I’m focused on the right question.
>>>
>>> But it is perfectly legal to have EXTINF durations that are less than EXT-X-TARGETDURATION. Much less, in fact.
>>>
>>> Moreover, regarding this comment:
>>>
>>>> To be compliant with the Apple mediastreamvalidator tool, video segments and audio segments should have the same duration. And the #EXT-X-TARGETDURATION tag should have the value 4 instead of 5.
>>>
>>> I don’t think that’s true. The mediastreamvalidator does not (or should not, anyway) require that video and audio segments have the same duration, only that their EXT-X-TARGETDURATION values match.
>>>
>>> To be clear, the EXT-X-TARGETDURATION is the max (roughly) of EXTINF durations. That’s all.
>>
>> Hi Roger Pantos,
>>
>>      have some more question i need more clearly.
>>
>>      When the longest segment's #EXTINF 1.020000
>>      EXT-X-TARGETDURATION should be 1 or 2?
>>
>>      The specification said:
>>       "The EXTINF duration of each Media Segment in the Playlist
>>   file, when rounded to the nearest integer, MUST be less than or equal
>>   to the target duration; longer segments can trigger playback stalls
>>   or other errors. "
>>
>>       1. read this logic, some people understand to :
>>       if (round(EXTINF_value) <= EXT-X-TARGETDURATION_value) {
>>           EXT-X-TARGETDURATION_value = lrint(EXTINF_value);
>>       } else {
>>            longer segments can trigger playback stalls or other errors
>>       }
>>
>> the result:
>>      The EXT-X-TARGETDURATION_value is set to 1 when the  longest
>> segment's #EXTINF is 1.020000,
>>      The EXT-X-TARGETDURATION_value is set to 2 when the  longest
>> segment's #EXTINF is 1.620000,
>>
>>
>>       2. but now i implement it like this:
>>
>>         // just get the EXTINF_value Fraction, if the Fraction large
>> than 0.001(this maybe 1000fps), +1, else = EXTINF_value, this can be
>> used in audio.
>>         EXT-X-TARGETDURATION_value = (int)((EXTINF_value - (int)
>> EXTINF_value) >= 0.001) ? (int)(EXTINF_value + 1) : (int)
>> EXTINF_value;
>>       }
>>
>> the result:
>>      The EXT-X-TARGETDURATION_value is set to 2 when the  longest
>> segment's #EXTINF is 1.020000,
>>      The EXT-X-TARGETDURATION_value is set to 2 when the  longest
>> segment's #EXTINF is 1.620000,
>>
>>
>>      this is our controversy point of the specification:
>> https://tools.ietf.org/html/rfc8216#page-22   4.3.3.1.
>> EXT-X-TARGETDURATION
>>
>> I cannot sure which one is better or which one is recommend?
>>
>>
>>
>> Thanks
>>
>>
>> Steven Liu
>>
>>
>>>
>>>
>>> regards,
>>>
>>> Roger Pantos
>>> Apple Inc.
>>>
>>>>
>>>>
>>>> Thanks
>>>>
>>>>
>>>> Steven Liu
>>>

comment:43 follow-ups: Changed 4 months ago by beloko

What's lrint(1.50) will return ?
1 or 2

comment:44 Changed 4 months ago by beloko

I was checking the real segments duration of the Apple's HLS sample stream with FFPROBE.

Video segments are really cut at 6 seconds exactly.

C:\Users\Beloko\Desktop\FFMPEG>ffprobe https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/v5/fileSequence2.ts
ffprobe version N-89544-gcfd5209-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-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.  6.100 / 56.  6.100
  libavcodec     58.  8.100 / 58.  8.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  7.100 /  7.  7.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, mpegts, from 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/v5/fileSequence2.ts':
  Duration: 00:00:06.00, start: 22.016667, bitrate: 2055 kb/s
  Program 1
    Stream #0:0[0x101]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p(progressive), 960x540 [SAR 1:1 DAR 16:9], Closed Captions, 60 fps, 60 tbr, 90k tbn, 120 tbc

But audio segments are roughly cut around 6 seconds.

Sometime at 5.33 before 6 seconds long.

C:\Users\Beloko\Desktop\FFMPEG>ffprobe https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/a1/fileSequence4.aac
ffprobe version N-89544-gcfd5209-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-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.  6.100 / 56.  6.100
  libavcodec     58.  8.100 / 58.  8.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  7.100 /  7.  7.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, aac, from 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/a1/fileSequence4.aac':
  Duration: 00:00:05.33, bitrate: 183 kb/s
    Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 183 kb/s

Or sometime at 6.22 after 6 seconds long.

C:\Users\Beloko\Desktop\FFMPEG>ffprobe https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/a1/fileSequence1.aac
ffprobe version N-89544-gcfd5209-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-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.  6.100 / 56.  6.100
  libavcodec     58.  8.100 / 58.  8.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  7.100 /  7.  7.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, aac, from 'https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/a1/fileSequence1.aac':
  Duration: 00:00:06.22, bitrate: 156 kb/s
    Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 156 kb/s

That's really strange results ?!
But it's what FFMPEG's segmenters already does currently.

So if Apple can provide HLS streams with approximative audio segment duration. Why FFMPEG segmenters couldn't simulate the same. Like rounding the #EXTINF value to the nearest integer that should be the expected segment duration in the FFMPEG command line.

Last edited 4 months ago by beloko (previous) (diff)

comment:45 in reply to: ↑ 43 Changed 4 months ago by stevenliu

Replying to beloko:

What's lrint(1.50) will return ?
1 or 2

maybe need more check about it. :(

Whatever, applied j_karthic first, if there have player or user report the bug, then fix bug is ok :D

MacBook:xxx StevenLiu$ ./ffmpeg -hide_banner -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 40 -r 25 -x264opts "scenecut=-1" -t 5 -vcodec libx264 -f mpegts a.ts
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/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, 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
File 'a.ts' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:2 -> #0:1 (ac3 (native) -> mp2 (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fcb0204b800] using SAR=1/1
[libx264 @ 0x7fcb0204b800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7fcb0204b800] profile High, level 4.0
Past duration 0.666664 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Output #0, mpegts, to 'a.ts':
  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.3.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p(progressive), 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.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.8.100 mp2
    Side data:
      audio service type: main
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      0kB time=00:00:01.45 bitrate=   0.0kbits/s dup=0 drop=6 speed=2.88x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      0kB time=00:00:01.93 bitrate=   0.0kbits/s dup=0 drop=8 speed=1.71x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      79kB time=00:00:02.41 bitrate= 267.3kbits/s dup=0 drop=11 speed=1.46x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     132kB time=00:00:02.89 bitrate= 373.1kbits/s dup=0 drop=15 speed=1.34x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     219kB time=00:00:03.85 bitrate= 464.8kbits/s dup=0 drop=19 speed=1.39x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     252kB time=00:00:04.33 bitrate= 477.2kbits/s dup=0 drop=21 speed=1.32x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
frame=  123 fps= 22 q=-1.0 Lsize=     711kB time=00:00:05.00 bitrate=1162.7kbits/s dup=0 drop=24 speed=0.881x
video:401kB audio:235kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 11.713006%
[libx264 @ 0x7fcb0204b800] frame I:4     Avg QP:14.69  size: 34222
[libx264 @ 0x7fcb0204b800] frame P:46    Avg QP:16.78  size:  4717
[libx264 @ 0x7fcb0204b800] frame B:73    Avg QP:19.06  size:   776
[libx264 @ 0x7fcb0204b800] consecutive B-frames: 18.7%  4.9%  4.9% 71.5%
[libx264 @ 0x7fcb0204b800] mb I  I16..4: 82.3% 12.4%  5.4%
[libx264 @ 0x7fcb0204b800] mb P  I16..4: 15.6%  4.0%  0.2%  P16..4:  4.8%  0.4%  0.4%  0.0%  0.0%    skip:74.6%
[libx264 @ 0x7fcb0204b800] mb B  I16..4:  4.7%  0.1%  0.0%  B16..8:  0.9%  0.1%  0.0%  direct: 3.6%  skip:90.6%  L0:37.6% L1:56.9% BI: 5.5%
[libx264 @ 0x7fcb0204b800] 8x8 transform intra:14.5% inter:60.5%
[libx264 @ 0x7fcb0204b800] coded y,uvDC,uvAC intra: 4.0% 12.3% 3.0% inter: 0.6% 4.2% 0.4%
[libx264 @ 0x7fcb0204b800] i16 v,h,dc,p: 86% 10%  3%  1%
[libx264 @ 0x7fcb0204b800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 14% 58%  2%  3%  2%  3%  1%  2%
[libx264 @ 0x7fcb0204b800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 24% 24%  4%  4%  5%  5%  3%  4%
[libx264 @ 0x7fcb0204b800] i8c dc,h,v,p: 79% 12%  8%  1%
[libx264 @ 0x7fcb0204b800] Weighted P-Frames: Y:45.7% UV:43.5%
[libx264 @ 0x7fcb0204b800] ref P L0: 84.4%  5.6%  8.2%  1.7%  0.2%
[libx264 @ 0x7fcb0204b800] ref B L0: 73.0% 23.8%  3.3%
[libx264 @ 0x7fcb0204b800] ref B L1: 94.6%  5.4%
[libx264 @ 0x7fcb0204b800] kb/s:667.49
MacBook:xxx StevenLiu$ rm -rf fileSequence* *.m3u8
MacBook:xxx StevenLiu$ mediafilesegmenter -A -t 1 a.ts
Dec 22 2017 08:28:11.281: Processing file /Users/StevenLiu/multimedia/ffmpeg/xxx/a.ts
Dec 22 2017 08:28:11.298: Finalized fileSequence0.ts
Dec 22 2017 08:28:11.298: segment bitrate 498.20 kbits/sec is new max
Dec 22 2017 08:28:11.299: Finalized fileSequence1.ts
Dec 22 2017 08:28:11.301: Finalized fileSequence2.ts
Dec 22 2017 08:28:11.301: segment does not contain sync frame
Dec 22 2017 08:28:11.303: Finalized fileSequence3.ts
Dec 22 2017 08:28:11.309: Finalized fileSequence4.ts
Dec 22 2017 08:28:11.309: segment bitrate  2.05 Mbits/sec is new max
Dec 22 2017 08:28:11.311: average bit rate is 693.92 kbits/sec - max file bit rate is  2.05 Mbits/sec
MacBook:xxx StevenLiu$ cat prog_index.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:0.96000,
fileSequence0.ts
#EXTINF:1.00000,
fileSequence1.ts
#EXTINF:1.00000,
fileSequence2.ts
#EXTINF:1.00000,
fileSequence3.ts
#EXTINF:0.96000,
fileSequence4.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$ cat iframe_index.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-I-FRAMES-ONLY
#EXTINF:1.60000,
#EXT-X-BYTERANGE:1316@376
fileSequence0.ts
#EXTINF:1.60000,
#EXT-X-BYTERANGE:32900@12408
fileSequence1.ts
#EXTINF:1.60000,
#EXT-X-BYTERANGE:28388@1504
fileSequence3.ts
#EXTINF:0.04000,
#EXT-X-BYTERANGE:78020@165816
fileSequence4.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$ ./ffmpeg -hide_banner -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 48 -r 25 -x264opts "scenecut=-1" -t 5 -vcodec libx264 -f mpegts a.ts
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/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, 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
File 'a.ts' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:2 -> #0:1 (ac3 (native) -> mp2 (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f8eb6040800] using SAR=1/1
[libx264 @ 0x7f8eb6040800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7f8eb6040800] profile High, level 4.0
Past duration 0.666664 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Output #0, mpegts, to 'a.ts':
  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.3.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p(progressive), 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.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.8.100 mp2
    Side data:
      audio service type: main
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      0kB time=00:00:01.93 bitrate=   0.0kbits/s dup=0 drop=8 speed=1.78x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      84kB time=00:00:02.41 bitrate= 284.1kbits/s dup=0 drop=12 speed=1.47x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     144kB time=00:00:03.37 bitrate= 349.9kbits/s dup=0 drop=16 speed=1.54x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     219kB time=00:00:03.85 bitrate= 465.6kbits/s dup=0 drop=19 speed=1.41x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     256kB time=00:00:04.33 bitrate= 483.9kbits/s dup=0 drop=22 speed=1.32x
Past duration 0.999992 too large
Past duration 0.833321 too large
frame=  123 fps= 22 q=-1.0 Lsize=     627kB time=00:00:05.00 bitrate=1025.4kbits/s dup=0 drop=24 speed=0.901x
video:323kB audio:235kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12.195335%
[libx264 @ 0x7f8eb6040800] frame I:3     Avg QP:15.49  size: 16217
[libx264 @ 0x7f8eb6040800] frame P:48    Avg QP:16.97  size:  4849
[libx264 @ 0x7f8eb6040800] frame B:72    Avg QP:19.26  size:   690
[libx264 @ 0x7f8eb6040800] consecutive B-frames: 19.5%  6.5%  2.4% 71.5%
[libx264 @ 0x7f8eb6040800] mb I  I16..4: 95.0%  0.7%  4.3%
[libx264 @ 0x7f8eb6040800] mb P  I16..4: 15.6%  4.4%  0.2%  P16..4:  5.1%  0.5%  0.4%  0.0%  0.0%    skip:73.9%
[libx264 @ 0x7f8eb6040800] mb B  I16..4:  3.7%  0.0%  0.0%  B16..8:  0.9%  0.1%  0.0%  direct: 2.8%  skip:92.4%  L0:40.4% L1:55.0% BI: 4.6%
[libx264 @ 0x7f8eb6040800] 8x8 transform intra:14.0% inter:62.0%
[libx264 @ 0x7f8eb6040800] coded y,uvDC,uvAC intra: 3.0% 10.9% 2.1% inter: 0.6% 3.8% 0.4%
[libx264 @ 0x7f8eb6040800] i16 v,h,dc,p: 85% 11%  3%  1%
[libx264 @ 0x7f8eb6040800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 13% 62%  2%  2%  2%  2%  1%  1%
[libx264 @ 0x7f8eb6040800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 25% 28%  4%  3%  4%  3%  2%  3%
[libx264 @ 0x7f8eb6040800] i8c dc,h,v,p: 79% 12%  8%  0%
[libx264 @ 0x7f8eb6040800] Weighted P-Frames: Y:47.9% UV:45.8%
[libx264 @ 0x7f8eb6040800] ref P L0: 80.9%  6.1% 11.2%  1.6%  0.2%
[libx264 @ 0x7f8eb6040800] ref B L0: 69.0% 28.0%  3.0%
[libx264 @ 0x7f8eb6040800] ref B L1: 93.6%  6.4%
[libx264 @ 0x7f8eb6040800] kb/s:538.42
MacBook:xxx StevenLiu$ rm -rf fileSequence* *.m3u8
MacBook:xxx StevenLiu$ mediafilesegmenter -A -t 1 a.ts
Dec 22 2017 08:29:16.221: Processing file /Users/StevenLiu/multimedia/ffmpeg/xxx/a.ts
Dec 22 2017 08:29:16.239: Finalized fileSequence0.ts
Dec 22 2017 08:29:16.239: segment bitrate 498.20 kbits/sec is new max
Dec 22 2017 08:29:16.240: Finalized fileSequence1.ts
Dec 22 2017 08:29:16.241: Finalized fileSequence2.ts
Dec 22 2017 08:29:16.241: segment does not contain sync frame
Dec 22 2017 08:29:16.242: Finalized fileSequence3.ts
Dec 22 2017 08:29:16.244: Finalized fileSequence4.ts
Dec 22 2017 08:29:16.244: segment bitrate  1.53 Mbits/sec is new max
Dec 22 2017 08:29:16.244: segment does not contain sync frame
Dec 22 2017 08:29:16.245: average bit rate is 561.55 kbits/sec - max file bit rate is  1.53 Mbits/sec
MacBook:xxx StevenLiu$ cat prog_index.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:0.96000,
fileSequence0.ts
#EXTINF:1.00000,
fileSequence1.ts
#EXTINF:1.00000,
fileSequence2.ts
#EXTINF:1.00000,
fileSequence3.ts
#EXTINF:0.96000,
fileSequence4.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$ cat iframe_index.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-I-FRAMES-ONLY
#EXTINF:1.92000,
#EXT-X-BYTERANGE:1316@376
fileSequence0.ts
#EXTINF:1.92000,
#EXT-X-BYTERANGE:32336@15228
fileSequence1.ts
#EXTINF:1.00000,
#EXT-X-BYTERANGE:16544@22936
fileSequence3.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$ ./ffmpeg -hide_banner -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 49 -r 25 -x264opts "scenecut=-1" -t 5 -vcodec libx264 -f mpegts a.ts
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/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, 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
File 'a.ts' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:2 -> #0:1 (ac3 (native) -> mp2 (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7f82bc0a1c00] using SAR=1/1
[libx264 @ 0x7f82bc0a1c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7f82bc0a1c00] profile High, level 4.0
Past duration 0.666664 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Output #0, mpegts, to 'a.ts':
  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.3.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p(progressive), 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.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: mp2, 48000 Hz, stereo, s16, 384 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.8.100 mp2
    Side data:
      audio service type: main
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      0kB time=00:00:01.45 bitrate=   0.0kbits/s dup=0 drop=6 speed= 2.9x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      0kB time=00:00:01.64 bitrate=   0.0kbits/s dup=0 drop=8 speed=1.64x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large      62kB time=00:00:01.93 bitrate= 261.3kbits/s dup=0 drop=10 speed=1.29x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     122kB time=00:00:02.89 bitrate= 344.6kbits/s dup=0 drop=14 speed=1.44x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     176kB time=00:00:03.85 bitrate= 374.2kbits/s dup=0 drop=18 speed= 1.5x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large     247kB time=00:00:04.33 bitrate= 467.1kbits/s dup=0 drop=21 speed=1.41x
Past duration 0.999992 too large
Past duration 0.833321 too large
Past duration 0.999992 too large
Past duration 0.833321 too large
frame=  123 fps= 21 q=-1.0 Lsize=     633kB time=00:00:05.00 bitrate=1036.2kbits/s dup=0 drop=24 speed=0.87x
video:328kB audio:235kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 12.390260%
[libx264 @ 0x7f82bc0a1c00] frame I:3     Avg QP:15.18  size: 15726
[libx264 @ 0x7f82bc0a1c00] frame P:46    Avg QP:17.19  size:  5047
[libx264 @ 0x7f82bc0a1c00] frame B:74    Avg QP:19.54  size:   768
[libx264 @ 0x7f82bc0a1c00] consecutive B-frames: 17.9%  3.3%  7.3% 71.5%
[libx264 @ 0x7f82bc0a1c00] mb I  I16..4: 95.1%  0.6%  4.2%
[libx264 @ 0x7f82bc0a1c00] mb P  I16..4: 17.7%  4.6%  0.2%  P16..4:  5.2%  0.5%  0.4%  0.0%  0.0%    skip:71.4%
[libx264 @ 0x7f82bc0a1c00] mb B  I16..4:  4.6%  0.1%  0.0%  B16..8:  0.9%  0.1%  0.0%  direct: 3.5%  skip:90.7%  L0:39.3% L1:55.7% BI: 5.0%
[libx264 @ 0x7f82bc0a1c00] 8x8 transform intra:12.8% inter:63.1%
[libx264 @ 0x7f82bc0a1c00] coded y,uvDC,uvAC intra: 2.7% 10.2% 1.9% inter: 0.6% 4.4% 0.4%
[libx264 @ 0x7f82bc0a1c00] i16 v,h,dc,p: 87% 10%  3%  1%
[libx264 @ 0x7f82bc0a1c00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 12% 62%  2%  2%  2%  2%  1%  1%
[libx264 @ 0x7f82bc0a1c00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 25% 28%  4%  3%  4%  3%  2%  3%
[libx264 @ 0x7f82bc0a1c00] i8c dc,h,v,p: 81% 12%  7%  0%
[libx264 @ 0x7f82bc0a1c00] Weighted P-Frames: Y:45.7% UV:43.5%
[libx264 @ 0x7f82bc0a1c00] ref P L0: 81.3%  5.5% 11.3%  1.6%  0.2%
[libx264 @ 0x7f82bc0a1c00] ref B L0: 68.1% 28.9%  3.0%
[libx264 @ 0x7f82bc0a1c00] ref B L1: 94.2%  5.8%
[libx264 @ 0x7f82bc0a1c00] kb/s:546.60
MacBook:xxx StevenLiu$ rm -rf fileSequence* *.m3u8
MacBook:xxx StevenLiu$ mediafilesegmenter -A -t 1 a.ts
Dec 22 2017 08:30:10.508: Processing file /Users/StevenLiu/multimedia/ffmpeg/xxx/a.ts
Dec 22 2017 08:30:10.526: Finalized fileSequence0.ts
Dec 22 2017 08:30:10.526: segment bitrate 498.20 kbits/sec is new max
Dec 22 2017 08:30:10.527: Finalized fileSequence1.ts
Dec 22 2017 08:30:10.528: segment does not contain sync frame
Dec 22 2017 08:30:10.529: Finalized fileSequence2.ts
Dec 22 2017 08:30:10.532: Finalized fileSequence3.ts
Dec 22 2017 08:30:10.539: Finalized fileSequence4.ts
Dec 22 2017 08:30:10.540: segment bitrate  1.54 Mbits/sec is new max
Dec 22 2017 08:30:10.540: segment does not contain sync frame
Dec 22 2017 08:30:10.541: average bit rate is 569.50 kbits/sec - max file bit rate is  1.54 Mbits/sec
MacBook:xxx StevenLiu$ cat prog_index.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:0.96000,
fileSequence0.ts
#EXTINF:1.00000,
fileSequence1.ts
#EXTINF:1.00000,
fileSequence2.ts
#EXTINF:1.00000,
fileSequence3.ts
#EXTINF:0.96000,
fileSequence4.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$ cat iframe_index.m3u8
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-I-FRAMES-ONLY
#EXTINF:1.96000,
#EXT-X-BYTERANGE:1316@376
fileSequence0.ts
#EXTINF:1.96000,
#EXT-X-BYTERANGE:32336@376
fileSequence2.ts
#EXTINF:0.92000,
#EXT-X-BYTERANGE:15040@30456
fileSequence3.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$

comment:46 in reply to: ↑ 43 Changed 4 months ago by stevenliu

Replying to beloko:

What's lrint(1.50) will return ?
1 or 2

MacBook:xxx StevenLiu$ cat lrint.c
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
    double value = 1.600000;
    fprintf(stdout, "value lrint = %ld\n", lrint(value));

    return 0;
}
MacBook:xxx StevenLiu$ gcc lrint.c -o lrint_test
MacBook:xxx StevenLiu$ ./lrint_test
value lrint = 2
MacBook:xxx StevenLiu$

comment:47 in reply to: ↑ 43 Changed 4 months ago by stevenliu

Replying to beloko:

What's lrint(1.50) will return ?
1 or 2

MacBook:xxx StevenLiu$ cat lrint.c
#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
    double value = 1.600000;
    fprintf(stdout, "value lrint = %ld\n", lrint(value));

    return 0;
}
MacBook:xxx StevenLiu$ gcc lrint.c -o lrint_test
MacBook:xxx StevenLiu$ ./lrint_test
value lrint = 2
MacBook:xxx StevenLiu$

comment:48 Changed 4 months ago by stevenliu

MacBook:xxx StevenLiu$ rm -rf fileSequence* *.m3u8;mediafilesegmenter -A  -t 1 a.ts;cat prog_index.m3u8 iframe_index.m3u8
Dec 22 2017 08:59:00.892: Processing file /Users/StevenLiu/multimedia/ffmpeg/xxx/a.ts
Dec 22 2017 08:59:00.907: Finalized fileSequence0.ts
Dec 22 2017 08:59:00.907: segment bitrate 496.63 kbits/sec is new max
Dec 22 2017 08:59:00.908: Finalized fileSequence1.ts
Dec 22 2017 08:59:00.912: Finalized fileSequence2.ts
Dec 22 2017 08:59:00.912: segment does not contain sync frame
Dec 22 2017 08:59:00.913: Finalized fileSequence3.ts
Dec 22 2017 08:59:00.915: Finalized fileSequence4.ts
Dec 22 2017 08:59:00.915: segment bitrate  1.79 Mbits/sec is new max
Dec 22 2017 08:59:00.916: average bit rate is 641.95 kbits/sec - max file bit rate is  1.79 Mbits/sec
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXTINF:0.96000,
fileSequence0.ts
#EXTINF:1.00000,
fileSequence1.ts
#EXTINF:1.00000,
fileSequence2.ts
#EXTINF:1.00000,
fileSequence3.ts
#EXTINF:0.96000,
fileSequence4.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:1
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-I-FRAMES-ONLY
#EXTINF:1.52000,
#EXT-X-BYTERANGE:1316@376
fileSequence0.ts
#EXTINF:1.52000,
#EXT-X-BYTERANGE:32712@11092
fileSequence1.ts
#EXTINF:1.52000,
#EXT-X-BYTERANGE:29704@752
fileSequence3.ts
#EXTINF:0.28000,
#EXT-X-BYTERANGE:58468@81968
fileSequence4.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$
MacBook:xxx StevenLiu$
MacBook:xxx StevenLiu$
MacBook:xxx StevenLiu$ rm -rf fileSequence* *.m3u8;mediafilesegmenter -A -start-segments-with-iframe  -t 1 a.ts;cat prog_index.m3u8 iframe_index.m3u8
Dec 22 2017 08:59:18.230: Processing file /Users/StevenLiu/multimedia/ffmpeg/xxx/a.ts
Dec 22 2017 08:59:18.245: Key frame distance of 1.52 exceeds target duration; target duration will be adjusted
Dec 22 2017 08:59:18.246: Finalized fileSequence0.ts
Dec 22 2017 08:59:18.246: segment bitrate 370.06 kbits/sec is new max
Dec 22 2017 08:59:18.247: Key frame distance of 1.52 exceeds target duration; target duration will be adjusted
Dec 22 2017 08:59:18.247: Finalized fileSequence1.ts
Dec 22 2017 08:59:18.249: Key frame distance of 1.52 exceeds target duration; target duration will be adjusted
Dec 22 2017 08:59:18.249: Finalized fileSequence2.ts
Dec 22 2017 08:59:18.249: segment bitrate 750.02 kbits/sec is new max
Dec 22 2017 08:59:18.250: Finalized fileSequence3.ts
Dec 22 2017 08:59:18.250: segment bitrate  1.17 Mbits/sec is new max
Dec 22 2017 08:59:18.251: average bit rate is 640.42 kbits/sec - max file bit rate is  1.17 Mbits/sec
#EXTM3U
#EXT-X-TARGETDURATION:2
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-INDEPENDENT-SEGMENTS
#EXTINF:1.52000,
fileSequence0.ts
#EXTINF:1.52000,
fileSequence1.ts
#EXTINF:1.52000,
fileSequence2.ts
#EXTINF:0.36000,
fileSequence3.ts
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-TARGETDURATION:2
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-I-FRAMES-ONLY
#EXTINF:1.52000,
#EXT-X-BYTERANGE:1316@376
fileSequence0.ts
#EXTINF:1.52000,
#EXT-X-BYTERANGE:32712@376
fileSequence1.ts
#EXTINF:1.52000,
#EXT-X-BYTERANGE:29704@376
fileSequence2.ts
#EXTINF:0.28000,
#EXT-X-BYTERANGE:58468@376
fileSequence3.ts
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$

comment:49 Changed 4 months ago by beloko

Perhaps rounding #EXTINF values like this in the audio playlist is more accurate.

#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
    double extinf = 4.010667;    
    extinf = round(extinf * 10.0) / 10.0;  

    fprintf(stdout, "value #EXTINF: %f\n", extinf);

    return 0;
}

4.010667 becomes 4.00000
3.989333 becomes 4.00000
1.520000 becomes 1.50000

comment:50 follow-up: Changed 4 months ago by j_karthic

@beloko
After yesterday's push to ffmpeg the target duration should now match. Could you please test the latest version and confirm if your issue is resolved? Then we can close this ticket.

Last edited 4 months ago by j_karthic (previous) (diff)

comment:51 in reply to: ↑ 50 Changed 4 months ago by stevenliu

Replying to j_karthic:

@beloko
After yesterday's push to ffmpeg the target duration should now match. Could you please test the latest version and confirm if your issue is resolved? Then we can close this ticket.

No, that patch have not fix this ticket, That patch just make EXT-X-TARGETDURATION lrint EXTINF, because cannot fix my problem,

when process 4k / 8k / VR media file, when the fps = 120, it can reproduce the problem, you can find lots of the 120fps file on google.

comment:52 follow-up: Changed 4 months ago by beloko

I encoded a 120fps video file.

Here is my FFMPEG command line processed :

C:\Users\Beloko\Desktop\FFMPEG>ffmpeg.exe -i "http://120hz.net/hypermatrix/120fpsvideo/bf.mp4" -loglevel verbose -threads 0 -c:a aac -sn -c:v libx264 -x264opts scenecut=-1 -force_key_frames "expr:gte(t,n_forced*4)" -r 120 -min_seg_duration 4000000 -window_size 99999 -t 60 -hls_playlist 1 "C:\inetpub\wwwroot\fmp4_x264\bf.mpd"
ffmpeg version N-89568-ge3b2c85-Reino Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.1.0 (GCC)
  configuration: --arch=x86_64 --target-os=mingw32 --cross-prefix=/home/beloko/FFMpeg_Builder/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-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-x86_64/x86_64-w64-mingw32 --enable-nonfree --enable-decklink --enable-libfdk-aac
  libavutil      56.  6.100 / 56.  6.100
  libavcodec     58.  8.100 / 58.  8.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  7.100 /  7.  7.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 @ 0000027bbbaafd40] Reinit context to 1920x1088, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://120hz.net/hypermatrix/120fpsvideo/bf.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2013-08-23T06:51:40.000000Z
    encoder         : HandBrake 0.9.9 2013052900
  Duration: 00:00:28.65, start: 0.000000, bitrate: 30163 kb/s
    Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(tv, bt709, left), 1920x1080 (1920x1088) [SAR 1:1 DAR 16:9], 29917 kb/s, 120 fps, 120 tbr, 90k tbn, 240 tbc (default)
    Metadata:
      creation_time   : 2013-08-23T06:51:40.000000Z
      encoder         : JVT/AVC Coding
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 160 kb/s (default)
    Metadata:
      creation_time   : 2013-08-23T06:51:40.000000Z
    Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, mono, fltp, 96 kb/s
    Metadata:
      creation_time   : 2013-08-23T06:51:40.000000Z
    Side data:
      audio service type: main
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[graph_1_in_0_1 @ 0000027bbc0cbd20] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x4
[h264 @ 0000027bbba9a760] Reinit context to 1920x1088, pix_fmt: yuv420p
[graph 0 input from stream 0:0 @ 0000027bbe30ee20] w:1920 h:1080 pixfmt:yuv420p tb:1/90000 fr:120/1 sar:1/1 sws_param:flags=2
[libx264 @ 0000027bbbaedea0] using SAR=1/1
[libx264 @ 0000027bbbaedea0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0000027bbbaedea0] profile High, level 5.1
[libx264 @ 0000027bbbaedea0] 264 - core 148 r2795M aaa9aa8 - 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=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=-2 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=250 keyint_min=25 scenecut=0 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
[dash @ 0000027bbbaf05a0] No bit rate set for stream 0
[dash @ 0000027bbbaf05a0] Opening 'init-stream0.m4s' for writing
[mp4 @ 0000027bbfca5e40] Empty MOOV enabled; disabling automatic bitstream filtering
[dash @ 0000027bbbaf05a0] Representation 0 init segment will be written to: init-stream0.m4s
[dash @ 0000027bbbaf05a0] Opening 'init-stream1.m4s' for writing
[mp4 @ 0000027bbfce86c0] Empty MOOV enabled; disabling automatic bitstream filtering
[dash @ 0000027bbbaf05a0] Representation 1 init segment will be written to: init-stream1.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
Bandwidth info not available, set audio and video bitrates
[dash @ 0000027bbbaf05a0] Manifest written to: C:\inetpub\wwwroot\fmp4_x264\bf.mpd
Output #0, dash, to 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : Lavf58.3.100
    Stream #0:0(und): Video: h264 (libx264), 1 reference frame, yuv420p(left), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 120 fps, 15360 tbn, 120 tbc (default)
    Metadata:
      creation_time   : 2013-08-23T06:51:40.000000Z
      encoder         : Lavc58.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC), 48000 Hz, mono, fltp, delay 1024, 69 kb/s (default)
    Metadata:
      creation_time   : 2013-08-23T06:51:40.000000Z
      encoder         : Lavc58.8.100 aac
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00001.m4s.tmp' for writing7x
[dash @ 0000027bbbaf05a0] Representation 0 media segment 2 written to: chunk-stream0-00001.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00001.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 2 written to: chunk-stream1-00001.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00002.m4s.tmp' for writing8x
[dash @ 0000027bbbaf05a0] Representation 0 media segment 3 written to: chunk-stream0-00002.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00002.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 3 written to: chunk-stream1-00002.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00003.m4s.tmp' for writing5x
[dash @ 0000027bbbaf05a0] Representation 0 media segment 4 written to: chunk-stream0-00003.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00003.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 4 written to: chunk-stream1-00003.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00004.m4s.tmp' for writing1x
[dash @ 0000027bbbaf05a0] Representation 0 media segment 5 written to: chunk-stream0-00004.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00004.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 5 written to: chunk-stream1-00004.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00005.m4s.tmp' for writing9x
[dash @ 0000027bbbaf05a0] Representation 0 media segment 6 written to: chunk-stream0-00005.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00005.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 6 written to: chunk-stream1-00005.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00006.m4s.tmp' for writing7x
[dash @ 0000027bbbaf05a0] Representation 0 media segment 7 written to: chunk-stream0-00006.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00006.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 7 written to: chunk-stream1-00006.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00007.m4s.tmp' for writing3x
[dash @ 0000027bbbaf05a0] Representation 0 media segment 8 written to: chunk-stream0-00007.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00007.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 8 written to: chunk-stream1-00007.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
No more output streams to write to, finishing.:28.60 bitrate=N/A speed=0.223x
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream0-00008.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 0 media segment 9 written to: chunk-stream0-00008.m4s
[dash @ 0000027bbbaf05a0] Opening 'chunk-stream1-00008.m4s.tmp' for writing
[dash @ 0000027bbbaf05a0] Representation 1 media segment 9 written to: chunk-stream1-00008.m4s
[dash @ 0000027bbbaf05a0] Opening 'C:\inetpub\wwwroot\fmp4_x264\bf.mpd.tmp' for writing
EXT-X-MEDIA-SEQUENCE:1
    Last message repeated 1 times
frame= 3435 fps= 26 q=-1.0 Lsize=N/A time=00:00:28.65 bitrate=N/A speed=0.221x
video:40967kB audio:249kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (http://120hz.net/hypermatrix/120fpsvideo/bf.mp4):
  Input stream #0:0 (video): 3435 packets read (107048925 bytes); 3435 frames decoded;
  Input stream #0:1 (audio): 1343 packets read (573303 bytes); 1342 frames decoded (1374208 samples);
  Input stream #0:2 (audio): 2 packets read (768 bytes);
  Total: 4780 packets (107622996 bytes) demuxed
Output file #0 (C:\inetpub\wwwroot\fmp4_x264\bf.mpd):
  Output stream #0:0 (video): 3435 frames encoded; 3435 packets muxed (41950678 bytes);
  Output stream #0:1 (audio): 1342 frames encoded (1374208 samples); 1343 packets muxed (254973 bytes);
  Total: 4778 packets (42205651 bytes) muxed
[libx264 @ 0000027bbbaedea0] frame I:15    Avg QP:23.98  size: 56984
[libx264 @ 0000027bbbaedea0] frame P:1411  Avg QP:27.05  size: 18602
[libx264 @ 0000027bbbaedea0] frame B:2009  Avg QP:29.40  size:  7391
[libx264 @ 0000027bbbaedea0] consecutive B-frames: 10.3% 29.9% 15.5% 44.3%
[libx264 @ 0000027bbbaedea0] mb I  I16..4: 19.1% 67.6% 13.2%
[libx264 @ 0000027bbbaedea0] mb P  I16..4:  9.2% 14.1%  1.1%  P16..4: 35.5%  4.6%  1.8%  0.0%  0.0%    skip:33.7%
[libx264 @ 0000027bbbaedea0] mb B  I16..4:  0.9%  1.1%  0.1%  B16..8: 37.2%  2.4%  0.3%  direct: 0.7%  skip:57.3%  L0:43.3% L1:55.2% BI: 1.4%
[libx264 @ 0000027bbbaedea0] 8x8 transform intra:57.6% inter:86.6%
[libx264 @ 0000027bbbaedea0] coded y,uvDC,uvAC intra: 20.9% 20.1% 0.7% inter: 6.6% 4.5% 0.0%
[libx264 @ 0000027bbbaedea0] i16 v,h,dc,p: 28% 39% 11% 22%
[libx264 @ 0000027bbbaedea0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 22% 23% 36%  3%  3%  3%  5%  2%  3%
[libx264 @ 0000027bbbaedea0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 24% 28% 21%  4%  5%  5%  6%  3%  4%
[libx264 @ 0000027bbbaedea0] i8c dc,h,v,p: 71% 17% 12%  1%
[libx264 @ 0000027bbbaedea0] Weighted P-Frames: Y:1.3% UV:0.6%
[libx264 @ 0000027bbbaedea0] ref P L0: 64.7% 19.3% 11.4%  4.4%  0.1%
[libx264 @ 0000027bbbaedea0] ref B L0: 89.9%  8.5%  1.6%
[libx264 @ 0000027bbbaedea0] ref B L1: 98.1%  1.9%
[libx264 @ 0000027bbbaedea0] kb/s:11724.01
[aac @ 0000027bbbaa65e0] Qavg: 286.305

Here is the video playlist content :

C:\Users\Beloko\Desktop\FFMPEG>type "C:\inetpub\wwwroot\fmp4_x264\media_0.m3u8"
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream0.m4s"
#EXTINF:4.000000,
chunk-stream0-00001.m4s
#EXTINF:4.000000,
chunk-stream0-00002.m4s
#EXTINF:4.000000,
chunk-stream0-00003.m4s
#EXTINF:4.000000,
chunk-stream0-00004.m4s
#EXTINF:4.000000,
chunk-stream0-00005.m4s
#EXTINF:4.000000,
chunk-stream0-00006.m4s
#EXTINF:4.000000,
chunk-stream0-00007.m4s
#EXTINF:0.625000,
chunk-stream0-00008.m4s
#EXT-X-ENDLIST

And here is the audio playlist content :

C:\Users\Beloko\Desktop\FFMPEG>type "C:\inetpub\wwwroot\fmp4_x264\media_1.m3u8"
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:3.989333,
chunk-stream1-00001.m4s
#EXTINF:4.010667,
chunk-stream1-00002.m4s
#EXTINF:3.989333,
chunk-stream1-00003.m4s
#EXTINF:4.010667,
chunk-stream1-00004.m4s
#EXTINF:3.989333,
chunk-stream1-00005.m4s
#EXTINF:4.010667,
chunk-stream1-00006.m4s
#EXTINF:3.989333,
chunk-stream1-00007.m4s
#EXTINF:0.661333,
chunk-stream1-00008.m4s
#EXT-X-ENDLIST

The #EXT-X-TARGETDURATION: has the same value in video and audio playlist.
This solves the "MUST" fix issue about "Different target durations detected" reported by the Apple mediastreamvalidator tool.

Belokos-Mac:~ beloko$ mediastreamvalidator http://192.168.1.3/fmp4_x264/master.m3u8
mediastreamvalidator: Version 1.2(170822)

[/fmp4_x264/master.m3u8] Started root playlist download
[media_0.m3u8] Started media playlist download
[media_1.m3u8] Started media playlist download
[media_1.m3u8] All media files delivered and have end tag, stopping
[media_0.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_0.m3u8
--------------------------------------------------------------------------------
Processed 8 out of 8 segments
Average segment duration: 3.578125
Total segment bitrates (all discontinuities): average: 11736.06 kb/s, max: 14084.05 kb/s
Playlist max bitrate: 14158.370000 kb/s
Audio Group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 8 of 8, duration: 28.625 sec, average: 11736.06 kb/s, max: 14084.05 kb/s
Track ID: 1
Video Codec: avc1
Video profile: High
Video level: 5.1
Video resolution: 1920x1080
Video average IDR interval: 2.000000, Standard deviation: 0.083333
Video frame rate: 120.000

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 8 out of 8 segments
Average segment duration: 3.581333
Total segment bitrates (all discontinuities): average: 73.11 kb/s, max: 74.32 kb/s
Rendition group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 8 of 8, duration: 28.651 sec, average: 73.11 kb/s, max: 74.32 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 48000 Hz
Audio channels: 1
Audio channel layout: Mono

However segments duration for chunk-stream1-00002.m4s, chunk-stream1-00004.m4s and chunk-stream1-00006.m4s exceed the #EXT-X-TARGETDURATION limit in the audio playlist.

I think #EXTINF values could be rounded like this :

#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
    double targetduration = 4.000000;
    double extinf = 4.010667;    
    
    if(extinf > targetduration)
    { extinf = round(extinf * 10.0) / 10.0; }  

    fprintf(stdout, "value #EXTINF: %f\n", extinf);

    return 0;
}

This is what Apple does to produce HLS streams with variant audio playlists to cover the RFC 8216's requirements.

Also I tested with 1 second segments and 10 seconds segments. And the difference between "extinf" and "targetduration" never exceed 0.100000 seconds.

. If -min_seg_duration 1000000 in FFMPEG's command line
then targetduraion = 1.000000 and max(extinf[]) = 1.002667.

. If -min_seg_duration 10000000 in FFMPEG's command line
then targetduraion = 10.000000 and max(extinf[]) = 10.005333.

Result is safe and comply with "The EXT-X-TARGETDURATION tag specifies the maximum Media Segment duration. The EXTINF duration of each Media Segment in the Playlist file, when rounded to the nearest integer, MUST be less than or equal to the target duration; longer segments can trigger playback stalls or other errors."

It said the #EXTINF can be rounded. But it must be less than or equal to the #EXT-X-TARGETDURATION.

Last edited 4 months ago by beloko (previous) (diff)

comment:53 Changed 4 months ago by stevenliu

./ffmpeg -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 150 -r 100 -x264opts "scenecut=-1" -f dash -min_seg_duration 1000000 -window_size 99999 -t 5 -hls_playlist 1 output_Steven.mpd

scene: cut some movies, and concat to a movie use the cut segments. then the keyframes interval is not same in the segments.


MacBook:xxx StevenLiu$ ./ffmpeg -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 150 -r 100 -x264opts "scenecut=-1" -f dash -min_seg_duration 1000000 -window_size 99999 -t 5 -hls_playlist 1 output_Steven.mpd
ffmpeg version N-89569-gd2a2bc9a9f Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration: --enable-libass --enable-opengl --enable-libx264 --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local --enable-libopencv --enable-libtesseract --enable-libspeex --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox
  libavutil      56.  6.100 / 56.  6.100
  libavcodec     58.  8.100 / 58.  8.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  7.100 /  7.  7.100
  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 '/Users/StevenLiu/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, 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) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x7fc091079e00] using SAR=1/1
[libx264 @ 0x7fc091079e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
[libx264 @ 0x7fc091079e00] profile High, level 5.1
[libx264 @ 0x7fc091079e00] 264 - core 133 r2334M a3ac64b - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - 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=-2 threads=6 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=150 keyint_min=15 scenecut=0 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
[aac @ 0x7fc091028800] Using a PCE to encode channel layout
[dash @ 0x7fc092001200] No bit rate set for stream 0
[dash @ 0x7fc092001200] Opening 'init-stream0.m4s' for writing
[dash @ 0x7fc092001200] Opening 'init-stream1.m4s' for writing
[dash @ 0x7fc092001200] Opening 'output_Steven.mpd.tmp' for writing
Bandwidth info not available, set audio and video bitrates
Output #0, dash, to 'output_Steven.mpd':
  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.3.100
    Stream #0:0(und): Video: h264 (libx264), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 100 fps, 12800 tbn, 100 tbc (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:39.000000Z
      handler_name    : GPAC ISO Video Handler
      encoder         : Lavc58.8.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(und): Audio: aac (LC), 48000 Hz, 5.1(side), fltp, 394 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16T17:44:42.000000Z
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc58.8.100 aac
    Side data:
      audio service type: main
[dash @ 0x7fc092001200] Opening 'chunk-stream0-00001.m4s.tmp' for writingdrop=0 speed=0.503x
[dash @ 0x7fc092001200] Opening 'chunk-stream1-00001.m4s.tmp' for writing
[dash @ 0x7fc092001200] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7fc092001200] Opening 'chunk-stream0-00002.m4s.tmp' for writingdrop=0 speed=0.569x
[dash @ 0x7fc092001200] Opening 'chunk-stream1-00002.m4s.tmp' for writing
[dash @ 0x7fc092001200] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7fc092001200] Opening 'chunk-stream0-00003.m4s.tmp' for writingdrop=0 speed=0.491x
[dash @ 0x7fc092001200] Opening 'chunk-stream1-00003.m4s.tmp' for writing
[dash @ 0x7fc092001200] Opening 'output_Steven.mpd.tmp' for writing
[dash @ 0x7fc092001200] Opening 'chunk-stream0-00004.m4s.tmp' for writing
[dash @ 0x7fc092001200] Opening 'chunk-stream1-00004.m4s.tmp' for writing
[dash @ 0x7fc092001200] Opening 'output_Steven.mpd.tmp' for writing
frame=  500 fps= 44 q=-1.0 Lsize=N/A time=00:00:05.01 bitrate=N/A dup=354 drop=0 speed=0.444x
video:365kB audio:241kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x7fc091079e00] frame I:4     Avg QP:16.78  size: 20153
[libx264 @ 0x7fc091079e00] frame P:150   Avg QP:20.52  size:  1625
[libx264 @ 0x7fc091079e00] frame B:346   Avg QP:18.64  size:   141
[libx264 @ 0x7fc091079e00] consecutive B-frames:  5.4%  5.2%  5.4% 84.0%
[libx264 @ 0x7fc091079e00] mb I  I16..4: 92.8%  3.1%  4.1%
[libx264 @ 0x7fc091079e00] mb P  I16..4:  6.0%  1.9%  0.1%  P16..4:  2.5%  0.2%  0.2%  0.0%  0.0%    skip:89.2%
[libx264 @ 0x7fc091079e00] mb B  I16..4:  0.2%  0.0%  0.0%  B16..8:  0.6%  0.0%  0.0%  direct: 0.2%  skip:99.0%  L0:33.2% L1:65.7% BI: 1.1%
[libx264 @ 0x7fc091079e00] 8x8 transform intra:17.9% inter:71.0%
[libx264 @ 0x7fc091079e00] coded y,uvDC,uvAC intra: 3.2% 11.7% 2.2% inter: 0.2% 0.7% 0.1%
[libx264 @ 0x7fc091079e00] i16 v,h,dc,p: 83% 12%  3%  1%
[libx264 @ 0x7fc091079e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 11% 62%  1%  2%  1%  2%  1%  1%
[libx264 @ 0x7fc091079e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 22% 28%  4%  4%  4%  4%  3%  4%
[libx264 @ 0x7fc091079e00] i8c dc,h,v,p: 77% 14%  9%  0%
[libx264 @ 0x7fc091079e00] Weighted P-Frames: Y:22.7% UV:22.0%
[libx264 @ 0x7fc091079e00] ref P L0: 83.9%  4.5%  9.7%  1.5%  0.4%
[libx264 @ 0x7fc091079e00] ref B L0: 73.8% 24.9%  1.3%
[libx264 @ 0x7fc091079e00] ref B L1: 97.2%  2.8%
[libx264 @ 0x7fc091079e00] kb/s:597.11
[aac @ 0x7fc091028800] Qavg: 190.813
MacBook:xxx StevenLiu$ cat media_1.m3u8 media_0.m3u8
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:1
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:1.493333,
chunk-stream1-00001.m4s
#EXTINF:1.493333,
chunk-stream1-00002.m4s
#EXTINF:1.493333,
chunk-stream1-00003.m4s
#EXTINF:0.520000,
chunk-stream1-00004.m4s
#EXT-X-ENDLIST
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:2
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream0.m4s"
#EXTINF:1.500000,
chunk-stream0-00001.m4s
#EXTINF:1.500000,
chunk-stream0-00002.m4s
#EXTINF:1.500000,
chunk-stream0-00003.m4s
#EXTINF:0.500000,
chunk-stream0-00004.m4s
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$

I think use beloko's suggestion way maybe better. bacause just round the origin value 1.493333 and 1.500000 will have different result, and if lrint(value * 10.0) / 10.0, the result should be: lrint(14.93333) / 10.0 and lrint(15.00000)/10.0, then the result is 1.5 and 1.5, so , it maybe better.

comment:54 in reply to: ↑ 52 Changed 4 months ago by j_karthic

Replying to beloko:

However segments duration for chunk-stream1-00002.m4s, chunk-stream1-00004.m4s and chunk-stream1-00006.m4s exceed the #EXT-X-TARGETDURATION limit in the audio playlist.

Why is that an issue? Are you observing any players/validators complaining about it? It is perfectly fine as per the spec. That is what last discussion was all about. EXT-X-TARGETDURATION can be lesser than EXTINF duration, as long as the round(EXTINF duration)<= EXT-X-TARGETDURATION.

I think #EXTINF values could be rounded like this :

#include <stdio.h>
#include <math.h>

int main(int argc, char *argv[])
{
    double targetduration = 4.000000;
    double extinf = 4.010667;    
    
    if(extinf > targetduration)
    { extinf = round(extinf * 10.0) / 10.0; }  

    fprintf(stdout, "value #EXTINF: %f\n", extinf);

    return 0;
}

This is what Apple does to produce HLS streams with variant audio playlists to cover the RFC 8216's requirements.

Also I tested with 1 second segments and 10 seconds segments. And the difference between "extinf" and "targetduration" never exceed 0.100000 seconds.

. If -min_seg_duration 1000000 in FFMPEG's command line
then targetduraion = 1.000000 and max(extinf[]) = 1.002667.

. If -min_seg_duration 10000000 in FFMPEG's command line
then targetduraion = 10.000000 and max(extinf[]) = 10.005333.

Result is safe and comply with "The EXT-X-TARGETDURATION tag specifies the maximum Media Segment duration. The EXTINF duration of each Media Segment in the Playlist file, when rounded to the nearest integer, MUST be less than or equal to the target duration; longer segments can trigger playback stalls or other errors."

It said the #EXTINF can be rounded. But it must be less than or equal to the #EXT-X-TARGETDURATION.

That was the definition for EXT-X-TARGETDURATION. It says round(EXTINF duration)<= EXT-X-TARGETDURATION. It doesn't say that rounded EXTINF duration must be specified in the playlist. Here is the definition for EXTINF duration.

4.3.2.1.  EXTINF

   The EXTINF tag specifies the duration of a Media Segment.  It applies
   only to the next Media Segment.  This tag is REQUIRED for each Media
   Segment.  Its format is:

   #EXTINF:<duration>,[<title>]

   where duration is a decimal-floating-point or decimal-integer number
   (as described in Section 4.2) that specifies the duration of the
   Media Segment in seconds.  Generally, durations SHOULD be decimal-
   floating-point, with enough accuracy to avoid perceptible error when
   segment durations are accumulated.  If the compatibility version
   number is less than 3, durations MUST be integers.  Durations that
   are reported as integers SHOULD be rounded to the nearest integer.
   The remainder of the line following the comma is an optional human-
   readable informative title of the Media Segment expressed as raw
   UTF-8 text.

It suggests providing enough accuracy to EXTINF duration. If you really want those durations to be same, we can round it off to the nearest integers and specify it as an integer instead of floating point, to be in line with the spec. Maybe we can add an option for round_durations similar to the one available in hlsenc.
But I think the current floating point duration is still legal, and most popular players should be fine with it.

comment:55 Changed 4 months ago by beloko

Yes many thanks for the #EXT-X-DURATION fix.
Now it satisfies the HLS validation tool used by the Apple Store team.
And it doesn't produce issue with most populars HLS players.


Fragmented MP4 protocol is only available on new mobile devices and operating systems. This means all HLS players supporting fMP4 (HLS version 6) should support the AVC high profile (since HLS version 4) and the #EXTINF floating point duration (since HLS version 3).

So it doesn't require to round all #EXTINF duration into an integer.


But no segments duration in a same playlist should exceed the #EXT-X-DURATION. This means audio segments shoud be cut earlier in certain cases.

Currently Dash segmenter produce audio playlist like this :

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:3.989333,
chunk-stream1-00001.m4s
#EXTINF:4.010667,
chunk-stream1-00002.m4s
#EXTINF:3.989333,
chunk-stream1-00003.m4s
#EXTINF:4.010667,
chunk-stream1-00004.m4s
#EXTINF:3.989333,
chunk-stream1-00005.m4s
#EXT-X-ENDLIST

4.010667 seconds exceed 4 seconds.
But 0.010667 seconds is peanuts.

That's why I suggest to round down only #EXTINF: values exceeding the #EXT-X-TARGETDURATION.

Then we get something like this :

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:3.989333,
chunk-stream1-00001.m4s
#EXTINF:4.000000,
chunk-stream1-00002.m4s
#EXTINF:3.989333,
chunk-stream1-00003.m4s
#EXTINF:4.000000,
chunk-stream1-00004.m4s
#EXTINF:3.989333,
chunk-stream1-00005.m4s
#EXT-X-ENDLIST

However it could be better to get something like this :

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:3.989333,
chunk-stream1-00001.m4s
#EXTINF:3.989333,
chunk-stream1-00002.m4s
#EXTINF:3.989333,
chunk-stream1-00003.m4s
#EXTINF:3.989333,
chunk-stream1-00004.m4s
#EXTINF:3.989333,
chunk-stream1-00005.m4s
#EXT-X-ENDLIST

In this Apple's HLS sample the audio streams aren't cut exactly each 6 seconds long. But around 6 seconds. Before few milliseconds. After few milliseconds.

https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8

I produced an HLS stream with FFMPEG and modified the .m3u8 audio playlist manually and tested the full movie with fixed #EXTINF value. The playback was succesfull with Apple's video players and Windows Edge browser.


Finally I don't understand why you're using this command line to produce an HLS video stream.

ffmpeg -hide_banner -i ~/bbb_sunflower_1080p_30fps_normal.mp4 -g 150 -r 100 -x264opts "scenecut=-1" -f dash -min_seg_duration 1000000 -window_size 99999 -t 5 -hls_playlist 1 output_Steven.mpd

If your framerate is 100 and your fixed segment duration 1.000000 second.
Your fixed GOP size should be 100 * 1 = 100.
And your command line with this two parameters : -g 100 -keyint_min 100

It should produce the same duration cut as -force_key_frames "expr:gte(t,n_forced*1)" parameter.

Is it a particular need or is there a special advantage to not create an IFrame at regular durations ?

comment:56 follow-up: Changed 4 months ago by stevenliu

If you don't have encoder, just remux stream or file to hls, then the GOP size cannot decide by you, for example, get a video from me, I ask you remux it to HLS, If transcode or modify the key frame interval I need cost lots of CPU, but i don't have lots of CPU, only used for IO ,for example CDN

Download some video files, and just use -c copy to make HLS, maybe you can understand that.

Last edited 4 months ago by stevenliu (previous) (diff)

comment:57 Changed 4 months ago by beloko

Your FFMPEG command gives me an idea : use a little bit shorter fixed GOP size than the expected duration. About few milliseconds.

ffmpeg.exe -i "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_normal.mp4" -loglevel verbose -threads 0 -c:a aac -sn -c:v libx264 -x264opts scenecut=-1 -g 99 -keyint_min 99 -r 25 -min_seg_duration 3900000 -window_size 99999 -hls_playlist 1 "C:\inetpub\wwwroot\fmp4_x264\big_bunny.mpd"

My expected duration is 4 seconds and my framerate is 25 pictures per seconds.
So 25 * 4 = 100.

Then I set -g 99 -keyint_min 99 instead of -g 100 -keyint_min 100.
Because 1 picture = 0.040000 seconds.

And its already more than 0.010667 seconds.
(4.010667 - 4.000000 = 0.010667)

My video playlist content is :

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream0.m4s"
#EXTINF:3.960000,
chunk-stream0-00001.m4s
#EXTINF:3.960000,
chunk-stream0-00002.m4s
#EXTINF:3.960000,
chunk-stream0-00003.m4s
#EXTINF:3.960000,
chunk-stream0-00004.m4s
#EXTINF:3.960000,
chunk-stream0-00005.m4s
#EXTINF:3.960000,
chunk-stream0-00006.m4s
#EXTINF:3.960000,
chunk-stream0-00007.m4s
#EXTINF:3.960000,
chunk-stream0-00008.m4s
#EXTINF:3.960000,
chunk-stream0-00009.m4s
#EXTINF:3.960000,
chunk-stream0-00010.m4s
#EXTINF:3.960000,
chunk-stream0-00011.m4s
#EXTINF:3.960000,
chunk-stream0-00012.m4s
#EXTINF:3.960000,
chunk-stream0-00013.m4s
#EXTINF:3.960000,
chunk-stream0-00014.m4s
#EXTINF:3.960000,
chunk-stream0-00015.m4s
#EXTINF:3.960000,
chunk-stream0-00016.m4s
#EXTINF:3.960000,
chunk-stream0-00017.m4s
#EXTINF:3.960000,
chunk-stream0-00018.m4s
#EXTINF:3.960000,
chunk-stream0-00019.m4s
#EXTINF:3.960000,
chunk-stream0-00020.m4s
...
#EXTINF:3.960000,
chunk-stream0-00150.m4s
#EXTINF:3.960000,
chunk-stream0-00151.m4s
#EXTINF:3.960000,
chunk-stream0-00152.m4s
#EXTINF:3.960000,
chunk-stream0-00153.m4s
#EXTINF:3.960000,
chunk-stream0-00154.m4s
#EXTINF:3.960000,
chunk-stream0-00155.m4s
#EXTINF:3.960000,
chunk-stream0-00156.m4s
#EXTINF:3.960000,
chunk-stream0-00157.m4s
#EXTINF:3.960000,
chunk-stream0-00158.m4s
#EXTINF:3.960000,
chunk-stream0-00159.m4s
#EXTINF:3.960000,
chunk-stream0-00160.m4s
#EXTINF:1.080000,
chunk-stream0-00161.m4s
#EXT-X-ENDLIST

My audio playlist content is :

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:4
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream1.m4s"
#EXTINF:3.882667,
chunk-stream1-00001.m4s
#EXTINF:3.968000,
chunk-stream1-00002.m4s
#EXTINF:3.968000,
chunk-stream1-00003.m4s
#EXTINF:3.946667,
chunk-stream1-00004.m4s
#EXTINF:3.968000,
chunk-stream1-00005.m4s
#EXTINF:3.946667,
chunk-stream1-00006.m4s
#EXTINF:3.968000,
chunk-stream1-00007.m4s
#EXTINF:3.968000,
chunk-stream1-00008.m4s
#EXTINF:3.946667,
chunk-stream1-00009.m4s
#EXTINF:3.968000,
chunk-stream1-00010.m4s
#EXTINF:3.968000,
chunk-stream1-00011.m4s
#EXTINF:3.946667,
chunk-stream1-00012.m4s
#EXTINF:3.968000,
chunk-stream1-00013.m4s
#EXTINF:3.946667,
chunk-stream1-00014.m4s
#EXTINF:3.968000,
chunk-stream1-00015.m4s
#EXTINF:3.968000,
chunk-stream1-00016.m4s
#EXTINF:3.946667,
chunk-stream1-00017.m4s
#EXTINF:3.968000,
chunk-stream1-00018.m4s
#EXTINF:3.968000,
chunk-stream1-00019.m4s
#EXTINF:3.946667,
chunk-stream1-00020.m4s
...
#EXTINF:3.946667,
chunk-stream1-00150.m4s
#EXTINF:3.968000,
chunk-stream1-00151.m4s
#EXTINF:3.968000,
chunk-stream1-00152.m4s
#EXTINF:3.946667,
chunk-stream1-00153.m4s
#EXTINF:3.968000,
chunk-stream1-00154.m4s
#EXTINF:3.968000,
chunk-stream1-00155.m4s
#EXTINF:3.946667,
chunk-stream1-00156.m4s
#EXTINF:3.968000,
chunk-stream1-00157.m4s
#EXTINF:3.946667,
chunk-stream1-00158.m4s
#EXTINF:3.968000,
chunk-stream1-00159.m4s
#EXTINF:3.968000,
chunk-stream1-00160.m4s
#EXTINF:0.608000,
chunk-stream1-00161.m4s
#EXT-X-ENDLIST

All segments durations in video and audio playlists are lower than the target duration. And the Apple mediastreamvalidator doesn't complain.

Belokos-Mac:~ beloko$ mediastreamvalidator http://192.168.1.3/fmp4_x264/master.m3u8
mediastreamvalidator: Version 1.2(170822)

[/fmp4_x264/master.m3u8] Started root playlist download
[media_0.m3u8] Started media playlist download
[media_1.m3u8] Started media playlist download
[media_1.m3u8] parsed media segment count: 75, duration: 300.885
[media_1.m3u8] parsed media segment count: 151, duration: 601.856
Can't deal with multiple sample timings per sample buffer
Can't deal with multiple sample timings per sample buffer
[media_1.m3u8] All media files delivered and have end tag, stopping
[media_0.m3u8] parsed media segment count: 75, duration: 300.960
[media_0.m3u8] parsed media segment count: 151, duration: 601.920
[media_0.m3u8] All media files delivered and have end tag, stopping

--------------------------------------------------------------------------------
media_0.m3u8
--------------------------------------------------------------------------------
Processed 161 out of 161 segments
Average segment duration: 3.942112
Total segment bitrates (all discontinuities): average: 3080.70 kb/s, max: 7709.42 kb/s
Playlist max bitrate: 8111.880000 kb/s
Audio Group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 161 of 161, duration: 634.680 sec, average: 3080.70 kb/s, max: 7709.42 kb/s
Track ID: 1
Video Codec: avc1
Video profile: High
Video level: 4.0
Video resolution: 1920x1080
Video average IDR interval: 3.960000, Standard deviation: 0.000000
Video frame rate: 25.000

--------------------------------------------------------------------------------
media_1.m3u8
--------------------------------------------------------------------------------
Processed 161 out of 161 segments
Average segment duration: 3.938783
Total segment bitrates (all discontinuities): average: 490.64 kb/s, max: 496.00 kb/s
Rendition group ID: media_1


Discontinuity: sequence: 0, parsed segment count: 161 of 161, duration: 634.144 sec, average: 490.64 kb/s, max: 496.00 kb/s
Track ID: 1
Audio Codec: AAC-LC
Audio sample rate: 48000 Hz
Audio channels: 6
Audio channel layout: 5.1 (C L R Ls Rs LFE)

--------------------------------------------------------------------------------
MUST fix issues
--------------------------------------------------------------------------------

Error: Zero sample count
--> Detail:  Track ID 295
--> Source:  media_1.m3u8 - chunk-stream1-00161.m4s
Version 0, edited 4 months ago by beloko (next)

comment:58 in reply to: ↑ 56 ; follow-up: Changed 4 months ago by beloko

Replying to stevenliu:

If you don't have encoder, just remux stream or file to hls, then the GOP size cannot decide by you, for example, get a video from me, I ask you remux it to HLS, If transcode or modify the key frame interval I need cost lots of CPU, but i don't have lots of CPU, only used for IO ,for example CDN

Download some video files, and just use -c copy to make HLS, maybe you can understand that.

The segmenter with -v copy cuts the content where it can. When an Iframe is available. It depends how the source file was encoded before. Usually when the video codec found a scenecut to preserve picture quality.

If the #EXT-X-TARGETDURATION value is 2 in the audio playlist and the #EXT-X-TARGETDURATION value is 1 in the video playlist. Fix the #EXT-X-TARGETDURATION value to 2 in the video playlist could solve your issue.

Last edited 4 months ago by beloko (previous) (diff)

comment:59 in reply to: ↑ 58 Changed 4 months ago by stevenliu

Replying to beloko:

Replying to stevenliu:

If you don't have encoder, just remux stream or file to hls, then the GOP size cannot decide by you, for example, get a video from me, I ask you remux it to HLS, If transcode or modify the key frame interval I need cost lots of CPU, but i don't have lots of CPU, only used for IO ,for example CDN

Download some video files, and just use -c copy to make HLS, maybe you can understand that.

The segmenter with -v copy cuts the content where it can. When an Iframe is available. It depends how the source file was encoded before. Usually when the video codec found a scenecut to preserve picture quality.

If the #EXT-X-TARGETDURATION value is 2 in the audio playlist and the #EXT-X-TARGETDURATION value is 1 in the video playlist. Fix the #EXT-X-TARGETDURATION value to 2 in the video playlist could solve your issue.

for example this file:

MacBook:xxx StevenLiu$ ffprobe -select_streams v -show_packets -of xml ~/Movies/objectC/facebook.mp4 |grep "flags=\"K_\""
ffprobe version N-83894-g4e3cc4b Copyright (c) 2007-2017 the FFmpeg developers
  built with Apple LLVM version 8.0.0 (clang-800.0.42.1)
  configuration: --enable-libass --enable-opengl --enable-libx264 --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local --enable-libopencv --enable-libtesseract --enable-libspeex --enable-libfreetype --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox
  libavutil      55. 48.100 / 55. 48.100
  libavcodec     57. 83.100 / 57. 83.100
  libavformat    57. 66.104 / 57. 66.104
  libavdevice    57.  3.100 / 57.  3.100
  libavfilter     6. 76.100 /  6. 76.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/Movies/objectC/facebook.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.22.102
    description     : This File is Created by Easy RealMedia Tools@!
  Duration: 02:00:27.85, start: 0.000000, bitrate: 893 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 797 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 87 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
        <packet codec_type="video" stream_index="0" pts="0" pts_time="0.000000" dts="-1024" dts_time="-0.080000" duration="512" duration_time="0.040000" size="10821" pos="48" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="128000" pts_time="10.000000" dts="126976" dts_time="9.920000" duration="512" duration_time="0.040000" size="34124" pos="1177352" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="256000" pts_time="20.000000" dts="254976" dts_time="19.920000" duration="512" duration_time="0.040000" size="37027" pos="2131255" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="297472" pts_time="23.240000" dts="296448" dts_time="23.160000" duration="512" duration_time="0.040000" size="9976" pos="2338695" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="404992" pts_time="31.640000" dts="403968" dts_time="31.560000" duration="512" duration_time="0.040000" size="41317" pos="3409409" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="475136" pts_time="37.120000" dts="474112" dts_time="37.040000" duration="512" duration_time="0.040000" size="47757" pos="4032978" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="587264" pts_time="45.880000" dts="586240" dts_time="45.800000" duration="512" duration_time="0.040000" size="44864" pos="4963173" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="658944" pts_time="51.480000" dts="657920" dts_time="51.400000" duration="512" duration_time="0.040000" size="25596" pos="5632046" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="757760" pts_time="59.200000" dts="756736" dts_time="59.120000" duration="512" duration_time="0.040000" size="54494" pos="6509848" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="882688" pts_time="68.960000" dts="881664" dts_time="68.880000" duration="512" duration_time="0.040000" size="45282" pos="7525818" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="949760" pts_time="74.200000" dts="948736" dts_time="74.120000" duration="512" duration_time="0.040000" size="51773" pos="8221447" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1020928" pts_time="79.760000" dts="1019904" dts_time="79.680000" duration="512" duration_time="0.040000" size="42980" pos="8792146" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1148416" pts_time="89.720000" dts="1147392" dts_time="89.640000" duration="512" duration_time="0.040000" size="54071" pos="9916720" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1230336" pts_time="96.120000" dts="1229312" dts_time="96.040000" duration="512" duration_time="0.040000" size="43265" pos="10585199" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1297408" pts_time="101.360000" dts="1296384" dts_time="101.280000" duration="512" duration_time="0.040000" size="22924" pos="11117246" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1425408" pts_time="111.360000" dts="1424384" dts_time="111.280000" duration="512" duration_time="0.040000" size="33675" pos="12221046" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1475072" pts_time="115.240000" dts="1474048" dts_time="115.160000" duration="512" duration_time="0.040000" size="37849" pos="12739731" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1563648" pts_time="122.160000" dts="1562624" dts_time="122.080000" duration="512" duration_time="0.040000" size="45802" pos="13507637" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1636864" pts_time="127.880000" dts="1635840" dts_time="127.800000" duration="512" duration_time="0.040000" size="50067" pos="14127715" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1690624" pts_time="132.080000" dts="1689600" dts_time="132.000000" duration="512" duration_time="0.040000" size="47706" pos="14746403" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1799680" pts_time="140.600000" dts="1798656" dts_time="140.520000" duration="512" duration_time="0.040000" size="51761" pos="15657409" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="1884672" pts_time="147.240000" dts="1883648" dts_time="147.160000" duration="512" duration_time="0.040000" size="27278" pos="16287661" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="2006016" pts_time="156.720000" dts="2004992" dts_time="156.640000" duration="512" duration_time="0.040000" size="46678" pos="17366396" flags="K_"/>
        <packet codec_type="video" stream_index="0" pts="2088448" pts_time="163.160000" dts="2087424" dts_time="163.080000" duration="512" duration_time="0.040000" size="51434" pos="18099029" flags="K_"/>

The keyframe is not set by me, just a VOD file from internet.

MacBook:xxx StevenLiu$ ./ffmpeg -i ~/Movies/objectC/facebook.mp4 -c copy  -f dash -hls_playlist 1 -an -min_seg_duration 1000000 -window_size 99999 -t 100 output_test.mpd
ffmpeg version N-89577-g4c78bbd313 Copyright (c) 2000-2017 the FFmpeg developers
  built with Apple LLVM version 8.1.0 (clang-802.0.42)
  configuration:
  libavutil      56.  6.100 / 56.  6.100
  libavcodec     58.  8.100 / 58.  8.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  7.100 /  7.  7.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/StevenLiu/Movies/objectC/facebook.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf55.22.102
    description     : This File is Created by Easy RealMedia Tools@!
  Duration: 02:00:27.85, start: 0.000000, bitrate: 893 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, 797 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 87 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
[dash @ 0x7fc93f01c800] Opening 'init-stream0.m4s' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
Output #0, dash, to 'output_test.mpd':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    description     : This File is Created by Easy RealMedia Tools@!
    encoder         : Lavf58.3.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x480, q=2-31, 797 kb/s, 25 fps, 25 tbr, 12800 tbn, 25 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00001.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00002.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00003.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00004.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00005.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00006.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00007.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00008.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00009.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00010.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00011.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00012.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00013.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'chunk-stream0-00014.m4s.tmp' for writing
[dash @ 0x7fc93f01c800] Opening 'output_test.mpd.tmp' for writing
frame= 2502 fps=0.0 q=-1.0 Lsize=N/A time=00:01:39.96 bitrate=N/A speed=1.17e+03x
video:9685kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
MacBook:xxx StevenLiu$ cat media_0.m3u8
#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:1
#EXT-X-MAP:URI="init-stream0.m4s"
#EXTINF:10.000000,
chunk-stream0-00001.m4s
#EXTINF:10.000000,
chunk-stream0-00002.m4s
#EXTINF:3.240000,
chunk-stream0-00003.m4s
#EXTINF:8.400000,
chunk-stream0-00004.m4s
#EXTINF:5.480000,
chunk-stream0-00005.m4s
#EXTINF:8.760000,
chunk-stream0-00006.m4s
#EXTINF:5.600000,
chunk-stream0-00007.m4s
#EXTINF:7.720000,
chunk-stream0-00008.m4s
#EXTINF:9.760000,
chunk-stream0-00009.m4s
#EXTINF:5.240000,
chunk-stream0-00010.m4s
#EXTINF:5.560000,
chunk-stream0-00011.m4s
#EXTINF:9.960000,
chunk-stream0-00012.m4s
#EXTINF:6.400000,
chunk-stream0-00013.m4s
#EXTINF:3.960000,
chunk-stream0-00014.m4s
#EXT-X-ENDLIST
MacBook:xxx StevenLiu$

Then the duration of file is not control by myself.

I have no question and have no problem, i just tell you, the problem is not EXT-X-TARGETDURATION different problem, and Pantos said is right.

I think you can fix the problem use the https://trac.ffmpeg.org/ticket/6915?replyto=58#comment:57 way if you worry to fix it.

comment:60 Changed 4 months ago by beloko

I'm agree the -an parameter fixes the #EXT-X-TARGETDURATION issue with variant audio playlist in any case.

And yes this technic bypasses the issue : https://trac.ffmpeg.org/ticket/6915?replyto=58#comment:57

So I suggest the ticket can be closed.

Thanks everyone for your helps.
Wish you Happy Holidays.

comment:61 Changed 4 months ago by beloko

  • Resolution set to worksforme
  • Status changed from open to closed
Note: See TracTickets for help on using tickets.