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

Josh de Kock josh at itanimul.li
Tue Oct 11 22:06:39 EEST 2016


Fixes ticket #5882. While it doesn't automatically set the timescale
for the user as that would destroy data without prompt, it will tell
the user how they could set the timescale (as this is mostly likely
what they want).

Signed-off-by: Josh de Kock <josh at itanimul.li>
---

>Would it be useful to print the max duration?
 I'm not entirely sure, open to suggestions though.

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

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d7c7158..6bada25 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5677,11 +5677,16 @@ static int mov_write_header(AVFormatContext *s)
                 ret = AVERROR(EINVAL);
                 goto error;
             }
-            if (track->mode == MODE_MOV && track->timescale > 100000)
+            if (track->mode == MODE_MOV && track->timescale > 100000) {
+                /* NOTE: forcing setting the suggested timescale manually means ffmpeg won't destroy
+                 * timestamps without explicit instruction. */
+                unsigned int suggested = (unsigned int)av_rescale(st->time_base.den, 1000, 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 quicktime. Specify a shorter timebase\n"
-                       "or choose different container.\n");
+                       "or choose different container. Using -video_track_timescale %d\n"
+                       "may fix this issue.\n", suggested);
+            }
             if (track->mode == MODE_MOV &&
                 track->par->codec_id == AV_CODEC_ID_RAWVIDEO &&
                 track->tag == MKTAG('r','a','w',' ')) {
-- 
2.8.4 (Apple Git-73)



More information about the ffmpeg-devel mailing list