[FFmpeg-devel] [PATCH] lavf/movenc: suggest video_track_timescale for invalid timescale

Alexey Eromenko al4321 at gmail.com
Tue Oct 11 15:40:57 EEST 2016


I have written a different patch, which should auto-fix the problem,
but I can't compile and test it now (due to build system issues):
movenc.c affects both MP4 and MOV containers, right ?

====

--- ./movenc.c.orig     2016-10-11 06:24:44.328730759 -0400
+++ ./ffmpeg-3.1.3/ffmpeg-3.1.3/libavformat/movenc.c    2016-10-11
08:12:50.626150035 -0400
@@ -5533,22 +5533,26 @@
                 track->timescale = mov->video_track_timescale;
             } else {
                 track->timescale = st->time_base.den;
                 while(track->timescale < 10000)
                     track->timescale *= 2;
             }
+            if (track->timescale > 100000) {
+                int timescale_new = ((st->time_base.den) * (0x10000)) /
+                (st->time_base.num)*1000;
+                av_log(s, AV_LOG_WARNING,
+                       "WARNING codec timebase is very high. If
duration is too long,\n"
+                       "file may not be playable by Apple Quicktime.
Auto-setting\n"
+                       "a shorter timebase %d instead of %d.\n",
timescale_new, track->timescale);
+                track->timescale = timescale_new;
+            }
             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);
                 ret = AVERROR(EINVAL);
                 goto error;
             }
-            if (track->mode == MODE_MOV && track->timescale > 100000)
-                av_log(s, AV_LOG_WARNING,
-                       "WARNING codec timebase is very high. If
duration is too long,\n"
-                       "file may not be playable by quicktime.
Specify a shorter timebase\n"
-                       "or choose different container.\n");
             if (track->mode == MODE_MOV &&
                 track->par->codec_id == AV_CODEC_ID_RAWVIDEO &&
                 track->tag == MKTAG('r','a','w',' ')) {
                 enum AVPixelFormat pix_fmt = track->par->format;
                 if (pix_fmt == AV_PIX_FMT_NONE &&
track->par->bits_per_coded_sample == 1)
                     pix_fmt = AV_PIX_FMT_MONOWHITE;


More information about the ffmpeg-devel mailing list