[FFmpeg-cvslog] avformat/hlsenc: fix ticket id 5988 for DISCONTINUITY
Steven Liu
git at videolan.org
Mon Dec 5 11:56:42 EET 2016
ffmpeg | branch: master | Steven Liu <lq at chinaffmpeg.org> | Mon Dec 5 17:55:33 2016 +0800| [55affd95bd9b3212dc505aec67f9be58d519b4fe] | committer: Steven Liu
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 at chinaffmpeg.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=55affd95bd9b3212dc505aec67f9be58d519b4fe
---
libavformat/hlsenc.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e16fb0c..0e55a31 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -46,6 +46,7 @@ typedef struct HLSSegment {
char filename[1024];
char sub_filename[1024];
double duration; /* in seconds */
+ int discont;
int64_t pos;
int64_t size;
@@ -107,6 +108,7 @@ typedef struct HLSContext {
int64_t max_seg_size; // every segment file max size
int nb_entries;
int discontinuity_set;
+ int discontinuity;
HLSSegment *segments;
HLSSegment *last_segment;
@@ -387,6 +389,12 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double
en->pos = pos;
en->size = size;
en->next = NULL;
+ en->discont = 0;
+
+ if (hls->discontinuity) {
+ en->discont = 1;
+ hls->discontinuity = 0;
+ }
if (hls->key_info_file) {
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;
}
+ hls->discontinuity = 0;
while (!avio_feof(in)) {
read_chomp_line(in, line, sizeof(line));
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;
}
+ if (en->discont) {
+ avio_printf(out, "#EXT-X-DISCONTINUITY\n");
+ }
+
if (hls->flags & HLS_ROUND_DURATIONS)
avio_printf(out, "#EXTINF:%ld,\n", lrint(en->duration));
else
@@ -883,6 +896,7 @@ static int hls_write_header(AVFormatContext *s)
if (hls->flags & HLS_APPEND_LIST) {
parse_playlist(s, s->filename);
+ hls->discontinuity = 1;
if (hls->init_time > 0) {
av_log(s, AV_LOG_WARNING, "append_list mode does not support hls_init_time,"
" hls_init_time value will have no effect\n");
More information about the ffmpeg-cvslog
mailing list