On 14/06/2012 18:02, Mark Kenna wrote:
Hi All

I am trying to implement a buffered solution using AVIOContext and AVFifoBuffer but I am getting an AccessViolationException on the call to "avformat_open_input".

Here is the read_packet method

static int read_packet(void *opaque, uint8_t *buf, int buf_size)
{
    AVFifoBuffer *circularBuf = (AVFifoBuffer*)opaque;
    int amountInBuffer = av_fifo_size(circularBuf);

    if (amountInBuffer >= buf_size)
        av_fifo_generic_read(circularBuf, buf, buf_size, NULL);

    amountInBuffer = av_fifo_size(circularBuf);

    return buf_size;
}

And here is the logic that's failing (last line throws the Exception)
    //load FFMPEG
    av_register_all();
    avdevice_register_all();

//allocate a FormatContext and a circular buffer for handling user data
    AVFormatContext *context = avformat_alloc_context();
    circularBuf = av_fifo_alloc(1024 * 1024 * 10);

//allocate FFMPEG's data buffer and create the IOContext for custom data I/O
    uint8_t *buffer = (uint8_t*)av_malloc(bufferSize);
AVIOContext *ioContext = avio_alloc_context(buffer, bufferSize, 0, circularBuf, read_packet, NULL, NULL);
    ioContext->seekable = 0;

    context->pb = ioContext;
    formatContext = context;

    AddData(data, 0);

    //FFMPEG will start reading from the buffer from here
    int err = avformat_open_input(&context, NULL, NULL, NULL);

I have tried various data input (flv, mpeg4, image,...) but they all fail with the same thing.

Is there something else I should be doing?

Thanks guys,
Mark.



I don't know if it helps but I have found that if I make the AVIOContext writable by setting the write_flag to 1, I no longer get the AccessViolationException - instead I get a failure code of "-1094995529".

Very strange - I think my next action will be to try a slightly older version of FFMpeg (automated builds) to see if it suffers the same issue.

Mark.

_______________________________________________
libav-api mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-api

Reply via email to