Re: [FFmpeg-devel] [PATCH 4/7] avformat/hlsenc: do not regenerate the playlist for each segment
On 2014-07-29 15:59, Michael Niedermayer wrote: On Fri, Jul 18, 2014 at 10:57:44AM +0200, Nicolas Martyanoff wrote: 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. doesnt this break playing back hls while its still written ? I believe you are right, I did not thing about the case where a client is reading the playlist while it is being written. However I am not sure about the way avio_* functions work. Depending on the way buffering is done, how does one guarantee that at a time T, the playlist is a valid HLS playlist ? The hlsenc muxer uses avio_open2(), a bunch of avio_printf() then avio_closep(). I have no idea whether a part of the file is readable by other processed before the call to avio_closep(). -- Nicolas Martyanoff http://wandrian.net khae...@gmail.com ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 4/7] avformat/hlsenc: do not regenerate the playlist for each segment
On Fri, Jul 18, 2014 at 10:57:44AM +0200, Nicolas Martyanoff wrote: 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. doesnt this break playing back hls while its still written ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH 4/7] avformat/hlsenc: do not regenerate the playlist for each segment
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