Utility functions

Miscellaneous utility functions related to both muxing and demuxing (or neither). More...

Modules

 RIFF FourCCs
 Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs.

Functions

void av_hex_dump (FILE *f, const uint8_t *buf, int size)
 Send a nice hexadecimal dump of a buffer to the specified file stream.
void av_hex_dump_log (void *avcl, int level, const uint8_t *buf, int size)
 Send a nice hexadecimal dump of a buffer to the log.
void av_pkt_dump2 (FILE *f, AVPacket *pkt, int dump_payload, AVStream *st)
 Send a nice dump of a packet to the specified file stream.
void av_pkt_dump_log2 (void *avcl, int level, AVPacket *pkt, int dump_payload, AVStream *st)
 Send a nice dump of a packet to the log.
enum AVCodecID av_codec_get_id (const struct AVCodecTag *const *tags, unsigned int tag)
 Get the AVCodecID for the given codec tag tag.
unsigned int av_codec_get_tag (const struct AVCodecTag *const *tags, enum AVCodecID id)
 Get the codec tag for the given codec id id.
int av_find_default_stream_index (AVFormatContext *s)
int av_index_search_timestamp (AVStream *st, int64_t timestamp, int flags)
 Get the index for a specific timestamp.
int av_add_index_entry (AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
 Add an index entry into a sorted list.
void av_url_split (char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
 Split a URL string into components.
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.
int av_get_frame_filename (char *buf, int buf_size, const char *path, int number)
 Return in 'buf' the path with 'd' replaced by a number.
int av_filename_number_test (const char *filename)
 Check whether filename actually is a numbered sequence generator.
int av_sdp_create (AVFormatContext *ac[], int n_files, char *buf, int size)
 Generate an SDP for an RTP session.
int av_match_ext (const char *filename, const char *extensions)
 Return a positive value if the given filename has one of the given extensions, 0 otherwise.
int avformat_query_codec (AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
 Test if the given container can store a codec.

Detailed Description

Miscellaneous utility functions related to both muxing and demuxing (or neither).

Function Documentation

void av_hex_dump ( FILE *  f,
const uint8_t *  buf,
int  size 
)

Send a nice hexadecimal dump of a buffer to the specified file stream.

Parameters
fThe file stream pointer where the dump should be sent to.
bufbuffer
sizebuffer size
See Also
av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2
void av_hex_dump_log ( void *  avcl,
int  level,
const uint8_t *  buf,
int  size 
)

Send a nice hexadecimal dump of a buffer to the log.

Parameters
avclA pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct.
levelThe importance level of the message, lower values signifying higher importance.
bufbuffer
sizebuffer size
See Also
av_hex_dump, av_pkt_dump2, av_pkt_dump_log2
void av_pkt_dump2 ( FILE *  f,
AVPacket pkt,
int  dump_payload,
AVStream st 
)

Send a nice dump of a packet to the specified file stream.

Parameters
fThe file stream pointer where the dump should be sent to.
pktpacket to dump
dump_payloadTrue if the payload must be displayed, too.
stAVStream that the packet belongs to
void av_pkt_dump_log2 ( void *  avcl,
int  level,
AVPacket pkt,
int  dump_payload,
AVStream st 
)

Send a nice dump of a packet to the log.

Parameters
avclA pointer to an arbitrary struct of which the first field is a pointer to an AVClass struct.
levelThe importance level of the message, lower values signifying higher importance.
pktpacket to dump
dump_payloadTrue if the payload must be displayed, too.
stAVStream that the packet belongs to
enum AVCodecID av_codec_get_id ( const struct AVCodecTag *const *  tags,
unsigned int  tag 
)

Get the AVCodecID for the given codec tag tag.

If no codec id is found returns AV_CODEC_ID_NONE.

Parameters
tagslist of supported codec_id-codec_tag pairs, as stored in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
tagcodec tag to match to a codec ID
unsigned int av_codec_get_tag ( const struct AVCodecTag *const *  tags,
enum AVCodecID  id 
)

Get the codec tag for the given codec id id.

If no codec tag is found returns 0.

Parameters
tagslist of supported codec_id-codec_tag pairs, as stored in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
idcodec ID to match to a codec tag
int av_find_default_stream_index ( AVFormatContext s)
int av_index_search_timestamp ( AVStream st,
int64_t  timestamp,
int  flags 
)

Get the index for a specific timestamp.

Parameters
ststream that the timestamp belongs to
timestamptimestamp to retrieve the index for
flagsif AVSEEK_FLAG_BACKWARD then the returned index will correspond to the timestamp which is <= the requested one, if backward is 0, then it will be >= if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
Returns
< 0 if no such timestamp could be found
int av_add_index_entry ( AVStream st,
int64_t  pos,
int64_t  timestamp,
int  size,
int  distance,
int  flags 
)

Add an index entry into a sorted list.

Update the entry if the list already contains it.

Parameters
timestamptimestamp in the time base of the given stream
void av_url_split ( char *  proto,
int  proto_size,
char *  authorization,
int  authorization_size,
char *  hostname,
int  hostname_size,
int *  port_ptr,
char *  path,
int  path_size,
const char *  url 
)

Split a URL string into components.

The pointers to buffers for storing individual components may be null, in order to ignore that component. Buffers for components not found are set to empty strings. If the port is not found, it is set to a negative value.

Parameters
protothe buffer for the protocol
proto_sizethe size of the proto buffer
authorizationthe buffer for the authorization
authorization_sizethe size of the authorization buffer
hostnamethe buffer for the host name
hostname_sizethe size of the hostname buffer
port_ptra pointer to store the port number in
paththe buffer for the path
path_sizethe size of the path buffer
urlthe URL to split
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.

Parameters
icthe context to analyze
indexthe index to print, if you have multiple inputs or outputs
urlthe URL to print, such as source or destination file
is_outputwhether the context is input or ouput
Examples:
output.c.

Referenced by main().

int av_get_frame_filename ( char *  buf,
int  buf_size,
const char *  path,
int  number 
)

Return in 'buf' the path with 'd' replaced by a number.

Also handles the '%0nd' format where 'n' is the total number of digits and '%'.

Parameters
bufdestination buffer
buf_sizedestination buffer size
pathnumbered sequence string
numberframe number
Returns
0 if OK, -1 on format error
int av_filename_number_test ( const char *  filename)

Check whether filename actually is a numbered sequence generator.

Parameters
filenamepossible numbered sequence string
Returns
1 if a valid numbered sequence string, 0 otherwise
int av_sdp_create ( AVFormatContext ac[],
int  n_files,
char *  buf,
int  size 
)

Generate an SDP for an RTP session.

Note, this overwrites the id values of AVStreams in the muxer contexts for getting unique dynamic payload types.

Parameters
acarray of AVFormatContexts describing the RTP streams. If the array is composed by only one context, such context can contain multiple AVStreams (one AVStream per RTP stream). Otherwise, all the contexts in the array (an AVCodecContext per RTP stream) must contain only one AVStream.
n_filesnumber of AVCodecContexts contained in ac
bufbuffer where the SDP will be stored (must be allocated by the caller)
sizethe size of the buffer
Returns
0 if OK, AVERROR_xxx on error
int av_match_ext ( const char *  filename,
const char *  extensions 
)

Return a positive value if the given filename has one of the given extensions, 0 otherwise.

Parameters
filenamefile name to check against the given extensions
extensionsa comma-separated list of filename extensions
int avformat_query_codec ( AVOutputFormat ofmt,
enum AVCodecID  codec_id,
int  std_compliance 
)

Test if the given container can store a codec.

Parameters
ofmtcontainer to check for compatibility
codec_idcodec to potentially store in container
std_compliancestandards compliance level, one of FF_COMPLIANCE_*
Returns
1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot. A negative number if this information is not available.