You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
avformat/hlsenc: fix ticket id 5988 for DISCONTINUITY
add EXT-X-DISCONTINUITY tag at the position of the append point. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
This commit is contained in:
@@ -46,6 +46,7 @@ typedef struct HLSSegment {
|
|||||||
char filename[1024];
|
char filename[1024];
|
||||||
char sub_filename[1024];
|
char sub_filename[1024];
|
||||||
double duration; /* in seconds */
|
double duration; /* in seconds */
|
||||||
|
int discont;
|
||||||
int64_t pos;
|
int64_t pos;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
|
|
||||||
@@ -107,6 +108,7 @@ typedef struct HLSContext {
|
|||||||
int64_t max_seg_size; // every segment file max size
|
int64_t max_seg_size; // every segment file max size
|
||||||
int nb_entries;
|
int nb_entries;
|
||||||
int discontinuity_set;
|
int discontinuity_set;
|
||||||
|
int discontinuity;
|
||||||
|
|
||||||
HLSSegment *segments;
|
HLSSegment *segments;
|
||||||
HLSSegment *last_segment;
|
HLSSegment *last_segment;
|
||||||
@@ -387,6 +389,12 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double
|
|||||||
en->pos = pos;
|
en->pos = pos;
|
||||||
en->size = size;
|
en->size = size;
|
||||||
en->next = NULL;
|
en->next = NULL;
|
||||||
|
en->discont = 0;
|
||||||
|
|
||||||
|
if (hls->discontinuity) {
|
||||||
|
en->discont = 1;
|
||||||
|
hls->discontinuity = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (hls->key_info_file) {
|
if (hls->key_info_file) {
|
||||||
av_strlcpy(en->key_uri, hls->key_uri, sizeof(en->key_uri));
|
av_strlcpy(en->key_uri, hls->key_uri, sizeof(en->key_uri));
|
||||||
@@ -446,6 +454,7 @@ static int parse_playlist(AVFormatContext *s, const char *url)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hls->discontinuity = 0;
|
||||||
while (!avio_feof(in)) {
|
while (!avio_feof(in)) {
|
||||||
read_chomp_line(in, line, sizeof(line));
|
read_chomp_line(in, line, sizeof(line));
|
||||||
if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
|
if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
|
||||||
@@ -560,6 +569,10 @@ static int hls_window(AVFormatContext *s, int last)
|
|||||||
iv_string = en->iv_string;
|
iv_string = en->iv_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (en->discont) {
|
||||||
|
avio_printf(out, "#EXT-X-DISCONTINUITY\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (hls->flags & HLS_ROUND_DURATIONS)
|
if (hls->flags & HLS_ROUND_DURATIONS)
|
||||||
avio_printf(out, "#EXTINF:%ld,\n", lrint(en->duration));
|
avio_printf(out, "#EXTINF:%ld,\n", lrint(en->duration));
|
||||||
else
|
else
|
||||||
@@ -883,6 +896,7 @@ static int hls_write_header(AVFormatContext *s)
|
|||||||
|
|
||||||
if (hls->flags & HLS_APPEND_LIST) {
|
if (hls->flags & HLS_APPEND_LIST) {
|
||||||
parse_playlist(s, s->filename);
|
parse_playlist(s, s->filename);
|
||||||
|
hls->discontinuity = 1;
|
||||||
if (hls->init_time > 0) {
|
if (hls->init_time > 0) {
|
||||||
av_log(s, AV_LOG_WARNING, "append_list mode does not support hls_init_time,"
|
av_log(s, AV_LOG_WARNING, "append_list mode does not support hls_init_time,"
|
||||||
" hls_init_time value will have no effect\n");
|
" hls_init_time value will have no effect\n");
|
||||||
|
Reference in New Issue
Block a user