[FFmpeg-trac] #6915(avformat:open): DASH audio segments duration doesn't match exactly with video segments duration.
FFmpeg
trac at avcodec.org
Fri Dec 22 18:40:15 EET 2017
#6915: DASH audio segments duration doesn't match exactly with video segments
duration.
------------------------------------+-------------------------------------
Reporter: beloko | Owner: stevenliu
Type: defect | Status: open
Priority: normal | Component: avformat
Version: git-master | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+-------------------------------------
Comment (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 or equal to the
#EXT-X-TARGETDURATION.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/6915#comment:52>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list