gpt4 book ai didi

c - 如何打开anullsrc输入?

转载 作者:行者123 更新时间:2023-12-04 22:56:40 25 4
gpt4 key购买 nike

我正在努力:

    avformat_open_input(
&input_context,
"anullsrc",
NULL,
NULL
);
然而,这不起作用, input_context保持为 NULL。
第三个参数, NULL , 是可选的 AVInputFormat .
https://ffmpeg.org/doxygen/trunk/group__lavf__decoding.html#gac05d61a2b492ae3985c658f34622c19d fmt If non-NULL, this parameter forces a specific input format. Otherwise the format is autodetected.我想通过首先创建 AVInputFormat 来提供它与 av_find_input_format - 但是找不到格式( lavfi ),因为它似乎没有在文件 ./libavformat/allformats.c 中注册即使它存在于 ./libavdevice/lavfi.c .
编辑
我可能发现了一个问题。当我做:
$ ffmpeg -v 0 -demuxers | grep lavfi
输出是:
 D  lavfi           Libavfilter virtual input device

但是,当我这样做时:
main | grep lavfi
main 是我的程序,其中包括:
    while ((fmt = av_demuxer_iterate(&i)))                                      
printf("%s\n", fmt->name);
我没有得到任何输出(如果我不 grep for lavfi,我确认列出了一些解复用器)。
看来, libavformat.h不知道 lavfi解复用器,而 ffmpeg 可以。所以看来我现在需要解决这个问题。

最佳答案

我找到了一个方法。
我需要包括:

#include <libavdevice/avdevice.h>
这允许我这样做:
    const AVInputFormat *ifmt = NULL;

while ((ifmt = av_input_audio_device_next(ifmt)))
{
printf("%s\n", ifmt->name);
if (!strcmp(ifmt->name, "lavfi"))
break;
}
然后这个工作:
    AVFormatContext *ic = NULL;
avformat_open_input(
&ic,
"anullsrc",
ifmt,
NULL
);

关于c - 如何打开anullsrc输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72120022/

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