52 memcpy(buf, bd->
ptr, buf_size);
59 int main(
int argc,
char *argv[])
64 size_t buffer_size, avio_ctx_buffer_size = 4096;
70 fprintf(stderr,
"usage: %s input_file\n" 71 "API example program to show how to read from a custom buffer " 72 "accessed through AVIOContext.\n", argv[0]);
75 input_filename = argv[1];
84 bd.
size = buffer_size;
91 avio_ctx_buffer =
av_malloc(avio_ctx_buffer_size);
92 if (!avio_ctx_buffer) {
102 fmt_ctx->
pb = avio_ctx;
106 fprintf(stderr,
"Could not open input\n");
112 fprintf(stderr,
"Could not find stream information\n");
129 fprintf(stderr,
"Error occurred: %s\n",
av_err2str(ret));
static AVFormatContext * fmt_ctx
unsigned char * buffer
Start of the buffer.
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
#define AVERROR_EOF
End of file.
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
AVIOContext * avio_alloc_context(unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
Allocate and initialize an AVIOContext for buffered I/O.
void av_file_unmap(uint8_t *bufptr, size_t size)
Unmap or free the buffer bufptr created by av_file_map().
int av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int log_offset, void *log_ctx)
Read the file with name filename, and put its content in a newly allocated buffer or map it with mmap...
size_t size
size left in the buffer
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static const char * input_filename
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
Libavcodec external API header.
AVIOContext * pb
I/O context.
int main(int argc, char *argv[])
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void avio_context_free(AVIOContext **s)
Free the supplied IO context and everything associated with it.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
printf("static const uint8_t my_array[100] = {\n")
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions