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

Introducing a codec specific 'quantizer' mode for VideoEncoder #633

Merged
merged 1 commit into from Mar 13, 2023

Conversation

Djuffin
Copy link
Contributor

@Djuffin Djuffin commented Feb 1, 2023

A codec specific quantizer is set for each video frame for constant quality or fine tuned external rate control.

Addressing Issue 270


Preview | Diff

@aboba
Copy link
Collaborator

aboba commented Feb 2, 2023

So quantizer support is only for VP9?

@Djuffin
Copy link
Contributor Author

Djuffin commented Feb 2, 2023

So quantizer support is only for VP9?

No, this PR is deliberately limited to VP9 to demonstrate the idea and keep the change small.
AV1 and H264 will follow.

@solmaks
Copy link

solmaks commented Feb 2, 2023

If there is no technical reason to exclude other codecs, can we come up with codec agnostic API surface from the get go?

@aboba
Copy link
Collaborator

aboba commented Feb 2, 2023

Could we have "VideoEncoderEncodeOptions" instead of "VideoEncoderEncodeOptionsForVp9"?

Also, might be helpful to expose the QPmin and QPmax and to use [EnforceRange] so quantizer values can't be set outside the range.

@Djuffin
Copy link
Contributor Author

Djuffin commented Feb 2, 2023

If there is no technical reason to exclude other codecs, can we come up with codec agnostic API surface from the get go?

Could we have "VideoEncoderEncodeOptions" instead of "VideoEncoderEncodeOptionsForVp9"?

We can certainly simply put quantizer into VideoEncoderEncodeOptions, like it was originally proposed in #270, but there is a concern that QP is too codec specific in its range and effect on encoding. It's like having very different parameters assigned to the same name.

Also, might be helpful to expose the QPmin and QPmax and to use [EnforceRange] so quantizer values can't be set outside the range.

I though [EnforceRange] only enforces integer range.
QPmin and QPmax are part of codec spec, power users that use per-frame QP probably know it already, don't they?

@Djuffin
Copy link
Contributor Author

Djuffin commented Feb 6, 2023

@padenot @youennf
What do you think about quantizer being codec specific rather than a generic parameter?

@solmaks
Copy link

solmaks commented Feb 7, 2023

Introducing an API surface that will need changes/updates for every new video codec is an unnecessary complexity (and extra work for everyone). For instance, getting this available for H264 will required a spec iteration (and more code in implementation), same for AV1, same for H265, same for some new codec 10 year later down the road. Is there a concern that QP does not apply to or does not have a similar effect (higher QP means higher compression, lower QP means lower compression) on current generation of video codecs used in the industry?

@Djuffin
Copy link
Contributor Author

Djuffin commented Feb 8, 2023

I don't feel very strongly about it, but since QP has different ranges for different codecs it seems logical to put them into codec specific parts of the spec.

@aboba
Copy link
Collaborator

aboba commented Feb 24, 2023

It is probably beyond the scope of this PR, but I'd note that the potential addition of segmentation metadata (for face detection and/or background blur) to the VideoFrame has raised the question of per-macroblock QP, which would allow the encoder to focus its efforts on "important" macro blocks (e.g. the macroblocks corresponding to the foreground, rather than a (blurred) background).

A codec specific quantizer is specified for each video frame for constant
quality or fine tuned external rate control.
@Djuffin Djuffin changed the title Introducing a new 'quantizer' mode for VideoEncoder Introducing a codec specific 'quantizer' mode for VideoEncoder Feb 28, 2023
@Djuffin
Copy link
Contributor Author

Djuffin commented Mar 8, 2023

This PR was approved at the last meeting of the media working group.

@dalecurtis dalecurtis merged commit 5c30e12 into w3c:main Mar 13, 2023
@Djuffin Djuffin deleted the qp branch March 31, 2023 23:46
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.

None yet

5 participants