[FFmpeg-trac] #6915(avformat:open): DASH audio segments duration doesn't match exactly with video segments duration.

FFmpeg trac at avcodec.org
Thu Dec 21 17:33:50 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 j_karthic):

 Replying to [comment:22 stevenliu]:
 > Replying to [comment:21 j_karthic]:
 > > Replying to [comment:19 stevenliu]:
 > > > Replying to [comment:18 stevenliu]:
 > > > > Replying to [comment:17 j_karthic]:
 > > > > > Replying to [comment:16 stevenliu]:
 > > > > > > Replying to [comment:15 j_karthic]:
 > > > > > > > Replying to [comment:14 stevenliu]:
 > > > > > > > > Replying to [comment:13 j_karthic]:
 > > > > > > > > > Replying to [comment:12 stevenliu]:
 > > > > > > > > > > Replying to [comment:11 j_karthic]:
 > > > > > > > > > > > Replying to [comment:10 stevenliu]:
 > > > > > > > > > > > > Replying to [comment:9 j_karthic]:
 > > > > > > > > > > > > > Replying to [comment:8 stevenliu]:
 > > > > > > > > > > > > > > Replying to [comment:7 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.
 }}}

 > > >
 > > >
 > > > > > > > >
 > > > > > > > >
 > > > > > > > > > >
 > > > > > > > > > > > > > >
 > > > > > > > > > > > > > > >
 > > > > > > > > > > > > > > >
 > > > > > > > > > > > > > > >
 > > > > > > > > > > > > > > >
 > > > > > > > > > > > > > > >

--
Ticket URL: <https://trac.ffmpeg.org/ticket/6915#comment:24>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list