可用字段
以下字段可在 parseMedia() 中使用:
🌐 The following fields are available in parseMedia():
dimensions
MediaParserDimensions | null
视频的尺寸。
任何旋转都已应用——尺寸就像媒体播放器显示的一样。
使用 unrotatedDimensions 获取旋转前的尺寸。
🌐 The dimensions of the video.
Any rotation is already applied - the dimensions are like a media player would show them.
Use unrotatedDimensions to get the dimensions before rotation.
如果传入的媒体是音频文件,这将返回 null。
🌐 If the media passed is an audio file, this will return null.
durationInSeconds
数字 | null
🌐 number | null
视频的时长(以秒为单位)。 只有在元数据中存储了时长时才返回非空值。
🌐 The duration of the video in seconds.
Only returns a non-null value if the duration is stored in the metadata.
slowDurationInSeconds
number
媒体的持续时间,以秒为单位,但保证会返回一个值。
🌐 The duration of the media in seconds, but it is guaranteed to return a value.
如果需要,将读取整个视频文件以确定时长。
然而,如果元数据中存储了时长,将会使用元数据,这样就不需要读取整个文件。
🌐 If needed, the entire video file is read to determine the duration.
However, if the duration is stored in the metadata, it will be used, so it will not read the entire file.
name
string
文件的名称。
🌐 The name of the file.
container
文件的容器。
🌐 The container of the file.
size
数字 | null
🌐 number | null
输入的字节大小。
🌐 The size of the input in bytes.
mimeType
字符串 | 空
🌐 string | null
获取文件时返回的文件的 MIME 类型。 仅在使用 webReader(默认)时可用。
🌐 The MIME type of the file that was returned when the file was fetched.
Only available if using the webReader (default).
slowStructure
视频的内部结构。不稳定的内部数据结构,请参考 TypeScript 类型查看内部内容。
🌐 The internal structure of the video. Unstable, internal data structure, refer to the TypeScript types to see what's inside.
fps
数字 | null
🌐 number | null
视频的帧率。
只有在元数据中存储了帧率时才返回非空值。
🌐 The frame rate of the video.
Only returns a non-null value if the frame rate is stored in the metadata.
slowFps
number
视频的帧率,但保证会返回一个值。
🌐 The frame rate of the video, but it is guaranteed to return a value.
如果需要,将读取整个视频文件以确定帧率。然而,如果元数据中存储了帧率,则会使用该帧率,因此不会读取整个文件。
🌐 If needed, the entire video file is read to determine the frame rate. However, if the frame rate is stored in the metadata, it will be used, so it will not read the entire file.
videoCodec
MediaParserVideoCodec | null
文件的视频编解码器。
如果存在多个视频轨道,这将是第一个视频轨道。
可能是 "h264"、"h265"、"vp8"、"vp9"、"av1"、"prores" 或 null(如果编解码器未知)。
🌐 The video codec of the file.
If multiple video tracks are present, this will be the first video track.
One of "h264", "h265", "vp8", "vp9", "av1", "prores" or null (in case of an unknown codec).
audioCodec
MediaParserAudioCodec | null
文件的音频编解码器。
如果存在多个音轨,这将是第一条音轨。
可以是 'aac'、'mp3'、'aiff'、'opus'、'pcm'、'flac'、'unknown'(有音频但无法识别)或 null(如果未检测到音频)。
🌐 The audio codec of the file.
If multiple audio tracks are present, this will be the first audio track.
One of 'aac', 'mp3', 'aiff', 'opus', 'pcm', 'flac', 'unknown' (audio is there but not recognized) or null (in case of no audio detected).
metadata
元数据字段,例如 ID3 标签或 EXIF 数据。
更多信息请参见 元数据。
🌐 Metadata fields such as ID3 tags or EXIF data.
See metadata for more information.
location
MediaParserLocation | null
视频拍摄的地点。如果不可用,则为 null 或者:
🌐 The location of the video was shot. Either null if not available or:
latitude:该位置的纬度longitude:该位置的经度altitude:该位置的海拔高度(可以是null)horizontalAccuracy:位置的水平精度(可以是null)
tracks
一个 MediaParserTrack 的数组。
🌐 An array of MediaParserTrack.
keyframes
MediaParserKeyframe[] | null
关键帧数组。每个关键帧具有以下结构:
🌐 An array of keyframes. Each keyframe has the following structure:
仅在关键帧信息存储在元数据中时返回,否则返回 null。
🌐 Only being returned if the keyframe information are stored in the metadata, otherwise null.
slowKeyframes
关键帧数组,与 keyframes 相同,但保证会返回一个值。
🌐 An array of keyframes, same as keyframes, but it is guaranteed to return a value.
将读取整个视频文件以确定关键帧。
🌐 Will read the entire video file to determine the keyframes.
slowNumberOfFrames
number
媒体中的视频帧数。
将读取整个视频文件以确定帧数。
🌐 The number of video frames in the media.
Will read the entire video file to determine the number of frames.
unrotatedDimensions
MediaParserDimensions | null
旋转前视频的尺寸。
🌐 The dimensions of the video before rotation.
isHdr
boolean
视频是否为 HDR(高动态范围)。
🌐 Whether the video is in HDR (High dynamic range).
rotation
number
视频的旋转角度(例如,90 表示逆时针旋转 90°)。
始终为以下值之一:0、90、180、270。
🌐 The rotation of the video in degrees (e.g. 90 for a 90° counter-clockwise rotation).
Always one of the following values: 0, 90, 180, 270.
从 v4.0.328 开始的重大更改:旋转现在是以 逆时针 度数为单位,而之前是以 顺时针 度数为单位。
这是因为 WebCodecs 规范现在支持旋转,并且由于 MediaParserVideoTrack 可以传递给 VideoDecoder.configure(),因此此更改是必要的,以确保旋转始终朝正确方向进行。
images
文件中的嵌入图片,例如 MP3 文件中的专辑封面。
🌐 Embedded images in the file, for example an album cover inside an MP3.
sampleRate
数字 | null
🌐 number | null
音频采样率,如果有音轨的话。
🌐 The audio sample rate, if there is an audio track.
numberOfAudioChannels
数字 | null
🌐 number | null
音频通道的数量,如果有音频轨道的话。
🌐 The number of audio channels, if there is an audio track.
slowAudioBitrate
number
音频比特率,单位为每秒比特。如果没有音频轨,则为 null。
🌐 The audio bitrate in bits per second. null if there is no audio track.
1字节等于8位。
slowVideoBitrate
数字 | null
🌐 number | null
视频比特率,以每秒比特数表示。如果没有视频轨道,则为 null。
🌐 The video bitrate in bits per second. null if there is no video track.
1字节等于8位。
m3uStreams
M3uStream[] | null
仅适用于 .m3u8,如果文件是播放列表,这将返回一个非 null 的值。
🌐 Only for .m3u8, this will return a non-null value if the file is a playlist.