[FFmpeg-devel] [PATCH] Apple Quicktime fix

Alexey Eromenko al4321 at gmail.com
Tue Oct 11 20:24:44 EEST 2016


---
 libavformat/movenc.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 8b4aa5f..0e2fc55 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5666,16 +5666,20 @@ static int mov_write_header(AVFormatContext *s)
                 while(track->timescale < 10000)
                     track->timescale *= 2;
             }
+            if (track->timescale > 100000 && (!mov->video_track_timescale)) {
+                unsigned int timescale_new = (unsigned int)((double)(st->time_base.den)
+                * 1000 / (double)(st->time_base.num));
+                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 %u 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',' ')) {
-- 
2.9.3



More information about the ffmpeg-devel mailing list