Skip to content

Commit

Permalink
mp4 properties: handle the case when mp4 file header has zero bitrate
Browse files Browse the repository at this point in the history
calculate it based on filesize and length
  • Loading branch information
Nick Shaforostoff committed Apr 13, 2019
1 parent 6455671 commit 6ca536b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion taglib/mp4/mp4properties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,12 @@ MP4::Properties::read(File *file, Atoms *atoms)
pos += 3;
}
pos += 10;
d->bitrate = static_cast<int>((data.toUInt(pos) + 500) / 1000.0 + 0.5);
if(data.toUInt(pos) != 0u || d->length <= 0) {
d->bitrate = static_cast<int>((data.toUInt(pos) + 500) / 1000.0 + 0.5);
}
else {
d->bitrate = 8 * (file->length() - atom->offset - atom->length) / d->length;
}
}
}
}
Expand Down

0 comments on commit 6ca536b

Please sign in to comment.