Class: Video
@providerprotocol/ai / @providerprotocol/ai / Video
Class: Video
Section titled “Class: Video”Defined in: src/core/media/Video.ts:79
Represents a video file that can be used in UPP messages.
Video can be created from various sources (files, bytes, base64) and converted to different formats as needed by providers. The class provides a unified interface regardless of the underlying source type.
Note: Providers have size limits for inline video data. Google Gemini limits inline data to 20MB per request. For larger files, consider using provider-specific file upload APIs.
Example
Section titled “Example”// Load from fileconst fileVideo = await Video.fromPath('./clip.mp4');
// From raw bytesconst bytesVideo = Video.fromBytes(uint8Array, 'video/webm');
// Use in a messageconst message = new UserMessage([video.toBlock()]);Properties
Section titled “Properties”
readonlydata:Uint8Array
Defined in: src/core/media/Video.ts:81
The video data as raw bytes
duration?
Section titled “duration?”
readonlyoptionalduration:number
Defined in: src/core/media/Video.ts:85
Duration in seconds, if known
height?
Section titled “height?”
readonlyoptionalheight:number
Defined in: src/core/media/Video.ts:89
Video height in pixels, if known
mimeType
Section titled “mimeType”
readonlymimeType:string
Defined in: src/core/media/Video.ts:83
MIME type of the video (e.g., ‘video/mp4’, ‘video/webm’)
width?
Section titled “width?”
readonlyoptionalwidth:number
Defined in: src/core/media/Video.ts:87
Video width in pixels, if known
Accessors
Section titled “Accessors”Get Signature
Section titled “Get Signature”get size():
number
Defined in: src/core/media/Video.ts:106
Gets the size of the video data in bytes.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”toBase64()
Section titled “toBase64()”toBase64():
string
Defined in: src/core/media/Video.ts:115
Converts the video to a base64-encoded string.
Returns
Section titled “Returns”string
The video data as a base64 string
toBlock()
Section titled “toBlock()”toBlock():
VideoBlock
Defined in: src/core/media/Video.ts:147
Converts this Video to a VideoBlock for use in UPP messages.
Returns
Section titled “Returns”A VideoBlock that can be included in message content arrays
toBytes()
Section titled “toBytes()”toBytes():
Uint8Array
Defined in: src/core/media/Video.ts:138
Gets the video data as raw bytes.
Returns
Section titled “Returns”Uint8Array
The video data as a Uint8Array
toDataUrl()
Section titled “toDataUrl()”toDataUrl():
string
Defined in: src/core/media/Video.ts:128
Converts the video to a data URL suitable for embedding.
Returns
Section titled “Returns”string
A data URL in the format data:{mimeType};base64,{data}
fromBase64()
Section titled “fromBase64()”
staticfromBase64(base64,mimeType,options?):Video
Defined in: src/core/media/Video.ts:240
Creates a Video from a base64-encoded string.
Parameters
Section titled “Parameters”base64
Section titled “base64”string
The base64-encoded video data (without data URL prefix)
mimeType
Section titled “mimeType”string
The MIME type of the video
options?
Section titled “options?”Optional metadata (duration, width, height)
duration?
Section titled “duration?”number
height?
Section titled “height?”number
width?
Section titled “width?”number
Returns
Section titled “Returns”Video
A Video containing the decoded data
Example
Section titled “Example”const video = Video.fromBase64(base64String, 'video/mp4');fromBlock()
Section titled “fromBlock()”
staticfromBlock(block):Video
Defined in: src/core/media/Video.ts:262
Creates a Video from an existing VideoBlock.
Useful for converting content blocks received from providers back into Video instances for further processing.
Parameters
Section titled “Parameters”A VideoBlock from message content
Returns
Section titled “Returns”Video
A Video with the block’s data and metadata
fromBytes()
Section titled “fromBytes()”
staticfromBytes(data,mimeType,options?):Video
Defined in: src/core/media/Video.ts:219
Creates a Video from raw byte data.
Parameters
Section titled “Parameters”Uint8Array
The video data as a Uint8Array
mimeType
Section titled “mimeType”string
The MIME type of the video
options?
Section titled “options?”Optional metadata (duration, width, height)
duration?
Section titled “duration?”number
height?
Section titled “height?”number
width?
Section titled “width?”number
Returns
Section titled “Returns”Video
A Video containing the byte data
Example
Section titled “Example”const video = Video.fromBytes(mp4Data, 'video/mp4');const videoWithMeta = Video.fromBytes(data, 'video/mp4', { duration: 60 });fromPath()
Section titled “fromPath()”
staticfromPath(path,options?):Promise<Video>
Defined in: src/core/media/Video.ts:174
Creates a Video by reading a file from disk.
The file is read into memory as bytes. MIME type is automatically detected from the file extension.
Parameters
Section titled “Parameters”string
Path to the video file
options?
Section titled “options?”Optional metadata (duration, width, height)
duration?
Section titled “duration?”number
height?
Section titled “height?”number
width?
Section titled “width?”number
Returns
Section titled “Returns”Promise<Video>
Promise resolving to a Video with the file contents
Example
Section titled “Example”const video = await Video.fromPath('./clips/demo.mp4');const videoWithMeta = await Video.fromPath('./clip.mp4', { duration: 30, width: 1920, height: 1080 });