提取ID3标签和EXIF数据
@remotion/media-parser 允许你提取嵌入视频文件中的元数据,例如 ID3 标签或 EXIF 数据。
Extracting metadataimport {parseMedia } from '@remotion/media-parser'; const {metadata } = awaitparseMedia ({src : 'https://remotion.media/video.mp4',fields : {metadata : true, }, });console .log (metadata ); /* [ { key: 'com.apple.quicktime.model', trackId: null, value: 'iPhone 15 Pro', }, { key: 'encoder', trackId: null, value: 'Lavf57.19.100', } ] */
一些元数据指的是某个特定的音轨,例如“encoder”字段。
在这种情况下,trackId 字段将包含非空值。你可以通过将 tracks 字段设置为 true 来获取音轨列表。
🌐 Some metadata refers to a certain track, such as the 'encoder' field.
In this case, the trackId field will contain a non-null value. You can get a list of tracks by setting the tracks field to true.
常见元数据字段
🌐 Common metadata fields
以下是一些常见元数据的非完整列表,你可能希望解析并显示这些元数据。
使用container字段获取视频的容器格式。
🌐 Here is a non-exhaustive list of commonly seen metadata that you may want to parse and display.
Use the container field to get the container format of the video.
ISO 基础媒体 (.mp4, .mov)
🌐 ISO Base Media (.mp4, .mov)
| Field | Description | Example value |
|---|---|---|
artist | ID3 Artist Tag | "Blender Foundation 2008, Janus Bager Kristensen 2013" |
album | ID3 Album Tag | "The Resistance" |
composer | ID3 Composer Tag | "Sacha Goedegebure" |
comment | ID3 Comment Tag | "Made with Remotion 4.0.234" |
releaseDate | ID3 Release Date Tag | |
genre | ID3 Genre Tag | "Animation" |
title | ID3 Title Tag | "Big Buck Bunny, Sunflower version" |
writer | ID3 Writer Tag | "Sacha Goedegebure" |
director | ID3 Director Tag | |
producer | ID3 Producer Tag | |
description | ID3 Description Tag | |
duration | ID3 Duration Tag | "00:00:10.000000000" |
encoder | Software used to encode the video/stream | "Lavf60.16.100" |
copyright | Copyright information | "Blender Foundation" |
major_brand | The major brand of the file | "isom" |
minor_version | The minor version of the file | "512" |
compatible_brands | Container compatibility | "isomav01iso2mp41" |
handler_name | Software used to mux the video | "GPAC ISO Video Handler" |
com.apple.quicktime.camera.focal_length.35mm_equivalent | 35mm-equivalent focal length | 23 |
com.apple.quicktime.camera.lens_model | Lens of Apple Device | "iPhone 15 Pro back camera 6.765mm f/1.78" |
com.apple.quicktime.creationdate | Creation date of video | "2024-10-01T12:46:18+0200" |
com.apple.quicktime.software | Operating System Version (e.g. iOS) of Device | "18.0" |
com.apple.quicktime.model | Device used to capture video | "iPhone 15 Pro" |
com.apple.quicktime.make | Maker of the device used to capture the video | "Apple" |
com.apple.quicktime.live-photo.vitality-score | An identifier that represents the vitality score of a Live Photo movie | 1 |
com.apple.quicktime.live-photo.vitality-scoring-version | An identifier that represents the version of the algorithm responsible for scoring the Live Photo movie for vitality | 4 |
com.apple.quicktime.content.identifier | An identifier that represents the content identifier in QuickTime | "2C1C7C94-E977-45D0-9B3F-9A9CA8EFB47D" |
com.apple.quicktime.full-frame-rate-playback-intent | An key that represents whether this movie should play at full frame rate | 1 |
com.apple.quicktime.live-photo.auto | An identifier that represents whether the live photo movie used auto mode | 1 |
com.apple.quicktime.location.accuracy.horizontal | An identifier that represents the horizontal accuracy of the location data | 1 |
com.apple.quicktime.information | General information | "Captured with VisionCamera by mrousavy" |
Matroska(.mkv,.webm)
🌐 Matroska (.mkv, .webm)
| 字段 | 描述 | 示例值 |
|---|---|---|
duration | 视频/流的持续时间 | "00:00:00.333000000" |
encoder | 用于编码流/视频的软件 | "Lavc60.31.102 libx264" |
comment | 用于编码流/视频的软件 | "Made with Remotion 4.0.192" |
RIFF(.avi)
🌐 RIFF (.avi)
| 字段 | 描述 | 示例值 |
|---|---|---|
encoder | 用于编码流/视频的软件 | "Lavf57.19.100" |
MP3
请参见这里了解可以返回的标签列表。
APIC 标签不会作为 metadata 字段的一部分返回,而是作为 images 数组中的独立元素返回。
🌐 See here for a list of tags that can be returned.
The APIC tag will not be returned as part of the metadata field, but separately as elements in the images array.
WAV
| 字段 | 描述 | 示例值 |
|---|---|---|
ISFT | 用于编码流/视频的软件 | "Lavf60.16.100 (libsndfile-1.0.31)" |
无损音频格式
🌐 FLAC
| 字段 | 描述 | 示例值 |
|---|---|---|
vendor | 用于编码流/视频的软件 | "reference libFLAC 1.3.2 20190804" |
title | 曲目名称 | "The Happy Meeting" |
date | 录制日期或年份 | "2020" |
album | 音乐专辑 | "Sample files" |
artist | 音乐艺术家 | "Sample files" |
tracknumber | 专辑中歌曲索引 | "4" |
genre | 音乐类型 | "Ambient" |
查看更多:https://www.rfc-editor.org/rfc/rfc9639.html#name-standard-field-names
🌐 See more: https://www.rfc-editor.org/rfc/rfc9639.html#name-standard-field-names
字段不是唯一的
🌐 Fields are not unique
某些字段在每个视频中可能出现多次,例如 encoder、comment 或 duration。通常它们会限定在某个特定的轨道上,这就是为什么元数据对象中存在 trackId 字段的原因。
🌐 Some fields may appear multiple times per video, such as encoder, comment or duration.
Oftentimes they are scoped to a certain track, which is why the trackId field is present in the metadata object.
另请参阅
🌐 See also