• 文档 >
  • libtorio >
  • torio::io::StreamingMediaDecoder >
  • 旧版本 (稳定版)
快捷方式

警告

从 2.8 版本开始,我们正在重构 TorchAudio,以使其进入维护阶段。因此:

  • torio 在 2.8 版本中已弃用,并将在 2.9 版本中移除。

  • PyTorch 用于音频和视频的解码和编码功能正在被整合到 TorchCodec 中。

请参阅 https://github.com/pytorch/audio/issues/3902 获取更多信息。

注意

顶级命名空间已从 torchaudio 更改为 torioStreamReader 已重命名为 StreamingMediaDecoder

torio::io::StreamingMediaDecoder

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

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

构造函数

StreamingMediaDecoder

class StreamingMediaDecoder

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

未命名组

私有:int drain();

//////////////////////////////////////////////////////////////////////////// 检索 //////////////////////////////////////////////////////////////////////////// 公有:/ /

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

/

/

警告

doxygenfunction:无法在目录:cpp/xml 中为项目“libtorio”的 doxygen xml 输出中解析带参数(const std::string&、const std::optional<std::string>&、const c10::optional<OptionDict>&)的函数“torio::io::StreamingMediaDecoder::StreamingMediaDecoder”。潜在匹配

- 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() const

使用 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() const

获取源媒体的元数据。

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”

流方法

seek

警告

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

process_packet

警告

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

process_packet_block

警告

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

process_all_packets

警告

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

fill_buffer

警告

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

检索方法

pop_chunks

警告

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

支持结构

Chunk

警告

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"

编解码器的长名称,人性化形式。

未命名组

/ /

/ 宽度 int width = -1;

/ 高度 int height = -1;

/ 帧率 AVRational frame_rate{0, 1};

/

torch::Tensor frames

};

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

double pts

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

OutputStreaminfo

警告

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

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

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

查看资源