Discussion:
[FFmpeg-devel] [PATCH 1/2] avformat/movenc: Added an option to disable SIDX atom
Karthick J
2018-12-04 08:41:59 UTC
Permalink
---
doc/muxers.texi | 2 ++
libavformat/movenc.c | 7 +++++--
libavformat/movenc.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..6ca27b04a3 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,8 @@ more efficient), but with this option set, the muxer writes one moof/mdat
pair for each track, making it easier to separate tracks.

This option is implicitly set when writing ismv (Smooth Streaming) files.
+@item -movflags no_sidx
+Don't write sidx atom.
@item -movflags faststart
Run a second pass moving the index (moov atom) to the beginning of the file.
This operation can take a while, and will not work in various situations such
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..83278e8bfd 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -75,6 +75,7 @@ static const AVOption options[] = {
{ "frag_discont", "Signal that the next fragment is discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "no_sidx", "Don't write sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_NO_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -4603,7 +4604,8 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks,
mov_write_moof_tag_internal(avio_buf, mov, tracks, 0);
moof_size = ffio_close_null_buf(avio_buf);

- if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
+ if (mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_NO_SIDX)))
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);

if (mov->write_prft > MOV_PRFT_NONE && mov->write_prft < MOV_PRFT_NB)
@@ -5422,7 +5424,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
* the next fragment. This means the cts of the first sample must
* be the same in all fragments, unless end_pts was updated by
* the packet causing the fragment to be written. */
- if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
+ if ((mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_NO_SIDX))) ||
mov->mode == MODE_ISM)
pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..ee6749bce2 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
+#define FF_MOV_FLAG_NO_SIDX (1 << 21)

int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
--
2.17.1 (Apple Git-112)
Karthick J
2018-12-04 08:42:00 UTC
Permalink
Anyways the intended behaviour was to disable SIDX atom.
---
libavformat/dashenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 4d9b564a94..84bc58d6c1 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1162,7 +1162,7 @@ static int dash_init(AVFormatContext *s)

if (os->segment_type == SEGMENT_TYPE_MP4) {
if (c->streaming)
- av_dict_set(&opts, "movflags", "frag_every_frame+dash+delay_moov+global_sidx", 0);
+ av_dict_set(&opts, "movflags", "frag_every_frame+dash+delay_moov+no_sidx", 0);
else
av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
} else {
--
2.17.1 (Apple Git-112)
Gyan Doshi
2018-12-04 08:48:04 UTC
Permalink
Post by Karthick J
diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..6ca27b04a3 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,8 @@ more efficient), but with this option set, the muxer writes one moof/mdat
pair for each track, making it easier to separate tracks.
This option is implicitly set when writing ismv (Smooth Streaming) files.
+Don't write sidx atom.
Append a short note advising when this is required or recommended and
when not.

Thanks,
Gyan
Jeyapal, Karthick
2018-12-05 06:23:49 UTC
Permalink
Post by Gyan Doshi
Post by Karthick J
[...]
+Don't write sidx atom.
Append a short note advising when this is required or recommended and
when not.
Thanks for your comment. I have added more details in PATCH v2. http://ffmpeg.org/pipermail/ffmpeg-devel/2018-December/237181.html

Regards,
Karthick
Post by Gyan Doshi
Thanks,
Gyan
Tobias Rapp
2018-12-04 10:55:32 UTC
Permalink
Post by Karthick J
---
doc/muxers.texi | 2 ++
libavformat/movenc.c | 7 +++++--
libavformat/movenc.h | 1 +
3 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..6ca27b04a3 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,8 @@ more efficient), but with this option set, the muxer writes one moof/mdat
pair for each track, making it easier to separate tracks.
This option is implicitly set when writing ismv (Smooth Streaming) files.
+Don't write sidx atom.
@item -movflags faststart
Run a second pass moving the index (moov atom) to the beginning of the file.
This operation can take a while, and will not work in various situations such
What about naming the option "skip_sidx" for symmetry with the existing
"skip_trailer"? Just my personal thought.

Also it might be worth mentioning in the docs how global_sidx and the
new option correlate (which one is preferred if both exists, or is it an
error to specify both?).
Post by Karthick J
[...]
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..ee6749bce2 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
+#define FF_MOV_FLAG_NO_SIDX (1 << 21)
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
Regards,
Tobias
Karthick J
2018-12-05 06:18:39 UTC
Permalink
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..ca10741900 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,10 @@ more efficient), but with this option set, the muxer writes one moof/mdat
pair for each track, making it easier to separate tracks.

This option is implicitly set when writing ismv (Smooth Streaming) files.
+@item -movflags skip_sidx
+Skip writing of sidx atom. When bitrate overhead due to sidx atom is high,
+this option could be used for cases where sidx atom is not mandatory.
+When global_sidx flag is enabled, this option will be ignored.
@item -movflags faststart
Run a second pass moving the index (moov atom) to the beginning of the file.
This operation can take a while, and will not work in various situations such
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..3781a32895 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -75,6 +75,7 @@ static const AVOption options[] = {
{ "frag_discont", "Signal that the next fragment is discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -4603,7 +4604,8 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks,
mov_write_moof_tag_internal(avio_buf, mov, tracks, 0);
moof_size = ffio_close_null_buf(avio_buf);

- if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
+ if (mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX)))
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);

if (mov->write_prft > MOV_PRFT_NONE && mov->write_prft < MOV_PRFT_NB)
@@ -5422,7 +5424,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
* the next fragment. This means the cts of the first sample must
* be the same in all fragments, unless end_pts was updated by
* the packet causing the fragment to be written. */
- if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
+ if ((mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX))) ||
mov->mode == MODE_ISM)
pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
@@ -6067,6 +6070,11 @@ static int mov_init(AVFormatContext *s)
s->flags &= ~AVFMT_FLAG_AUTO_BSF;
}

+ if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && s->flags & FF_MOV_FLAG_SKIP_SIDX) {
+ av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring skip_sidx option\n");
+ s->flags &= ~FF_MOV_FLAG_SKIP_SIDX;
+ }
+
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..68d6f23a5a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
+#define FF_MOV_FLAG_SKIP_SIDX (1 << 21)

int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
--
2.17.1 (Apple Git-112)
Karthick J
2018-12-05 06:18:40 UTC
Permalink
Anyways the intended behaviour was to disable SIDX atom.
---
libavformat/dashenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 4d9b564a94..585b34cb97 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1162,7 +1162,7 @@ static int dash_init(AVFormatContext *s)

if (os->segment_type == SEGMENT_TYPE_MP4) {
if (c->streaming)
- av_dict_set(&opts, "movflags", "frag_every_frame+dash+delay_moov+global_sidx", 0);
+ av_dict_set(&opts, "movflags", "frag_every_frame+dash+delay_moov+skip_sidx", 0);
else
av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
} else {
--
2.17.1 (Apple Git-112)
Tobias Rapp
2018-12-05 12:40:18 UTC
Permalink
Post by Karthick J
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..ca10741900 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,10 @@ more efficient), but with this option set, the muxer writes one moof/mdat
pair for each track, making it easier to separate tracks.
This option is implicitly set when writing ismv (Smooth Streaming) files.
+Skip writing of sidx atom. When bitrate overhead due to sidx atom is high,
+this option could be used for cases where sidx atom is not mandatory.
+When global_sidx flag is enabled, this option will be ignored.
@item -movflags faststart
Run a second pass moving the index (moov atom) to the beginning of the file.
This operation can take a while, and will not work in various situations such
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..3781a32895 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -75,6 +75,7 @@ static const AVOption options[] = {
{ "frag_discont", "Signal that the next fragment is discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -4603,7 +4604,8 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks,
mov_write_moof_tag_internal(avio_buf, mov, tracks, 0);
moof_size = ffio_close_null_buf(avio_buf);
- if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
+ if (mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX)))
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);
if (mov->write_prft > MOV_PRFT_NONE && mov->write_prft < MOV_PRFT_NB)
@@ -5422,7 +5424,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
* the next fragment. This means the cts of the first sample must
* be the same in all fragments, unless end_pts was updated by
* the packet causing the fragment to be written. */
- if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
+ if ((mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX))) ||
mov->mode == MODE_ISM)
pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
@@ -6067,6 +6070,11 @@ static int mov_init(AVFormatContext *s)
s->flags &= ~AVFMT_FLAG_AUTO_BSF;
}
+ if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && s->flags & FF_MOV_FLAG_SKIP_SIDX) {
+ av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring skip_sidx option\n");
+ s->flags &= ~FF_MOV_FLAG_SKIP_SIDX;
+ }
+
I guess this should use mov->flags instead of s->flags?
Post by Karthick J
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..68d6f23a5a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
+#define FF_MOV_FLAG_SKIP_SIDX (1 << 21)
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
Otherwise changes look fine, but I am not the maintainer of this file.

Regards,
Tobias
Karthick J
2018-12-06 05:07:55 UTC
Permalink
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..ca10741900 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,10 @@ more efficient), but with this option set, the muxer writes one moof/mdat
pair for each track, making it easier to separate tracks.

