@@ -36,6 +36,7 @@ def to_file(
3636 self ,
3737 dest : Union [str , Path ],
3838 * ,
39+ codec : Optional [str ] = None ,
3940 pixel_format : Optional [str ] = None ,
4041 crf : Optional [Union [int , float ]] = None ,
4142 preset : Optional [Union [str , int ]] = None ,
@@ -46,6 +47,9 @@ def to_file(
4647 dest (str or ``pathlib.Path``): The path to the output file, e.g.
4748 ``video.mp4``. The extension of the file determines the video
4849 container format.
50+ codec (str, optional): The codec to use for encoding (e.g., "libx264",
51+ "h264"). If not specified, the default codec
52+ for the container format will be used.
4953 pixel_format (str, optional): The pixel format for encoding (e.g.,
5054 "yuv420p", "yuv444p"). If not specified, uses codec's default format.
5155 crf (int or float, optional): Constant Rate Factor for encoding quality. Lower values
@@ -61,6 +65,7 @@ def to_file(
6165 frames = self ._frames ,
6266 frame_rate = self ._frame_rate ,
6367 filename = str (dest ),
68+ codec = codec ,
6469 pixel_format = pixel_format ,
6570 crf = crf ,
6671 preset = preset ,
@@ -70,6 +75,7 @@ def to_tensor(
7075 self ,
7176 format : str ,
7277 * ,
78+ codec : Optional [str ] = None ,
7379 pixel_format : Optional [str ] = None ,
7480 crf : Optional [Union [int , float ]] = None ,
7581 preset : Optional [Union [str , int ]] = None ,
@@ -78,7 +84,10 @@ def to_tensor(
7884
7985 Args:
8086 format (str): The container format of the encoded frames, e.g. "mp4", "mov",
81- "mkv", "avi", "webm", "flv", etc.
87+ "mkv", "avi", "webm", "flv", etc.
88+ codec (str, optional): The codec to use for encoding (e.g., "libx264",
89+ "h264"). If not specified, the default codec
90+ for the container format will be used.
8291 pixel_format (str, optional): The pixel format to encode frames into (e.g.,
8392 "yuv420p", "yuv444p"). If not specified, uses codec's default format.
8493 crf (int or float, optional): Constant Rate Factor for encoding quality. Lower values
@@ -90,13 +99,14 @@ def to_tensor(
9099 (which will use encoder's default).
91100
92101 Returns:
93- Tensor: The raw encoded bytes as 4D uint8 Tensor.
102+ Tensor: The raw encoded bytes as 1D uint8 Tensor.
94103 """
95104 preset_value = str (preset ) if isinstance (preset , int ) else preset
96105 return _core .encode_video_to_tensor (
97106 frames = self ._frames ,
98107 frame_rate = self ._frame_rate ,
99108 format = format ,
109+ codec = codec ,
100110 pixel_format = pixel_format ,
101111 crf = crf ,
102112 preset = preset_value ,
@@ -107,6 +117,7 @@ def to_file_like(
107117 file_like ,
108118 format : str ,
109119 * ,
120+ codec : Optional [str ] = None ,
110121 pixel_format : Optional [str ] = None ,
111122 crf : Optional [Union [int , float ]] = None ,
112123 preset : Optional [Union [str , int ]] = None ,
@@ -121,6 +132,9 @@ def to_file_like(
121132 int = 0) -> int``.
122133 format (str): The container format of the encoded frames, e.g. "mp4", "mov",
123134 "mkv", "avi", "webm", "flv", etc.
135+ codec (str, optional): The codec to use for encoding (e.g., "libx264",
136+ "h264"). If not specified, the default codec
137+ for the container format will be used.
124138 pixel_format (str, optional): The pixel format for encoding (e.g.,
125139 "yuv420p", "yuv444p"). If not specified, uses codec's default format.
126140 crf (int or float, optional): Constant Rate Factor for encoding quality. Lower values
@@ -137,6 +151,7 @@ def to_file_like(
137151 frame_rate = self ._frame_rate ,
138152 format = format ,
139153 file_like = file_like ,
154+ codec = codec ,
140155 pixel_format = pixel_format ,
141156 crf = crf ,
142157 preset = preset ,
0 commit comments