From 6ca536b5b6d0e2c1b847bbb3b7bddea12f0fd68e Mon Sep 17 00:00:00 2001 From: Nick Shaforostoff Date: Sat, 13 Apr 2019 18:43:44 +0200 Subject: [PATCH] mp4 properties: handle the case when mp4 file header has zero bitrate calculate it based on filesize and length --- taglib/mp4/mp4properties.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index faa43c270..f5be91f7b 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -213,7 +213,12 @@ MP4::Properties::read(File *file, Atoms *atoms) pos += 3; } pos += 10; - d->bitrate = static_cast((data.toUInt(pos) + 500) / 1000.0 + 0.5); + if(data.toUInt(pos) != 0u || d->length <= 0) { + d->bitrate = static_cast((data.toUInt(pos) + 500) / 1000.0 + 0.5); + } + else { + d->bitrate = 8 * (file->length() - atom->offset - atom->length) / d->length; + } } } }