diff --git a/src/mp4util.cpp b/src/mp4util.cpp index 47bd74e..932b22d 100644 --- a/src/mp4util.cpp +++ b/src/mp4util.cpp @@ -259,7 +259,8 @@ uint64_t MP4ConvertTime(uint64_t t, // check if we can safely use integer operations if (ilog2(t) + ilog2(newTimeScale) <= 64) { - return (t * newTimeScale) / oldTimeScale; + // convert with rounding. + return (t * newTimeScale + oldTimeScale / 2) / oldTimeScale; } // final resort is to use floating point