@remotion/media-parser
这是一个解析视频和音频文件以提取元数据和样本的包。
🌐 This is a package that parses video and audio files to extract metadata and samples.
设计目标:
🌐 Design goals:
- 支持所有主要容器:
.mp4、.mov、.webm、.mkv、.avi、.m3u8、.ts、.mp3、.wav、.aac、.m4a和.flac。 - 轻松获取多媒体文件的各种信息
- 在浏览器、Node.js 和 Bun 中工作
- 以最少的获取满足你的查询
- 函数式 TypeScript API
- 在传递不支持的媒体时有用
- 允许使用 WebCodecs 解码视频帧和音频样本
- 可暂停、可恢复和可取消
- 能够在媒体文件中寻求到不同的位置
- 无依赖
介绍视频
🌐 Introduction video
安装
🌐 Installation
- Remotion CLI
- npm
- bun
- pnpm
- yarn
npx remotion add @remotion/media-parser
This assumes you are currently using v4.0.431 of Remotion.npm i --save-exact @remotion/media-parser@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.This assumes you are currently using v4.0.431 of Remotion.pnpm i @remotion/media-parser@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.This assumes you are currently using v4.0.431 of Remotion.bun i @remotion/media-parser@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.This assumes you are currently using v4.0.431 of Remotion.yarn --exact add @remotion/media-parser@4.0.431
Also update
remotion and all `@remotion/*` packages to the same version.Remove all
^ character in front of the version numbers of it as it can lead to a version conflict.你好,世界
🌐 Hello World
从视频文件获取元数据 - 支持超过20个不同的字段。
🌐 Get metadata from a video file - over 20 different fields are supported.
Get the duration and codec of a videoimport {parseMedia } from '@remotion/media-parser'; const {durationInSeconds ,videoCodec } = awaitparseMedia ({src : 'https://remotion.media/video.mp4',fields : {durationInSeconds : true,videoCodec : true, }, });console .log (durationInSeconds ); // 5.056;console .log (videoCodec ); // 'h264';
从视频文件中提取样本 - 支持 WebCodecs。
🌐 Extract samples from a video file - supports WebCodecs.
Extract samples from a videoimport {parseMedia } from '@remotion/media-parser'; awaitparseMedia ({src : 'https://remotion.media/video.mp4',onVideoTrack : ({track }) => { // Get information about theconsole .log (track .width );console .log (track .height ); return (sample ) => { // Retrieve samples as they are extractedconsole .log (sample .timestamp ); // 0console .log (sample .data ); // Uint8Array(12345) }; }, });
样品是什么?
样本包含音频或视频数据——但它们使用像 AAC(音频)或 H.264(视频)这样的编解码器进行压缩。 你可以通过解码将音频样本转换为波形,将视频样本转换为图片。
🌐 Samples contain audio or video data - but they are compressed using codecs like AAC for audio or H.264 for video.
You can turn audio samples into a waveform and video samples into images by decoding them.
指南
🌐 Guide
parseMedia()应用接口
🌐 APIs
以下 API 可用:
🌐 The following APIs are available:
1_000_000) of WebCodecs as a constant.读者
🌐 Readers
为你的文件来源选择适当的读取器:
🌐 Choose the appropriate reader for your file source:
作家
🌐 Writers
选择如何存储使用 downloadAndParseMedia() 下载的文件:
🌐 Choose how to store files downloaded using downloadAndParseMedia():
类型
🌐 Types
这与 FFmpeg 比较如何?
🌐 How does this compare to FFmpeg?
- Media Parser 专注于 JavaScript 和网络。它旨在拥抱这一语言并利用 JavaScript 提供的 API。
- 与 FFmpeg 不同,Remotion Media Parser 不具备解码和编码功能——它仅解析媒体文件。相反,我们希望你将它与 WebCodecs(浏览器内置的原生 API)结合使用。
- Media Parser 没有命令行接口,无法集成到本地应用中。
这与 MP4Box.js 相比如何?
🌐 How does this compare to MP4Box.js?
MP4Box.js 在解析 ISO 基本媒体格式(.mp4、.m4a、.mov)方面做得更好,并且支持从中读取更多信息。
Remotion Media Parser 支持更多的容器格式,其目标是能够处理任意用户提供的媒体文件。
🌐 MP4Box.js does a better job at parsing the ISO Base Media Format (.mp4, .m4a, .mov) and supports reading more information from it.
Remotion Media Parser supports more container formats, with the goal that it can handle arbitrary user-provided media files.
谢谢
🌐 Thank you
![]() | 感谢 Tella 通过 $10,000 推动 @remotion/media-parser 的发展! |
许可证
🌐 License
