Confused by `VideoDecoderConfig.codedWidth`, does not reflect the actual coded width of the underlying coded frame
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript
- 领域
- api, audio-video-rtc
调研方向
先从 WebCodecs 中 VideoDecoderConfig.codedWidth 和 VideoFrame.codedWidth 的定义开始,然后运行所提供的 VideoEncoder/VideoDecoder AVC 复现。将报告的配置尺寸与解码帧的尺寸进行比较;完成的标准是确定该行为是否符合预期,并就规范是否需要修改以及如何修改达成一致。
由索引模型根据 Issue 内容生成。
描述
In all permutations I have tried ((Chrome, Firefox, Safari) x (Windows, Mac)), the codedWidth and codedHeight properties in the VideoDecoderConfig emitted by VideoEncoder contain the display dimensions of the frame, or in other words, the dimensions with which the encoder was initialized. In my work on Mediabunny, I have relied on this behavior extensively as a means to communicate video dimensions to muxers.
However, I kind of just realized... that behavior is wrong (probably)? The definition of VideoDecoderConfig.codedWidth is:
Width of the VideoFrame in pixels, potentially including non-visible padding, and prior to considering potential ratio adjustments.
Which is identical to the definition of VideoFrame.codedWidth.
So let's say we do this:
const decoder = new VideoDecoder({
output: (frame) => {
console.log("Actual coded width:", frame.codedWidth);
console.log(frame);
},
error: console.error,
});
const encoder = new VideoEncoder({
output: (chunk, meta) => {
console.log("Reported coded width:", meta.decoderConfig.codedWidth);
decoder.configure(meta.decoderConfig);
decoder.decode(chunk);
decoder.flush();
},
error: console.error,
});
encoder.configure({
codec: 'avc1.64001f',
width: 650,
height: 650,
bitrate: 1e6,
});
const canvas = new OffscreenCanvas(650, 650);
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'red';
ctx.fillRect(100, 100, 200, 200);
const frame = new VideoFrame(canvas, { timestamp: 0 });
encoder.encode(frame);
await encoder.flush();
We encode a 650x650 frame using AVC, which then, when decoded, has a codedWidth of 656. Makes total sense, since the dimensions have been rounded up to the nearest 16x16 macroblock, and 16 divides 656. But, the decoder config reports the codedWidth as 650.
So, same field, same definition in the spec, different values.
While I think it's useful that it contains the display dimensions, I would argue the behavior is not technically correct. Here's what I would expect:
codedWidthreflects the actualcodedWidthyou'd get by decoding the chunks (this makes it consistent, and actually provides new information that you didn't already know based on how you set up the encoder)VideoDecoderConfigis extended withdisplayWidth,displayHeight,visibleRect, andcodedRect, with definitions identical to those onVideoFrame.
What do you guys think? Is the current behavior of codedWidth faulty or intentional? Can this be fixed, or is it too late now since any change might break existing software that relies on the current behavior?
Edit:
My proposed ""change"" to codedWidth would mean that demuxers, when extracting VideoDecoderConfig for VideoDecoder, would need more complicated logic to derive the coded width, since they likely only know the display dimensions from the container metadata. Luckily, the fields are optional, so any demuxer could just omit it. But still, kinda annoying. Perhaps one should go the other route, retconning codedWidth to be defined in the spec as it is currently provided by browsers?
- 主要语言
- HTML
- 星标
- 1.3k
- 派生
- 192
- 平均合并
- 21 小时 7 分钟
- 30 天内合并 PR
- 8
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
w3c/webcodecs 的其他 Issue
-
privacy-needs-resolution
难度 1/5 1 小时以内 新手友好度 65/100
维护者通常 1 天内回复
-
editorial
难度 1/5 1 小时以内 新手友好度 68/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
NaturalIntelligence/fast-xml-parser#890 · 1 条评论 ·
维护者通常 3 天内回复
-
enhancement
难度 1/5 1 小时以内 新手友好度 85/100
FujiNetWIFI/fujinet-lib#122 · 1 条评论 ·
维护者通常 1 天内回复
-
effort: low prio: low ready
难度 2/5 1-3 小时 新手友好度 82/100
digitalfabrik/integreat-cms#4616 ·
维护者通常 5 天内回复
-
[BUG] Cloudflare KV binding 模式下 kvDriver.list() 沿用 EdgeOne 语义,字段名不匹配导致 key 格式下初始化 500 并耗尽 list 配额可能已有人在做 @wumingzhinu 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 64/100
OpenListTeam/OpenList-Worker#125 ·
维护者通常 2 天内回复
-
refactor topic-map
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 1 天内回复