Skip to main content

TypeScript 类型参考

@remotion/media-parser 的以下类型是稳定 API 的一部分:

🌐 The following types are part of the stable API of @remotion/media-parser:

MediaParserDimensions

import type {MediaParserDimensions} from '@remotion/media-parser';
(alias) type MediaParserDimensions = { width: number; height: number; } import MediaParserDimensions

MediaParserAudioCodec

import type {MediaParserAudioCodec} from '@remotion/media-parser';
(alias) type MediaParserAudioCodec = "opus" | "aac" | "mp3" | "ac3" | "vorbis" | "pcm-u8" | "pcm-s16" | "pcm-s24" | "pcm-s32" | "pcm-f32" | "flac" | "aiff" import MediaParserAudioCodec

将来可能会添加更多值,这不会被视为破坏性更改。

🌐 More values may be added in the future, this would not be considered a breaking change.

MediaParserVideoCodec

import type {MediaParserVideoCodec} from '@remotion/media-parser';
(alias) type MediaParserVideoCodec = "vp8" | "vp9" | "h264" | "av1" | "h265" | "prores" import MediaParserVideoCodec

将来可能会添加更多值,这不会被视为破坏性更改。

🌐 More values may be added in the future, this would not be considered a breaking change.

MediaParserContainer

import type {MediaParserContainer} from '@remotion/media-parser';
(alias) type MediaParserContainer = "mp4" | "webm" | "avi" | "transport-stream" | "mp3" | "aac" | "flac" | "m3u8" | "wav" import MediaParserContainer

将来可能会添加更多值,这不会被视为破坏性更改。

🌐 More values may be added in the future, this would not be considered a breaking change.

MediaParserLocation

import type {MediaParserLocation} from '@remotion/media-parser';
(alias) type MediaParserLocation = { latitude: number; longitude: number; altitude: number | null; horizontalAccuracy: number | null; } import MediaParserLocation

MediaParserEmbeddedImage

import type {MediaParserEmbeddedImage} from '@remotion/media-parser';
(alias) type MediaParserEmbeddedImage = { description: string | null; mimeType: string | null; data: Uint8Array; } import MediaParserEmbeddedImage
  • mimeType:图片的 MIME 类型,或 null
  • description:图片的描述,或 null
  • data:作为 Uint8Array 的图片数据

MediaParserKeyframe

import type {MediaParserKeyframe} from '@remotion/media-parser';
(alias) type MediaParserKeyframe = { positionInBytes: number; sizeInBytes: number; presentationTimeInSeconds: number; decodingTimeInSeconds: number; trackId: number; } import MediaParserKeyframe
  • presentationTimeInSeconds:关键帧应该呈现的时间(以秒为单位)
  • decodingTimeInSeconds:关键帧应该解码的时间(以秒为单位)
  • positionInBytes:关键帧在文件中的字节位置
  • sizeInBytes:关键帧的字节大小
  • trackId:该帧所属轨迹的ID

MediaParserLogLevel

import type {MediaParserLogLevel} from '@remotion/media-parser';
(alias) type MediaParserLogLevel = "trace" | "verbose" | "info" | "warn" | "error" import MediaParserLogLevel

MediaParserMetadataEntry

import type {MediaParserMetadataEntry} from '@remotion/media-parser';
(alias) type MediaParserMetadataEntry = { key: string; value: string | number; trackId: number | null; } import MediaParserMetadataEntry

MediaParserAudioSample

import type {MediaParserAudioSample} from '@remotion/media-parser';
(alias) type MediaParserAudioSample = { data: Uint8Array; timestamp: number; duration: number | undefined; type: "key" | "delta"; decodingTimestamp: number; offset: number; } import MediaParserAudioSample

MediaParserOnAudioSample

import type {MediaParserOnAudioSample} from '@remotion/media-parser';
(alias) type MediaParserOnAudioSample = (sample: MediaParserAudioSample) => void | Promise<OnTrackDoneCallback | void> | Promise<void> | OnTrackDoneCallback import MediaParserOnAudioSample

datatimestampdurationtype 字段的格式是这样的,以便这种类型可以传递给 EncodedAudioChunk 构造函数。

🌐 The data, timestamp, duration, type fields are in a format so that this type can be passed into the EncodedAudioChunk constructor.

其他字段是用于提供信息的。

🌐 The other fields are for informative purposes.

MediaParserVideoSample

import type {MediaParserVideoSample} from '@remotion/media-parser';
(alias) type MediaParserVideoSample = { data: Uint8Array; timestamp: number; type: "key" | "delta"; duration: number | undefined; decodingTimestamp: number; offset: number; avc?: MediaParserAvcExtraInfo; } import MediaParserVideoSample

注意:timestamp 是样本的显示时间戳。decodingTimestamp 是样本将被解码时的时间戳。

🌐 Note: timestamp is the presentation timestamp of the sample. decodingTimestamp is the timestamp of the sample when it will be decoded.

datatimestampdurationtype 字段的格式是这样的,以便这种类型可以传递给 EncodedVideoChunk 构造函数。

🌐 The data, timestamp, duration, type fields are in a format so that this type can be passed into the EncodedVideoChunk constructor.

其他字段是用于提供信息的。

🌐 The other fields are for informative purposes.

MediaParserOnVideoSample

import type {MediaParserOnVideoSample} from '@remotion/media-parser';
(alias) type MediaParserOnVideoSample = (sample: MediaParserVideoSample) => void | Promise<OnTrackDoneCallback | void> | Promise<void> | OnTrackDoneCallback import MediaParserOnVideoSample

MediaParserAudioTrack

import type {MediaParserAudioTrack} from '@remotion/media-parser';
(alias) type MediaParserAudioTrack = { codec: string; sampleRate: number; description: Uint8Array | undefined; numberOfChannels: number; type: "audio"; trackId: number; codecEnum: MediaParserAudioCodec; timescale: 1000000; originalTimescale: number; codecData: MediaParserCodecData | null; startInSeconds: number; trackMediaTimeOffsetInTrackTimescale: number; } import MediaParserAudioTrack

MediaParserOnAudioTrackParams

import type {MediaParserOnAudioTrackParams} from '@remotion/media-parser';
(alias) type MediaParserOnAudioTrackParams = { track: MediaParserAudioTrack; container: MediaParserContainer; } import MediaParserOnAudioTrackParams

MediaParserOnVideoTrackParams

import type {MediaParserOnVideoTrackParams} from '@remotion/media-parser';
(alias) type MediaParserOnVideoTrackParams = { track: MediaParserVideoTrack; container: MediaParserContainer; } import MediaParserOnVideoTrackParams

MediaParserAdvancedColor

import type {MediaParserAdvancedColor} from '@remotion/media-parser';
(alias) type MediaParserAdvancedColor = { transfer: MediaParserTransferCharacteristics | null; matrix: MediaParserMatrixCoefficients | null; primaries: MediaParserPrimaries | null; fullRange: boolean | null; } import MediaParserAdvancedColor

MediaParserMatrixCoefficients

import type {MediaParserMatrixCoefficients} from '@remotion/media-parser';
(alias) type MediaParserMatrixCoefficients = "rgb" | "bt709" | "bt470bg" | "smpte170m" | "bt2020-ncl" import MediaParserMatrixCoefficients

将来可能会添加更多值,这不会被视为破坏性更改。

🌐 More values may be added in the future, this would not be considered a breaking change.

MediaParserPrimaries

import type {MediaParserPrimaries} from '@remotion/media-parser';
(alias) type MediaParserPrimaries = "bt709" | "bt470bg" | "smpte170m" | "bt2020" | "smpte432" | null import MediaParserPrimaries

将来可能会添加更多值,这不会被视为破坏性更改。

🌐 More values may be added in the future, this would not be considered a breaking change.

MediaParserTransferCharacteristics

import type {MediaParserTransferCharacteristics} from '@remotion/media-parser';
(alias) type MediaParserTransferCharacteristics = "bt709" | "smpte170m" | "iec61966-2-1" | "linear" | "pq" | "hlg" import MediaParserTransferCharacteristics

将来可能会添加更多值,这不会被视为破坏性更改。

🌐 More values may be added in the future, this would not be considered a breaking change.

MediaParserVideoTrack

import {MediaParserVideoCodec, MediaParserCodecData, MediaParserSampleAspectRatio, MediaParserAdvancedColor} from '@remotion/media-parser';

export type MediaParserVideoTrack = {
  // WebCodecs
  codec: string;
  description: Uint8Array | undefined;
  colorSpace: VideoColorSpaceInit;
  codedWidth: number;
  codedHeight: number;
  displayAspectWidth: number;
  displayAspectHeight: number;
  // Non-WebCodecs
  type: 'video';
  trackId: number;
  codecEnum: MediaParserVideoCodec;
  codecData: MediaParserCodecData | null;
  sampleAspectRatio: MediaParserSampleAspectRatio;
  width: number;
  height: number;
  rotation: number;
  fps: number | null;
  timescale: number;
  advancedColor: MediaParserAdvancedColor;
  m3uStreamFormat: 'ts' | 'mp4' | null;
  // When the track starts in seconds - can be non-zero for MP4 containers.
  // You don't need to account for it, as the samples will already be offset by this amount.
  startInSeconds: number;
};

参见:VideoColorSpaceInit WebCodecs 定义

🌐 See: VideoColorSpaceInit WebCodecs definition

MediaParserAudioTrack

import type {MediaParserAudioTrack} from '@remotion/media-parser';
(alias) type MediaParserAudioTrack = { codec: string; sampleRate: number; description: Uint8Array | undefined; numberOfChannels: number; type: "audio"; trackId: number; codecEnum: MediaParserAudioCodec; timescale: 1000000; originalTimescale: number; codecData: MediaParserCodecData | null; startInSeconds: number; trackMediaTimeOffsetInTrackTimescale: number; } import MediaParserAudioTrack

MediaParserOtherTrack

import type {MediaParserOtherTrack} from '@remotion/media-parser';
(alias) type MediaParserOtherTrack = { type: "other"; trackId: number; timescale: 1000000; originalTimescale: number; trakBox: TrakBox | null; startInSeconds: number; trackMediaTimeOffsetInTrackTimescale: number; } import MediaParserOtherTrack

MediaParserTrack

import type {MediaParserTrack} from '@remotion/media-parser';
(alias) type MediaParserTrack = MediaParserVideoTrack | MediaParserAudioTrack | MediaParserOtherTrack import MediaParserTrack

MediaParserSampleAspectRatio

import type {MediaParserSampleAspectRatio} from '@remotion/media-parser';
(alias) type MediaParserSampleAspectRatio = { numerator: number; denominator: number; } import MediaParserSampleAspectRatio

MediaParserOnVideoTrack

import type {MediaParserOnVideoTrack} from '@remotion/media-parser';
(alias) type MediaParserOnVideoTrack = (options: MediaParserOnVideoTrackParams) => MediaParserOnVideoSample | Promise<MediaParserOnVideoSample | null> | null import MediaParserOnVideoTrack

MediaParserOnAudioTrack

import type {MediaParserOnAudioTrack} from '@remotion/media-parser';
(alias) type MediaParserOnAudioTrack = (options: MediaParserOnAudioTrackParams) => MediaParserOnAudioSample | Promise<MediaParserOnAudioSample | null> | null import MediaParserOnAudioTrack

MediaParserOnVideoTrackParams

import type {MediaParserOnVideoTrackParams} from '@remotion/media-parser';
(alias) type MediaParserOnVideoTrackParams = { track: MediaParserVideoTrack; container: MediaParserContainer; } import MediaParserOnVideoTrackParams

MediaParserOnAudioTrackParams

import type {MediaParserOnAudioTrackParams} from '@remotion/media-parser';
(alias) type MediaParserOnAudioTrackParams = { track: MediaParserAudioTrack; container: MediaParserContainer; } import MediaParserOnAudioTrackParams

ParseMediaSrc

import type {ParseMediaSrc} from '@remotion/media-parser';
(alias) type ParseMediaSrc = string | Blob | URL import ParseMediaSrc

M3uStream

import type {M3uStream} from '@remotion/media-parser';
(alias) type M3uStream = { src: string; bandwidthInBitsPerSec: number | null; averageBandwidthInBitsPerSec: number | null; dimensions: MediaParserDimensions | null; codecs: string[] | null; id: number; associatedPlaylists: M3uAssociatedPlaylist[]; } import M3uStream
  • bandwidthInBitsPerSec:流的带宽。可能是 null
  • averageBandwidthInBitsPerSec:流的平均带宽。可能是 null
  • resolution:流的分辨率。可能是 null
  • codecs:流的编解码器字符串作为数组可能是 null
  • src:流的 URL 或文件路径
  • id:Remotion 给流分配的唯一标识符
  • associatedPlaylists:一个 M3uAssociatedPlaylist 的数组——其他(可能是音频)轨道,它们与此流相关联,但存储在单独的文件中。

M3uAssociatedPlaylist

import type {M3uAssociatedPlaylist} from '@remotion/media-parser';
(alias) type M3uAssociatedPlaylist = { groupId: string; language: string | null; name: string | null; autoselect: boolean; default: boolean; channels: number | null; src: string; id: number; isAudio: boolean; } import M3uAssociatedPlaylist
  • src:音频轨道的 URL 或文件路径
  • autoselect:对应 HLS 播放列表中的 AUTOSELECT 属性
  • default:对应 HLS 播放列表中的 DEFAULT 属性
  • language:音轨的语言
  • name:音轨的名称
  • groupId:音轨的组ID
  • channels:音轨中的音频通道数量,或 null

SeekResolutionv4.0.312

import type {SeekResolution} from '@remotion/media-parser';
(alias) type SeekResolution = { type: "valid-but-must-wait"; } | { type: "invalid"; } | { type: "intermediary-seek"; byte: number; } | { type: "do-seek"; byte: number; timeInSeconds: number; } import SeekResolution