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

Add AvcEncoderConfig to specify optional annex-b format. #117

Merged
merged 2 commits into from
Feb 10, 2021

Conversation

chcunningham
Copy link
Collaborator

@chcunningham chcunningham commented Dec 21, 2020

Add AvcEncoderConfig to specify annex-b format.

Previously the spec doesn't say which format is used. This clarifies
that the default format is AVC and that the AVCConfigurationBox
(contents of MP4 avcC) is emitted by the encoder output callback.

Furhter, it the ability to instead use annex-b format.

Fixes #72. Fixes #97.


Preview | Diff

Previously the spec doesn't say which format is used. This clarifies
that the default format is AVC and that the AVCConfigurationBox
(contents of MP4 avcC) is emitted by the encoder output callback.

Furhter, it the ability to instead use annex-b format.

Fixes #72.
@chcunningham chcunningham changed the base branch from master to encoder_emits_decoder_config December 21, 2020 20:50
@chcunningham chcunningham linked an issue Dec 21, 2020 that may be closed by this pull request
Copy link
Member

@jianjunz jianjunz left a comment

Choose a reason for hiding this comment

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

Hi,

How about adding a similar item to VideoDecoderConfig, so the decoder could be configured to decode Annex B bitstreams.

@@ -1201,6 +1213,8 @@
required unsigned long cropHeight;
unsigned long displayWidth;
unsigned long displayHeight;

AvcEncoderConfig avc;
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps it could be named as codecSpecificConfig, and the type could be (AvcEncoderConfig or CodecnameEncoderConfig) in the future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I follow, but I don't think the (X or Y) syntax plays nice when X and Y are both dictionaries. The UA code that converts js -> c++ binding doesn't know how to disambiguate. In some cases, we may even have two dictionary types with some overlapping of keys.

Copy link
Collaborator Author

@chcunningham chcunningham left a comment

Choose a reason for hiding this comment

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

How about adding a similar item to VideoDecoderConfig, so the decoder could be configured to decode Annex B bitstreams.

We do plan to add support support annex-b in VideoDecoder, but via a different mechanism. The idea is that the VideoDecoderConfig.description, when present, will contain the AVCC info and we will assume avc format. If absent, we will assume the AVC stream is in annex-b format.

The assymetric mechanism is a bit weird, but I think its the lesser evil. Think of VideoDecoderConfig.description as essentially the 'extradata' from FFmpeg's AVCodecContext. This is a common notion for all codecs, but the details are codec specific. Like AVC, other codecs including opus, aac, and vorbis will also use this mechanism to provide various metadata (e.g. the opus header, or the vorbis codebook).

Using description in this way should be familiar and avoids needing to create a decoder-config codec specific structure for each codec.

For encoding, codec specific configuration seems unavoidable. The avc vs annex-b is just the tip of the iceberg for possible codec-specific encoder configuration parameters.

@@ -1201,6 +1213,8 @@
required unsigned long cropHeight;
unsigned long displayWidth;
unsigned long displayHeight;

AvcEncoderConfig avc;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I follow, but I don't think the (X or Y) syntax plays nice when X and Y are both dictionaries. The UA code that converts js -> c++ binding doesn't know how to disambiguate. In some cases, we may even have two dictionary types with some overlapping of keys.

@chcunningham
Copy link
Collaborator Author

@padenot approved these api shape changes in our weekly editors call.

@chcunningham chcunningham merged commit 2d2f06b into encoder_emits_decoder_config Feb 10, 2021
@jianjunz
Copy link
Member

Thanks for your explanation.

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.

Codec specific configuration parameters Video h264 decoder supports both Annex B and AVCC format
2 participants