[FFmpeg-devel] [PATCH] Added support for unequal duration for VOD playlist
Somsak Sriprayoonsakul
somsaks at gmail.com
Fri Apr 20 07:17:50 EEST 2018
---
libavformat/hlsenc.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index c27a66ea79..b6260b262d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1026,26 +1026,28 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls,
vs->last_segment = en;
- // EVENT or VOD playlists imply sliding window cannot be used
- if (hls->pl_type != PLAYLIST_TYPE_NONE)
+ // EVENT playlists imply sliding window cannot be used
+ if ( (hls->pl_type == PLAYLIST_TYPE_EVENT) || (hls->pl_type == PLAYLIST_TYPE_NB) )
hls->max_nb_segments = 0;
if (hls->max_nb_segments && vs->nb_entries >= hls->max_nb_segments) {
- en = vs->segments;
- vs->initial_prog_date_time += en->duration;
- vs->segments = en->next;
- if (en && hls->flags & HLS_DELETE_SEGMENTS &&
+ if( hls->pl_type != PLAYLIST_TYPE_VOD ) {
+ en = vs->segments;
+ vs->initial_prog_date_time += en->duration;
+ vs->segments = en->next;
+ if (en && hls->flags & HLS_DELETE_SEGMENTS &&
#if FF_API_HLS_WRAP
- !(hls->flags & HLS_SINGLE_FILE || hls->wrap)) {
+ !(hls->flags & HLS_SINGLE_FILE || hls->wrap)) {
#else
- !(hls->flags & HLS_SINGLE_FILE)) {
+ !(hls->flags & HLS_SINGLE_FILE)) {
#endif
- en->next = vs->old_segments;
- vs->old_segments = en;
- if ((ret = hls_delete_old_segments(s, hls, vs)) < 0)
- return ret;
- } else
- av_free(en);
+ en->next = vs->old_segments;
+ vs->old_segments = en;
+ if ((ret = hls_delete_old_segments(s, hls, vs)) < 0)
+ return ret;
+ } else
+ av_free(en);
+ }
} else
vs->nb_entries++;
--
2.14.1
More information about the ffmpeg-devel
mailing list