[Libav-user] Getings alsa inout format fails
Marcin Wielechowski
panmarcinwielechowski at gmail.com
Fri Aug 12 23:28:56 EEST 2016
Hello
I'm trying to write application that grabbs audio using alsa on
Raspberry pi.
By I have a problem with getting alsa input format.
Function av_find_input_format("alsa") returning null.
Do You have any advices what may I be doing wrong? All help is appreciated.
The code that fails:
const char* alsaName = "alsa";
avdevice_register_all();
avcodec_register_all();
av_register_all();
AVInputFormat* format = av_find_input_format(alsaName); // format
is null here
if(format == nullptr)
{
printf("Alsa format not found.\n");
}
What is strange, iterating aver audio device formats return alsa:
AVInputFormat* p = nullptr;
format = nullptr;
while (p = av_input_audio_device_next(p))
{
if (strcmp(p->name, alsaName) == 0)
{
format = p;
}
}
if(format == nullptr) // here format is not null
{
printf("Alsa format not found.\n");
}
And when I trying to use this format in avformat_open_input, I got SEGFAULT.
Also avdevice_list_input_sources works well, what is more strange that
it is using internally av_find_input_format.
Also console command
ffmpeg -f alsa -ac 1 -i hw:1 -t 30 out.wav
is working.
Best regards
Marcin Wielechowski
More information about the Libav-user
mailing list