This option is implicitly set when writing ismv (Smooth Streaming) files.
+@item -movflags skip_sidx
+Skip writing of sidx atom. When bitrate overhead due to sidx atom is high,
+this option could be used for cases where sidx atom is not mandatory.
+When global_sidx flag is enabled, this option will be ignored.
@item -movflags faststart
Run a second pass moving the index (moov atom) to the beginning of the file.
This operation can take a while, and will not work in various situations such
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..2f7755bf69 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -75,6 +75,7 @@ static const AVOption options[] = {
{ "frag_discont", "Signal that the next fragment is discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -4603,7 +4604,8 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks,
mov_write_moof_tag_internal(avio_buf, mov, tracks, 0);
moof_size = ffio_close_null_buf(avio_buf);

- if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
+ if (mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX)))
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);

if (mov->write_prft > MOV_PRFT_NONE && mov->write_prft < MOV_PRFT_NB)
@@ -5422,7 +5424,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
* the next fragment. This means the cts of the first sample must
* be the same in all fragments, unless end_pts was updated by
* the packet causing the fragment to be written. */
- if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
+ if ((mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX))) ||
mov->mode == MODE_ISM)
pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
@@ -6067,6 +6070,11 @@ static int mov_init(AVFormatContext *s)
s->flags &= ~AVFMT_FLAG_AUTO_BSF;
}

+ if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && s->flags & FF_MOV_FLAG_SKIP_SIDX) {
+ av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring skip_sidx option\n");
+ mov->flags &= ~FF_MOV_FLAG_SKIP_SIDX;
+ }
+
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..68d6f23a5a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
+#define FF_MOV_FLAG_SKIP_SIDX (1 << 21)

int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
--
2.17.1 (Apple Git-112)
Tobias Rapp
2018-12-06 07:24:31 UTC
Permalink
Post by Karthick J
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)
[...]
@@ -6067,6 +6070,11 @@ static int mov_init(AVFormatContext *s)
s->flags &= ~AVFMT_FLAG_AUTO_BSF;
}
+ if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && s->flags & FF_MOV_FLAG_SKIP_SIDX) {
+ av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring skip_sidx option\n");
+ mov->flags &= ~FF_MOV_FLAG_SKIP_SIDX;
+ }
+
There is still one use of s->flags instead of mov->flags, that should be
changed.
Post by Karthick J
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..68d6f23a5a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
+#define FF_MOV_FLAG_SKIP_SIDX (1 << 21)
int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
Regards,
Tobias
Karthick J
2018-12-06 07:28:01 UTC
Permalink
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..ca10741900 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,10 @@ more efficient), but with this option set, the muxer writes one moof/mdat
pair for each track, making it easier to separate tracks.

This option is implicitly set when writing ismv (Smooth Streaming) files.
+@item -movflags skip_sidx
+Skip writing of sidx atom. When bitrate overhead due to sidx atom is high,
+this option could be used for cases where sidx atom is not mandatory.
+When global_sidx flag is enabled, this option will be ignored.
@item -movflags faststart
Run a second pass moving the index (moov atom) to the beginning of the file.
This operation can take a while, and will not work in various situations such
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..28cf8b719c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -75,6 +75,7 @@ static const AVOption options[] = {
{ "frag_discont", "Signal that the next fragment is discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "delay_moov", "Delay writing the initial moov until the first fragment is cut, or until the first fragment flush", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "global_sidx", "Write a global sidx index at the start of the file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+ { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_colr", "Write colr atom (Experimental, may be renamed or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "write_gama", "Write deprecated gama atom", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
{ "use_metadata_tags", "Use mdta atom for metadata.", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -4603,7 +4604,8 @@ static int mov_write_moof_tag(AVIOContext *pb, MOVMuxContext *mov, int tracks,
mov_write_moof_tag_internal(avio_buf, mov, tracks, 0);
moof_size = ffio_close_null_buf(avio_buf);

- if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX))
+ if (mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX)))
mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 + mdat_size);

if (mov->write_prft > MOV_PRFT_NONE && mov->write_prft < MOV_PRFT_NB)
@@ -5422,7 +5424,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
* the next fragment. This means the cts of the first sample must
* be the same in all fragments, unless end_pts was updated by
* the packet causing the fragment to be written. */
- if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags & FF_MOV_FLAG_GLOBAL_SIDX)) ||
+ if ((mov->flags & FF_MOV_FLAG_DASH &&
+ !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX | FF_MOV_FLAG_SKIP_SIDX))) ||
mov->mode == MODE_ISM)
pkt->pts = pkt->dts + trk->end_pts - trk->cluster[trk->entry].dts;
} else {
@@ -6067,6 +6070,11 @@ static int mov_init(AVFormatContext *s)
s->flags &= ~AVFMT_FLAG_AUTO_BSF;
}

+ if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && mov->flags & FF_MOV_FLAG_SKIP_SIDX) {
+ av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring skip_sidx option\n");
+ mov->flags &= ~FF_MOV_FLAG_SKIP_SIDX;
+ }
+
if (mov->flags & FF_MOV_FLAG_FASTSTART) {
mov->reserved_moov_size = -1;
}
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..68d6f23a5a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
#define FF_MOV_FLAG_SKIP_TRAILER (1 << 18)
#define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS (1 << 19)
#define FF_MOV_FLAG_FRAG_EVERY_FRAME (1 << 20)
+#define FF_MOV_FLAG_SKIP_SIDX (1 << 21)

int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
--
2.17.1 (Apple Git-112)
Tobias Rapp
2018-12-06 09:47:41 UTC
Permalink
Post by Karthick J
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)
[...]
Looks OK now, no more comments from my side.

Regards,
Tobias
Ronak
2018-12-11 03:36:57 UTC
Permalink
Post by Tobias Rapp
Post by Karthick J
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)
[...]
Looks OK now, no more comments from my side.
I actually was going to submit a patch that would remove sidx atoms being written out for any non-video content.

Is that now unnecessary because of your changes here?

So adding -movflags skip_sidx for our audio only fmp4 files would allow us to skip the sidx atoms?

Ronak
Post by Tobias Rapp
Regards,
Tobias
_______________________________________________
ffmpeg-devel mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Jeyapal, Karthick
2018-12-11 05:35:54 UTC
Permalink
Post by Ronak
Post by Tobias Rapp
---
[...]
Looks OK now, no more comments from my side.
I actually was going to submit a patch that would remove sidx atoms being written out for any non-video content.
Is that now unnecessary because of your changes here?
So adding -movflags skip_sidx for our audio only fmp4 files would allow us to skip the sidx atoms?
Yes
Post by Ronak
Ronak
Post by Tobias Rapp
Regards,
Tobias
Jeyapal, Karthick
2018-12-11 05:32:44 UTC
Permalink
Post by Tobias Rapp
Post by Karthick J
---
doc/muxers.texi | 4 ++++
libavformat/movenc.c | 12 ++++++++++--
libavformat/movenc.h | 1 +
3 files changed, 15 insertions(+), 2 deletions(-)
[...]
Looks OK now, no more comments from my side.
Pushed.

Regards,
Karthick
Post by Tobias Rapp
Regards,
Tobias
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Andrey Semashev
2018-12-06 09:21:55 UTC
Permalink
---
  doc/muxers.texi      |  4 ++++
  libavformat/movenc.c | 12 ++++++++++--
  libavformat/movenc.h |  1 +
  3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/doc/muxers.texi b/doc/muxers.texi
index f1cc6f5fee..ca10741900 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -1325,6 +1325,10 @@ more efficient), but with this option set, the
muxer writes one moof/mdat
  pair for each track, making it easier to separate tracks.
  This option is implicitly set when writing ismv (Smooth Streaming)
files.
+Skip writing of sidx atom. When bitrate overhead due to sidx atom is high,
+this option could be used for cases where sidx atom is not mandatory.
+When global_sidx flag is enabled, this option will be ignored.
  Run a second pass moving the index (moov atom) to the beginning of
the file.
  This operation can take a while, and will not work in various
situations such
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..2f7755bf69 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -75,6 +75,7 @@ static const AVOption options[] = {
      { "frag_discont", "Signal that the next fragment is
discontinuous from earlier ones", 0, AV_OPT_TYPE_CONST, {.i64 =
FF_MOV_FLAG_FRAG_DISCONT}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
      { "delay_moov", "Delay writing the initial moov until the first
fragment is cut, or until the first fragment flush", 0,
AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_DELAY_MOOV}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
      { "global_sidx", "Write a global sidx index at the start of the
file", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_GLOBAL_SIDX},
INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
+    { "skip_sidx", "Skip writing of sidx atom", 0, AV_OPT_TYPE_CONST,
{.i64 = FF_MOV_FLAG_SKIP_SIDX}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
      { "write_colr", "Write colr atom (Experimental, may be renamed
or changed, do not use from scripts)", 0, AV_OPT_TYPE_CONST, {.i64 =
FF_MOV_FLAG_WRITE_COLR}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM,
"movflags" },
      { "write_gama", "Write deprecated gama atom", 0,
AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_WRITE_GAMA}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
      { "use_metadata_tags", "Use mdta atom for metadata.", 0,
AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_USE_MDTA}, INT_MIN, INT_MAX,
AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
@@ -4603,7 +4604,8 @@ static int mov_write_moof_tag(AVIOContext *pb,
MOVMuxContext *mov, int tracks,
      mov_write_moof_tag_internal(avio_buf, mov, tracks, 0);
      moof_size = ffio_close_null_buf(avio_buf);
-    if (mov->flags & FF_MOV_FLAG_DASH && !(mov->flags &
FF_MOV_FLAG_GLOBAL_SIDX))
+    if (mov->flags & FF_MOV_FLAG_DASH &&
+        !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX |
FF_MOV_FLAG_SKIP_SIDX)))
          mov_write_sidx_tags(pb, mov, tracks, moof_size + 8 +
mdat_size);
      if (mov->write_prft > MOV_PRFT_NONE && mov->write_prft <
MOV_PRFT_NB)
@@ -5422,7 +5424,8 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
               * the next fragment. This means the cts of the first
sample must
               * be the same in all fragments, unless end_pts was
updated by
               * the packet causing the fragment to be written. */
-            if ((mov->flags & FF_MOV_FLAG_DASH && !(mov->flags &
FF_MOV_FLAG_GLOBAL_SIDX)) ||
+            if ((mov->flags & FF_MOV_FLAG_DASH &&
+                !(mov->flags & (FF_MOV_FLAG_GLOBAL_SIDX |
FF_MOV_FLAG_SKIP_SIDX))) ||
                  mov->mode == MODE_ISM)
                  pkt->pts = pkt->dts + trk->end_pts -
trk->cluster[trk->entry].dts;
          } else {
@@ -6067,6 +6070,11 @@ static int mov_init(AVFormatContext *s)
          s->flags &= ~AVFMT_FLAG_AUTO_BSF;
      }
+    if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && s->flags &
FF_MOV_FLAG_SKIP_SIDX) {
s->flags here should be mov->flags as well.
Sorry, didn't read the later messages.
+        av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring
skip_sidx option\n");
+        mov->flags &= ~FF_MOV_FLAG_SKIP_SIDX;
+    }
+
      if (mov->flags & FF_MOV_FLAG_FASTSTART) {
          mov->reserved_moov_size = -1;
      }
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index fe605d1ad2..68d6f23a5a 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -257,6 +257,7 @@ typedef struct MOVMuxContext {
  #define FF_MOV_FLAG_SKIP_TRAILER          (1 << 18)
  #define FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS  (1 << 19)
  #define FF_MOV_FLAG_FRAG_EVERY_FRAME      (1 << 20)
+#define FF_MOV_FLAG_SKIP_SIDX             (1 << 21)
  int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
Jeyapal, Karthick
2018-12-06 05:11:50 UTC
Permalink
Post by Tobias Rapp
Post by Karthick J
[...]
+ if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX && s->flags & FF_MOV_FLAG_SKIP_SIDX) {
+ av_log(s, AV_LOG_WARNING, "Global SIDX enabled; Ignoring skip_sidx option\n");
+ s->flags &= ~FF_MOV_FLAG_SKIP_SIDX;
+ }
+
I guess this should use mov->flags instead of s->flags?
Oops. Sorry about it. Thanks for pointing it out. Have sent PATCH v3 with this change.
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-December/237232.html
Post by Tobias Rapp
Post by Karthick J
[...]
Otherwise changes look fine, but I am not the maintainer of this file.
Regards,
Tobias
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Jeyapal, Karthick
2018-12-05 06:22:08 UTC
Permalink
Post by Tobias Rapp
Post by Karthick J
[...]
Run a second pass moving the index (moov atom) to the beginning of the file.
This operation can take a while, and will not work in various situations such
What about naming the option "skip_sidx" for symmetry with the existing
"skip_trailer"? Just my personal thought.
Also it might be worth mentioning in the docs how global_sidx and the
new option correlate (which one is preferred if both exists, or is it an
error to specify both?).
Thanks for your comments. I have addressed both your feedbacks points in PATCH v2 http://ffmpeg.org/pipermail/ffmpeg-devel/2018-December/237181.html

Regards,
Karthick
Post by Tobias Rapp
Post by Karthick J
[...]
Regards,
Tobias
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Loading...