Search code examples
ffmpeglibav

What's the meaning of return val about the "write_packet()/seek()" callback functions in "AVIOContext" struct?


I'm writing a muxer DirectShow Filter using libav, I need to redirect muxer's output to filter's output pin, So I use avio_alloc_context() to create AVIOContext with my write_packet and seek callback functions, these 2 functions are defined below:

int (*write_packet)(void *opaque, uint8_t *buf, int buf_size)
int64_t (*seek)(void *opaque, int64_t offset, int whence)

I can understand the meaning of these functions' input parameters, but what's the meaning of its return? Is it means the bytes written actually?


Solution

  • int (*write_packet)(void *opaque, uint8_t *buf, int buf_size)

    Number of bytes written. Negative values indicate error.

    int64_t (*seek)(void *opaque, int64_t offset, int whence)

    The position of the offset, in bytes, achieved by the seek call, measured from the start of the output file. Negative values indicate error.