javascript - 使用 VideoDecoder 解码 MP4 视频

标签 javascript mp4 video-processing webcodecs

我想制作一个网络应用程序,它提取 MP4 文件的每一帧,并将其另存为 PNG。设置

我正在使用VideoDecoder 。它有一个 decode 方法,该方法接收一个 EncodedVideoChunk,其中包含一个字节数组 - “视频 block ”。

我解析了this MP4 file获取“moov”-“trak”-0-“mdia”-“minf”-“stbl”。我从 stbl.stco[0] 中切出一段 MP4 文件,长度为 stbl.stsz[0](本例中为 80 和 42548)。字节为

[0, 0, 0, 2,   9, 16, 0, 0,   166, 42, 37, 136,   128, 67, 255, 235, ...]

我仍然看到一条错误消息:

Failed to execute 'decode' on 'VideoDecoder': A key frame is required after configure() or flush().

我做错了什么?如何找到应该提供给 VideoDecoder 的正确数据?

最佳答案

我的所有步骤都是正确的。问题是,VideoDecoder 在 configure() 期间错过了 description 参数。似乎没有它就无法解码任何 MP4 文件。

使用stbl.stsd.extraData.avcC处的40字节序列作为描述的值。

关于javascript - 使用 VideoDecoder 解码 MP4 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73184093/

相关文章:

javascript - 在React.tsx中使用createContext传递useState

javascript - Node.js 移动繁重的 CPU 密集型任务

animation - FFmpeg,动画类型 : How to move the video screen along the large images?

python-2.7 - 使用Python查找blackpixels的平均位置

java - 是否有 EGLImage 的 java 版本可以有效地从 OpenGL 读取像素?

javascript - Jquery TokenInput 未加载结果

javascript - 如何在 iOS 中使 select 的模糊事件与桌面匹配?

php - 获取 H.264 MP4 的尺寸

html - Google Chrome 28 无法播放 mp4 视频

video - 哪些视频编解码器适用于 Google Chromebook