[FFmpeg-trac] #6533(avformat:reopened): Invalid EXT-X-TARGETDURATION in HLS

FFmpeg trac at avcodec.org
Thu Aug 10 11:46:18 EEST 2017

             Reporter:  tonn81       |                    Owner:
                 Type:  defect       |                   Status:  reopened
             Priority:  normal       |                Component:  avformat
              Version:  unspecified  |               Resolution:
             Keywords:  hls          |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |

Comment (by tonn81):

 Replying to [comment:5 stevenliu]:
 > >    ffmpeg should generate chunks not longer than given with
 `--hls_time`. For `--hls_time 4` it generated `4.02` chunk instead of
 `4.0` or less.
 > Write a full frame is better than half frame. for example, the frame
 duration is 40, the frame sequence is: IPPIPPIPP, if the hls_time is set
 to 100ms. Do you mean it should split IP and half of next P and leave the
 other half to the next segment? Or leave the full P frame to the next
 segment start frame to make sure the hls_time 0.100?

 I cannot tell here. I just see that chunk duration is longer than

 > > 2. **ffmpeg converts chunk duration into `EXT-X-TARGETDURATION`
 > >
 > >    According to official HLS validator (`mediastreamvalidator`), there
 could be 25% difference between actual chunk size and value. That means we
 should not ceil the value but rather round to nearest integer (so that
 delta between maximum chunk duration and `TARGETDURATION` is minimal).
 Then `4.02` would become `4`, not `5`.
 > Reference Spec:
 > https://tools.ietf.org/html/draft-pantos-http-live-streaming-22#page-49
 >    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.

 In other words, we take maximum chunk duration (`4.02`), round to nearest
 integer (`4`). Then `EXT-X-TARGETDURATION` should be greater or equal to
 this `4`.

 Technically, `5` also matches the specification in this case (`4 <= 5`)
 but `4` is more precise.

 So my proposal matches the specification -- we should round maximum chunk
 duration to nearest integer, not ceil it.

Ticket URL: <https://trac.ffmpeg.org/ticket/6533#comment:6>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker

More information about the FFmpeg-trac mailing list