Closed daijh closed 1 year ago
Thanks for filing @daijh. Can you say more on why per-frame is important vs making this part of the config (affecting N frames). I'm surprised we would want to adjust it with every frame (e.g. 30 times a second).
@chcunningham The BRC is something intrinsic of the video encoder, and it usually cannot be much changed after platform shipped. Some developers would like to use their own BRC cross all platforms, instead of platform intrinsic BRC. Per-frame QP enables the developer to implement customized BRC, by set QP of every frame according to previous encoded frames size and bitrate budget, as mentioned in #56
As I see it we’ll need to make at least 3 following changes in the API. I'm curious to know what the community thinks
qpRange
This range is populated by VideoEncoder.isConfiguSupported() when an input config has bitrateMode=’qp’
. It gives API users a range of expected QP values. VideoEncoder.configure() expects that config.qpRange value will be the same as the one returned by VideoEncoder.isConfiguSupported(). This works as an extra check that API users are aware of the expected QP range.unsigned long qp
. API users can set a new QP value while submitting a new frame to VideoEncoder.encode().
If a new QP value is not given, it’s assumed to be the same as the previous frame.unsigned long qp
. API users will need to reconfigure a video encoder by calling VideoEncoder.configure() each time they want to change the QP value.It also might be a good idea to replace QP by a more generic term.
Some thoughts:
Editors Call discussion w/ @aboba
Thanks @Djuffin for moving this along!
For bitrate mode: Could we just use "VBR" here? I like reasoning about both cases as "variable".
Related questions:
For range discovery:
For setting a QP value, I also prefer option 1. This is a per-frame config, so doing it per-frame feels right.
Chrome folks met just now. Notes:
For bitrate mode: Could we just use "VBR" here? I like reasoning about both cases as "variable".
Simplicity of just doing VBR is clear, but also this is modeled on AVCodec (Mac), which has a distinct "mode" for setting QP. No super strong opinions though.
should we define the behavior where setting per-frame QP comes to override any previously configured config.bitrate? (do underlying libraries support combining these things? My hunch is it's probably either-or).
@Djuffin assumed they would be exclusive. Combining is an error.
I also like 1 better. I wonder if we need to return a supported range, or if we can instead get by with a static codec specific range defined in each codec registration?
Some preference for codec-specific route w/ ranges in registry.
If range-support is impl specific, would you support throwing an error (rather than silent failure) for unsupported values.
Throw an unsupported error.
Do you know the semantic meaning of QP across codecs....
Seems like another good reason to consider codec specific route (w/ codec specific names if appropriate).
I spoke with James Zern from the encoding team today:
API proposal: https://github.com/w3c/webcodecs/pull/633
This is PR introduces codec specific quantizer fields in VideoEncoderEncodeOptions dictionary.
dictionary VideoEncoderEncodeOptions {
boolean keyFrame;
VideoEncoderEncodeOptionsForVp9 vp9;
VideoEncoderEncodeOptionsForAv1 av1;
};
dictionary VideoEncoderEncodeOptionsForVp9 {
unsigned short? quantizer;
}
Alternative API https://github.com/w3c/webcodecs/pull/642
This is PR introduces a generic quantizer field in VideoEncoderEncodeOptions dictionary.
dictionary VideoEncoderEncodeOptions {
boolean keyFrame;
double? quantizer;
};
On March 7th w3c media working group decided that codec specific quantizer fields are preferred. API proposal: https://github.com/w3c/webcodecs/pull/633
Rationale:
@dalecurtis Can we close this issue?
Now landed.
Customize BRCs by applications, in addition to CBR/VBR provided by VideoEncoder.
Some applications prefer to implement its own BRC according to per-frame QP, to better response to network bandwidth estimation. One such per-frame QP BRC implement can be found: https://github.com/intel/libmebo/blob/master/explainer.md