[FFmpeg-devel] avformat/movenc : Don't write sidx for empty urls

Submitted by kjeyapal@akamai.com on Nov. 28, 2018, 2:40 p.m.

Details

Message ID 20181128144011.95972-1-kjeyapal@akamai.com
State New
Headers show

Commit Message

kjeyapal@akamai.com Nov. 28, 2018, 2:40 p.m.
When movenc is used by other segmenting muxers such as dashenc, url field is always empty.
In such cases it is better to not write sidx, instead of throwing errors.
---
 libavformat/movenc.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Moritz Barsnick Nov. 28, 2018, 2:48 p.m.
On Wed, Nov 28, 2018 at 20:10:11 +0530, Karthick J wrote:
> +            // If url is an empty string("") don't write sidx atom.
> +            if (s->url[0] == '\0')
> +                return res;

Probably clearer if you return 0, as res hasn't been assigned anything
up to this point, except its initial 0.

Moritz
kjeyapal@akamai.com Nov. 28, 2018, 4:17 p.m.
>On 11/28/18, 8:19 PM, "Moritz Barsnick" <barsnick@gmx.net> wrote:

>

>On Wed, Nov 28, 2018 at 20:10:11 +0530, Karthick J wrote:

>> +            // If url is an empty string("") don't write sidx atom.

>> +            if (s->url[0] == '\0')

>> +                return res;

>

>Probably clearer if you return 0, as res hasn't been assigned anything

>up to this point, except its initial 0.

Makes sense. Sent PATCH v2 with this change.

Regards,
Karthick
>

>Moritz

Patch hide | download patch | download mbox

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..150a505a4a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6706,6 +6706,9 @@  static int mov_write_trailer(AVFormatContext *s)
            mov->tracks[i].data_offset = 0;
         if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) {
             int64_t end;
+            // If url is an empty string("") don't write sidx atom.
+            if (s->url[0] == '\0')
+                return res;
             av_log(s, AV_LOG_INFO, "Starting second pass: inserting sidx atoms\n");
             res = shift_data(s);
             if (res < 0)