Introducing Gradio Clients

Watch

New to Gradio? Start here: Getting Started

See the Release History

Video

gradio.Video(···)
import gradio as gr with gr.Blocks() as demo: gr.Video() demo.launch()

Description

Creates a video component that can be used to upload/record videos (as an input) or display videos (as an output). For the video to be playable in the browser it must have a compatible container and codec combination. Allowed combinations are .mp4 with h264 codec, .ogg with theora codec, and .webm with vp9 codec. If the component detects that the output video would not be playable in the browser it will attempt to convert it to a playable mp4 video. If the conversion fails, the original video is returned.

Behavior

As input component: Passes the uploaded video as a str filepath or URL whose extension can be modified by format.

Your function should accept one of these types:
def predict(
	value: str | None
)
	...

As output component: Expects a str or pathlib.Path filepath to a video which is displayed, or a Tuple[str | pathlib.Path, str | pathlib.Path | None] where the first element is a filepath to a video and the second element is an optional filepath to a subtitle file.

Your function should return one of these types:
def predict(···) -> str | Path | tuple[str | Path, str | Path | None] | None
	...	
	return value

Initialization

Parameters

Shortcuts

Class Interface String Shortcut Initialization

gradio.Video

"video"

Uses default values

gradio.PlayableVideo

"playablevideo"

Uses format="mp4"

Demos

import gradio as gr def video_identity(video): return video demo = gr.Interface(video_identity, gr.Video(), "playable_video", ) if __name__ == "__main__": demo.launch()

Event Listeners

Description

Event listeners allow you to respond to user interactions with the UI components you've defined in a Gradio Blocks app. When a user interacts with an element, such as changing a slider value or uploading an image, a function is called.

Supported Event Listeners

The Video component supports the following event listeners. Each event listener takes the same parameters, which are listed in the Event Parameters table below.

Listener Description

Video.change(fn, ···)

Triggered when the value of the Video changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input.

Video.clear(fn, ···)

This listener is triggered when the user clears the Video using the X button for the component.

Video.start_recording(fn, ···)

This listener is triggered when the user starts recording with the Video.

Video.stop_recording(fn, ···)

This listener is triggered when the user stops recording with the Video.

Video.stop(fn, ···)

This listener is triggered when the user reaches the end of the media playing in the Video.

Video.play(fn, ···)

This listener is triggered when the user plays the media in the Video.

Video.pause(fn, ···)

This listener is triggered when the media in the Video stops for any reason.

Video.end(fn, ···)

This listener is triggered when the user reaches the end of the media playing in the Video.

Video.upload(fn, ···)

This listener is triggered when the user uploads a file into the Video.

Event Parameters

Parameters