New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FrameMapper Audio Crackles/Popping Fixes #653
Conversation
…erent framerates (30/1, 24/1, 30000/1001, 119/4), and fixes a huge issue with mapping frame numbers incorrectly causing audio crackles/pops. Also fixes a bug which causes crashes on NON-STEREO channel layouts.
@@ -1683,7 +1681,7 @@ void FFmpegWriter::write_audio_packets(bool is_final) { | |||
); | |||
|
|||
// Set remaining samples | |||
remaining_frame_samples = nb_samples * av_get_bytes_per_sample(AV_SAMPLE_FMT_S16); | |||
remaining_frame_samples = total_frame_samples; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes a bug where MONO channel layout crashes libopenshot
int original_samples = Frame::GetSamplesPerFrame(AdjustFrameNumber(end_samples_frame), original, reader->info.sample_rate, reader->info.channels) - end_samples_position; | ||
// Get original samples (with NO framerate adjustments) | ||
// This is the original reader's frame numbers | ||
int original_samples = Frame::GetSamplesPerFrame(end_samples_frame, original, reader->info.sample_rate, reader->info.channels) - end_samples_position; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing AdjustFrameNumber()
method from original samples calculation, since this access the original reader, and is always in original frame #'s... never mapped to the Timeline offset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Does this also fix the export issue? When we were getting deformed waveforms when exporting to different FPS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably! But I would love to test that again. The new unit test had hundreds of thousands of failures without this fix. And zero failures with it. But I didn't notice the failures until the Timeline merged the audio, and some frames had the wrong # of samples, and thus introduced some high frequency pops.
Codecov Report
@@ Coverage Diff @@
## develop #653 +/- ##
===========================================
+ Coverage 51.75% 52.04% +0.28%
===========================================
Files 151 151
Lines 12255 12315 +60
===========================================
+ Hits 6343 6409 +66
+ Misses 5912 5906 -6
Continue to review full report at Codecov.
|
@jonoomph There needs to be a I fixed all of them while I was porting the tests to Catch2, so when that gets merged (hopefully ASAP, just had some fine-tuning to do) it'll be sorted out. Just an FYI. |
Added new unit test which distributes audio samples between many different frame rates (30/1, 24/1, 30000/1001, 119/4), and fixes a huge issue with mapping frame numbers incorrectly causing audio crackles/pops. Also fixes a bug which causes crashes on NON-STEREO channel layouts.
For example, when using a source video with a 119/4 frame rate (29.75 fps) and converting it to 30 fps (and positioning the Clip at position 3.77 seconds), it would generate a huge amount of high frequency pops, due to incorrect frame # adjustments inside FrameMapper.