Function rsmpeg::ffi::av_read_frame[][src]

pub unsafe extern "C" fn av_read_frame(
    s: *mut AVFormatContext,
    pkt: *mut AVPacket
) -> i32
Expand description

Return the next frame of a stream. This function returns what is stored in the file, and does not validate that what is there are valid frames for the decoder. It will split what is stored in the file into frames and return one for each call. It will not omit invalid data between valid frames so as to give the decoder the maximum information possible for decoding.

On success, the returned packet is reference-counted (pkt->buf is set) and valid indefinitely. The packet must be freed with av_packet_unref() when it is no longer needed. For video, the packet contains exactly one frame. For audio, it contains an integer number of frames if each frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames have a variable size (e.g. MPEG audio), then it contains one frame.

pkt->pts, pkt->dts and pkt->duration are always set to correct values in AVStream.time_base units (and guessed if the format cannot provide them). pkt->pts can be AV_NOPTS_VALUE if the video format has B-frames, so it is better to rely on pkt->dts if you do not decompress the payload.

@return 0 if OK, < 0 on error or end of file. On error, pkt will be blank (as if it came from av_packet_alloc()).

@note pkt will be initialized, so it may be uninitialized, but it must not contain data that needs to be freed.