Discussion:
[Libav-user] Getings alsa inout format fails
Marcin Wielechowski
2016-08-12 20:28:56 UTC
Permalink
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
taojingyun
2016-09-22 02:43:04 UTC
Permalink
hello

you should add alsa lib path when you configure ffmpeg, like this

./configure ...... --extra-cflags="-I/your_path/alsa/include"
--extra-ldflags="-L/your_path/alsa/lib"

then the ffmpeg will support alsa indev&outdev.



--
View this message in context: http://libav-users.943685.n4.nabble.com/Libav-user-Getings-alsa-inout-format-fails-tp4662414p4662738.html
Sent from the libav-users mailing list archive at Nabble.com.

Loading...