mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-04-04 15:21:34 +00:00
lavf/segment: mark #EXT-X-ENDLIST in M3U8 only at the end of stream
Should fix immediate playback termination. In particular, should fix trac ticket #2172.
This commit is contained in:
parent
8b8ac78ef3
commit
ca68acd7ac
@ -258,7 +258,7 @@ static void segment_list_print_entry(AVIOContext *list_ioctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int segment_end(AVFormatContext *s, int write_trailer)
|
static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
|
||||||
{
|
{
|
||||||
SegmentContext *seg = s->priv_data;
|
SegmentContext *seg = s->priv_data;
|
||||||
AVFormatContext *oc = seg->avf;
|
AVFormatContext *oc = seg->avf;
|
||||||
@ -300,7 +300,7 @@ static int segment_end(AVFormatContext *s, int write_trailer)
|
|||||||
goto end;
|
goto end;
|
||||||
for (entry = seg->segment_list_entries; entry; entry = entry->next)
|
for (entry = seg->segment_list_entries; entry; entry = entry->next)
|
||||||
segment_list_print_entry(seg->list_pb, seg->list_type, entry);
|
segment_list_print_entry(seg->list_pb, seg->list_type, entry);
|
||||||
if (seg->list_type == LIST_TYPE_M3U8)
|
if (seg->list_type == LIST_TYPE_M3U8 && is_last)
|
||||||
avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n");
|
avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n");
|
||||||
} else {
|
} else {
|
||||||
segment_list_print_entry(seg->list_pb, seg->list_type, &seg->cur_entry);
|
segment_list_print_entry(seg->list_pb, seg->list_type, &seg->cur_entry);
|
||||||
@ -664,7 +664,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
(pkt->pts != AV_NOPTS_VALUE &&
|
(pkt->pts != AV_NOPTS_VALUE &&
|
||||||
av_compare_ts(pkt->pts, st->time_base,
|
av_compare_ts(pkt->pts, st->time_base,
|
||||||
end_pts-seg->time_delta, AV_TIME_BASE_Q) >= 0))) {
|
end_pts-seg->time_delta, AV_TIME_BASE_Q) >= 0))) {
|
||||||
ret = segment_end(s, seg->individual_header_trailer);
|
ret = segment_end(s, seg->individual_header_trailer, 0);
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = segment_start(s, seg->individual_header_trailer);
|
ret = segment_start(s, seg->individual_header_trailer);
|
||||||
@ -729,13 +729,13 @@ static int seg_write_trailer(struct AVFormatContext *s)
|
|||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
if (!seg->write_header_trailer) {
|
if (!seg->write_header_trailer) {
|
||||||
if ((ret = segment_end(s, 0)) < 0)
|
if ((ret = segment_end(s, 0, 1)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
open_null_ctx(&oc->pb);
|
open_null_ctx(&oc->pb);
|
||||||
ret = av_write_trailer(oc);
|
ret = av_write_trailer(oc);
|
||||||
close_null_ctx(oc->pb);
|
close_null_ctx(oc->pb);
|
||||||
} else {
|
} else {
|
||||||
ret = segment_end(s, 1);
|
ret = segment_end(s, 1, 1);
|
||||||
}
|
}
|
||||||
fail:
|
fail:
|
||||||
if (seg->list)
|
if (seg->list)
|
||||||
|
Loading…
Reference in New Issue
Block a user