-
Notifications
You must be signed in to change notification settings - Fork 141
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
It's hard to set size(width/height) information in VideoDecoderConfig
#94
Comments
Take a look at #26 for reasoning behind the current design. In general we cannot know what the size will be before a frame is decoded, typically this information is provided by the media container instead. In a prototype we had fields for aspect ratio instead of size, but we thought this was more difficult to explain. I'll leave this open to discuss that choice. |
Thank you for information of current design. On the other hands, MPEG2-System (like MPEG2-TS/PS Format) doesn't include this kind of information(width/height/PAR/DAR). AS #26 (comment) points out, For So I'd appreciate it if WebCodecs would consider that let me set
(Aspect ratio is complicated one for some not experts, so |
My apologies for bothering you repeatedly. I'm not good at JavaScript (and English😅), so following description might seem oddly.
It means that how about does WebCodecs allow us to call |
Your request is understood, and I believe it is possible. |
I'm sorry for bothering agin. (Currently, I've been able to configure without |
@chcunningham: Last time this was discussed this there wasn't a reason to mark these as required, and Chrome's implementation without required has been working. Chrome's implementation doesn't handle any of this correctly, I filed crbug.com/1179101. |
@sandersdan if it's only function is to hint at what type of internal decoder (hardware vs software) should be created, perhaps we should also drop the crop and display sizes? |
For VideoDecoderConfig, the coded size attributes are no longer required. They only serve as a hint for the UA to create an approriate underlying decoder (e.g. hardware accelerated for higher resolutions) and are not strictly required. Fixes #94. For VideoEncoderConfig, cropWidth and cropHeight are renamed to simply be width and height. The crop prefix was added in #113 as I realized that we were describing the "crop" size of the encoded VideoFrames. But I now think this risks giving the impression that the encoder is going to crop frames. Being intuitive is more important than being pedantic.
The crop and display sizes are already optional, but they are used to compute the pixel aspect ratio to apply to decoded frames. I didn't find a satisfactory way to use them without also providing a coded size though, so I'm not sure where to go from here. Some options:
|
Re-opening to track resolution of the above comment |
+1 As a codec side perspective, resolution and sample aspect ratio settings are only for encoders, not for decoders in general. A decoder just reads such information from bitstream. Important thing in here In regards to So IMO, here is the thing... dictionary VideoEncoderConfig {
required DOMString codec;
unsigned long long bitrate;
required unsigned long width; // it is width of resolution
required unsigned long height;
unsigned long sar_width; // or dar_width (display aspect ratio)
unsigned long sar_height; // or dar_height
HardwareAcceleration hardwareAcceleration = "allow";
}; dictionary VideoDecoderConfig {
required DOMString codec;
BufferSource description;
unsigned long sar_width; // or dar_width. It'll overwrite bitstream settings if set
unsigned long sar_height; // or dar_height
HardwareAcceleration hardwareAcceleration = "allow";
}; [Exposed=(Window,DedicatedWorker)]
interface VideoFrame {
...
readonly attribute PixelFormat format;
readonly attribute FrozenArray<Plane> planes;
readonly attribute unsigned long width;
readonly attribute unsigned long height;
readonly attribute unsigned long cropLeft;
readonly attribute unsigned long cropTop;
readonly attribute unsigned long cropWidth;
readonly attribute unsigned long cropHeight;
readonly attribute unsigned long displayWidth; // it'll be ignore at encoding
readonly attribute unsigned long displayHeight;
readonly attribute unsigned long long? duration;
readonly attribute unsigned long long? timestamp;
...
}; I would appreciate it if you would confirm. |
The IDL you provided seems logical to me, but the description doesn't seem quite right. Decoders shouldn't care about aspect ratio in general, but they do produce VideoFrames which contain that information. Depending on the codec the aspect ratio information may be in the bitstream or in the container (or both), so a generic decode API does need to include it. (Note: Chrome's <video> implementation prefers container aspect ratio metadata over in-band for more consistent cross-platform behavior. This matches your description of SAR is the most technically correct way to provide the information to the decoder, but it's usually quite inconvenient to work with (eg. MP4 metadata [excluding optional PASP] includes only a DAR, and conversions are lossy). Intended display size is at least usually integer values. I don't know if there is a silver bullet here, but I think it's down to two choices:
I'm leaning towards (2) because we can always add a PAR path later if there is demand for it, in a backwards-compatible way. This would mean that apps would need to reconfigure at places where the DAR changes, but it's likely they would be doing that anyway. |
Thank you for your confirmation.
Totally agree. SAR/DAR information are just a metadata for codec.
+1. So I wanted to ask that is it possible to consider to revise like in the following?
(Some webcam may output raw bitstream which include PAR in VUI, that's why I hope above) |
If we did this, it would likely be on a best-effort basis (allowed but not mandated by the spec). My reasoning is that not all decoders reliably expose this information, so a given implementation may not be able to do this correctly in every case. Usually I prefer solutions that result in reliable cross-platform behavior, but I'm interested to hear if you prefer best-effort here. |
Thank you. I'm sorry that I overlooked the point regarding standardization. It reminds me that some other person told that there are no way to get some metadata from bitstream (like SPS, VUI, SEI in H.26x) with WebCodecs. So, I prefer original (2) in #94 (comment) as you describe, too. On the other hand, I think WebCodecs needs a method to get Metadata (including feature check method, as informative in spec?) Anyway, thank you so match for hearing my voice. |
I think the above points are persuasive (great discussion). I support option (2) in #94 (comment)
I've filed #198 to track this request |
Triage note: marked 'breaking', as the outcome of the above discussion is to deprecate crop sizing from the VideoDecoderConfig. In practice this shouldn't actually break anyone, as Chrome's impl doesn't currently use those sizes (other than to validate them), so they're ignored either way. |
In reviewing the PR I realized I didn't completely understand the resolution above. I thought config.displayWidth|Height was a passthrough to set frame.displayWidht|Height. But @sandersdan clarified his intent was that this actually provide an aspect ratio setting, which would have the effect of increasing one of frame.displayWidth or frame.displayHeight as needed to produce the describe aspect ratio as described in html. Beyond the html historical precedent, using scaling in this way has the nice property that it allows for inband resoution changes to occur (assuming the new resolution uses the same DAR). To help users avoid the confusion I was having, we propose renaming config.displayWidth|Height -> config.displayAspectWidth|Height. |
It looks clear for me. I have another idea. This Issue figured out that a aspect ratio is just a meta data for rendering. This is my just idea. |
I think this is the same as #161? |
Wow, it's great and perfect! 🎉 Thanks for your telling 😄 |
The spec has been updated to remove the crop attributes, in #250 Please re-open if necessary! |
(I'm sorry if this issue is duplicated one.)
According to Spec,
VideoDecoder
requires size(codec and crop) information to configure decoder.But I think that it's hard to set without analyzing raw stream when I received only raw stream.
Like H.26x codec includes coded size information in SPS as RBSP. So decoder may do without passing size information.
VideoFrame
already has information to render appropriately. However I would be happy if there is some notification callback to get size information before decoding a first frame.The text was updated successfully, but these errors were encountered: