'How to open anullsrc input?
I'm trying:
avformat_open_input(
&input_context,
"anullsrc",
NULL,
NULL
);
That however does not work and input_context remains NULL.
The 3rd argument, NULL, is an optional 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.
I wanted to supply it by first creating the AVInputFormat with av_find_input_format - that however fails to find the format (lavfi), because it seems not to be registered in file ./libavformat/allformats.c even though it exists in ./libavdevice/lavfi.c.
Edit
I might have found an issue. When I do:
$ ffmpeg -v 0 -demuxers | grep lavfi
The output is:
D lavfi Libavfilter virtual input device
However, when I do:
main | grep lavfi
Where main is my program which includes:
while ((fmt = av_demuxer_iterate(&i)))
printf("%s\n", fmt->name);
I get no output (I confirm that some demuxers are listed if I don't grep for lavfi).
So it seems then, that libavformat.h does not know about lavfi demuxer, whereas ffmpeg does. So it seems I need to fix this issue now.
Solution 1:[1]
I found a way.
I need to include:
#include <libavdevice/avdevice.h>
Which allows me to do:
const AVInputFormat *ifmt = NULL;
while ((ifmt = av_input_audio_device_next(ifmt)))
{
printf("%s\n", ifmt->name);
if (!strcmp(ifmt->name, "lavfi"))
break;
}
And then this works:
AVFormatContext *ic = NULL;
avformat_open_input(
&ic,
"anullsrc",
ifmt,
NULL
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | dgsgsdgsgdhddhg |
