目录

警告

TorchAudio 的 C++ API 是一个原型功能。 不保证 API/ABI 向后兼容性。

注意

顶级命名空间已从 更改为 。 已重命名为 。torchaudiotorioStreamReaderStreamingMediaDecoder

torio::io::StreamingMediaDecoder

StreamingMediaDecoder是 Python 等效项使用的实现,并提供类似的接口。 当使用自定义 I/O (如内存数据) 时,可以使用 class 。StreamingMediaDecoderCustomIO

这两个类都定义了相同的方法,因此它们的用法是相同的。

构造 函数

StreamingMedia解码器

StreamingMediaDecoder

逐块获取和解码音频/视频流。

未命名组

私有的: int drain();

检索////////////////////////////////////////////////////////////////////////////公开:/ /

/ 从每个输出流中弹出一个块(如果可用)。std::vector<std::optional<Chunk>> pop_chunks();

/

/

警告

doxygen函数:无法在项目“libtorio”的 doxygen xml 输出中解析函数“torio::io::StreamingMediaDecoder::StreamingMediaDecoder””,该函数具有参数(const std::string&、const std::optional<std::string>&、const c10::optional<OptionDict>&)来自目录:cpp/xml。 可能的匹配项:

- StreamingMediaDecoder(const std::string &src, const std::optional<std::string> &format = std::nullopt, const std::optional<OptionDict> &option = std::nullopt)

StreamingMediaDecoderCustomIO

警告

doxygenclass:在目录 cpp/xml 中项目 “libtorio” 的 doxygen xml 输出中找不到类 “torio::io::StreamingMediaDecoderCustomIO”

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoderCustomIO::StreamingMediaDecoderCustomIO”

查询方法

find_best_audio_stream

int64_t torio::io::StreamingMediaDecoder::find_best_audio_stream() 常量

使用 ffmpeg 中的启发式方法找到合适的音频流。

如果成功,则返回最佳流的索引 (>=0)。否则,将返回负值。

find_best_video_stream

int64_t torio::io::StreamingMediaDecoder::find_best_video_stream() const

使用 ffmpeg 中的启发式方法找到合适的视频流。

如果成功,则返回最佳流的索引 (0>=)。否则返回负值。

get_metadata

OptionDict torio::io::StreamingMediaDecoder::get_metadata 常量

获取源媒体的元数据。

num_src_streams

int64_t torio::io::StreamingMediaDecoder::num_src_streams const

获取在输入媒体中找到的源流数。

源流不仅包括音频/视频流,还包括字幕等。

get_src_stream_info

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::get_src_stream_info”

num_out_streams

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::num_out_streams”

get_out_stream_info

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::get_out_stream_info”

is_buffer_ready

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::is_buffer_ready”

配置方法

add_audio_stream

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::add_audio_stream”

add_video_stream

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::add_video_stream”

remove_stream

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::remove_stream”

Stream 方法

寻求

警告

doxygenfunction:在目录 cpp/xml 中项目 “libtorio” 的 doxygen xml 输出中找不到函数 “torio::io::StreamingMediaDecoder::seek”

process_packet

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::p rocess_packet”

process_packet_block

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::p rocess_packet_block”

process_all_packets

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::p rocess_all_packets”

fill_buffer

警告

doxygenfunction:在项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::fill_buffer”,来自目录:cpp/xml

检索方法

pop_chunks

警告

doxygenfunction:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到函数“torio::io::StreamingMediaDecoder::p op_chunks”

支撑结构

警告

doxygenstruct:在目录 cpp/xml 中项目“libtorio”的 doxygen xml 输出中找不到类“torio::io::Chunk”

SrcStreaminfo

struct SrcStreamInfo

有关在输入媒体中找到的源流的信息。

普通成员

AVMediaType media_type

流媒体类型。

请参阅 FFmpeg 文档了解可用值

待办事项:

引入自己的枚举并摆脱 FFmpeg 依赖

const char *codec_name = “N/A”

编解码器的名称。

const char *codec_long_name = “N/A”

编解码器的名称,采用较长的、人类友好的形式。

未命名组

/ /

/ width int width = -1;

/ 高度 int height = -1;

/ 帧率 AVRational frame_rate{0, 1};

/

torch::Tensor

};

/ 存储解码的帧和元数据 结构 Chunk { / Audio/video frames. / / 对于音频,形状为 ,/ 取决于输出流配置。/ / 对于视频,形状为 ,/ 为 。[time, num_channels]dtype[time, channel, height, width]dtypetorch.uint8

双倍 Pts

第一帧的演示文稿时间戳,以秒为单位。

输出流信息

警告

doxygenstruct:在目录 cpp/xml 中项目 “libtorio” 的 doxygen xml 输出中找不到类 “torio::io::OutputStreamInfo”

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源