1111
1212from ..utils import _log_api_usage_once
1313from . import _video_opt
14+ from ._video_deprecation_warning import _raise_video_deprecation_warning
1415
1516try :
1617 import av
@@ -66,7 +67,15 @@ def write_video(
6667 audio_options : Optional [Dict [str , Any ]] = None ,
6768) -> None :
6869 """
69- Writes a 4d tensor in [T, H, W, C] format in a video file.
70+ [DEPRECATED] Writes a 4d tensor in [T, H, W, C] format in a video file.
71+
72+ .. warning::
73+
74+ DEPRECATED: All the video decoding and encoding capabilities of torchvision
75+ are deprecated from version 0.22 and will be removed in version 0.24. We
76+ recommend that you migrate to
77+ `TorchCodec<https://github.com/pytorch/torchcodec>`_, where we'll
78+ consolidate the future decoding/encoding capabilities of PyTorch
7079
7180 This function relies on PyAV (therefore, ultimately FFmpeg) to encode
7281 videos, you can get more fine-grained control by referring to the other
@@ -107,6 +116,7 @@ def write_video(
107116 >>> write_video("video.mp4", options = {"crf": "17"})
108117
109118 """
119+ _raise_video_deprecation_warning ()
110120 if not torch .jit .is_scripting () and not torch .jit .is_tracing ():
111121 _log_api_usage_once (write_video )
112122 _check_av_available ()
@@ -276,16 +286,15 @@ def read_video(
276286 pts_unit : str = "pts" ,
277287 output_format : str = "THWC" ,
278288) -> Tuple [torch .Tensor , torch .Tensor , Dict [str , Any ]]:
279- """
280- Reads a video from a file, returning both the video frames and the audio frames
289+ """[DEPRECATED] Reads a video from a file, returning both the video frames and the audio frames
281290
282291 .. warning::
283292
284- In the near future, we intend to centralize PyTorch's video decoding
285- capabilities within the `torchcodec
286- <https://github.com/pytorch/torchcodec>`_ project. We encourage you to
287- try it out and share your feedback, as the torchvision video decoders
288- will eventually be deprecated.
293+ DEPRECATED: All the video decoding and encoding capabilities of torchvision
294+ are deprecated from version 0.22 and will be removed in version 0.24. We
295+ recommend that you migrate to
296+ `TorchCodec<https://github.com/pytorch/torchcodec>`_, where we'll
297+ consolidate the future decoding/encoding capabilities of PyTorch
289298
290299 Args:
291300 filename (str): path to the video file. If using the pyav backend, this can be whatever ``av.open`` accepts.
@@ -302,6 +311,7 @@ def read_video(
302311 aframes (Tensor[K, L]): the audio frames, where `K` is the number of channels and `L` is the number of points
303312 info (Dict): metadata for the video and audio. Can contain the fields video_fps (float) and audio_fps (int)
304313 """
314+ _raise_video_deprecation_warning ()
305315 if not torch .jit .is_scripting () and not torch .jit .is_tracing ():
306316 _log_api_usage_once (read_video )
307317
@@ -408,16 +418,15 @@ def _decode_video_timestamps(container: "av.container.Container") -> List[int]:
408418
409419
410420def read_video_timestamps (filename : str , pts_unit : str = "pts" ) -> Tuple [List [int ], Optional [float ]]:
411- """
412- List the video frames timestamps.
421+ """[DEPREACTED] List the video frames timestamps.
413422
414423 .. warning::
415424
416- In the near future, we intend to centralize PyTorch's video decoding
417- capabilities within the `torchcodec
418- <https://github.com/pytorch/torchcodec>`_ project. We encourage you to
419- try it out and share your feedback, as the torchvision video decoders
420- will eventually be deprecated.
425+ DEPRECATED: All the video decoding and encoding capabilities of torchvision
426+ are deprecated from version 0.22 and will be removed in version 0.24. We
427+ recommend that you migrate to
428+ `TorchCodec<https://github.com/pytorch/torchcodec>`_, where we'll
429+ consolidate the future decoding/encoding capabilities of PyTorch
421430
422431 Note that the function decodes the whole video frame-by-frame.
423432
@@ -432,6 +441,7 @@ def read_video_timestamps(filename: str, pts_unit: str = "pts") -> Tuple[List[in
432441 video_fps (float, optional): the frame rate for the video
433442
434443 """
444+ _raise_video_deprecation_warning ()
435445 if not torch .jit .is_scripting () and not torch .jit .is_tracing ():
436446 _log_api_usage_once (read_video_timestamps )
437447 from torchvision import get_video_backend
0 commit comments