gpt4 book ai didi

c - av_find_stream_info 适用于文件,不适用于管道

转载 作者:太空狗 更新时间:2023-10-29 15:36:30 28 4
gpt4 key购买 nike

我有以下代码:

av_register_all();
pFormatCtx = avformat_alloc_context();
const char* input = "pipe:";
AVInputFormat* iFormat = av_find_input_format("mpegts");
if ( avformat_open_input(&pFormatCtx, input, iFormat, NULL) != 0 )
return -1;
int res = av_find_stream_info(pFormatCtx);

当我的输入是一个常规文件时,这很好地工作并且 pFormatCtx 填充了文件中的流。但是,当我将输入设置为“pipe:”时,av_find_stream_info 返回 -1。

我正在使用相同的文件并通过运行管道传输它cat mpeg.ts |我的应用程序

有什么想法吗?

谢谢,阿里扎

最佳答案

原来我使用的文件太短了。

av_format_open_input 读取文件的 8K & av_find_stream_info 根据 max_analyze_duration(AVFormatContext)读取。

由于我的文件太短,它在到达 max_analyze_duration 之前就到达了管道的末端,因此返回 -1。

我仍然不确定为什么它与常规文件一起工作 - 也许它在调用 av_format_open_input 之后返回到开头。

无论如何,我能够通过将 max_analyze_duration 设置为较小的值或使用更长的文件来解决他的问题。

关于c - av_find_stream_info 适用于文件,不适用于管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11339730/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com