Demuxing
[I/O and Muxing/Demuxing Library]


Data Structures

struct  AVInputFormat

Functions

AVInputFormatav_find_input_format (const char *short_name)
 Find AVInputFormat based on the short name of the input format.
AVInputFormatav_probe_input_format (AVProbeData *pd, int is_opened)
 Guess the file format.
AVInputFormatav_probe_input_format2 (AVProbeData *pd, int is_opened, int *score_max)
 Guess the file format.
AVInputFormatav_probe_input_format3 (AVProbeData *pd, int is_opened, int *score_ret)
 Guess the file format.
int av_probe_input_buffer (AVIOContext *pb, AVInputFormat **fmt, const char *filename, void *logctx, unsigned int offset, unsigned int max_probe_size)
 Probe a bytestream to determine the input format.
attribute_deprecated int av_open_input_stream (AVFormatContext **ic_ptr, AVIOContext *pb, const char *filename, AVInputFormat *fmt, AVFormatParameters *ap)
 Allocate all the structures needed to read an input stream.
attribute_deprecated int av_open_input_file (AVFormatContext **ic_ptr, const char *filename, AVInputFormat *fmt, int buf_size, AVFormatParameters *ap)
 Open a media file as input.
int avformat_open_input (AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
 Open an input stream and read the header.
int av_demuxer_open (AVFormatContext *ic, AVFormatParameters *ap)
attribute_deprecated int av_find_stream_info (AVFormatContext *ic)
 Read packets of a media file to get stream information.
int avformat_find_stream_info (AVFormatContext *ic, AVDictionary **options)
 Read packets of a media file to get stream information.
AVProgramav_find_program_from_stream (AVFormatContext *ic, AVProgram *last, int s)
 Find the programs which belong to a given stream.
int av_find_best_stream (AVFormatContext *ic, enum AVMediaType type, int wanted_stream_nb, int related_stream, AVCodec **decoder_ret, int flags)
 Find the "best" stream in the file.
int av_read_packet (AVFormatContext *s, AVPacket *pkt)
 Read a transport packet from a media file.
int av_read_frame (AVFormatContext *s, AVPacket *pkt)
 Return the next frame of a stream.
int av_seek_frame (AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
 Seek to the keyframe at timestamp.
int avformat_seek_file (AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
 Seek to timestamp ts.
int av_read_play (AVFormatContext *s)
 Start playing a network-based stream (e.g.
int av_read_pause (AVFormatContext *s)
 Pause a network-based stream (e.g.
void av_close_input_stream (AVFormatContext *s)
 Free a AVFormatContext allocated by av_open_input_stream.
attribute_deprecated void av_close_input_file (AVFormatContext *s)
void avformat_close_input (AVFormatContext **s)
 Close an opened input AVFormatContext.

Function Documentation

attribute_deprecated void av_close_input_file ( AVFormatContext s  ) 

void av_close_input_stream ( AVFormatContext s  ) 

Free a AVFormatContext allocated by av_open_input_stream.

Parameters:
s context to free

Definition at line 2776 of file utils.c.

Referenced by avformat_close_input(), ff_rtsp_close_streams(), and http_receive_data().

int av_demuxer_open ( AVFormatContext ic,
AVFormatParameters ap 
)

Definition at line 514 of file utils.c.

int av_find_best_stream ( AVFormatContext ic,
enum AVMediaType  type,
int  wanted_stream_nb,
int  related_stream,
AVCodec **  decoder_ret,
int  flags 
)

Find the "best" stream in the file.

The best stream is determined according to various heuristics as the most likely to be what the user expects. If the decoder parameter is non-NULL, av_find_best_stream will find the default decoder for the stream's codec; streams for which no decoder can be found are ignored.

Parameters:
ic media file handle
type stream type: video, audio, subtitles, etc.
wanted_stream_nb user-requested stream number, or -1 for automatic selection
related_stream try to find a stream related (eg. in the same program) to this one, or -1 if none
decoder_ret if non-NULL, returns the decoder for the selected stream
flags flags; none are currently defined
Returns:
the non-negative stream number in case of success, AVERROR_STREAM_NOT_FOUND if no stream with the requested type could be found, AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
Note:
If av_find_best_stream returns successfully and decoder_ret is not NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.

Definition at line 2703 of file utils.c.

Referenced by movie_common_init(), open_input_file(), and read_thread().

AVInputFormat* av_find_input_format ( const char *  short_name  ) 

Find AVInputFormat based on the short name of the input format.

Definition at line 257 of file utils.c.

Referenced by http_receive_data(), movie_common_init(), opt_format(), opt_input_file(), parse_ffconfig(), and sap_read_header().

AVProgram* av_find_program_from_stream ( AVFormatContext ic,
AVProgram last,
int  s 
)

Find the programs which belong to a given stream.

Parameters:
ic media file handle
last the last found program, the search will start after this program, or from the beginning if it is NULL
s stream index
Returns:
the next program which belongs to s, NULL if no program is found or the last program is not among the programs of ic.

Definition at line 2686 of file utils.c.

Referenced by av_find_best_stream().

attribute_deprecated int av_find_stream_info ( AVFormatContext ic  ) 

Read packets of a media file to get stream information.

This is useful for file formats with no headers such as MPEG. This function also computes the real framerate in case of MPEG-2 repeat frame mode. The logical file position is not changed by this function; examined packets may be buffered for later processing.

Parameters:
ic media file handle
Returns:
>=0 if OK, AVERROR_xxx on error
Todo:
Let the user decide somehow what information is needed so that we do not waste time getting stuff the user does not need.
Deprecated:
use avformat_find_stream_info.

Definition at line 2363 of file utils.c.

Referenced by open_input_file().

attribute_deprecated int av_open_input_file ( AVFormatContext **  ic_ptr,
const char *  filename,
AVInputFormat fmt,
int  buf_size,
AVFormatParameters ap 
)

Open a media file as input.

The codecs are not opened. Only the file header (if present) is read.

Parameters:
ic_ptr The opened media file handle is put here.
filename filename to open
fmt If non-NULL, force the file format to use.
buf_size optional buffer size (zero if default is OK)
ap Additional parameters needed when opening the file (NULL if default).
Returns:
0 if OK, AVERROR_xxx otherwise
Deprecated:
use avformat_open_input instead.

Definition at line 608 of file utils.c.

attribute_deprecated int av_open_input_stream ( AVFormatContext **  ic_ptr,
AVIOContext pb,
const char *  filename,
AVInputFormat fmt,
AVFormatParameters ap 
)

Allocate all the structures needed to read an input stream.

This does not open the needed codecs for decoding the stream[s].

Deprecated:
use avformat_open_input instead.

Allocate all the structures needed to read an input stream.

'fmt' must be specified.

Definition at line 472 of file utils.c.

int av_probe_input_buffer ( AVIOContext pb,
AVInputFormat **  fmt,
const char *  filename,
void *  logctx,
unsigned int  offset,
unsigned int  max_probe_size 
)

Probe a bytestream to determine the input format.

Each time a probe returns with a score that is too low, the probe buffer size is increased and another attempt is made. When the maximum probe size is reached, the input format with the highest score is returned.

Parameters:
pb the bytestream to probe
fmt the input format is put here
filename the filename of the stream
logctx the log context
offset the offset within the bytestream to probe from
max_probe_size the maximum probe buffer size (zero for default)
Returns:
0 in case of success, a negative value corresponding to an AVERROR code otherwise

Definition at line 534 of file utils.c.

Referenced by applehttp_read_header(), and init_input().

AVInputFormat* av_probe_input_format ( AVProbeData pd,
int  is_opened 
)

Guess the file format.

Parameters:
is_opened Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed.

Definition at line 381 of file utils.c.

Referenced by init_input().

AVInputFormat* av_probe_input_format2 ( AVProbeData pd,
int  is_opened,
int *  score_max 
)

Guess the file format.

Parameters:
is_opened Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed.
score_max A probe score larger that this is required to accept a detection, the variable is set to the actual detection score afterwards. If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended to retry with a larger probe buffer.

Definition at line 370 of file utils.c.

Referenced by av_probe_input_buffer(), av_probe_input_format(), and read_gab2_sub().

AVInputFormat* av_probe_input_format3 ( AVProbeData pd,
int  is_opened,
int *  score_ret 
)

Guess the file format.

Parameters:
is_opened Whether the file is already opened; determines whether demuxers with or without AVFMT_NOFILE are probed.
score_ret The score of the best detection.

Definition at line 330 of file utils.c.

Referenced by av_probe_input_format2(), and set_codec_from_probe_data().

int av_read_frame ( AVFormatContext s,
AVPacket pkt 
)

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.

The returned packet is valid until the next av_read_frame() or until av_close_input_file() and must be freed with av_free_packet. 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.

Returns:
0 if OK, < 0 on error or end of file

Definition at line 1318 of file utils.c.

Referenced by applehttp_read_packet(), asf_read_pts(), http_prepare_data(), main(), mpc_read_seek(), mpegts_get_dts(), read_thread(), sap_fetch_packet(), search_hi_lo_keyframes(), seek_frame_generic(), show_packets(), transcode(), and wv_read_seek().

int av_read_packet ( AVFormatContext s,
AVPacket pkt 
)

Read a transport packet from a media file.

This function is obsolete and should never be used. Use av_read_frame() instead.

Parameters:
s media file handle
pkt is filled
Returns:
0 if OK, AVERROR_xxx on error

Definition at line 750 of file utils.c.

Referenced by asfrtp_parse_packet(), estimate_timings_from_pts(), extract_mpeg4_header(), get_subtitle_pkt(), read_frame_internal(), read_gab2_sub(), and seek_subtitle().

int av_read_pause ( AVFormatContext s  ) 

Pause a network-based stream (e.g.

RTSP stream).

Use av_read_play() to resume it.

Definition at line 2767 of file utils.c.

Referenced by read_thread().

int av_read_play ( AVFormatContext s  ) 

Start playing a network-based stream (e.g.

RTSP stream) at the current position.

Definition at line 2758 of file utils.c.

Referenced by read_thread().

int av_seek_frame ( AVFormatContext s,
int  stream_index,
int64_t  timestamp,
int  flags 
)

Seek to the keyframe at timestamp.

'timestamp' in 'stream_index'.

Parameters:
stream_index If stream_index is (-1), a default stream is selected, and timestamp is automatically converted from AV_TIME_BASE units to the stream specific time_base.
timestamp Timestamp in AVStream.time_base units or, if no stream is specified, in AV_TIME_BASE units.
flags flags which select direction and seeking mode
Returns:
>= 0 on success

Definition at line 1875 of file utils.c.

Referenced by avformat_seek_file(), movie_common_init(), open_input_stream(), and opt_input_file().

void avformat_close_input ( AVFormatContext **  s  ) 

Close an opened input AVFormatContext.

Free it and all its contents and set *s to NULL.

Definition at line 2833 of file utils.c.

Referenced by av_close_input_file().

int avformat_find_stream_info ( AVFormatContext ic,
AVDictionary **  options 
)

Read packets of a media file to get stream information.

This is useful for file formats with no headers such as MPEG. This function also computes the real framerate in case of MPEG-2 repeat frame mode. The logical file position is not changed by this function; examined packets may be buffered for later processing.

Parameters:
ic media file handle
options If non-NULL, an ic.nb_streams long array of pointers to dictionaries, where i-th member contains options for codec corresponding to i-th stream. On return each dictionary will be filled with options that were not found.
Returns:
>=0 if OK, AVERROR_xxx on error
Note:
this function isn't guaranteed to open all the codecs, so options being non-empty at return is a perfectly normal behavior.
Todo:
Let the user decide somehow what information is needed so that we do not waste time getting stuff the user does not need.

Definition at line 2369 of file utils.c.

Referenced by av_find_stream_info(), build_file_streams(), main(), movie_common_init(), open_input_file(), open_input_stream(), opt_input_file(), and read_thread().

int avformat_open_input ( AVFormatContext **  ps,
const char *  filename,
AVInputFormat fmt,
AVDictionary **  options 
)

Open an input stream and read the header.

The codecs are not opened. The stream must be closed with av_close_input_file().

Parameters:
ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). May be a pointer to NULL, in which case an AVFormatContext is allocated by this function and written into ps. Note that a user-supplied AVFormatContext will be freed on failure.
filename Name of the stream to open.
fmt If non-NULL, this parameter forces a specific input format. Otherwise the format is autodetected.
options A dictionary filled with AVFormatContext and demuxer-private options. On return this parameter will be destroyed and replaced with a dict containing options that were not found. May be NULL.
Returns:
0 on success, a negative AVERROR on failure.
Note:
If you want to use custom IO, preallocate the format context and set its pb field.

Definition at line 656 of file utils.c.

Referenced by applehttp_read_header(), av_open_input_file(), av_open_input_stream(), build_feed_streams(), build_file_streams(), ff_wms_parse_sdp_a_line(), http_receive_data(), main(), movie_common_init(), open_input_file(), open_input_stream(), opt_input_file(), rdt_new_context(), read_ffserver_streams(), read_gab2_sub(), read_thread(), and sap_read_header().

int avformat_seek_file ( AVFormatContext s,
int  stream_index,
int64_t  min_ts,
int64_t  ts,
int64_t  max_ts,
int  flags 
)

Seek to timestamp ts.

Seeking will be done so that the point from which all active streams can be presented successfully will be closest to ts and within min/max_ts. Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.

If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and are the file position (this may not be supported by all demuxers). If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames in the stream with stream_index (this may not be supported by all demuxers). Otherwise all timestamps are in units of the stream selected by stream_index or if stream_index is -1, in AV_TIME_BASE units. If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as keyframes (this may not be supported by all demuxers).

Parameters:
stream_index index of the stream which is used as time base reference
min_ts smallest acceptable timestamp
ts target timestamp
max_ts largest acceptable timestamp
flags flags
Returns:
>=0 on success, error code otherwise
Note:
This is part of the new seek API which is still under construction. Thus do not use this yet. It may change at any time, do not expect ABI compatibility yet!

Definition at line 1920 of file utils.c.

Referenced by main(), read_thread(), and seek_subtitle().


Generated on Fri Oct 26 02:43:54 2012 for FFmpeg by  doxygen 1.5.8