Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/exiv2/quicktimevideo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,10 @@ class EXIV2API QuickTimeVideo : public Image {
*/
void discard(size_t size);

//! Variable which stores Time Scale unit, used to calculate time.
uint64_t timeScale_ = 0;
//! Variable which stores Time Scale unit retrieved from mvhd box, used to calculate time.
uint64_t mvhdTimeScale_ = 0;
//! Variable which stores Time Scale unit retrieved from mdhd box, used to calculate time.
uint64_t mdhdTimeScale_ = 0;
//! Variable which stores current stream being processed.
int currentStream_ = 0;
//! Variable to check the end of metadata traversing.
Expand Down
20 changes: 11 additions & 9 deletions src/quicktimevideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ using namespace Exiv2::Internal;

QuickTimeVideo::QuickTimeVideo(BasicIo::UniquePtr io, size_t max_recursion_depth) :
Image(ImageType::qtime, mdNone, std::move(io)),
timeScale_(1),
mvhdTimeScale_(1),
mdhdTimeScale_(1),
currentStream_(Null),
max_recursion_depth_(max_recursion_depth) {
} // QuickTimeVideo::QuickTimeVideo
Expand Down Expand Up @@ -1170,7 +1171,7 @@ void QuickTimeVideo::timeToSampleDecoder() {
if (timeOfFrames == 0)
timeOfFrames = 1;
xmpData_["Xmp.video.FrameRate"] =
static_cast<double>(totalframes) * static_cast<double>(timeScale_) / static_cast<double>(timeOfFrames);
static_cast<double>(totalframes) * static_cast<double>(mdhdTimeScale_) / static_cast<double>(timeOfFrames);
}
} // QuickTimeVideo::timeToSampleDecoder

Expand Down Expand Up @@ -1437,6 +1438,7 @@ void QuickTimeVideo::mediaHeaderDecoder(size_t size) {
time_scale = buf.read_uint32(0, bigEndian);
if (time_scale <= 0)
time_scale = 1;
mdhdTimeScale_ = time_scale;
break;
case MediaDuration:
if (currentStream_ == Video)
Expand Down Expand Up @@ -1496,9 +1498,9 @@ void QuickTimeVideo::trackHeaderDecoder(size_t size) {
break;
case TrackDuration:
if (currentStream_ == Video)
xmpData_["Xmp.video.TrackDuration"] = timeScale_ ? buf.read_uint32(0, bigEndian) / timeScale_ : 0;
xmpData_["Xmp.video.TrackDuration"] = mvhdTimeScale_ ? buf.read_uint32(0, bigEndian) / mvhdTimeScale_ : 0;
else if (currentStream_ == Audio)
xmpData_["Xmp.audio.TrackDuration"] = timeScale_ ? buf.read_uint32(0, bigEndian) / timeScale_ : 0;
xmpData_["Xmp.audio.TrackDuration"] = mvhdTimeScale_ ? buf.read_uint32(0, bigEndian) / mvhdTimeScale_ : 0;
break;
case TrackLayer:
if (currentStream_ == Video)
Expand Down Expand Up @@ -1555,13 +1557,13 @@ void QuickTimeVideo::movieHeaderDecoder(size_t size) {
break;
case TimeScale:
xmpData_["Xmp.video.TimeScale"] = buf.read_uint32(0, bigEndian);
timeScale_ = buf.read_uint32(0, bigEndian);
if (timeScale_ <= 0)
timeScale_ = 1;
mvhdTimeScale_ = buf.read_uint32(0, bigEndian);
if (mvhdTimeScale_ <= 0)
mvhdTimeScale_ = 1;
break;
case Duration:
if (timeScale_ != 0) { // To prevent division by zero
xmpData_["Xmp.video.Duration"] = buf.read_uint32(0, bigEndian) * 1000 / timeScale_;
if (mvhdTimeScale_ != 0) { // To prevent division by zero
xmpData_["Xmp.video.Duration"] = buf.read_uint32(0, bigEndian) * 1000 / mvhdTimeScale_;
}
break;
case PreferredRate:
Expand Down
2 changes: 1 addition & 1 deletion test/data/test_reference_files/sample_640x360.mov.out
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ Xmp.video.XResolution XmpText 2 72 72
Xmp.video.YResolution XmpText 2 72 72
Xmp.video.Compressor XmpText 22 Lavc57.107.100 libx264 Lavc57.107.100 libx264
Xmp.video.BitDepth XmpText 2 24 24
Xmp.video.FrameRate XmpText 8 0.999001 0.999001
Xmp.video.FrameRate XmpText 5 29.97 29.97
Xmp.video.SoftwareVersion XmpText 13 Lavf57.83.100 Lavf57.83.100
Xmp.video.AspectRatio XmpText 4 16:9 16:9
2 changes: 1 addition & 1 deletion test/data/test_reference_files/small_video.mp4.out
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Xmp.video.XResolution XmpText 2 72 72
Xmp.video.YResolution XmpText 2 72 72
Xmp.video.Compressor XmpText 21 Lavc59.37.100 libx265 Lavc59.37.100 libx265
Xmp.video.BitDepth XmpText 2 24 24
Xmp.video.FrameRate XmpText 7 1.95312 1.95312
Xmp.video.FrameRate XmpText 2 30 30
Xmp.audio.TrackHeaderVersion XmpText 1 0 0
Xmp.audio.TrackCreateDate XmpText 1 0 0
Xmp.audio.TrackModifyDate XmpText 1 0 0
Expand Down
Loading