快捷方式

ffmpeg_utils

用於更改 FFmpeg 庫(例如 libavformat)配置的模組。

它影響 torchaudio.io 中的功能(以及間接影響 torchaudio.load())。

clear_cuda_context_cache

torchaudio.utils.ffmpeg_utils.clear_cuda_context_cache()[source]

清除 CUDA 硬體加速影片解碼使用的 CUDA 上下文

get_audio_decoders

torchaudio.utils.ffmpeg_utils.get_audio_decoders() Dict[str, str][source]

獲取可用的音訊解碼器。

返回值:

從解碼器短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_audio_decoders().items():
>>>     print(f"{k}: {v}")
... a64: a64 - video for Commodore 64
... ac3: raw AC-3
... adts: ADTS AAC (Advanced Audio Coding)
... adx: CRI ADX
... aiff: Audio IFF

get_audio_encoders

torchaudio.utils.ffmpeg_utils.get_audio_encoders() Dict[str, str][source]

獲取可用的音訊編碼器。

返回值:

從編碼器短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_audio_encoders().items():
>>>     print(f"{k}: {v}")
... comfortnoise: RFC 3389 comfort noise generator
... s302m: SMPTE 302M
... aac: AAC (Advanced Audio Coding)
... ac3: ATSC A/52A (AC-3)
... ac3_fixed: ATSC A/52A (AC-3)
... alac: ALAC (Apple Lossless Audio Codec)

get_build_config

torchaudio.utils.ffmpeg_utils.get_build_config() str[source]

獲取 FFmpeg 構建配置

返回值:

構建配置字串。

返回型別:

str

示例
>>> print(get_build_config())
--prefix=/Users/runner/miniforge3 --cc=arm64-apple-darwin20.0.0-clang --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-neon --enable-libx264 --enable-libx265 --enable-libaom --enable-libsvtav1 --enable-libxml2 --enable-libvpx --enable-pic --enable-pthreads --enable-shared --disable-static --enable-version3 --enable-zlib --enable-libmp3lame --pkg-config=/Users/runner/miniforge3/conda-bld/ffmpeg_1646229390493/_build_env/bin/pkg-config --enable-cross-compile --arch=arm64 --target-os=darwin --cross-prefix=arm64-apple-darwin20.0.0- --host-cc=/Users/runner/miniforge3/conda-bld/ffmpeg_1646229390493/_build_env/bin/x86_64-apple-darwin13.4.0-clang  # noqa

get_demuxers

torchaudio.utils.ffmpeg_utils.get_demuxers() Dict[str, str][source]

獲取可用的解複用器。

返回值:

從解複用器(格式)短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_demuxers().items():
>>>     print(f"{k}: {v}")
... aa: Audible AA format files
... aac: raw ADTS AAC (Advanced Audio Coding)
... aax: CRI AAX
... ac3: raw AC-3

get_input_devices

torchaudio.utils.ffmpeg_utils.get_input_devices() Dict[str, str][source]

獲取可用的輸入裝置。

返回值:

從裝置短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_input_devices().items():
>>>     print(f"{k}: {v}")
... avfoundation: AVFoundation input device
... lavfi: Libavfilter virtual input device

get_input_protocols

torchaudio.utils.ffmpeg_utils.get_input_protocols() List[str][source]

獲取支援的輸入協議。

返回值:

支援的輸入協議名稱

返回型別:

List[str]

示例
>>> print(get_input_protocols())
... ['file', 'ftp', 'hls', 'http','https', 'pipe', 'rtmp', 'tcp', 'tls', 'udp', 'unix']

get_log_level

torchaudio.utils.ffmpeg_utils.get_log_level() int[source]

獲取 FFmpeg 的日誌級別。

詳見 set_log_level()

get_muxers

torchaudio.utils.ffmpeg_utils.get_muxers() Dict[str, str][source]

獲取可用的複用器。

返回值:

從複用器(格式)短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_muxers().items():
>>>     print(f"{k}: {v}")
... a64: a64 - video for Commodore 64
... ac3: raw AC-3
... adts: ADTS AAC (Advanced Audio Coding)
... adx: CRI ADX
... aiff: Audio IFF

get_output_devices

