Go to the documentation of this file.
82 }
else if (num >= den) {
96 for (j=2; j<14; j+= 1+(j>2))
97 while (q.
den / q.
num < min_precision && q.
num % j == 0)
99 while (q.
den / q.
num < min_precision && q.
den < (1<<24))
136 const char *
format,
const char *filename)
164 s->oformat = oformat;
165 if (
s->oformat->priv_data_size > 0) {
169 if (
s->oformat->priv_class) {
170 *(
const AVClass**)
s->priv_data=
s->oformat->priv_class;
177 #if FF_API_FORMAT_FILENAME
209 for (n = 0;
s->oformat->codec_tag[n]; n++) {
210 avctag =
s->oformat->codec_tag[n];
245 if (
s->priv_data &&
s->oformat->priv_class && *(
const AVClass**)
s->priv_data==
s->oformat->priv_class &&
249 #if FF_API_FORMAT_FILENAME
260 #if FF_API_LAVF_AVCTX
265 "The AVFormatContext is not in set to bitexact mode, only "
266 "the AVCodecContext. If this is not intended, set "
267 "AVFormatContext.flags |= AVFMT_FLAG_BITEXACT.\n");
280 for (
i = 0;
i <
s->nb_streams;
i++) {
284 #if FF_API_LAVF_AVCTX
289 "parameters to muxers is deprecated, use AVStream.codecpar "
332 "(%d/%d) and encoder layer (%d/%d)\n",
363 "Tag %s incompatible with output codec id '%d' (%s)\n",
373 s->internal->nb_interleaved_streams++;
406 if (
s->oformat->init) {
407 if ((
ret =
s->oformat->init(
s)) < 0) {
408 if (
s->oformat->deinit)
409 s->oformat->deinit(
s);
428 for (
i = 0;
i <
s->nb_streams;
i++) {
456 if (
s->avoid_negative_ts < 0) {
459 s->avoid_negative_ts = 0;
469 if (
s->pb &&
s->pb->error >= 0) {
479 if (
s->oformat &&
s->oformat->deinit &&
s->internal->initialized)
480 s->oformat->deinit(
s);
481 s->internal->initialized =
482 s->internal->streams_initialized = 0;
492 s->internal->initialized = 1;
493 s->internal->streams_initialized =
ret;
495 if (
s->oformat->init &&
ret) {
508 int already_initialized =
s->internal->initialized;
509 int streams_already_initialized =
s->internal->streams_initialized;
511 if (!already_initialized)
517 if (
s->oformat->write_header) {
518 ret =
s->oformat->write_header(
s);
519 if (
ret >= 0 &&
s->pb &&
s->pb->error < 0)
528 if (!
s->internal->streams_initialized) {
533 return streams_already_initialized;
540 #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
543 #if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX
552 if (!
s->internal->missing_ts_warning &&
557 "Timestamps are unset in a packet for stream %d. "
558 "This is deprecated and will stop working in the future. "
559 "Fix your code to set the timestamps properly\n", st->
index);
560 s->internal->missing_ts_warning = 1;
564 av_log(
s,
AV_LOG_DEBUG,
"compute_muxer_pkt_fields: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
613 "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %s >= %s\n",
619 "pts (%s) < dts (%s) in stream %d\n",
669 if (
s->output_ts_offset) {
679 if (
s->avoid_negative_ts > 0) {
682 int64_t ts =
s->internal->avoid_negative_ts_use_pts ?
pkt->
pts :
pkt->
dts;
686 s->internal->offset = -ts;
693 s->internal->offset_timebase,
703 if (
s->internal->avoid_negative_ts_use_pts) {
706 "pts %s in stream %d.\n"
707 "Try -avoid_negative_ts 1 as a possible workaround.\n",
716 "Packets poorly interleaved, failed to avoid negative "
717 "timestamp %s in stream %d.\n"
718 "Try -max_interleave_delta 0 as a possible workaround.\n",
731 ret =
s->oformat->write_packet(
s,
pkt);
734 if (
s->pb &&
ret >= 0) {
736 if (
s->pb->error < 0)
764 #if !FF_API_COMPUTE_PKT_FIELDS2 || !FF_API_LAVF_AVCTX
780 "Timestamps are unset in a packet for stream %d\n", st->
index);
790 "Application provided invalid, non monotonically increasing "
791 "dts to muxer in stream %d: %" PRId64
" >= %" PRId64
"\n",
810 #define CHUNK_START 0x1000
818 int chunked =
s->max_chunk_size ||
s->max_chunk_duration;
837 next_point = &
s->internal->packet_buffer;
861 if (
compare(
s, &
s->internal->packet_buffer_end->pkt,
pkt)) {
863 && ((chunked && !((*next_point)->pkt.flags&
CHUNK_START))
865 next_point = &(*next_point)->
next;
869 next_point = &(
s->internal->packet_buffer_end->next);
874 s->internal->packet_buffer_end = this_pktl;
877 this_pktl->
next = *next_point;
891 if (
s->audio_preload) {
894 if (preload != preload2) {
896 preload *=
s->audio_preload;
897 preload2 *=
s->audio_preload;
905 comp = (ts2 > ts) - (ts2 < ts);
918 int stream_count = 0;
919 int noninterleaved_count = 0;
928 for (
i = 0;
i <
s->nb_streams;
i++) {
929 if (
s->streams[
i]->last_in_packet_buffer) {
934 ++noninterleaved_count;
938 if (
s->internal->nb_interleaved_streams == stream_count)
941 if (
s->max_interleave_delta > 0 &&
942 s->internal->packet_buffer &&
944 s->internal->nb_interleaved_streams == stream_count+noninterleaved_count
946 AVPacket *top_pkt = &
s->internal->packet_buffer->pkt;
947 int64_t delta_dts = INT64_MIN;
952 for (
i = 0;
i <
s->nb_streams;
i++) {
960 s->streams[
i]->time_base,
962 delta_dts =
FFMAX(delta_dts, last_dts - top_dts);
965 if (delta_dts >
s->max_interleave_delta) {
967 "Delay between the first packet and last packet in the "
968 "muxing queue is %"PRId64
" > %"PRId64
": forcing output\n",
969 delta_dts,
s->max_interleave_delta);
974 if (
s->internal->packet_buffer &&
978 AVPacket *top_pkt = &
s->internal->packet_buffer->pkt;
986 while (
s->internal->packet_buffer) {
987 AVPacket *top_pkt = &
s->internal->packet_buffer->pkt;
993 if (
s->internal->shortest_end + 1 >= top_dts)
996 pktl =
s->internal->packet_buffer;
999 s->internal->packet_buffer = pktl->
next;
1000 if (!
s->internal->packet_buffer)
1001 s->internal->packet_buffer_end =
NULL;
1012 if (stream_count &&
flush) {
1014 pktl =
s->internal->packet_buffer;
1016 st =
s->streams[
out->stream_index];
1018 s->internal->packet_buffer = pktl->
next;
1019 if (!
s->internal->packet_buffer)
1020 s->internal->packet_buffer_end =
NULL;
1043 if (
s->output_ts_offset)
1069 if (
s->oformat->interleave_packet) {
1070 return s->oformat->interleave_packet(
s,
out,
in,
flush);
1082 if (
s->oformat->check_bitstream) {
1084 if ((
ret =
s->oformat->check_bitstream(
s,
pkt)) < 0)
1121 #if FF_API_COMPUTE_PKT_FIELDS2 && FF_API_LAVF_AVCTX
1142 "Failed to send packet to filter %s for stream %d\n",
1160 if (
ret >= 0 && !interleaved)
1197 ret =
s->oformat->write_packet(
s,
NULL);
1199 if (
ret >= 0 &&
s->pb &&
s->pb->error < 0)
1253 int i, ret1,
ret = 0;
1257 for (
i = 0;
i <
s->nb_streams;
i++) {
1258 if (
s->streams[
i]->internal->bsfc) {
1270 if (
s->oformat->write_trailer) {
1274 ret =
s->oformat->write_trailer(
s);
1276 s->oformat->write_trailer(
s);
1285 ret =
s->pb ?
s->pb->error : 0;
1286 for (
i = 0;
i <
s->nb_streams;
i++) {
1290 if (
s->oformat->priv_class)
1297 int64_t *dts, int64_t *wall)
1299 if (!
s->oformat || !
s->oformat->get_output_timestamp)
1301 s->oformat->get_output_timestamp(
s, stream, dts, wall);
1338 if (!
s->oformat->write_uncoded_frame) {
1391 if (!
s->oformat->write_uncoded_frame)
1393 return s->oformat->write_uncoded_frame(
s, stream_index,
NULL,
static void error(const char *err)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define FF_ENABLE_DEPRECATION_WARNINGS
#define AV_LOG_WARNING
Something somehow does not look correct.
static int interleave_compare_dts(AVFormatContext *s, const AVPacket *next, const AVPacket *pkt)
int reorder
Set to 1 if the codec allows reordering, so pts can be different from dts.
#define AVSTREAM_INIT_IN_WRITE_HEADER
stream parameters initialized in avformat_write_header
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
static int prepare_input_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
#define FFSWAP(type, a, b)
AVCodecContext * avctx
The codec context used by avformat_find_stream_info, the parser, etc.
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
This struct describes the properties of an encoded stream.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AVERROR_EOF
End of file.
#define MKTAG(a, b, c, d)
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
struct AVPacketList * next
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
This structure describes decoded (raw) audio or video data.
AVStream ** streams
A list of all streams in the file.
unsigned int avpriv_toupper4(unsigned int x)
int av_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write an uncoded frame to an output media file.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index)
Test whether a muxer supports uncoded frame.
int avformat_init_output(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and initialize the codec, but do not write the header.
AVBSFContext * bsfc
bitstream filter to run on stream
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
The bitstream filter state.
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
ff_const59 AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
static double val(void *priv, double ch)
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
@ AV_ROUND_UP
Round toward +infinity.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Shift timestamps and call muxer; the original pts/dts are not kept.
static int write_packet_common(AVFormatContext *s, AVStream *st, AVPacket *pkt, int interleaved)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
#define AV_PKT_FLAG_UNCODED_FRAME
This struct describes the properties of a single codec described by an AVCodecID.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
AVRational sample_aspect_ratio
Video only.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write an uncoded frame to an output media file.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
static int init_muxer(AVFormatContext *s, AVDictionary **options)
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
static void flush(AVCodecContext *avctx)
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
@ AVIO_DATA_MARKER_TRAILER
Trailer data, which doesn't contain actual content, but only for finalizing the output file.
int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, int(*compare)(AVFormatContext *, const AVPacket *, const AVPacket *))
Add packet to an AVFormatContext's packet_buffer list, determining its interleaved position using com...
Rational number (pair of numerator and denominator).
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
int64_t interleaver_chunk_duration
struct AVPacketList * last_in_packet_buffer
last packet in packet_buffer for this stream when muxing.
void av_opt_free(void *obj)
Free all allocated objects in obj.
static void frac_add(FFFrac *f, int64_t incr)
Fractional addition to f: f = f + (incr / f->den).
int av_write_frame(AVFormatContext *s, AVPacket *in)
Write a packet to an output media file.
#define AV_EF_EXPLODE
abort decoding on minor error detection
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt, AVFormatContext *src, int interleave)
Write a packet to another muxer than the one the user originally intended.
int sample_rate
Audio only.
AVCodecID
Identify the syntax and semantics of the bitstream.
static int write_packets_common(AVFormatContext *s, AVPacket *pkt, int interleaved)
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
const OptionDef options[]
int64_t mux_ts_offset
Timestamp offset added to timestamps before muxing.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
static void flush_if_needed(AVFormatContext *s)
#define AV_CODEC_PROP_REORDER
Codec supports frame reordering.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int64_t pts_buffer[MAX_REORDER_DELAY+1]
#define AV_NOPTS_VALUE
Undefined timestamp value.
@ AVCHROMA_LOC_UNSPECIFIED
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
int flags
A combination of AV_PKT_FLAG values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another.
#define FF_COMPLIANCE_NORMAL
AVChromaLocation
Location of chroma samples.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
int av_packet_copy_props(AVPacket *dst, const AVPacket *src)
Copy only "properties" fields from src to dst.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_TIME_BASE
Internal time base represented as integer.
int block_align
Audio only.
int av_get_output_timestamp(struct AVFormatContext *s, int stream, int64_t *dts, int64_t *wall)
Get timing information for the data currently output.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
AVRational time_base_out
The timebase used for the timestamps of the output packets.
enum AVFieldOrder field_order
Video only.
@ AVIO_DATA_MARKER_UNKNOWN
This is any, unlabelled data.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
int disposition
AV_DISPOSITION_* bit field.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precision)
Chooses a timebase for muxing the specified stream.
#define AV_INPUT_BUFFER_PADDING_SIZE
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
enum AVChromaLocation chroma_location
static void deinit_muxer(AVFormatContext *s)
static int check_packet(AVFormatContext *s, AVPacket *pkt)
int index
stream index in AVFormatContext
static float compare(const AVFrame *haystack, const AVFrame *obj, int offx, int offy)
static int write_uncoded_frame_internal(AVFormatContext *s, int stream_index, AVFrame *frame, int interleaved)
@ AVCHROMA_LOC_CENTER
MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0.
@ AVIO_DATA_MARKER_HEADER
Header data; this needs to be present for the stream to be decodeable.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
#define AVSTREAM_INIT_IN_INIT_OUTPUT
stream parameters initialized in avformat_init_output
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
int ff_interleaved_peek(AVFormatContext *s, int stream, AVPacket *pkt, int add_offset)
Find the next packet in the interleaving queue for the given stream.
#define FF_DISABLE_DEPRECATION_WARNINGS
const struct AVBitStreamFilter * filter
The bitstream filter this context is an instance of.
char * av_strdup(const char *s)
Duplicate a string.
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
static int write_packets_from_bsfs(AVFormatContext *s, AVStream *st, AVPacket *pkt, int interleaved)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
Interleave an AVPacket per dts so it can be muxed.
enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st)
Chooses a timebase for muxing the specified stream.
int video_delay
Video only.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static int init_pts(AVFormatContext *s)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
static void frac_init(FFFrac *f, int64_t val, int64_t num, int64_t den)
f = val + (num / den) + 0.5.
This structure stores compressed data.
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
static void uncoded_frame_free(void *unused, uint8_t *data)
static int interleaved_write_packet(AVFormatContext *s, AVPacket *pkt, int flush)
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int64_t interleaver_chunk_size
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
int avformat_alloc_output_context2(AVFormatContext **avctx, ff_const59 AVOutputFormat *oformat, const char *format, const char *filename)
Allocate an AVFormatContext for an output format.
The exact value of the fractional number is: 'val + num / den'.
static int check_bitstream(AVFormatContext *s, AVStream *st, AVPacket *pkt)
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define av_fourcc2str(fourcc)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int bitstream_checked
Whether or not check_bitstream should still be run on each packet.
@ AVIO_DATA_MARKER_FLUSH_POINT
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...