Decodes a video frame from
The avcodec_decode_video() function decodes a video frame from the input buffer
buf of size
buf_size. To decode it, it makes use of the video codec which was coupled with
avctx using avcodec_open(). The resulting decoded frame is stored in
Warning: The input buffer must be
FF_INPUT_BUFFER_PADDING_SIZE larger than the actual read bytes because some optimized bitstream readers read 32 or 64 bits at once and could read over the end.
Warning: The end of the input buffer
buf should be set to 0 to ensure that no overreading happens for damaged MPEG streams.
Note: You might have to align the input buffer
buf and output buffer
samples. The alignment requirements depend on the CPU: on some CPUs it isn't necessary at all, on others it won't work at all if not aligned and on others it will work but it will have an impact on performance. In practice, the bitstream should have 4 byte alignment at minimum and all sample data should
be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If the linesize is not a multiple of 16 then there's no sense in aligning the start of the buffer to 16.
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, uint8_t *buf, int buf_size);
A AVCodecContext pointer to the codec context.
A pointer to the AVFrame in which the decoded video frame will be stored.
An int pointer to which zero is written if no frame could be decompressed, otherwise, it is nonzero.
The input buffer.
The size of the input buffer in bytes.
On error a negative value is returned, otherwise the number of bytes used or zero if no frame could be decompressed.
Back to ffmpeg