diff mbox

[FFmpeg-devel] avformat/hlsenc: fix ticket 6231

Message ID 20170313075015.17926-1-lq@chinaffmpeg.org
State Accepted
Commit d3ce067e7687203cf4a0a475ffd4b733b7c3b4f4
Headers show

Commit Message

Liu Steven March 13, 2017, 7:50 a.m. UTC
check if the hls_flags is byterange_mode and check if should close fd

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/hlsenc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Steven Liu March 14, 2017, 2:17 a.m. UTC | #1
2017-03-13 15:50 GMT+08:00 Steven Liu <lq@chinaffmpeg.org>:

> check if the hls_flags is byterange_mode and check if should close fd
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/hlsenc.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index b8122f1..5bcface 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1319,6 +1319,7 @@ static int hls_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>                                     end_pts, AV_TIME_BASE_Q) >= 0) {
>          int64_t new_start_pos;
>          char *old_filename = av_strdup(hls->avf->filename);
> +        int byterange_mode = (hls->flags & HLS_SINGLE_FILE) ||
> (hls->max_seg_size > 0);
>
>          if (!old_filename) {
>              return AVERROR(ENOMEM);
> @@ -1329,9 +1330,11 @@ static int hls_write_packet(AVFormatContext *s,
> AVPacket *pkt)
>          new_start_pos = avio_tell(hls->avf->pb);
>          hls->size = new_start_pos - hls->start_pos;
>
> -        ff_format_io_close(s, &oc->pb);
> -        if (hls->vtt_avf) {
> -            ff_format_io_close(s, &hls->vtt_avf->pb);
> +        if (!byterange_mode) {
> +            ff_format_io_close(s, &oc->pb);
> +            if (hls->vtt_avf) {
> +                ff_format_io_close(s, &hls->vtt_avf->pb);
> +            }
>          }
>          if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
>              if (!(hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size <=
> 0))
> --
> 2.10.1.382.ga23ca1b.dirty
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


applied!
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index b8122f1..5bcface 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1319,6 +1319,7 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                                    end_pts, AV_TIME_BASE_Q) >= 0) {
         int64_t new_start_pos;
         char *old_filename = av_strdup(hls->avf->filename);
+        int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0);
 
         if (!old_filename) {
             return AVERROR(ENOMEM);
@@ -1329,9 +1330,11 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
         new_start_pos = avio_tell(hls->avf->pb);
         hls->size = new_start_pos - hls->start_pos;
 
-        ff_format_io_close(s, &oc->pb);
-        if (hls->vtt_avf) {
-            ff_format_io_close(s, &hls->vtt_avf->pb);
+        if (!byterange_mode) {
+            ff_format_io_close(s, &oc->pb);
+            if (hls->vtt_avf) {
+                ff_format_io_close(s, &hls->vtt_avf->pb);
+            }
         }
         if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
             if (!(hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size <= 0))