[Libav-user] building a webradio with libav

Nicolas Mora nicolas at babelouest.org
Fri Jun 16 18:26:28 EEST 2017


Hello,

I'm trying to buid a webradio based on libav. The program would read a 
list of files in sequence, transcode them, then broadcast the result on 
a http stream.

I use Ubuntu 17.04 ffmpeg-libav* libraries

Ubuntu version:
libavcodec-dev:amd64 - 7:3.2.4-1build2 - amd64

the file version.h says:
#define LIBAVCODEC_VERSION_MAJOR  57
#define LIBAVCODEC_VERSION_MINOR  64
#define LIBAVCODEC_VERSION_MICRO 101

I'm based on the example program transcode.c and I'm currently stuck at 
getting an output buffer correctly.

As I can see, the transcode.c file uses avio_open in the function 
open_output_file to write the output data in the specified output file.

In my case I would like to skip the output file part and work directly 
with a buffer in memory but I can't seem to have it right.

Instead of open_output_file, I try using avio_alloc_context to define a 
in-memory context like this:

if ((output_io_context = avio_alloc_context(*av_buffer, BUFFER_SIZE, 0, 
audio_buffer, &read_packet, &write_packet, NULL)) == NULL) {
   fprintf(stderr, "Could not open context\n");
   return AVERROR(ENOMEM);
}

But for some reason, the functions read_packet or write_packet are never 
called when av_write_frame is called in the function encode_audio_frame. 
Which means I'm wrong in my approach or in my implementation or both.

Can anyone help point where I'm wrong and guide me through the right way 
to handle the output data with the AVFormatContext structure?

Thanks in advance


More information about the Libav-user mailing list