Skip to content

Wrong FPS value returned from some mp4 files #3436

@nkming2

Description

@nkming2

Describe the bug

Currently the FPS value is calculated using the stts box.

exiv2/src/quicktimevideo.cpp

Lines 1172 to 1173 in d17cfb6

xmpData_["Xmp.video.FrameRate"] =
static_cast<double>(totalframes) * static_cast<double>(timeScale_) / static_cast<double>(timeOfFrames);

And timeScale_ is set in movieHeaderDecoder, reading from the mvhd box.

exiv2/src/quicktimevideo.cpp

Lines 1555 to 1561 in d17cfb6

break;
case TimeScale:
xmpData_["Xmp.video.TimeScale"] = buf.read_uint32(0, bigEndian);
timeScale_ = buf.read_uint32(0, bigEndian);
if (timeScale_ <= 0)
timeScale_ = 1;
break;

However the time scale value from mvhd is not supposed to be used here. Instead, each track contains a mdia box that defines a time scale value specific for this media in the mdhd box. The stts box belonging to this media should use the mdhd value and not the one from mvhd box.

Image Image

Currently some mp4 files may work if the two values are identical, but not all files are so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions