@@ -62,7 +62,12 @@ def write_video(
62
62
audio_options : Optional [Dict [str , Any ]] = None ,
63
63
) -> None :
64
64
"""
65
- Writes a 4d tensor in [T, H, W, C] format in a video file
65
+ Writes a 4d tensor in [T, H, W, C] format in a video file.
66
+
67
+ This function relies on PyAV (therefore, ultimately FFmpeg) to encode
68
+ videos, you can get more fine-grained control by referring to the other
69
+ options at your disposal within `the FFMpeg wiki
70
+ <http://trac.ffmpeg.org/wiki#Encoding>`_.
66
71
67
72
.. warning::
68
73
@@ -78,12 +83,25 @@ def write_video(
78
83
as a uint8 tensor in [T, H, W, C] format
79
84
fps (Number): video frames per second
80
85
video_codec (str): the name of the video codec, i.e. "libx264", "h264", etc.
81
- options (Dict): dictionary containing options to be passed into the PyAV video stream
86
+ options (Dict): dictionary containing options to be passed into the PyAV video stream.
87
+ The list of options is codec-dependent and can all
88
+ be found from `the FFMpeg wiki <http://trac.ffmpeg.org/wiki#Encoding>`_.
82
89
audio_array (Tensor[C, N]): tensor containing the audio, where C is the number of channels
83
90
and N is the number of samples
84
91
audio_fps (Number): audio sample rate, typically 44100 or 48000
85
92
audio_codec (str): the name of the audio codec, i.e. "mp3", "aac", etc.
86
- audio_options (Dict): dictionary containing options to be passed into the PyAV audio stream
93
+ audio_options (Dict): dictionary containing options to be passed into the PyAV audio stream.
94
+ The list of options is codec-dependent and can all
95
+ be found from `the FFMpeg wiki <http://trac.ffmpeg.org/wiki#Encoding>`_.
96
+
97
+ Examples::
98
+ >>> # Creating libx264 video with CRF 17, for visually lossless footage:
99
+ >>>
100
+ >>> from torchvision.io import write_video
101
+ >>> # 1000 frames of 100x100, 3-channel image.
102
+ >>> vid = torch.randn(1000, 100, 100, 3, dtype = torch.uint8)
103
+ >>> write_video("video.mp4", options = {"crf": "17"})
104
+
87
105
"""
88
106
if not torch .jit .is_scripting () and not torch .jit .is_tracing ():
89
107
_log_api_usage_once (write_video )
0 commit comments