-
Notifications
You must be signed in to change notification settings - Fork 190
Adds Opus codec config support #431
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
base: main
Are you sure you want to change the base?
Conversation
add custom opus codec support
@danrossi Thanks for the code contribution, please check out the failing unit tests if you have time. |
I'm so sorry. I'll run the lint check. Somehow after making the change to allow opus codec configs. There is no audio track encoded or muxed. This is the output I get from the muxer when doing an encode in chrome. Firefox doesn't like the output when loading into a video element the blob also. Firefox and the polyfill for Audioencoder for IOS / macOS need opus audio codec. Still figuring it out. The main branch build is ok.
|
In my WSL environment I get this error running the tests
|
I've figured out the tests run on selenium and requires to be done on windows to connect to a chrome browser. I can see the failure and it's to do with what I saw no audio track is added. |
@@ -10,6 +10,8 @@ export interface ICombinatorOpts { | |||
fps?: number; | |||
bgColor?: string; | |||
videoCodec?: string; | |||
audioCodec?: 'opus' | 'aac'; |
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.
It is recommended to change the audio
field type to
export interface ICombinatorOpts {
width?: number;
height?: number;
bitrate?: number;
fps?: number;
bgColor?: string;
videoCodec?: string;
/**
* When specifying a composite video file,
* setting `audio: false` will ignore the audio track;
* if you want to include audio, you can configure the codec and other parameters via `audio: { codec: 'aac' | 'opus'; opusConfig?: OpusEncoderConfig }`.
* The default value is `audio: { dodec: ‘aac’ }`
*/
audio?: false | { codec: 'aac' | 'opus'; opusConfig?: OpusEncoderConfig };
/**
* 向输出的视频中写入 meta tags 数据
*/
metaDataTags?: Record<string, string>;
/**
* 不安全,随时可能废弃
*/
__unsafe_hardwareAcceleration__?: HardwarePreference;
}
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.
Then remove the audioCodec
and opusConfig
fields
There is a typo in the codec map. The tests are useful to prevent having to do a build importing the dist files then running browser tests which was slow. Has to be done in powershell not WSL though. |
I renamed the hooks directory to stop it running. Should be fixed. |
The tests pass , the audio track is created but is corrupted. And so no audio output is made. Firefox can't decode the blob. in ffprobe it shows this error. I think there is a muxer error maybe libav as the muxer might work around.
The AAC license makes things complicated and problematic not able to use AAC in firefox or the polyfill for libav. |
The opus codec doesn't work in chrome or firefox. I can't tell if it's the muxer doing that. Polyfill in macOS safari has issues for now also. IOS can't check due to memory issues. |
… only supported on certain GPU models.
I'm still working on Opus codec testing to get Firefox working. But just discovered with hardware preference enabled the encoder failed with AV1 due to only supported on certain GPU models like RTX4000+ I am on a 2060. So added an option for that in the checker. the VideoEncoder doesn't return a promise on configure and will only work out it fails on the error callback. |
I'm sorry opus is encoding but it's not being muxed correctly now perhaps. There is an audio track but it's corrupted so there is no audio being previewed. It's a problem on both Chrome and Firefox. ffprobe produces an error like
|
I believe this is the issue, it's taking the opus decoder config info and hardcoding aac ? https://github.com/WebAV-Tech/WebAV/blob/main/packages/internal-utils/src/recodemux.ts#L471 |
The Opus codec I discovered is 0xAD. byte muxing is a grey area for me. I hope that is all it needs. Should it somehow get that from the decoder config ? |
Changing that didn't helped. Does the internal muxer need to support Opus ? |
Confirming changing the code to |
add codec code map to ESDS
It should be fixed now but VLC doesn't want to play the file. OK in the browser. There is no fast start on the mp4 it seems so VLC takes a while to play. |
Firefox doesn't like the audio mux code after encoding and previewing. even with the codec code changes. It's ok in Chrome. If audio is disabled it will load the blob. It won't load a file with opus created in chrome. VLC won't play back the audio. generated video with opus. https://downloads-electroteque-org.s3.amazonaws.com/just%20do%20it-trimmed-1752600908898_opus.mp4 https://electroteque.org/dev/webav/opus.html aac generated file loads ok in firefox. All the generated videos are very slow to load with blocky pixels when seeking. |
This is a known unfixed issue, see #183 |
It's very strange. VLC player won't show the picture of a h264/aac encoded video. It will play the video with opus in it but no picture also. The picture shows up at the end. Firefox will decode and preview the aac audio video but not the opus audio video. But wont autoload and takes a while to show up. I think there is still muxing issues with the video track also. https://downloads-electroteque-org.s3.amazonaws.com/just%20do%20it-trimmed-1752600811403.mp4 |
Fixes Issue #429
Internally opus was supported but a hardcoded config of
aac
was being sent to the AudioEncoder.This became a problem attempting to use an AudioEncoder libav polyfill for IOS and Firefox support. Which doesn't support aac by default and requires opus codec.
A new config called
opusConfig
is added to add opus codec specific settings. Which is configured on theopus
property.