[FFmpeg-cvslog] avformat/hlsenc.c: the size of init.mp4 is zero.

Charles Liu git at videolan.org
Tue Oct 30 05:13:53 EET 2018


ffmpeg | branch: master | Charles Liu <liuchh83 at gmail.com> | Tue Oct 30 11:10:27 2018 +0800| [76b8e42c1f0453215244c45114d5aa302e2add7b] | committer: Steven Liu

avformat/hlsenc.c: the size of init.mp4 is zero.

The size of init.mp4 is zero in fmp4 mode,
when the input duraton smaller than the expected segment time.

fix ticket: 7166

Signed-off-by: Charles Liu <liuchh83 at gmail.com>
Signed-off-by: Steven Liu <lq at chinaffmpeg.org>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=76b8e42c1f0453215244c45114d5aa302e2add7b
---

 libavformat/hlsenc.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0fd5d2a995..8b3a9b78f4 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2348,6 +2348,25 @@ static int hls_write_trailer(struct AVFormatContext *s)
             return AVERROR(ENOMEM);
         }
         if ( hls->segment_type == SEGMENT_TYPE_FMP4) {
+            if (!vs->init_range_length) {
+                av_write_frame(vs->avf, NULL); /* Flush any buffered data */
+                avio_flush(oc->pb);
+
+                uint8_t *buffer = NULL;
+                int range_length = avio_close_dyn_buf(oc->pb, &buffer);
+                avio_write(vs->out, buffer, range_length);
+                av_free(buffer);
+                vs->init_range_length = range_length;
+                avio_open_dyn_buf(&oc->pb);
+                vs->packets_written = 0;
+                vs->start_pos = range_length;
+                int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0);
+                if (!byterange_mode) {
+                    ff_format_io_close(s, &vs->out);
+                    hlsenc_io_close(s, &vs->out, vs->base_output_dirname);
+                }
+            }
+
             int range_length = 0;
             if (!(hls->flags & HLS_SINGLE_FILE)) {
                 ret = hlsenc_io_open(s, &vs->out, vs->avf->url, NULL);



More information about the ffmpeg-cvslog mailing list