torchaudio.utils.ffmpeg_utils.get_output_devices() Dict[str, str][source]

獲取可用的輸出裝置。

返回值:

從裝置短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_output_devices().items():
>>>     print(f"{k}: {v}")
... audiotoolbox: AudioToolbox output device

get_output_protocols

torchaudio.utils.ffmpeg_utils.get_output_protocols() List[str][source]

獲取支援的輸出協議。

返回值:

支援的輸出協議名稱

返回型別:

list of str

示例
>>> print(get_output_protocols())
... ['file', 'ftp', 'http', 'https', 'md5', 'pipe', 'prompeg', 'rtmp', 'tee', 'tcp', 'tls', 'udp', 'unix']

get_versions

torchaudio.utils.ffmpeg_utils.get_versions() Dict[str, Tuple[int]][source]

獲取 FFmpeg 庫的版本

返回值:

庫名稱到版本字串的對映,

例如 “libavutil”: (56, 22, 100)

返回型別:

dict

使用 get_versions 的教程
AudioEffector Usages

AudioEffector 用法

AudioEffector 用法
Accelerated video encoding with NVENC

使用 NVENC 進行加速影片編碼

使用 NVENC 進行加速影片編碼
StreamWriter Basic Usage

StreamWriter 基本用法

StreamWriter 基本用法
Accelerated video decoding with NVDEC

使用 NVDEC 進行加速影片解碼

使用 NVDEC 進行加速影片解碼

get_video_decoders

torchaudio.utils.ffmpeg_utils.get_video_decoders() Dict[str, str][source]

獲取可用的影片解碼器。

返回值:

從解碼器短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_video_decoders().items():
>>>     print(f"{k}: {v}")
... aasc: Autodesk RLE
... aic: Apple Intermediate Codec
... alias_pix: Alias/Wavefront PIX image
... agm: Amuse Graphics Movie
... amv: AMV Video
... anm: Deluxe Paint Animation
使用 get_video_decoders 的教程
Accelerated video decoding with NVDEC

使用 NVDEC 進行加速影片解碼

使用 NVDEC 進行加速影片解碼

get_video_encoders

torchaudio.utils.ffmpeg_utils.get_video_encoders() Dict[str, str][source]

獲取可用的影片編碼器。

返回值:

從編碼器短名稱到長名稱的對映。

返回型別:

Dict[str, str]

示例
>>> for k, v in get_audio_encoders().items():
>>>     print(f"{k}: {v}")
... a64multi: Multicolor charset for Commodore 64
... a64multi5: Multicolor charset for Commodore 64, extended with 5th color (colram)
... alias_pix: Alias/Wavefront PIX image
... amv: AMV Video
... apng: APNG (Animated Portable Network Graphics) image
... asv1: ASUS V1
... asv2: ASUS V2
使用 get_video_encoders 的教程
Accelerated video encoding with NVENC

使用 NVENC 進行加速影片編碼

使用 NVENC 進行加速影片編碼

set_log_level

torchaudio.utils.ffmpeg_utils.set_log_level(level: int)[source]

設定 FFmpeg (libavformat 等) 的日誌級別

引數:

level (int) –

日誌級別。值越大,日誌越詳細。

以下是常用值、對應的 ffmpeg-loglevel 選項值和說明。

  • -8 (quiet):不列印任何輸出。

  • 0 (panic):發生嚴重錯誤,程式即將崩潰。

  • 8 (fatal):發生錯誤且無法恢復。例如,依賴頭部的格式未找到頭部,或使用了非法的引數組合。

  • 16 (error):發生錯誤且無法無損恢復。但並非所有後續資料都會受到影響。

  • 24 (warning):某些地方看起來不正確。這可能導致問題,也可能不會。

  • 32 (info):標準資訊。

  • 40 (verbose):詳細資訊。

  • 48 (debug):僅對 libav* 開發者有用的資訊。

  • 56 (trace):極其詳細的除錯資訊,對 libav* 開發有用。

使用 set_log_level 的教程
Accelerated video encoding with NVENC

使用 NVENC 進行加速影片編碼

使用 NVENC 進行加速影片編碼

文件

查閱 PyTorch 的完整開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源