FFmpeg: libavformat/mux.c Source File
Go to the documentation of this file. 1 /*
2 * muxing functions for use within FFmpeg
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
35
36 /**
37 * @file
38 * muxing functions for use within libavformat
39 */
40
41 /* fraction handling */
42
43 /**
44 * f = val + (num / den) + 0.5.
45 *
46 * 'num' is normalized so that it is such as 0 <= num < den.
47 *
48 * @param f fractional number
49 * @param val integer value
50 * @param num must be >= 0
51 * @param den must be >= 1
52 */
54 {
55 num += (den >> 1);
56 if (num >= den) {
58 num = num % den;
59 }
63 }
64
65 /**
66 * Fractional addition to f: f = f + (incr / f->den).
67 *
68 * @param f fractional number
69 * @param incr increment, can be positive or negative
70 */
72 {
73 int64_t num, den;
74
77 if (num < 0) {
79 num = num % den;
80 if (num < 0) {
81 num += den;
83 }
84 } else if (num >= den) {
86 num = num % den;
87 }
89 }
90
92 const char *
format,
const char *filename)
93 {
96
99 goto nomem;
100
101 if (!oformat) {
104 if (!oformat) {
108 }
109 } else {
111 if (!oformat) {
114 filename);
116 }
117 }
118 }
119
120 s->oformat = oformat;
124 goto nomem;
125 if (
s->oformat->priv_class) {
126 *(
const AVClass**)
s->priv_data=
s->oformat->priv_class;
128 }
129 } else
131
132 if (filename) {
134 goto nomem;
135
136 }
138 return 0;
139 nomem:
145 }
146
148 {
153
154 /**
155 * Check that tag + id is in the table
156 * If neither is in the table -> OK
157 * If tag is in the table with another id -> FAIL
158 * If id is in the table with another tag -> FAIL unless strict < normal
159 */
160 for (
int n = 0;
s->oformat->codec_tag[n]; n++) {
161 avctag =
s->oformat->codec_tag[n];
166 return 1;
167 }
170 avctag++;
171 }
172 }
174 return 0;
176 return 0;
177 return 1;
178 }
179
180
182 {
188
191
194 if (
s->priv_data &&
s->oformat->priv_class && *(
const AVClass**)
s->priv_data==
s->oformat->priv_class &&
197
201 }
202
203 // some sanity checks
208 }
209
210 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
215
217 /* fall back on the default timebase values */
220 else
222 }
223
230 }
231
232 #if FF_API_OLD_CHANNEL_LAYOUT
234 /* if the caller is using the deprecated channel layout API,
235 * convert it to the new style */
237 par->channels) {
238 if (par->channel_layout) {
240 } else {
243 }
244 }
246 #endif
247
251 break;
258 }
261 ) {
267 "(%d/%d) and encoder layer (%d/%d)\n",
273 }
274 }
275 break;
276 }
277
281
283
290 // the current rawvideo encoding system ends up setting
291 // the wrong codec_tag for avi/mov, we override it here
293 }
298 "Tag %s incompatible with output codec id '%d' (%s)\n",
302 }
303 } else
305 }
306
309 }
315
321 }
327 }
328 }
329
330 /* set muxer identification string */
333 } else {
335 }
336
339 }
340
344 }
345
351 }
353 }
354
355 return 0;
356
360 }
361
363 {
365
366 /* init PTS generation */
367 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
371
375 break;
378 break;
379 default:
380 break;
381 }
382
387
389 if (den <= 0)
391
393 }
394 }
395
397 if (
s->avoid_negative_ts < 0) {
402 } else
406
407 return 0;
408 }
409
411 {
412 if (
s->pb &&
s->pb->error >= 0) {
417 }
418 }
419
421 {
428 }
429
431 {
434
437
440
444
446 }
447
449 }
450
452 {
457
458 if (!already_initialized)
461
466 if (
ret >= 0 &&
s->pb &&
s->pb->error < 0)
471 }
474
478 }
479
480 return streams_already_initialized;
481
485 }
486
487 #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
488
489
490 #if FF_API_COMPUTE_PKT_FIELDS2
492 //FIXME merge with compute_pkt_fields
494 {
499
500 if (!si->missing_ts_warning &&
505 "Timestamps are unset in a packet for stream %d. "
506 "This is deprecated and will stop working in the future. "
507 "Fix your code to set the timestamps properly\n", st->
index);
508 si->missing_ts_warning = 1;
509 }
510
512 av_log(
s,
AV_LOG_DEBUG,
"compute_muxer_pkt_fields: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
514
517
518 //XXX/FIXME this is a temporary hack until all encoders output pts
520 static int warned;
521 if (!warned) {
523 warned = 1;
524 }
526 // pkt->pts= st->cur_dts;
528 }
529
530 //calculate dts from pts
537
539 }
540
547 "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %s >= %s\n",
550 }
553 "pts (%s) < dts (%s) in stream %d\n",
557 }
558
562
565
566 /* update pts */
572
573 /* HACK/FIXME, we skip the initial 0 size packets as they are most
574 * likely equal to the encoder delay, but it would be better if we
575 * had the real timestamps from the encoder */
578 }
579 break;
582 break;
583 }
584 return 0;
585 }
587 #endif
588
590 {
595 }
596
598 return;
599
607 break;
614 }
615 break;
616 }
617 }
618 }
619
622 {
625
627 return;
628
633
635 return;
636
638
639 /* Peek into the muxing queue to improve our estimate
640 * of the lowest timestamp if av_interleaved_write_frame() is used. */
642 pktl; pktl = pktl->
next) {
643 AVRational cmp_tb =
s->streams[pktl->pkt.stream_index]->time_base;
644 int64_t cmp_ts = use_pts ? pktl->pkt.pts : pktl->pkt.dts;
646 continue;
648 if (
s->output_ts_offset)
651 ts = cmp_ts;
653 }
654 }
655
656 if (ts < 0 ||
658 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
664 }
665 }
667 }
668
670
675
679 "pts %s in stream %d.\n"
680 "Try -avoid_negative_ts 1 as a possible workaround.\n",
683 );
684 }
685 } else {
688 "Packets poorly interleaved, failed to avoid negative "
689 "timestamp %s in stream %d.\n"
690 "Try -max_interleave_delta 0 as a possible workaround.\n",
693 );
694 }
695 }
696 }
697
698 /**
699 * Shift timestamps and call muxer; the original pts/dts are not kept.
700 *
701 * FIXME: this function should NEVER get undefined pts/dts beside when the
702 * AVFMT_NOTIMESTAMPS is set.
703 * Those additional safety checks should be dropped once the correct checks
704 * are set in the callers.
705 */
707 {
712
713 // If the timestamp offsetting below is adjusted, adjust
714 // ff_interleaved_peek similarly.
715 if (
s->output_ts_offset) {
717
722 }
724
729 } else {
731 }
732
733 if (
s->pb &&
ret >= 0) {
735 if (
s->pb->error < 0)
737 }
738
741
743 }
744
746 {
751 }
752
756 }
757
758 return 0;
759 }
760
762 {
764 #if !FF_API_COMPUTE_PKT_FIELDS2
765 /* sanitize the timestamps */
767
768 /* when there is no reordering (so dts is equal to pts), but
769 * only one of them is set, set the other as well */
775 }
776
777 /* check that the timestamps are set */
780 "Timestamps are unset in a packet for stream %d\n", st->
index);
782 }
783
784 /* check that the dts are increasing (or at least non-decreasing,
785 * if the format allows it */
790 "Application provided invalid, non monotonically increasing "
791 "dts to muxer in stream %d: %" PRId64 " >= %" PRId64 "\n",
794 }
795
800 }
801 }
802 #endif
803 /* update flags */
806
808 /* Such empty packets signal EOS for the BSF API; so sanitize
809 * the packet by allocating data of size 0 (+ padding). */
812 }
813
814 return 0;
815 }
816
817 #define CHUNK_START 0x1000
818
821 {
827 int chunked =
s->max_chunk_size ||
s->max_chunk_duration;
828
829 this_pktl =
av_malloc(
sizeof(*this_pktl));
830 if (!this_pktl) {
833 }
838 }
839
842
845 } else {
847 }
848
849 if (chunked) {
860
862 } else
864 }
865 }
866 if (*next_point) {
868 goto next_non_null;
869
871 while ( *next_point
872 && ((chunked && !((*next_point)->pkt.flags&
CHUNK_START))
874 next_point = &(*next_point)->
next;
876 goto next_non_null;
877 } else {
879 }
880 }
882
884 next_non_null:
885
886 this_pktl->
next = *next_point;
887
889
890 return 0;
891 }
892
895 {
900 if (
s->audio_preload) {
903 if (preload != preload2) {
904 int64_t ts, ts2;
905 preload *=
s->audio_preload;
906 preload2 *=
s->audio_preload;
909 if (ts == ts2) {
912 ts2 = 0;
913 }
914 comp = (ts2 > ts) - (ts2 < ts);
915 }
916 }
917
921 }
922
924 int flush,
int has_packet)
925 {
927 int stream_count = 0;
928 int noninterleaved_count = 0;
931
932 if (has_packet) {
935 }
936
937 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
942 ++stream_count;
946 ++noninterleaved_count;
947 }
948 }
949
952
953 if (
s->max_interleave_delta > 0 &&
958 ) {
960 int64_t delta_dts = INT64_MIN;
964
965 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
969 int64_t last_dts;
970
971 if (!last)
972 continue;
973
977 delta_dts =
FFMAX(delta_dts, last_dts - top_dts);
978 }
979
980 if (delta_dts >
s->max_interleave_delta) {
982 "Delay between the first packet and last packet in the "
983 "muxing queue is %"PRId64" > %"PRId64": forcing output\n",
984 delta_dts,
s->max_interleave_delta);
986 }
987 }
988
990 eof &&
994
998 }
999
1008
1010 break;
1011
1015
1018
1022 }
1023 }
1024
1025 if (stream_count &&
flush) {
1029
1033
1034 return 1;
1035 } else {
1036 return 0;
1037 }
1038 }
1039
1041 int flush,
int has_packet)
1042 {
1043 return has_packet;
1044 }
1045
1047 {
1049
1050 if (stream_index < 0 || stream_index >=
s->nb_streams)
1052
1053 st =
s->streams[stream_index];
1055
1056 if (
s->output_ts_offset)
1058
1059 return 0;
1060 }
1061
1063 {
1066 while (pktl) {
1069 }
1071 }
1073 }
1074
1076 {
1078
1080 return 1;
1081
1088 }
1089 }
1090
1091 return 1;
1092 }
1093
1095 int flush,
int has_packet)
1096 {
1098 for (;; ) {
1102
1103 has_packet = 0;
1104
1109 }
1110 }
1111
1113 {
1115
1119
1121
1122 #if FF_API_COMPUTE_PKT_FIELDS2
1125 #endif
1126
1127 if (interleaved) {
1131 } else {
1133 }
1134 }
1135
1137 {
1141
1144 "Failed to send packet to filter %s for stream %d\n",
1147 }
1148
1149 do {
1153 return 0;
1157 continue;
1159 }
1162 if (
ret >= 0 && !interleaved)
// a successful write_packet_common already unrefed pkt for interleaved
1165
1167 }
1168
1170 {
1178
1182
1186
1189 } else {
1191 }
1192 }
1193
1195 {
1199
1204 if (
ret >= 0 &&
s->pb &&
s->pb->error < 0)
1207 }
1208 return 1;
1209 }
1210
1213 } else {
1214 /* We don't own in, so we have to make sure not to modify it.
1215 * (ff_write_chained() relies on this fact.)
1216 * The following avoids copying in's data unnecessarily.
1217 * Copying side data is unavoidable as a bitstream filter
1218 * may change it, e.g. free it on errors. */
1229 }
1230 }
1231 }
1232
1234
1236 // Uncoded frames using the noninterleaved codepath are also freed here
1239 }
1240
1242 {
1244
1250 } else {
1253 }
1254 }
1255
1257 {
1261
1262 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
1267 if (ret1 < 0)
1271 }
1272 }
1276
1283 }
1284
1286
1290 ret =
s->pb ?
s->pb->error : 0;
1291 for (
unsigned i = 0;
i <
s->nb_streams;
i++) {
1294 }
1295 if (
s->oformat->priv_class)
1300 }
1301
1303 int64_t *dts, int64_t *wall)
1304 {
1309 return 0;
1310 }
1311
1313 {
1318
1320
1324 }
1325
1328
1333 }
1334
1339 }
1340 }
1341
1345 }
1346
1348
1350 "Automatically inserted bitstream filter '%s'; args='%s'\n",
1351 name, args ? args :
"");
1352 return 1;
1353 }
1354
1357 {
1362
1364
1366 src->streams[stream_index]->time_base,
1368
1371 /* We only have to backup and restore the fields that
1372 * we changed ourselves, because av_write_frame() does not
1373 * modify the packet given to it. */
1379 } else
1381
1383 }
1384
1386 {
1389 }
1390
1393 {
1396
1401 }
1402
1405 } else {
1408
1409 if (!framep)
1418 }
1420
1425 #if FF_API_PKT_DURATION
1427 if (
frame->pkt_duration)
1429 else
1431 #endif
1435 }
1436
1439 }
1440
1443 {
1445 }
1446
1449 {
1451 }
1452
1454 {
1461 }
static void error(const char *err)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define FF_ENABLE_DEPRECATION_WARNINGS
AVCodecParameters * par_in
Parameters of the input stream.
#define AV_LOG_WARNING
Something somehow does not look correct.
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 default minimum maximum flags name is the option name
int avpriv_packet_list_get(PacketList *pkt_buffer, AVPacket *pkt)
Remove the oldest AVPacket in the list and return it.
#define AV_EF_EXPLODE
abort decoding on minor error detection
#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
int(* interleave_packet)(struct AVFormatContext *s, AVPacket *pkt, int flush, int has_packet)
The interleavement function in use.
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.
struct AVBSFContext * bsfc
bitstream filter to run on stream
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.
#define AVERROR_EOF
End of file.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
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.
int64_t interleaver_chunk_size
int av_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write an uncoded frame to an output media file.
AVRational avg_frame_rate
Average framerate.
int initialized
Whether or not avformat_init_output has already been called.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
unsigned int ff_toupper4(unsigned int x)
#define AV_LOG_VERBOSE
Detailed information.
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).
enum AVChannelOrder order
Channel order used in this layout.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
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.
int nb_channels
Number of channels in this layout.
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
The bitstream filter state.
int64_t shortest_end
Timestamp of the end of the shortest stream.
void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type)
Mark the written bytestream as a specific type.
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
static double val(void *priv, double ch)
@ AV_ROUND_UP
Round toward +infinity.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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.
This struct describes the properties of a single codec described by an AVCodecID.
PacketList packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
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.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
FF_ENABLE_DEPRECATION_WARNINGS int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const FFOutputFormat * ffofmt(const AVOutputFormat *fmt)
AVRational time_base_in
The timebase used for the timestamps of the input packets.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **pctx)
Allocate a context for a given bitstream filter.
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.
uint8_t * data
samples buffer
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
AVStream pub
The public context.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Describe the class of an AVClass context structure.
static __device__ float fabs(float a)
int bitstream_checked
Whether or not check_bitstream should still be run on each packet.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
@ AVIO_DATA_MARKER_TRAILER
Trailer data, which doesn't contain actual content, but only for finalizing the output file.
Rational number (pair of numerator and denominator).
#define AVERROR_BSF_NOT_FOUND
Bitstream filter not found.
const AVClass * priv_class
A class for the private data, used to declare bitstream filter private AVOptions.
void av_opt_free(void *obj)
Free all allocated objects in obj.
int av_write_frame(AVFormatContext *s, AVPacket *in)
Write a packet to an output media file.
AVChannelLayout ch_layout
Audio only.
int64_t interleaver_chunk_duration
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
struct PacketListEntry * next
int sample_rate
Audio only.
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
int64_t nb_frames
number of frames in this stream if known or 0
AVCodecID
Identify the syntax and semantics of the bitstream.
static void interleave(uint8_t *dst, uint8_t *src, int w, int h, int dst_linesize, int src_linesize, enum FilterMode mode, int swap)
const OptionDef options[]
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
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.
#define AV_CODEC_PROP_REORDER
Codec supports frame reordering.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_NOPTS_VALUE
Undefined timestamp value.
int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes)
This function is the same as av_get_audio_frame_duration(), except it works with AVCodecParameters in...
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.
#define FF_COMPLIANCE_NORMAL
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.
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.
int64_t mux_ts_offset
Timestamp offset added to timestamps before muxing.
#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.
int reorder
Set to 1 if the codec allows reordering, so pts can be different from dts.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
int64_t pts_buffer[MAX_REORDER_DELAY+1]
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
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.
PacketListEntry * last_in_packet_buffer
last packet in packet_buffer for this stream when muxing.
@ AVIO_DATA_MARKER_UNKNOWN
This is any, unlabelled data.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
void * priv_data
Opaque filter-specific private data.
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
#define FFSWAP(type, a, b)
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
#define AV_INPUT_BUFFER_PADDING_SIZE
int index
stream index in AVFormatContext
static float compare(const AVFrame *haystack, const AVFrame *obj, int offx, int offy)
@ 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.
@ AV_WRITE_UNCODED_FRAME_QUERY
Query whether the feature is possible on this stream.
#define AVSTREAM_INIT_IN_INIT_OUTPUT
stream parameters initialized in avformat_init_output
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
#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 streams_initialized
Whether or not avformat_init_output fully initialized streams.
const 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...
void(* flush)(AVBSFContext *ctx)
int video_delay
Video only.
AVPacket * pkt
Used to hold temporary packets for the generic demuxing code.
AudioData in
input audio data
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
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.
#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...
#define MKTAG(a, b, c, d)
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
The exact value of the fractional number is: 'val + num / den'.
AVFormatContext pub
The public context.
int64_t lowest_ts_allowed
This is the lowest ts allowed in this track; it may be set by the muxer during init or write_header a...
enum FFFormatContext::@282 avoid_negative_ts_status
Whether the timestamp shift offset has already been determined.
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.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
AVRational time_base
Time base of the packet's timestamps.
int nb_interleaved_streams
Number of streams relevant for interleaving.
#define av_fourcc2str(fourcc)
@ AVIO_DATA_MARKER_FLUSH_POINT
A point in the output bytestream where the underlying AVIOContext might flush the buffer depending on...
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
int avoid_negative_ts_use_pts
Generated on Tue Feb 28 2023 21:33:03 for FFmpeg by
doxygen
1.8.17