diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index 0ac77342..ba821547 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -187,7 +187,7 @@ MP4::Properties::read(File *file, Atoms *atoms) length = data.toUInt(24U); } if(unit > 0 && length > 0) - d->length = static_cast(length * 1000.0 / unit); + d->length = static_cast(length * 1000.0 / unit + 0.5); MP4::Atom *atom = trak->find("mdia", "minf", "stbl", "stsd"); if(!atom) { diff --git a/tests/test_mp4.cpp b/tests/test_mp4.cpp index c110a612..58dbae42 100644 --- a/tests/test_mp4.cpp +++ b/tests/test_mp4.cpp @@ -40,7 +40,7 @@ public: CPPUNIT_ASSERT(f.audioProperties()); CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->length()); CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->lengthInSeconds()); - CPPUNIT_ASSERT_EQUAL(3707, f.audioProperties()->lengthInMilliseconds()); + CPPUNIT_ASSERT_EQUAL(3708, f.audioProperties()->lengthInMilliseconds()); CPPUNIT_ASSERT_EQUAL(3, f.audioProperties()->bitrate()); CPPUNIT_ASSERT_EQUAL(2, f.audioProperties()->channels()); CPPUNIT_ASSERT_EQUAL(44100, f.audioProperties()->sampleRate());