Skip to content

Conversation

@elthariel
Copy link
Contributor

I don't know the precise conditions in which it happens, but I've multiple webm files where the audio bitrate isn't stored in the headers, in which case ffmpeg returns a bitrate of 0.
In that case, the bitrate used during transcode is set to 0, using the default for the codec instead of the user provided value.

Copy link
Collaborator

@bajankristof bajankristof left a comment

Choose a reason for hiding this comment

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

Hey @elthariel! Thanks for the opening up this PR!

I would handle this a little differently.

In the min_bit_rate method at the bottom of the changed file we have a values.compact. I would modify that method to use values.filter_map instead of values.compact and filter out nils and 0 values there (that way it applies to all adjusted_* methods.

Also can you please add at least one spec to back up this new functionality?

Finally please use all lowercase for the commit message.

Thanks again for opening the PR!

@elthariel elthariel force-pushed the lta/fix-missing-audio-br branch from 0ae7a7d to 80aa4aa Compare September 30, 2025 10:28
@elthariel
Copy link
Contributor Author

Thanks for the quick replay @bajankristof. I've updated my PR accordingly.

If you allow me to abuse this PR chat space to ask you a question (feel free to ignore), I'm wondering how you'd recommend implementing two pass encoding using your lib. I'm specifically interested in webm 2-pass encoding.

A naive approach could just be to call transcode twice with 2 different presets, but was wondering if you had any ideas or plan regarding this.

@bajankristof bajankristof changed the title fix: Handle missing audio bitrate in some muxers fix: handle missing audio bitrate in some muxers Sep 30, 2025
@bajankristof
Copy link
Collaborator

Thanks for the quick replay @bajankristof. I've updated my PR accordingly.

If you allow me to abuse this PR chat space to ask you a question (feel free to ignore), I'm wondering how you'd recommend implementing two pass encoding using your lib. I'm specifically interested in webm 2-pass encoding.

A naive approach could just be to call transcode twice with 2 different presets, but was wondering if you had any ideas or plan regarding this.

@elthariel it looks like there are some linter errors to fix (weirdly enough some are for files you haven't even touched, but still)

we currently don't have plans to extend the functionality with multi-pass specific transcoders, so for the moment being your best bet is to use presets like you said, I also don't see any straightforward API to back this up ATM (maybe a TwoPassTranscoder class that does exactly that ☝️, but adds -pass #{n} to the arguments, anyway, even with the current API I don't see any reason not to just use

pass1_preset.transcode!(media, File::NULL)
pass2_preset.transcode!(media, 'actualoutput.mp4')

this is already pretty easy on the eyes

@elthariel elthariel force-pushed the lta/fix-missing-audio-br branch from 80aa4aa to 2c27266 Compare September 30, 2025 13:12
@elthariel elthariel force-pushed the lta/fix-missing-audio-br branch from 2c27266 to 5bb8270 Compare September 30, 2025 13:13
@elthariel
Copy link
Contributor Author

I was fixing the lint while you were answering me. It should be green now.

As for two pass, I thank you for your feedback 💌 . I'll dabble with this soon-ish and report back (maybe with a doc PR)

@bajankristof bajankristof merged commit 9098c10 into instructure:main Sep 30, 2025
13 checks passed
@bajankristof
Copy link
Collaborator

@elthariel thanks for the contribution! I'll have a github release soon (because of some other features that are still in beta, this will go into the 8.1.0-beta.3 release, just FYI the 8.1.0 is still beta, but has actually been running in production for us for a while now, we just need to finish up a bit of work before it becomes a final release)

@bajankristof
Copy link
Collaborator

@elthariel
Copy link
Contributor Author

No rush, I'm still pulling from my fork

@elthariel
Copy link
Contributor Author

Thanks for your patience and reactivity ! 🙏

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.

2 participants