WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 270159
264893
VideoEncoder outputs mostly key frames
https://bugs.webkit.org/show_bug.cgi?id=264893
Summary
VideoEncoder outputs mostly key frames
Jacob Bandes-Storch
Reported
2023-11-15 12:19:31 PST
VideoEncoder with `avc1.42001f` seems to output mostly `key` frames, and rarely any `delta` frames, using the following configuration: { codec: "avc1.42001f", // Baseline profile (42 00) with level 3.1 (1f) width, height, avc: { format: "annexb" }, } Steps to reproduce: 1. Visit
https://codesandbox.io/s/crimson-http-nvddmr?file=/src/index.mjs
2. Open the console tab and observe the output is "{keyFrames: 20, deltaFrames: 0}". 3. Try changing the config's `framerate` and `bitrate`, but no changes seem to produce delta frames. This occurs on macOS 14.0 (23A344). Same behavior in Safari 17.0 (19616.1.27.211.1) and also in Safari Technology Preview 182 (Safari 17.4, WebKit 19618.1.4.1). Full code below: ``` async function main() { const width = 200; const height = 100; const img = new ImageData(width, height); for (let r=0;r<height;r++) { for (let c=0;c<width;c++) { img.data[(r*width+c)*4+0] = Math.floor(r/height*255); img.data[(r*width+c)*4+1] = Math.floor(c/width*255); img.data[(r*width+c)*4+2] = 127; img.data[(r*width+c)*4+3] = 255; } } const bitmap = await createImageBitmap(img); let keyFrames=0; let deltaFrames=0; const encoder = new VideoEncoder({ output: (chunk, metadata) => { if (chunk.type==="key") { ++keyFrames; } else if (chunk.type === "delta") { ++deltaFrames; } console.log('output chunk',chunk,metadata); }, error: (err) => { console.error('encode error', err) } }) encoder.addEventListener("dequeue", (event) => { console.log('dequeued') }) const fps = 30; encoder.configure({ codec: "avc1.42001f", // Baseline profile (42 00) with level 3.1 (1f) width, height, // latencyMode: "realtime", // framerate: fps, avc: { format: "annexb" }, // hardwareAcceleration:"prefer-software" // bitrate:1000000, // bitrate: 10000000, }); for (let i=0; i < 20; i++) { const frame = new VideoFrame(bitmap, { timestamp:i * 1/fps * 1e6, duration:1/fps * 1e6, }); encoder.encode(frame, {keyFrame: i === 0}); frame.close(); } bitmap.close(); console.log("sent frames"); await encoder.flush(); console.log("flushed", {keyFrames,deltaFrames}) encoder.close(); console.log("closed", {keyFrames,deltaFrames}) } main().catch((e) => console.error(e,e.message)); ```
Attachments
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2023-11-22 12:20:18 PST
<
rdar://problem/118725469
>
youenn fablet
Comment 2
2023-11-22 13:05:23 PST
I canot reproduce on my local AS device with STP 182. I got 19 delta frames and 1 key frame. This might be below WebKit.
tamaina
Comment 3
2023-12-16 07:41:21 PST
I have created a video transpiler that is complete in a web browser and am facing the same problem.
https://github.com/tamaina/venc2/issues/4
https://venc2.vercel.app
macOS 14.2(23C64) Safari TP Release 184 (Safari 17.4, WebKit 19618.1.7.1.1)
tamaina
Comment 4
2023-12-16 11:20:45 PST
I forked the reproduction and modified it slightly.
https://codesandbox.io/p/sandbox/crimson-http-nvddmr?file=%2Fsrc%2Findex.mjs%3A58%2C5
My 14" MacBook Pro with M1Pro and iPhone 13 both have keyFrames of 20.
Jacob Bandes-Storch
Comment 5
2023-12-16 11:45:29 PST
I believe the URL you shared is the same as the original repro I posted. You may need to explicitly "save" the codesandbox for it to give you a new URL. Can you share what modifications you needed to make?
tamaina
Comment 6
2023-12-17 05:15:10 PST
Wow, sorry. The modifications are to display the logs on the browser screen (since opening the console on a mobile device is a pain) and to delay the encode dispatch.
https://codesandbox.io/p/sandbox/trusting-elgamal-zyks56
tamaina
Comment 7
2024-02-06 07:25:48 PST
I know it's probably taboo to post this, but is there any update?
youenn fablet
Comment 8
2024-02-06 07:35:48 PST
Would it be possible to send to me (
youenn@apple.com
) a sysdiagnose with the timestamp where the issue happens?
Jacob Bandes-Storch
Comment 9
2024-03-04 19:13:48 PST
It's a bit large to send by email, but I just created FB13674236 and attached the sysdiagnose there. After starting the sysdiagnose I refreshed the demo page several times in Safari while watching for the `keyFrames: 20` message -- this was between 7:03 and 7:04 PM.
Michael Hagar
Comment 10
2024-03-07 08:12:01 PST
I'm also seeing this on Safari 17.4 on Mac OS 14.4. Opening the original demo page, Safari shows 20 keyframes. Chrome Shows 1 keyframe, 19 delta frames.
youenn fablet
Comment 11
2024-03-29 00:23:25 PDT
Can anyone that was able to reproduce the issue validate this is now working properly on STP 191? *** This bug has been marked as a duplicate of
bug 270159
***
Michael Hagar
Comment 12
2024-03-29 07:09:14 PDT
I confirmed this is fixed in Safari Technology Preview 191, with the demo now showing 1 keyframe and 19 delta frames (just like Chrome and Firefox).
tamaina
Comment 13
2024-03-30 07:59:44 PDT
I too saw the generation of delta frames and a significant reduction in file size after encoding.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug