[FFmpeg-trac] #5419(avformat:new): HLS EXT-X-DISCONTINUITY tag is not supported

FFmpeg trac at avcodec.org
Wed Jan 11 10:48:21 EET 2017


#5419: HLS EXT-X-DISCONTINUITY tag is not supported
------------------------------------+------------------------------------
             Reporter:  xyq204101   |                    Owner:
                 Type:  defect      |                   Status:  new
             Priority:  normal      |                Component:  avformat
              Version:  git-master  |               Resolution:
             Keywords:  hls         |               Blocked By:
             Blocking:              |  Reproduced by developer:  1
Analyzed by developer:  1           |
------------------------------------+------------------------------------

Comment (by damengzai):

 Replying to [comment:9 HoldenForever]:
 >
 > There have been many attempts to make this work from various people.
 Check out AirStachPlayer hls.c file:
 https://github.com/AirStash/AirStashPlayer/blob/d0013059c63cf0807196c1dd396aa4ba2bbc1663/android/contrib
 /ffmpeg-x86_64/libavformat/hls.c
 >
 > I have not made their implementation work as of yet. You can hack around
 the problem by modifying the hls_read_packet function and change the end
 of the function to:
 >
 > /* If we got a packet, return it */
 >     if (minplaylist >= 0) {
 >         struct playlist *pls = c->playlists[minplaylist];
 >         *pkt = pls->pkt;
 >         pkt->stream_index += pls->stream_offset;
 >         reset_packet(&c->playlists[minplaylist]->pkt);
 >
 >         if (pkt->dts != AV_NOPTS_VALUE)
 >             c->cur_timestamp = av_rescale_q(pkt->dts,
 >
 pls->ctx->streams[pls->pkt.stream_index]->time_base,
 >                                             AV_TIME_BASE_Q);
 >
 >         pkt->dts = AV_NOPTS_VALUE;
 >         pkt->pts = AV_NOPTS_VALUE;
 >
 >         return 0;
 >     }
 >     return AVERROR_EOF;
 >
 >
 > Just add the 2 lines:
 >
 >         pkt->dts = AV_NOPTS_VALUE;
 >         pkt->pts = AV_NOPTS_VALUE;
 >
 >
 > This seems to make FFMPEG handle #EXT-X-DISCONTINUITY
 >
 > Obviously you will need to compile your own build to make this work.


 This is useful but not work,I changed some code and it work.
 Like this:

 ret = av_read_frame(pls->ctx, &pls->pkt);

                                 int seq_no = pls->cur_seq_no -
 pls->start_seq_no;
                                 struct segment *seg =
 pls->segments[seq_no];
                                 int64_t pred =
 av_rescale_q(seg->previous_duration,
                                                 AV_TIME_BASE_Q,
 s->streams[pkt->stream_index]->time_base);
                                 int64_t max_ts =
 av_rescale_q(seg->start_time + seg->duration,
                                                 AV_TIME_BASE_Q,
 s->streams[pkt->stream_index]->time_base);
                                 max_ts += 2 * AV_TIME_BASE;
                                 if(s->start_time > 0){
                                         max_ts+=
 av_rescale_q(s->start_time,
                                                         AV_TIME_BASE_Q,
 s->streams[pkt->stream_index]->time_base);
                                 }
                                 if(pls->pkt.dts != AV_NOPTS_VALUE &&
 pls->pkt.dts + pred < max_ts)
                                 pls->pkt.dts += pred;
                                 if(pls->pkt.pts != AV_NOPTS_VALUE &&
 pls->pkt.pts + pred < max_ts)
                                 pls->pkt.pts += pred;
 {{{

 }}}
 Just change the position of the code above.Others didn`t change.
 Because if tag EXT-X-DISCONTINUITY appear ,means dts and pts changed,and
 if dts less than seek_timestamp,it will stuck here( ts_diff =
 av_rescale_rnd(pls->pkt.dts, AV_TIME_BASE,
                                             tb.den, AV_ROUND_DOWN) -
                             pls->seek_timestamp;

                     if (ts_diff >= 0 && (pls->seek_flags  &
 AVSEEK_FLAG_ANY ||
                                         pls->pkt.flags & AV_PKT_FLAG_KEY))
 {
                         pls->seek_timestamp = AV_NOPTS_VALUE;
                         break;
                     })
 hope helpful,if something wrong tell me please.

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


More information about the FFmpeg-trac mailing list