GNOME Bugzilla – Bug 703350
qtdemux: Reports wrong framerate
Last modified: 2013-07-10 07:20:53 UTC
Created attachment 248087 [details] [review] Patch Currently qtdemux takes one sample from first 20 samples and uses its duration to compute framerate. For some files this can give invalid results (one file I tried this with shows 35fps). Also the timescale that is usually used (2400) means that single sample duration can not be used to compute framerate of 24000/1001. Best case scenario currently is that the sample will have duration of 100, resulting in 24fps, but that's not precise. Some samples have duration 99 making the average framerate 23.98. Patch uses average sample duration and scales the timescale appropriately (so that it gives proper framerate for 24000/1001).
I meant 101 instead of 99 in previous comment of course.
Review of attachment 248087 [details] [review]: ::: gst/isomp4/qtdemux.c @@ +5464,3 @@ + /* we might need to scale the timescale to get precise framerate */ + const int required_scale = log10 (10000); + int current_scale = log10 (stream->timescale); You need to link with $(LIBM) for this, and also log10() is not available everywhere. Only log() is safe to use. @@ +5474,3 @@ + stream->fps_d = + floor ((double) (stream->duration * factor) / + (double) stream->n_samples + 0.5); gst_util_uint64_scale_int_round() maybe?
Created attachment 248098 [details] [review] Patch Added libm, uses log instead and gst_util_uint64_scale_int_round
commit 4053e1d6acc241d7690c7b1325d3b43775b83e48 Author: Matej Knopp <matej.knopp@gmail.com> Date: Sun Jun 30 21:01:20 2013 +0200 qtdemux: compute framerate from average sample duration https://bugzilla.gnome.org/show_bug.cgi?id=703350
Created attachment 248754 [details] [review] Correct argument order in gst_util_uint64_scale_int_round This needs to be applied otherwise the call fails with long streams. I'm not sure how I missed it.
commit 7b69f427f11e9c936e624e34863f2956232af5b1 Author: Matej Knopp <matej.knopp@gmail.com> Date: Tue Jul 9 19:10:17 2013 +0200 qtdemux: correct argument order in gst_util_uint64_scale_int_round https://bugzilla.gnome.org/show_bug.cgi?id=703350