Bug 1910668 Comment 2 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Note that the encoding works if the VideoFrame is constructed from ImageBitmap instead of <canvas>
```
    async function encode(index) {
        const img = await createImageBitmap(canvas);
        const frame = new VideoFrame(/*canvas*/ img, {
          timestamp: index * DURATION_PER_FRAME_US,
          duration: DURATION_PER_FRAME_US,
        });
        let keyFrame = index % KEYFRAME_INDEX_INTERVAL == 0;
        encoder.encode(frame, { keyFrame });
        frame.close();
      }
```
Note that the encoding works if the VideoFrame is constructed from ImageBitmap instead of <canvas>
```js
      async function encode(index) {
        const img = await createImageBitmap(canvas);
        const frame = new VideoFrame(/*canvas*/ img, {
          timestamp: index * DURATION_PER_FRAME_US,
          duration: DURATION_PER_FRAME_US,
        });
        let keyFrame = index % KEYFRAME_INDEX_INTERVAL == 0;
        encoder.encode(frame, { keyFrame });
        frame.close();
      }
```
Note that the encoding works if the VideoFrame is constructed from ImageBitmap instead of <canvas> (the mp4 mux in the demo has some problems, but the seek the video in Firefox should make it play).
```js
      async function encode(index) {
        const img = await createImageBitmap(canvas);
        const frame = new VideoFrame(/*canvas*/ img, {
          timestamp: index * DURATION_PER_FRAME_US,
          duration: DURATION_PER_FRAME_US,
        });
        let keyFrame = index % KEYFRAME_INDEX_INTERVAL == 0;
        encoder.encode(frame, { keyFrame });
        frame.close();
      }
```

Back to Bug 1910668 Comment 2