[FFmpeg-devel] [PATCH 1/2] avformat movenc add flag to disable silent limit on timescale

vectronic hello.vectronic at gmail.com
Mon May 4 19:24:27 EEST 2020


Add a flag to allow user to disable the forcing of a track timescale to be greater than 10000. Log a debug message if the timescale is forced to be greater than 10000.

Signed-off-by: vectronic <hello.vectronic at gmail.com>
---
 libavformat/movenc.c | 4 ++++
 libavformat/movenc.h | 1 +
 2 files changed, 5 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 32e8109268..143b00063d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -107,6 +107,7 @@ static const AVOption options[] = {
     { "wallclock", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_WALLCLOCK}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM, "prft"},
     { "pts", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = MOV_PRFT_SRC_PTS}, 0, 0, AV_OPT_FLAG_ENCODING_PARAM, "prft"},
     { "empty_hdlr_name", "write zero-length name string in hdlr atoms within mdia and minf atoms", offsetof(MOVMuxContext, empty_hdlr_name), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
+    { "allow_small_timescale", "Do not force track timescale to be >= 10000", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_ALLOW_SMALL_TSCALE}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
     { NULL },
 };
 
@@ -6460,8 +6461,11 @@ static int mov_init(AVFormatContext *s)
                     av_log(s, AV_LOG_WARNING, "Warning: some tools, like mp4split, assume a timescale of 10000000 for ISMV.\n");
             } else {
                 track->timescale = st->time_base.den;
+                if (!(mov->flags & FF_MOV_FLAG_ALLOW_SMALL_TSCALE)) {
                 while(track->timescale < 10000)
                     track->timescale *= 2;
+                    av_log(s, AV_LOG_DEBUG, "track timescale was less than 10000, it has been forced to %d\n", track->timescale);
+                }
             }
             if (st->codecpar->width > 65535 || st->codecpar->height > 65535) {
                 av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for mov/mp4\n", st->codecpar->width, st->codecpar->height);
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index 997b2d61c0..f91cd3420f 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -261,6 +261,7 @@ typedef struct MOVMuxContext {
 #define FF_MOV_FLAG_SKIP_SIDX             (1 << 21)
 #define FF_MOV_FLAG_CMAF                  (1 << 22)
 #define FF_MOV_FLAG_PREFER_ICC            (1 << 23)
+#define FF_MOV_FLAG_ALLOW_SMALL_TSCALE    (1 << 24)
 
 int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt);
 
-- 
2.24.2 (Apple Git-127)



More information about the ffmpeg-devel mailing list