Fixed a bug calculating # of samples per frame, to use FPS instead of video time base.

This commit is contained in:
Jonathan Thomas
2012-02-26 17:22:24 -06:00
parent eae0c0bbfb
commit 063c1481bd

View File

@@ -854,8 +854,9 @@ audio_packet_location FFmpegReader::GetAudioPTSLocation(int pts)
int FFmpegReader::GetSamplesPerFrame(int frame_number)
{
// Get the total # of samples for the previous frame, and the current frame (rounded)
double previous_samples = round((info.sample_rate * info.video_timebase.ToDouble()) * (frame_number - 1));
double total_samples = round((info.sample_rate * info.video_timebase.ToDouble()) * frame_number);
double fps = info.fps.Reciprocal().ToDouble();
double previous_samples = round((info.sample_rate * fps) * (frame_number - 1));
double total_samples = round((info.sample_rate * fps) * frame_number);
// 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.