Skip to content
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

ffmpeg: Estimate duration for some audio formats in GetCodecInfoBytes #414

Closed
wants to merge 1 commit into from

Conversation

j0sh
Copy link
Collaborator

@j0sh j0sh commented Jul 31, 2024

not all formats have a duration baked into the container. in those cases, ffmpeg normally uses the file size and bitrate to estimate the duration, but pipes do not have a file size ... however, we do know the file size from the input parameter (a byte slice, data) so calculate the duration ourselves for a few audio formats.

Also add a couple of small test files to cover codecs where we do not compile in encoders (mp3 and opus), and extend the existing test cases to also call GetCodecInfoBytes

Note that certain formats are known not to work with this method, eg ogg does not return a bitrate at all. This is covered in test cases as well.

@j0sh j0sh requested review from emranemran and rickstaa July 31, 2024 07:43
@eliteprox
Copy link
Contributor

Tested these changes on the audio-to-text Whisper pipeline and it is working excellent. Great work!

@rickstaa
Copy link
Member

rickstaa commented Aug 7, 2024

@j0sh I checked the code and everything looks correct. I could not test this pull request directly but #415 which worked perfectly.

Copy link
Member

@rickstaa rickstaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and tests look good. Tested it out using #415 since I'm on Ubuntu 24 which doesn't easily allow running the lower ffmpeg version.

@j0sh
Copy link
Collaborator Author

j0sh commented Aug 9, 2024

Merged into master via #415

@j0sh j0sh closed this Aug 9, 2024
@rickstaa rickstaa deleted the ja/audio-durations branch August 9, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants