| | |
| | | * into component streams, and the reverse process of muxing - writing supplied |
| | | * data in a specified container format. It also has an @ref lavf_io |
| | | * "I/O module" which supports a number of protocols for accessing the data (e.g. |
| | | * file, tcp, http and others). Before using lavf, you need to call |
| | | * av_register_all() to register all compiled muxers, demuxers and protocols. |
| | | * file, tcp, http and others). |
| | | * Unless you are absolutely sure you won't use libavformat's network |
| | | * capabilities, you should also call avformat_network_init(). |
| | | * |
| | | * A supported input format is described by an AVInputFormat struct, conversely |
| | | * an output format is described by AVOutputFormat. You can iterate over all |
| | | * registered input/output formats using the av_iformat_next() / |
| | | * av_oformat_next() functions. The protocols layer is not part of the public |
| | | * API, so you can only get the names of supported protocols with the |
| | | * avio_enum_protocols() function. |
| | | * input/output formats using the av_demuxer_iterate / av_muxer_iterate() functions. |
| | | * The protocols layer is not part of the public API, so you can only get the names |
| | | * of supported protocols with the avio_enum_protocols() function. |
| | | * |
| | | * Main lavf structure used for both muxing and demuxing is AVFormatContext, |
| | | * which exports all information about the file being read or written. As with |
| | |
| | | * Otherwise, if AVPacket.buf is NULL, the packet data is backed by a |
| | | * static storage somewhere inside the demuxer and the packet is only valid |
| | | * until the next av_read_frame() call or closing the file. If the caller |
| | | * requires a longer lifetime, av_dup_packet() will make an av_malloc()ed copy |
| | | * of it. |
| | | * requires a longer lifetime, av_packet_make_refcounted() will ensure that |
| | | * the data is reference counted, copying the data if necessary. |
| | | * In both cases, the packet must be freed with av_packet_unref() when it is no |
| | | * longer needed. |
| | | * |
| | |
| | | * New public fields should be added right above. |
| | | ***************************************************************** |
| | | */ |
| | | struct AVOutputFormat *next; |
| | | /** |
| | | * The ff_const59 define is not part of the public API and will |
| | | * be removed without further warning. |
| | | */ |
| | | #if FF_API_AVIOFORMAT |
| | | #define ff_const59 |
| | | #else |
| | | #define ff_const59 const |
| | | #endif |
| | | ff_const59 struct AVOutputFormat *next; |
| | | /** |
| | | * size of private data so that it can be allocated in the wrapper |
| | | */ |
| | |
| | | |
| | | /** |
| | | * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, |
| | | * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, |
| | | * AVFMT_NOTIMESTAMPS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, |
| | | * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS. |
| | | */ |
| | | int flags; |
| | |
| | | * New public fields should be added right above. |
| | | ***************************************************************** |
| | | */ |
| | | struct AVInputFormat *next; |
| | | ff_const59 struct AVInputFormat *next; |
| | | |
| | | /** |
| | | * Raw demuxers store their codec ID here. |
| | |
| | | * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes |
| | | * big so you do not have to check for that unless you need more. |
| | | */ |
| | | int (*read_probe)(AVProbeData *); |
| | | int (*read_probe)(const AVProbeData *); |
| | | |
| | | /** |
| | | * Read the format header and initialize the AVFormatContext |
| | |
| | | #define AV_DISPOSITION_DESCRIPTIONS 0x20000 |
| | | #define AV_DISPOSITION_METADATA 0x40000 |
| | | #define AV_DISPOSITION_DEPENDENT 0x80000 ///< dependent audio stream (mix_type=0 in mpegts) |
| | | #define AV_DISPOSITION_STILL_IMAGE 0x100000 ///< still images in video stream (still_picture_flag=1 in mpegts) |
| | | |
| | | /** |
| | | * Options for behavior on timestamp wrap detection. |
| | |
| | | */ |
| | | int stream_identifier; |
| | | |
| | | /** |
| | | * Details of the MPEG-TS program which created this stream. |
| | | */ |
| | | int program_num; |
| | | int pmt_version; |
| | | int pmt_stream_idx; |
| | | |
| | | int64_t interleaver_chunk_size; |
| | | int64_t interleaver_chunk_duration; |
| | | |
| | |
| | | int program_num; |
| | | int pmt_pid; |
| | | int pcr_pid; |
| | | int pmt_version; |
| | | |
| | | /***************************************************************** |
| | | * All fields below this line are not part of the public API. They |
| | |
| | | * |
| | | * Demuxing only, set by avformat_open_input(). |
| | | */ |
| | | struct AVInputFormat *iformat; |
| | | ff_const59 struct AVInputFormat *iformat; |
| | | |
| | | /** |
| | | * The output container format. |
| | | * |
| | | * Muxing only, must be set by the caller before avformat_write_header(). |
| | | */ |
| | | struct AVOutputFormat *oformat; |
| | | ff_const59 struct AVOutputFormat *oformat; |
| | | |
| | | /** |
| | | * Format private data. This is an AVOptions-enabled struct |
| | |
| | | * This flag is mainly intended for testing. |
| | | */ |
| | | #define AVFMT_FLAG_BITEXACT 0x0400 |
| | | #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Enable RTP MP4A-LATM payload |
| | | #if FF_API_LAVF_MP4A_LATM |
| | | #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Deprecated, does nothing. |
| | | #endif |
| | | #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) |
| | | #define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) |
| | | #if FF_API_LAVF_KEEPSIDE_FLAG |
| | |
| | | * - decoding: set by user |
| | | */ |
| | | int max_streams; |
| | | |
| | | /** |
| | | * Skip duration calcuation in estimate_timings_from_pts. |
| | | * - encoding: unused |
| | | * - decoding: set by user |
| | | */ |
| | | int skip_estimate_duration_from_pts; |
| | | } AVFormatContext; |
| | | |
| | | #if FF_API_FORMAT_GET_SET |
| | |
| | | * @return >= 0 in case of success, a negative AVERROR code in case of |
| | | * failure |
| | | */ |
| | | int avformat_alloc_output_context2(AVFormatContext **ctx, AVOutputFormat *oformat, |
| | | int avformat_alloc_output_context2(AVFormatContext **ctx, ff_const59 AVOutputFormat *oformat, |
| | | const char *format_name, const char *filename); |
| | | |
| | | /** |
| | |
| | | /** |
| | | * Find AVInputFormat based on the short name of the input format. |
| | | */ |
| | | AVInputFormat *av_find_input_format(const char *short_name); |
| | | ff_const59 AVInputFormat *av_find_input_format(const char *short_name); |
| | | |
| | | /** |
| | | * Guess the file format. |
| | |
| | | * @param is_opened Whether the file is already opened; determines whether |
| | | * demuxers with or without AVFMT_NOFILE are probed. |
| | | */ |
| | | AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened); |
| | | ff_const59 AVInputFormat *av_probe_input_format(ff_const59 AVProbeData *pd, int is_opened); |
| | | |
| | | /** |
| | | * Guess the file format. |
| | |
| | | * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended |
| | | * to retry with a larger probe buffer. |
| | | */ |
| | | AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened, int *score_max); |
| | | ff_const59 AVInputFormat *av_probe_input_format2(ff_const59 AVProbeData *pd, int is_opened, int *score_max); |
| | | |
| | | /** |
| | | * Guess the file format. |
| | |
| | | * demuxers with or without AVFMT_NOFILE are probed. |
| | | * @param score_ret The score of the best detection. |
| | | */ |
| | | AVInputFormat *av_probe_input_format3(AVProbeData *pd, int is_opened, int *score_ret); |
| | | ff_const59 AVInputFormat *av_probe_input_format3(ff_const59 AVProbeData *pd, int is_opened, int *score_ret); |
| | | |
| | | /** |
| | | * Probe a bytestream to determine the input format. Each time a probe returns |
| | |
| | | * the maximal score is AVPROBE_SCORE_MAX |
| | | * AVERROR code otherwise |
| | | */ |
| | | int av_probe_input_buffer2(AVIOContext *pb, AVInputFormat **fmt, |
| | | int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt, |
| | | const char *url, void *logctx, |
| | | unsigned int offset, unsigned int max_probe_size); |
| | | |
| | | /** |
| | | * Like av_probe_input_buffer2() but returns 0 on success |
| | | */ |
| | | int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt, |
| | | int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt, |
| | | const char *url, void *logctx, |
| | | unsigned int offset, unsigned int max_probe_size); |
| | | |
| | |
| | | * |
| | | * @note If you want to use custom IO, preallocate the format context and set its pb field. |
| | | */ |
| | | int avformat_open_input(AVFormatContext **ps, const char *url, AVInputFormat *fmt, AVDictionary **options); |
| | | int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options); |
| | | |
| | | attribute_deprecated |
| | | int av_demuxer_open(AVFormatContext *ic); |
| | |
| | | * @param mime_type if non-NULL checks if mime_type matches with the |
| | | * MIME type of the registered formats |
| | | */ |
| | | AVOutputFormat *av_guess_format(const char *short_name, |
| | | ff_const59 AVOutputFormat *av_guess_format(const char *short_name, |
| | | const char *filename, |
| | | const char *mime_type); |
| | | |
| | | /** |
| | | * Guess the codec ID based upon muxer and filename. |
| | | */ |
| | | enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, |
| | | enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name, |
| | | const char *filename, const char *mime_type, |
| | | enum AVMediaType type); |
| | | |