Skip to main content

@remotion/media-parser

Media Parser

这是一个解析视频和音频文件以提取元数据和样本的包。

🌐 This is a package that parses video and audio files to extract metadata and samples.

设计目标:

🌐 Design goals:

介绍视频

🌐 Introduction video


安装

🌐 Installation

npx remotion add @remotion/media-parser

你好,世界

🌐 Hello World

从视频文件获取元数据 - 支持超过20个不同的字段。

🌐 Get metadata from a video file - over 20 different fields are supported.

Get the duration and codec of a video
import {parseMedia} from '@remotion/media-parser'; const {durationInSeconds, videoCodec} = await parseMedia({ 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 video
import {parseMedia} from '@remotion/media-parser'; await parseMedia({ src: 'https://remotion.media/video.mp4', onVideoTrack: ({track}) => { // Get information about the console.log(track.width); console.log(track.height); return (sample) => { // Retrieve samples as they are extracted console.log(sample.timestamp); // 0 console.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

应用接口

🌐 APIs

以下 API 可用:

🌐 The following APIs are available:

读者

🌐 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

Remotion 许可证