torchcodec 1.0.0__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- torchcodec/__init__.py +50 -0
- torchcodec/_core/AVIOContextHolder.cpp +85 -0
- torchcodec/_core/AVIOContextHolder.h +44 -0
- torchcodec/_core/AudioCommon.cpp +101 -0
- torchcodec/_core/AudioCommon.h +48 -0
- torchcodec/_core/AudioConverter.cpp +130 -0
- torchcodec/_core/AudioConverter.h +59 -0
- torchcodec/_core/BetaCudaDeviceInterface.cpp +1635 -0
- torchcodec/_core/BetaCudaDeviceInterface.h +364 -0
- torchcodec/_core/CMakeLists.txt +661 -0
- torchcodec/_core/CUDACommon.cpp +129 -0
- torchcodec/_core/CUDACommon.h +115 -0
- torchcodec/_core/Cache.h +126 -0
- torchcodec/_core/CodecParameters.cpp +98 -0
- torchcodec/_core/CodecParameters.h +59 -0
- torchcodec/_core/ColorConverter.cpp +92 -0
- torchcodec/_core/ColorConverter.h +40 -0
- torchcodec/_core/CpuDeviceInterface.cpp +654 -0
- torchcodec/_core/CpuDeviceInterface.h +153 -0
- torchcodec/_core/CudaDeviceInterface.cpp +519 -0
- torchcodec/_core/CudaDeviceInterface.h +92 -0
- torchcodec/_core/DecodeAvif.cpp +284 -0
- torchcodec/_core/DecodeAvif.h +28 -0
- torchcodec/_core/DecodeGif.cpp +488 -0
- torchcodec/_core/DecodeGif.h +32 -0
- torchcodec/_core/DecodeHeic.cpp +306 -0
- torchcodec/_core/DecodeHeic.h +18 -0
- torchcodec/_core/DecodeJpeg.cpp +489 -0
- torchcodec/_core/DecodeJpeg.h +17 -0
- torchcodec/_core/DecodeJpegCuda.cpp +638 -0
- torchcodec/_core/DecodeJpegCuda.h +92 -0
- torchcodec/_core/DecodePng.cpp +569 -0
- torchcodec/_core/DecodePng.h +31 -0
- torchcodec/_core/DecodeWebp.cpp +238 -0
- torchcodec/_core/DecodeWebp.h +17 -0
- torchcodec/_core/Demuxer.cpp +415 -0
- torchcodec/_core/Demuxer.h +158 -0
- torchcodec/_core/DeviceInterface.cpp +152 -0
- torchcodec/_core/DeviceInterface.h +255 -0
- torchcodec/_core/EncodeJpeg.cpp +223 -0
- torchcodec/_core/EncodeJpeg.h +19 -0
- torchcodec/_core/EncodeJpegCuda.cpp +272 -0
- torchcodec/_core/EncodeJpegCuda.h +56 -0
- torchcodec/_core/EncodePng.cpp +207 -0
- torchcodec/_core/EncodePng.h +19 -0
- torchcodec/_core/Encoder.cpp +1023 -0
- torchcodec/_core/Encoder.h +144 -0
- torchcodec/_core/Exif.h +241 -0
- torchcodec/_core/FFMPEGCommon.cpp +1159 -0
- torchcodec/_core/FFMPEGCommon.h +506 -0
- torchcodec/_core/FileIO.cpp +78 -0
- torchcodec/_core/FileIO.h +34 -0
- torchcodec/_core/FileLikeIO.cpp +76 -0
- torchcodec/_core/FileLikeIO.h +68 -0
- torchcodec/_core/FilterGraph.cpp +211 -0
- torchcodec/_core/FilterGraph.h +59 -0
- torchcodec/_core/Frame.cpp +75 -0
- torchcodec/_core/Frame.h +76 -0
- torchcodec/_core/IOInterface.h +44 -0
- torchcodec/_core/ImageCommon.h +113 -0
- torchcodec/_core/Logging.cpp +42 -0
- torchcodec/_core/Logging.h +38 -0
- torchcodec/_core/Metadata.cpp +312 -0
- torchcodec/_core/Metadata.h +115 -0
- torchcodec/_core/NVCUVIDRuntimeLoader.cpp +324 -0
- torchcodec/_core/NVCUVIDRuntimeLoader.h +14 -0
- torchcodec/_core/NVDECCache.cpp +111 -0
- torchcodec/_core/NVDECCache.h +136 -0
- torchcodec/_core/NVDECCacheConfig.cpp +61 -0
- torchcodec/_core/NVDECCacheConfig.h +30 -0
- torchcodec/_core/PacketDecoder.cpp +358 -0
- torchcodec/_core/PacketDecoder.h +140 -0
- torchcodec/_core/SingleStreamDecoder.cpp +1856 -0
- torchcodec/_core/SingleStreamDecoder.h +424 -0
- torchcodec/_core/StableABICompat.h +213 -0
- torchcodec/_core/StreamOptions.h +93 -0
- torchcodec/_core/SwScale.cpp +124 -0
- torchcodec/_core/SwScale.h +67 -0
- torchcodec/_core/TensorIO.cpp +136 -0
- torchcodec/_core/TensorIO.h +53 -0
- torchcodec/_core/Transform.cpp +207 -0
- torchcodec/_core/Transform.h +125 -0
- torchcodec/_core/ValidationUtils.cpp +65 -0
- torchcodec/_core/ValidationUtils.h +29 -0
- torchcodec/_core/WavDecoder.cpp +494 -0
- torchcodec/_core/WavDecoder.h +73 -0
- torchcodec/_core/__init__.py +45 -0
- torchcodec/_core/_decoder_utils.py +258 -0
- torchcodec/_core/_ffmpeg_op_names.py +95 -0
- torchcodec/_core/_ffmpeg_ops.py +699 -0
- torchcodec/_core/_file_like.py +221 -0
- torchcodec/_core/_metadata.py +402 -0
- torchcodec/_core/color_conversion.cpp +316 -0
- torchcodec/_core/color_conversion.cu +391 -0
- torchcodec/_core/color_conversion.h +150 -0
- torchcodec/_core/custom_ops.cpp +2438 -0
- torchcodec/_core/fetch_and_expose_non_gpl_ffmpeg_libs.cmake +192 -0
- torchcodec/_core/fetch_avif_from_s3.cmake +81 -0
- torchcodec/_core/giflib/README +28 -0
- torchcodec/_core/giflib/dgif_lib.c +1313 -0
- torchcodec/_core/giflib/gif_hash.c +129 -0
- torchcodec/_core/giflib/gif_hash.h +43 -0
- torchcodec/_core/giflib/gif_lib.h +292 -0
- torchcodec/_core/giflib/gif_lib_private.h +73 -0
- torchcodec/_core/giflib/gifalloc.c +426 -0
- torchcodec/_core/giflib/openbsd-reallocarray.c +74 -0
- torchcodec/_core/heic_custom_ops.cpp +20 -0
- torchcodec/_core/image_custom_ops.cpp +137 -0
- torchcodec/_core/nvcuvid_include/cuviddec.h +1374 -0
- torchcodec/_core/nvcuvid_include/nvcuvid.h +610 -0
- torchcodec/_core/ops.py +103 -0
- torchcodec/_core/sources.bzl +113 -0
- torchcodec/_frame.py +146 -0
- torchcodec/_internally_replaced_utils.py +129 -0
- torchcodec/_logging.py +59 -0
- torchcodec/decoders/__init__.py +50 -0
- torchcodec/decoders/_audio_decoder.py +183 -0
- torchcodec/decoders/_blocks/__init__.py +48 -0
- torchcodec/decoders/_blocks/_audio_converter.py +155 -0
- torchcodec/decoders/_blocks/_codec_parameters.py +229 -0
- torchcodec/decoders/_blocks/_color_converter.py +107 -0
- torchcodec/decoders/_blocks/_demuxer.py +678 -0
- torchcodec/decoders/_blocks/_frame.py +577 -0
- torchcodec/decoders/_blocks/_helpers.py +53 -0
- torchcodec/decoders/_blocks/_packet_decoder.py +357 -0
- torchcodec/decoders/_decoder_utils.py +128 -0
- torchcodec/decoders/_image_decoders.py +1575 -0
- torchcodec/decoders/_video_decoder.py +592 -0
- torchcodec/decoders/_wav_decoder.py +131 -0
- torchcodec/encoders/__init__.py +4 -0
- torchcodec/encoders/_audio_encoder.py +167 -0
- torchcodec/encoders/_image_encoders.py +181 -0
- torchcodec/encoders/_multi_stream_encoder.py +272 -0
- torchcodec/encoders/_video_encoder.py +227 -0
- torchcodec/jpeg8.dll +0 -0
- torchcodec/libavif.dll +0 -0
- torchcodec/libpng16.dll +0 -0
- torchcodec/libsharpyuv.dll +0 -0
- torchcodec/libtorchcodec_core4.dll +0 -0
- torchcodec/libtorchcodec_core5.dll +0 -0
- torchcodec/libtorchcodec_core6.dll +0 -0
- torchcodec/libtorchcodec_core7.dll +0 -0
- torchcodec/libtorchcodec_core8.dll +0 -0
- torchcodec/libtorchcodec_core9.dll +0 -0
- torchcodec/libtorchcodec_custom_ops4.dll +0 -0
- torchcodec/libtorchcodec_custom_ops5.dll +0 -0
- torchcodec/libtorchcodec_custom_ops6.dll +0 -0
- torchcodec/libtorchcodec_custom_ops7.dll +0 -0
- torchcodec/libtorchcodec_custom_ops8.dll +0 -0
- torchcodec/libtorchcodec_custom_ops9.dll +0 -0
- torchcodec/libtorchcodec_heic.dll +0 -0
- torchcodec/libtorchcodec_image.dll +0 -0
- torchcodec/libwebp.dll +0 -0
- torchcodec/libwebpdecoder.dll +0 -0
- torchcodec/libwebpdemux.dll +0 -0
- torchcodec/libwebpmux.dll +0 -0
- torchcodec/libzstd.dll +0 -0
- torchcodec/py.typed +0 -0
- torchcodec/samplers/__init__.py +2 -0
- torchcodec/samplers/_common.py +83 -0
- torchcodec/samplers/_index_based.py +287 -0
- torchcodec/samplers/_time_based.py +360 -0
- torchcodec/share/cmake/TorchCodec/TorchCodecConfig.cmake +76 -0
- torchcodec/share/cmake/TorchCodec/ffmpeg_versions.cmake +128 -0
- torchcodec/transforms/__init__.py +12 -0
- torchcodec/transforms/_decoder_transforms.py +375 -0
- torchcodec/version.py +1 -0
- torchcodec/zlib.dll +0 -0
- torchcodec-1.0.0.dist-info/METADATA +275 -0
- torchcodec-1.0.0.dist-info/RECORD +179 -0
- torchcodec-1.0.0.dist-info/WHEEL +5 -0
- torchcodec-1.0.0.dist-info/licenses/LICENSE +28 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/COPYING.dav1d +23 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libavif +387 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libjpeg-turbo +135 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libpng +134 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libwebp +30 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.libyuv +29 -0
- torchcodec-1.0.0.dist-info/licenses/third_party/LICENSE.zlib +22 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import io
|
|
9
|
+
from collections.abc import Sequence
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
from torch import nn, Tensor
|
|
13
|
+
from torchcodec._core._metadata import (
|
|
14
|
+
AudioStreamMetadata,
|
|
15
|
+
get_container_metadata,
|
|
16
|
+
VideoStreamMetadata,
|
|
17
|
+
)
|
|
18
|
+
from torchcodec._core.ops import (
|
|
19
|
+
_blocks_create_demuxer_from_bytes,
|
|
20
|
+
_blocks_create_demuxer_from_file,
|
|
21
|
+
_blocks_create_demuxer_from_file_like,
|
|
22
|
+
_blocks_create_demuxer_from_tensor,
|
|
23
|
+
add_audio_stream,
|
|
24
|
+
add_video_stream,
|
|
25
|
+
create_from_bytes,
|
|
26
|
+
create_from_file,
|
|
27
|
+
create_from_file_like,
|
|
28
|
+
create_from_tensor,
|
|
29
|
+
create_wav_decoder_from_bytes,
|
|
30
|
+
create_wav_decoder_from_file,
|
|
31
|
+
create_wav_decoder_from_file_like,
|
|
32
|
+
create_wav_decoder_from_tensor,
|
|
33
|
+
)
|
|
34
|
+
from torchcodec._internally_replaced_utils import load_core_libraries
|
|
35
|
+
from torchcodec.transforms import DecoderTransform
|
|
36
|
+
from torchcodec.transforms._decoder_transforms import _make_transform_specs
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
_ERROR_REPORTING_INSTRUCTIONS = """
|
|
40
|
+
This should never happen. Please report an issue following the steps in
|
|
41
|
+
https://github.com/pytorch/torchcodec/issues/new?assignees=&labels=&projects=&template=bug-report.yml.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def create_decoder(
|
|
46
|
+
*,
|
|
47
|
+
source: str | Path | io.RawIOBase | io.BufferedReader | bytes | Tensor,
|
|
48
|
+
seek_mode: str,
|
|
49
|
+
) -> Tensor:
|
|
50
|
+
load_core_libraries()
|
|
51
|
+
if isinstance(source, str):
|
|
52
|
+
return create_from_file(source, seek_mode)
|
|
53
|
+
elif isinstance(source, Path):
|
|
54
|
+
return create_from_file(str(source), seek_mode)
|
|
55
|
+
elif isinstance(source, io.RawIOBase) or isinstance(source, io.BufferedReader):
|
|
56
|
+
return create_from_file_like(source, seek_mode)
|
|
57
|
+
elif isinstance(source, bytes):
|
|
58
|
+
return create_from_bytes(source, seek_mode)
|
|
59
|
+
elif isinstance(source, Tensor):
|
|
60
|
+
return create_from_tensor(source, seek_mode)
|
|
61
|
+
elif isinstance(source, io.TextIOBase):
|
|
62
|
+
raise TypeError(
|
|
63
|
+
"source is for reading text, likely from open(..., 'r'). Try with 'rb' for binary reading?"
|
|
64
|
+
)
|
|
65
|
+
elif hasattr(source, "read") and hasattr(source, "seek"):
|
|
66
|
+
return create_from_file_like(source, seek_mode)
|
|
67
|
+
|
|
68
|
+
raise TypeError(
|
|
69
|
+
f"Unknown source type: {type(source)}. "
|
|
70
|
+
"Supported types are str, Path, bytes, Tensor and file-like objects with "
|
|
71
|
+
"read(self, size: int) -> bytes and "
|
|
72
|
+
"seek(self, offset: int, whence: int) -> int methods."
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def create_demuxer(
|
|
77
|
+
*,
|
|
78
|
+
source: str | Path | io.RawIOBase | io.BufferedReader | bytes | Tensor,
|
|
79
|
+
) -> Tensor:
|
|
80
|
+
"""Open a container and probe its header. No stream is followed yet, and no
|
|
81
|
+
packet is read: call ``_blocks_demuxer_add_stream`` for each stream to
|
|
82
|
+
follow, before demuxing anything."""
|
|
83
|
+
load_core_libraries()
|
|
84
|
+
if isinstance(source, str):
|
|
85
|
+
return _blocks_create_demuxer_from_file(source)
|
|
86
|
+
elif isinstance(source, Path):
|
|
87
|
+
return _blocks_create_demuxer_from_file(str(source))
|
|
88
|
+
elif isinstance(source, bytes):
|
|
89
|
+
return _blocks_create_demuxer_from_bytes(source)
|
|
90
|
+
elif isinstance(source, Tensor):
|
|
91
|
+
return _blocks_create_demuxer_from_tensor(source)
|
|
92
|
+
elif isinstance(source, (io.RawIOBase, io.BufferedReader)):
|
|
93
|
+
return _blocks_create_demuxer_from_file_like(source)
|
|
94
|
+
elif isinstance(source, io.TextIOBase):
|
|
95
|
+
raise TypeError(
|
|
96
|
+
"source is for reading text, likely from open(..., 'r'). Try with 'rb' for binary reading?"
|
|
97
|
+
)
|
|
98
|
+
elif hasattr(source, "read") and hasattr(source, "seek"):
|
|
99
|
+
return _blocks_create_demuxer_from_file_like(source)
|
|
100
|
+
|
|
101
|
+
raise TypeError(
|
|
102
|
+
f"Unknown source type: {type(source)}. "
|
|
103
|
+
"Supported types are str, Path, bytes, Tensor and file-like objects with "
|
|
104
|
+
"read(self, size: int) -> bytes and "
|
|
105
|
+
"seek(self, offset: int, whence: int) -> int methods."
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def create_audio_decoder(
|
|
110
|
+
*,
|
|
111
|
+
source: str | Path | io.RawIOBase | io.BufferedReader | bytes | Tensor,
|
|
112
|
+
seek_mode: str,
|
|
113
|
+
stream_index: int | None = None,
|
|
114
|
+
sample_rate: int | None = None,
|
|
115
|
+
num_channels: int | None = None,
|
|
116
|
+
) -> tuple[Tensor, int, AudioStreamMetadata]:
|
|
117
|
+
|
|
118
|
+
decoder = create_decoder(source=source, seek_mode=seek_mode)
|
|
119
|
+
|
|
120
|
+
container_metadata = get_container_metadata(decoder)
|
|
121
|
+
|
|
122
|
+
if stream_index is None:
|
|
123
|
+
stream_index = container_metadata.best_audio_stream_index
|
|
124
|
+
if stream_index is None:
|
|
125
|
+
raise ValueError(
|
|
126
|
+
"The best audio stream is unknown and there is no specified stream. "
|
|
127
|
+
+ _ERROR_REPORTING_INSTRUCTIONS
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
if stream_index >= len(container_metadata.streams):
|
|
131
|
+
raise ValueError(f"The stream at index {stream_index} is not a valid stream.")
|
|
132
|
+
|
|
133
|
+
metadata = container_metadata.streams[stream_index]
|
|
134
|
+
if not isinstance(metadata, AudioStreamMetadata):
|
|
135
|
+
raise ValueError(f"The stream at index {stream_index} is not an audio stream.")
|
|
136
|
+
|
|
137
|
+
add_audio_stream(
|
|
138
|
+
decoder,
|
|
139
|
+
stream_index=stream_index,
|
|
140
|
+
sample_rate=sample_rate,
|
|
141
|
+
num_channels=num_channels,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
return (decoder, stream_index, metadata)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def create_wav_decoder(
|
|
148
|
+
source: str | Path | io.RawIOBase | io.BufferedReader | bytes | Tensor,
|
|
149
|
+
) -> Tensor:
|
|
150
|
+
# WavDecoder currently lives in the FFmpeg-linked core library (it uses the
|
|
151
|
+
# FFmpeg-based AVIO I/O layer), so it needs FFmpeg too, for now.
|
|
152
|
+
load_core_libraries()
|
|
153
|
+
if isinstance(source, str):
|
|
154
|
+
return create_wav_decoder_from_file(source)
|
|
155
|
+
elif isinstance(source, Path):
|
|
156
|
+
return create_wav_decoder_from_file(str(source))
|
|
157
|
+
elif isinstance(source, bytes):
|
|
158
|
+
return create_wav_decoder_from_bytes(source)
|
|
159
|
+
elif isinstance(source, Tensor):
|
|
160
|
+
return create_wav_decoder_from_tensor(source)
|
|
161
|
+
elif isinstance(source, (io.RawIOBase, io.BufferedReader)):
|
|
162
|
+
return create_wav_decoder_from_file_like(source)
|
|
163
|
+
elif isinstance(source, io.TextIOBase):
|
|
164
|
+
raise TypeError(
|
|
165
|
+
"source is for reading text, likely from open(..., 'r'). "
|
|
166
|
+
"Try with 'rb' for binary reading?"
|
|
167
|
+
)
|
|
168
|
+
elif hasattr(source, "read") and hasattr(source, "seek"):
|
|
169
|
+
return create_wav_decoder_from_file_like(source)
|
|
170
|
+
|
|
171
|
+
raise TypeError(
|
|
172
|
+
f"Unknown source type: {type(source)}. "
|
|
173
|
+
"Supported types are str, Path, bytes, Tensor and file-like objects."
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _get_and_validate_video_stream_metadata(
|
|
178
|
+
*,
|
|
179
|
+
decoder: Tensor,
|
|
180
|
+
stream_index: int | None = None,
|
|
181
|
+
) -> tuple[VideoStreamMetadata, int]:
|
|
182
|
+
container_metadata = get_container_metadata(decoder)
|
|
183
|
+
|
|
184
|
+
if stream_index is None:
|
|
185
|
+
if (stream_index := container_metadata.best_video_stream_index) is None:
|
|
186
|
+
raise ValueError(
|
|
187
|
+
"The best video stream is unknown and there is no specified stream. "
|
|
188
|
+
+ _ERROR_REPORTING_INSTRUCTIONS
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
if stream_index >= len(container_metadata.streams):
|
|
192
|
+
raise ValueError(f"The stream index {stream_index} is not a valid stream.")
|
|
193
|
+
|
|
194
|
+
metadata = container_metadata.streams[stream_index]
|
|
195
|
+
if not isinstance(metadata, VideoStreamMetadata):
|
|
196
|
+
raise ValueError(f"The stream at index {stream_index} is not a video stream. ")
|
|
197
|
+
|
|
198
|
+
if metadata.begin_stream_seconds is None:
|
|
199
|
+
raise ValueError(
|
|
200
|
+
"The minimum pts value in seconds is unknown. "
|
|
201
|
+
+ _ERROR_REPORTING_INSTRUCTIONS
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
if metadata.end_stream_seconds is None:
|
|
205
|
+
raise ValueError(
|
|
206
|
+
"The maximum pts value in seconds is unknown. "
|
|
207
|
+
+ _ERROR_REPORTING_INSTRUCTIONS
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
if metadata.num_frames is None:
|
|
211
|
+
raise ValueError(
|
|
212
|
+
"The number of frames is unknown. " + _ERROR_REPORTING_INSTRUCTIONS
|
|
213
|
+
)
|
|
214
|
+
|
|
215
|
+
return (metadata, stream_index)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def create_video_decoder(
|
|
219
|
+
*,
|
|
220
|
+
source: str | Path | io.RawIOBase | io.BufferedReader | bytes | Tensor,
|
|
221
|
+
seek_mode: str,
|
|
222
|
+
stream_index: int | None = None,
|
|
223
|
+
dimension_order: str = "NCHW",
|
|
224
|
+
num_ffmpeg_threads: int = 1,
|
|
225
|
+
device: str,
|
|
226
|
+
device_variant: str = "default",
|
|
227
|
+
transforms: Sequence[DecoderTransform | nn.Module] | None = None,
|
|
228
|
+
custom_frame_mappings: tuple[Tensor, Tensor, Tensor] | None = None,
|
|
229
|
+
output_dtype: str = "uint8",
|
|
230
|
+
) -> tuple[Tensor, int, VideoStreamMetadata]:
|
|
231
|
+
|
|
232
|
+
decoder = create_decoder(source=source, seek_mode=seek_mode)
|
|
233
|
+
|
|
234
|
+
(
|
|
235
|
+
metadata,
|
|
236
|
+
stream_index,
|
|
237
|
+
) = _get_and_validate_video_stream_metadata(
|
|
238
|
+
decoder=decoder, stream_index=stream_index
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
transform_specs = _make_transform_specs(
|
|
242
|
+
transforms,
|
|
243
|
+
input_dims=(metadata.height, metadata.width),
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
add_video_stream(
|
|
247
|
+
decoder,
|
|
248
|
+
stream_index=stream_index,
|
|
249
|
+
dimension_order=dimension_order,
|
|
250
|
+
num_threads=num_ffmpeg_threads,
|
|
251
|
+
device=device,
|
|
252
|
+
device_variant=device_variant,
|
|
253
|
+
transform_specs=transform_specs,
|
|
254
|
+
custom_frame_mappings=custom_frame_mappings,
|
|
255
|
+
output_dtype=output_dtype,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
return (decoder, stream_index, metadata)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
#
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
6
|
+
|
|
7
|
+
"""The names of all FFmpeg-dependent ops and helpers exposed by ``ops.py``.
|
|
8
|
+
|
|
9
|
+
Kept in its own tiny module so both ``ops.py`` and ``_ffmpeg_ops.py`` can import
|
|
10
|
+
it without importing each other.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
FFMPEG_OP_NAMES = frozenset(
|
|
14
|
+
{
|
|
15
|
+
"create_from_file",
|
|
16
|
+
"create_from_tensor",
|
|
17
|
+
"_create_from_file_like",
|
|
18
|
+
"_add_video_stream_raw",
|
|
19
|
+
"_add_video_stream",
|
|
20
|
+
"add_video_stream",
|
|
21
|
+
"add_audio_stream",
|
|
22
|
+
"seek_to_pts",
|
|
23
|
+
"get_next_frame",
|
|
24
|
+
"get_frame_at_pts",
|
|
25
|
+
"get_frame_at_index",
|
|
26
|
+
"_get_frames_at_indices_tensor_input",
|
|
27
|
+
"_get_frames_by_pts_tensor_input",
|
|
28
|
+
"get_frames_in_range",
|
|
29
|
+
"get_frames_by_pts_in_range",
|
|
30
|
+
"get_frames_by_pts_in_range_audio",
|
|
31
|
+
"get_json_metadata",
|
|
32
|
+
"_blocks_create_demuxer_from_file",
|
|
33
|
+
"_blocks_create_demuxer_from_tensor",
|
|
34
|
+
"_blocks_create_demuxer_from_bytes",
|
|
35
|
+
"_blocks_create_demuxer_from_file_like",
|
|
36
|
+
"_blocks_demuxer_add_stream",
|
|
37
|
+
"_blocks_demuxer_get_audio_video_stream_indices",
|
|
38
|
+
"_blocks_demuxer_container_json_metadata",
|
|
39
|
+
"_blocks_demuxer_stream_json_metadata",
|
|
40
|
+
"_blocks_demuxer_next_packet",
|
|
41
|
+
"_blocks_demuxer_seek",
|
|
42
|
+
"_blocks_demuxer_scan",
|
|
43
|
+
"_blocks_demuxer_get_codec_parameters",
|
|
44
|
+
"_blocks_create_packet_decoder",
|
|
45
|
+
"_blocks_create_packet",
|
|
46
|
+
"_blocks_packet_get_fields",
|
|
47
|
+
"_blocks_packet_decoder_send_packet",
|
|
48
|
+
"_blocks_packet_decoder_send_eof",
|
|
49
|
+
"_blocks_packet_decoder_reset",
|
|
50
|
+
"_blocks_packet_decoder_receive_frame",
|
|
51
|
+
"_blocks_audio_packet_decoder_receive_frame",
|
|
52
|
+
"_blocks_create_color_converter",
|
|
53
|
+
"_blocks_create_audio_converter",
|
|
54
|
+
"_blocks_audio_converter_convert",
|
|
55
|
+
"_blocks_audio_converter_drain",
|
|
56
|
+
"_blocks_audio_converter_reset",
|
|
57
|
+
"_blocks_convert_frame",
|
|
58
|
+
"_blocks_frame_metadata",
|
|
59
|
+
"_blocks_get_ffmpeg_enum_name",
|
|
60
|
+
"_blocks_frame_planes",
|
|
61
|
+
"_test_frame_pts_equality",
|
|
62
|
+
"_get_container_json_metadata",
|
|
63
|
+
"_get_key_frame_indices",
|
|
64
|
+
"scan_all_streams_to_update_metadata",
|
|
65
|
+
"_get_stream_json_metadata",
|
|
66
|
+
"_get_json_ffmpeg_library_versions",
|
|
67
|
+
"_get_backend_details",
|
|
68
|
+
"create_streaming_encoder",
|
|
69
|
+
"streaming_encoder_close",
|
|
70
|
+
"streaming_encoder_add_video_stream",
|
|
71
|
+
"streaming_encoder_add_audio_stream",
|
|
72
|
+
"streaming_encoder_open_file",
|
|
73
|
+
"_streaming_encoder_open_file_like",
|
|
74
|
+
"streaming_encoder_add_frames",
|
|
75
|
+
"streaming_encoder_add_samples",
|
|
76
|
+
"set_nvdec_cache_capacity",
|
|
77
|
+
"get_nvdec_cache_capacity",
|
|
78
|
+
"_get_nvdec_cache_size",
|
|
79
|
+
"_set_cpp_log_level",
|
|
80
|
+
"_get_log_level",
|
|
81
|
+
"create_wav_decoder_from_file",
|
|
82
|
+
"create_wav_decoder_from_tensor",
|
|
83
|
+
"_create_wav_decoder_from_file_like",
|
|
84
|
+
"get_wav_samples_in_range",
|
|
85
|
+
"get_wav_metadata_from_decoder",
|
|
86
|
+
"create_from_bytes",
|
|
87
|
+
"create_from_file_like",
|
|
88
|
+
"create_wav_decoder_from_bytes",
|
|
89
|
+
"create_wav_decoder_from_file_like",
|
|
90
|
+
"streaming_encoder_open_file_like",
|
|
91
|
+
"get_frames_at_indices",
|
|
92
|
+
"get_frames_by_pts",
|
|
93
|
+
"get_ffmpeg_library_versions",
|
|
94
|
+
}
|
|
95
|
+
)
|