Since we need all segments to find out the target duration, we can only generate the playlist after writing all segments.
There is no need to rewrite the segment list every time we create a new segment file. --- libavformat/hlsenc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 76cbd0e..5dde17a 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -198,7 +198,7 @@ static void hls_free_segments(HLSContext *hls) } } -static int hls_generate_playlist(AVFormatContext *ctx, int last) +static int hls_generate_playlist(AVFormatContext *ctx) { HLSContext *hls; HLSSegment *segment; @@ -233,8 +233,7 @@ static int hls_generate_playlist(AVFormatContext *ctx, int last) (hls->baseurl ? hls->baseurl : ""), segment->filename); } - if (last) - avio_printf(hls->pb, "#EXT-X-ENDLIST\n"); + avio_printf(hls->pb, "#EXT-X-ENDLIST\n"); avio_closep(&hls->pb); return 0; @@ -395,10 +394,6 @@ static int hls_write_packet(AVFormatContext *ctx, AVPacket *pkt) ret = hls_create_file(ctx); if (ret) return ret; - - ret = hls_generate_playlist(ctx, 0); - if (ret < 0) - return ret; } ret = ff_write_chained(hls->ctx, pkt->stream_index, pkt, ctx); @@ -420,7 +415,7 @@ static int hls_write_trailer(struct AVFormatContext *ctx) av_free(hls->media_filename); hls_append_segment(hls); - hls_generate_playlist(ctx, 1); + hls_generate_playlist(ctx); hls_free_segments(hls); avio_close(hls->pb); -- 1.8.5.5 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel