Table of Contents
Shortcuts

# write_video

torchvision.io.write_video(filename: str, video_array: Tensor, fps: float, video_codec: str = 'libx264', options: Optional[Dict[str, Any]] = None, audio_array: Optional[Tensor] = None, audio_fps: Optional[float] = None, audio_codec: Optional[str] = None, audio_options: Optional[Dict[str, Any]] = None) → None

  Writes a 4d tensor in [T, H, W, C] format in a video file

  Parameters:

    - filename (str) – path where the video will be saved

    - video_array (Tensor[T, H, W, C]) – tensor containing the individual frames, as a uint8 tensor in [T, H, W, C] format

    - fps (Number) – video frames per second

    - video_codec (str) – the name of the video codec, i.e. “libx264”, “h264”, etc.

    - options (Dict) – dictionary containing options to be passed into the PyAV video stream

    - audio_array (Tensor[C, N]) – tensor containing the audio, where C is the number of channels and N is the number of samples

    - audio_fps (Number) – audio sample rate, typically 44100 or 48000

    - audio_codec (str) – the name of the audio codec, i.e. “mp3”, “aac”, etc.

    - audio_options (Dict) – dictionary containing options to be passed into the PyAV audio stream

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.