Fix many bugs around FPS and video length calculation (especially for MP3 and streaming WEBM formats). Also protecting samples_per_frame calculation to keep from crashing on undetected FPS.

This commit is contained in:
Jonathan Thomas
2018-09-17 00:27:30 -05:00
parent c0929d22d4
commit b63a63ceb2
2 changed files with 26 additions and 9 deletions

View File

@@ -512,6 +512,8 @@ int Frame::GetSamplesPerFrame(int64_t number, Fraction fps, int sample_rate, int
// Subtract the previous frame's total samples with this frame's total samples. Not all sample rates can
// be evenly divided into frames, so each frame can have have different # of samples.
int samples_per_frame = round(total_samples - previous_samples);
if (samples_per_frame < 0)
samples_per_frame = 0;
return samples_per_frame;
}