Skip to main content

提取ID3标签和EXIF数据

@remotion/media-parser 允许你提取嵌入视频文件中的元数据,例如 ID3 标签或 EXIF 数据。

Extracting metadata
import {parseMedia} from '@remotion/media-parser'; const {metadata} = await parseMedia({ 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)

FieldDescriptionExample value
artistID3 Artist Tag"Blender Foundation 2008, Janus Bager Kristensen 2013"
albumID3 Album Tag"The Resistance"
composerID3 Composer Tag"Sacha Goedegebure"
commentID3 Comment Tag"Made with Remotion 4.0.234"
releaseDateID3 Release Date Tag
genreID3 Genre Tag"Animation"
titleID3 Title Tag"Big Buck Bunny, Sunflower version"
writerID3 Writer Tag"Sacha Goedegebure"
directorID3 Director Tag
producerID3 Producer Tag
descriptionID3 Description Tag
durationID3 Duration Tag"00:00:10.000000000"
encoderSoftware used to encode the video/stream"Lavf60.16.100"
copyrightCopyright information"Blender Foundation"
major_brandThe major brand of the file"isom"
minor_versionThe minor version of the file"512"
compatible_brandsContainer compatibility"isomav01iso2mp41"
handler_nameSoftware used to mux the video"GPAC ISO Video Handler"
com.apple.quicktime.camera.focal_length.35mm_equivalent35mm-equivalent focal length23
com.apple.quicktime.camera.lens_modelLens of Apple Device"iPhone 15 Pro back camera 6.765mm f/1.78"
com.apple.quicktime.creationdateCreation date of video"2024-10-01T12:46:18+0200"
com.apple.quicktime.softwareOperating System Version (e.g. iOS) of Device"18.0"
com.apple.quicktime.modelDevice used to capture video"iPhone 15 Pro"
com.apple.quicktime.makeMaker of the device used to capture the video"Apple"
com.apple.quicktime.live-photo.vitality-scoreAn identifier that represents the vitality score of a Live Photo movie1
com.apple.quicktime.live-photo.vitality-scoring-versionAn identifier that represents the version of the algorithm responsible for scoring the Live Photo movie for vitality4
com.apple.quicktime.content.identifierAn identifier that represents the content identifier in QuickTime"2C1C7C94-E977-45D0-9B3F-9A9CA8EFB47D"
com.apple.quicktime.full-frame-rate-playback-intentAn key that represents whether this movie should play at full frame rate1
com.apple.quicktime.live-photo.autoAn identifier that represents whether the live photo movie used auto mode1
com.apple.quicktime.location.accuracy.horizontalAn identifier that represents the horizontal accuracy of the location data1
com.apple.quicktime.informationGeneral 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

某些字段在每个视频中可能出现多次,例如 encodercommentduration。通常它们会限定在某个特定的轨道上,这就是为什么元数据对象中存在 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