How can I use the ffmpeg's avdevices c library to output audio to an audio device (specifically alsa). All I could find is its doxygen and the only useful thing I was able to take out of it is, quote
"the (de)muxers in libavdevice are of the AVFMT_NOFILE type (they use their own I/O functions). The filename passed to avformat_open_input() often does not refer to an actually existing file, but has some special device-specific meaning - e.g. for xcbgrab it is the display name."
but I don't understand where do I specify AVFMT_NOFILE and where do I specify which device I want use.I see how I can get an 'AVOutputFormat' pointer but then what do I do with it?
update: so now i found the function 'avformat_alloc_output_context2' so my code looks like this:
AVPacket pkt = av_packet_alloc();
avformat_alloc_output_context2(&ofmt_ctx, NULL, "alsa", NULL);
avformat_new_stream(ofmt_ctx, NULL);
while(av_read_frame(fmt_ctx, pkt) == 0){
av_write_frame(ofmt_ctx, pkt);
}
fmt_ctx is the input file's AVFormatContext.
but I am still getting an error '[alsa @ 0x555daf361140] Invalid packet stream index: 1' what am I missing?