FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
mux.c
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 
22 #include "avformat.h"
23 #include "avio_internal.h"
24 #include "internal.h"
25 #include "libavcodec/internal.h"
26 #include "libavcodec/bytestream.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/dict.h"
29 #include "libavutil/pixdesc.h"
30 #include "libavutil/timestamp.h"
31 #include "metadata.h"
32 #include "id3v2.h"
33 #include "libavutil/avassert.h"
34 #include "libavutil/avstring.h"
35 #include "libavutil/internal.h"
36 #include "libavutil/mathematics.h"
37 #include "libavutil/parseutils.h"
38 #include "libavutil/time.h"
39 #include "riff.h"
40 #include "audiointerleave.h"
41 #include "url.h"
42 #include <stdarg.h>
43 #if CONFIG_NETWORK
44 #include "network.h"
45 #endif
46 
47 /**
48  * @file
49  * muxing functions for use within libavformat
50  */
51 
52 /* fraction handling */
53 
54 /**
55  * f = val + (num / den) + 0.5.
56  *
57  * 'num' is normalized so that it is such as 0 <= num < den.
58  *
59  * @param f fractional number
60  * @param val integer value
61  * @param num must be >= 0
62  * @param den must be >= 1
63  */
64 static void frac_init(FFFrac *f, int64_t val, int64_t num, int64_t den)
65 {
66  num += (den >> 1);
67  if (num >= den) {
68  val += num / den;
69  num = num % den;
70  }
71  f->val = val;
72  f->num = num;
73  f->den = den;
74 }
75 
76 /**
77  * Fractional addition to f: f = f + (incr / f->den).
78  *
79  * @param f fractional number
80  * @param incr increment, can be positive or negative
81  */
82 static void frac_add(FFFrac *f, int64_t incr)
83 {
84  int64_t num, den;
85 
86  num = f->num + incr;
87  den = f->den;
88  if (num < 0) {
89  f->val += num / den;
90  num = num % den;
91  if (num < 0) {
92  num += den;
93  f->val--;
94  }
95  } else if (num >= den) {
96  f->val += num / den;
97  num = num % den;
98  }
99  f->num = num;
100 }
101 
103 {
104  AVRational q;
105  int j;
106 
107  q = st->time_base;
108 
109  for (j=2; j<14; j+= 1+(j>2))
110  while (q.den / q.num < min_precision && q.num % j == 0)
111  q.num /= j;
112  while (q.den / q.num < min_precision && q.den < (1<<24))
113  q.den <<= 1;
114 
115  return q;
116 }
117 
119 {
120  AVCodecContext *avctx = st->codec;
121  const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(avctx->pix_fmt);
122 
124  return avctx->chroma_sample_location;
125 
126  if (pix_desc) {
127  if (pix_desc->log2_chroma_h == 0) {
128  return AVCHROMA_LOC_TOPLEFT;
129  } else if (pix_desc->log2_chroma_w == 1 && pix_desc->log2_chroma_h == 1) {
130  if (avctx->field_order == AV_FIELD_UNKNOWN || avctx->field_order == AV_FIELD_PROGRESSIVE) {
131  switch (avctx->codec_id) {
132  case AV_CODEC_ID_MJPEG:
134  }
135  }
136  if (avctx->field_order == AV_FIELD_UNKNOWN || avctx->field_order != AV_FIELD_PROGRESSIVE) {
137  switch (avctx->codec_id) {
139  }
140  }
141  }
142  }
143 
145 
146 }
147 
149  const char *format, const char *filename)
150 {
152  int ret = 0;
153 
154  *avctx = NULL;
155  if (!s)
156  goto nomem;
157 
158  if (!oformat) {
159  if (format) {
160  oformat = av_guess_format(format, NULL, NULL);
161  if (!oformat) {
162  av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
163  ret = AVERROR(EINVAL);
164  goto error;
165  }
166  } else {
167  oformat = av_guess_format(NULL, filename, NULL);
168  if (!oformat) {
169  ret = AVERROR(EINVAL);
170  av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
171  filename);
172  goto error;
173  }
174  }
175  }
176 
177  s->oformat = oformat;
178  if (s->oformat->priv_data_size > 0) {
180  if (!s->priv_data)
181  goto nomem;
182  if (s->oformat->priv_class) {
183  *(const AVClass**)s->priv_data= s->oformat->priv_class;
185  }
186  } else
187  s->priv_data = NULL;
188 
189  if (filename)
190  av_strlcpy(s->filename, filename, sizeof(s->filename));
191  *avctx = s;
192  return 0;
193 nomem:
194  av_log(s, AV_LOG_ERROR, "Out of memory\n");
195  ret = AVERROR(ENOMEM);
196 error:
198  return ret;
199 }
200 
202 {
203  const AVCodecTag *avctag;
204  int n;
205  enum AVCodecID id = AV_CODEC_ID_NONE;
206  int64_t tag = -1;
207 
208  /**
209  * Check that tag + id is in the table
210  * If neither is in the table -> OK
211  * If tag is in the table with another id -> FAIL
212  * If id is in the table with another tag -> FAIL unless strict < normal
213  */
214  for (n = 0; s->oformat->codec_tag[n]; n++) {
215  avctag = s->oformat->codec_tag[n];
216  while (avctag->id != AV_CODEC_ID_NONE) {
217  if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codec->codec_tag)) {
218  id = avctag->id;
219  if (id == st->codec->codec_id)
220  return 1;
221  }
222  if (avctag->id == st->codec->codec_id)
223  tag = avctag->tag;
224  avctag++;
225  }
226  }
227  if (id != AV_CODEC_ID_NONE)
228  return 0;
229  if (tag >= 0 && (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL))
230  return 0;
231  return 1;
232 }
233 
234 
236 {
237  int ret = 0, i;
238  AVStream *st;
239  AVDictionary *tmp = NULL;
240  AVCodecContext *codec = NULL;
241  AVOutputFormat *of = s->oformat;
243 
244  if (options)
245  av_dict_copy(&tmp, *options, 0);
246 
247  if ((ret = av_opt_set_dict(s, &tmp)) < 0)
248  goto fail;
249  if (s->priv_data && s->oformat->priv_class && *(const AVClass**)s->priv_data==s->oformat->priv_class &&
250  (ret = av_opt_set_dict2(s->priv_data, &tmp, AV_OPT_SEARCH_CHILDREN)) < 0)
251  goto fail;
252 
253  if (s->nb_streams && s->streams[0]->codec->flags & AV_CODEC_FLAG_BITEXACT) {
254  if (!(s->flags & AVFMT_FLAG_BITEXACT)) {
255 #if FF_API_LAVF_BITEXACT
257  "Setting the AVFormatContext to bitexact mode, because "
258  "the AVCodecContext is in that mode. This behavior will "
259  "change in the future. To keep the current behavior, set "
260  "AVFormatContext.flags |= AVFMT_FLAG_BITEXACT.\n");
262 #else
264  "The AVFormatContext is not in set to bitexact mode, only "
265  "the AVCodecContext. If this is not intended, set "
266  "AVFormatContext.flags |= AVFMT_FLAG_BITEXACT.\n");
267 #endif
268  }
269  }
270 
271  // some sanity checks
272  if (s->nb_streams == 0 && !(of->flags & AVFMT_NOSTREAMS)) {
273  av_log(s, AV_LOG_ERROR, "No streams to mux were specified\n");
274  ret = AVERROR(EINVAL);
275  goto fail;
276  }
277 
278  for (i = 0; i < s->nb_streams; i++) {
279  st = s->streams[i];
280  codec = st->codec;
281 
282 #if FF_API_LAVF_CODEC_TB
284  if (!st->time_base.num && codec->time_base.num) {
285  av_log(s, AV_LOG_WARNING, "Using AVStream.codec.time_base as a "
286  "timebase hint to the muxer is deprecated. Set "
287  "AVStream.time_base instead.\n");
288  avpriv_set_pts_info(st, 64, codec->time_base.num, codec->time_base.den);
289  }
291 #endif
292 
293  if (!st->time_base.num) {
294  /* fall back on the default timebase values */
295  if (codec->codec_type == AVMEDIA_TYPE_AUDIO && codec->sample_rate)
296  avpriv_set_pts_info(st, 64, 1, codec->sample_rate);
297  else
298  avpriv_set_pts_info(st, 33, 1, 90000);
299  }
300 
301  switch (codec->codec_type) {
302  case AVMEDIA_TYPE_AUDIO:
303  if (codec->sample_rate <= 0) {
304  av_log(s, AV_LOG_ERROR, "sample rate not set\n");
305  ret = AVERROR(EINVAL);
306  goto fail;
307  }
308  if (!codec->block_align)
309  codec->block_align = codec->channels *
310  av_get_bits_per_sample(codec->codec_id) >> 3;
311  break;
312  case AVMEDIA_TYPE_VIDEO:
313  if ((codec->width <= 0 || codec->height <= 0) &&
314  !(of->flags & AVFMT_NODIMENSIONS)) {
315  av_log(s, AV_LOG_ERROR, "dimensions not set\n");
316  ret = AVERROR(EINVAL);
317  goto fail;
318  }
321  ) {
322  if (st->sample_aspect_ratio.num != 0 &&
323  st->sample_aspect_ratio.den != 0 &&
324  codec->sample_aspect_ratio.num != 0 &&
325  codec->sample_aspect_ratio.den != 0) {
326  av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between muxer "
327  "(%d/%d) and encoder layer (%d/%d)\n",
329  codec->sample_aspect_ratio.num,
330  codec->sample_aspect_ratio.den);
331  ret = AVERROR(EINVAL);
332  goto fail;
333  }
334  }
335  break;
336  }
337 
338  if (of->codec_tag) {
339  if ( codec->codec_tag
340  && codec->codec_id == AV_CODEC_ID_RAWVIDEO
341  && ( av_codec_get_tag(of->codec_tag, codec->codec_id) == 0
342  || av_codec_get_tag(of->codec_tag, codec->codec_id) == MKTAG('r', 'a', 'w', ' '))
343  && !validate_codec_tag(s, st)) {
344  // the current rawvideo encoding system ends up setting
345  // the wrong codec_tag for avi/mov, we override it here
346  codec->codec_tag = 0;
347  }
348  if (codec->codec_tag) {
349  if (!validate_codec_tag(s, st)) {
350  char tagbuf[32], tagbuf2[32];
351  av_get_codec_tag_string(tagbuf, sizeof(tagbuf), codec->codec_tag);
352  av_get_codec_tag_string(tagbuf2, sizeof(tagbuf2), av_codec_get_tag(s->oformat->codec_tag, codec->codec_id));
353  av_log(s, AV_LOG_ERROR,
354  "Tag %s/0x%08x incompatible with output codec id '%d' (%s)\n",
355  tagbuf, codec->codec_tag, codec->codec_id, tagbuf2);
356  ret = AVERROR_INVALIDDATA;
357  goto fail;
358  }
359  } else
360  codec->codec_tag = av_codec_get_tag(of->codec_tag, codec->codec_id);
361  }
362 
363  if (of->flags & AVFMT_GLOBALHEADER &&
366  "Codec for stream %d does not use global headers "
367  "but container format requires global headers\n", i);
368 
369  if (codec->codec_type != AVMEDIA_TYPE_ATTACHMENT)
371  }
372 
373  if (!s->priv_data && of->priv_data_size > 0) {
375  if (!s->priv_data) {
376  ret = AVERROR(ENOMEM);
377  goto fail;
378  }
379  if (of->priv_class) {
380  *(const AVClass **)s->priv_data = of->priv_class;
382  if ((ret = av_opt_set_dict2(s->priv_data, &tmp, AV_OPT_SEARCH_CHILDREN)) < 0)
383  goto fail;
384  }
385  }
386 
387  /* set muxer identification string */
388  if (!(s->flags & AVFMT_FLAG_BITEXACT)) {
389  av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
390  } else {
391  av_dict_set(&s->metadata, "encoder", NULL, 0);
392  }
393 
394  for (e = NULL; e = av_dict_get(s->metadata, "encoder-", e, AV_DICT_IGNORE_SUFFIX); ) {
395  av_dict_set(&s->metadata, e->key, NULL, 0);
396  }
397 
398  if (options) {
399  av_dict_free(options);
400  *options = tmp;
401  }
402 
403  return 0;
404 
405 fail:
406  av_dict_free(&tmp);
407  return ret;
408 }
409 
411 {
412  int i;
413  AVStream *st;
414 
415  /* init PTS generation */
416  for (i = 0; i < s->nb_streams; i++) {
417  int64_t den = AV_NOPTS_VALUE;
418  st = s->streams[i];
419 
420  switch (st->codec->codec_type) {
421  case AVMEDIA_TYPE_AUDIO:
422  den = (int64_t)st->time_base.num * st->codec->sample_rate;
423  break;
424  case AVMEDIA_TYPE_VIDEO:
425  den = (int64_t)st->time_base.num * st->codec->time_base.den;
426  break;
427  default:
428  break;
429  }
430 
431  if (!st->priv_pts)
432  st->priv_pts = av_mallocz(sizeof(*st->priv_pts));
433  if (!st->priv_pts)
434  return AVERROR(ENOMEM);
435 
436  if (den != AV_NOPTS_VALUE) {
437  if (den <= 0)
438  return AVERROR_INVALIDDATA;
439 
440  frac_init(st->priv_pts, 0, 0, den);
441  }
442  }
443 
444  return 0;
445 }
446 
448 {
449  int ret = 0;
450 
451  if ((ret = init_muxer(s, options)) < 0)
452  return ret;
453 
454  if (s->oformat->write_header) {
455  ret = s->oformat->write_header(s);
456  if (ret >= 0 && s->pb && s->pb->error < 0)
457  ret = s->pb->error;
458  if (ret < 0)
459  return ret;
460  if (s->flush_packets && s->pb && s->pb->error >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS)
461  avio_flush(s->pb);
462  }
463 
464  if ((ret = init_pts(s)) < 0)
465  return ret;
466 
467  if (s->avoid_negative_ts < 0) {
470  s->avoid_negative_ts = 0;
471  } else
473  }
474 
475  return 0;
476 }
477 
478 #define AV_PKT_FLAG_UNCODED_FRAME 0x2000
479 
480 /* Note: using sizeof(AVFrame) from outside lavu is unsafe in general, but
481  it is only being used internally to this file as a consistency check.
482  The value is chosen to be very unlikely to appear on its own and to cause
483  immediate failure if used anywhere as a real size. */
484 #define UNCODED_FRAME_PACKET_SIZE (INT_MIN / 3 * 2 + (int)sizeof(AVFrame))
485 
486 
487 //FIXME merge with compute_pkt_fields
489 {
490  int delay = FFMAX(st->codec->has_b_frames, st->codec->max_b_frames > 0);
491  int num, den, i;
492  int frame_size;
493 
494  if (s->debug & FF_FDEBUG_TS)
495  av_log(s, AV_LOG_TRACE, "compute_pkt_fields2: pts:%s dts:%s cur_dts:%s b:%d size:%d st:%d\n",
496  av_ts2str(pkt->pts), av_ts2str(pkt->dts), av_ts2str(st->cur_dts), delay, pkt->size, pkt->stream_index);
497 
498  if (pkt->duration < 0 && st->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) {
499  av_log(s, AV_LOG_WARNING, "Packet with invalid duration %d in stream %d\n",
500  pkt->duration, pkt->stream_index);
501  pkt->duration = 0;
502  }
503 
504  /* duration field */
505  if (pkt->duration == 0) {
506  ff_compute_frame_duration(s, &num, &den, st, NULL, pkt);
507  if (den && num) {
508  pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den * st->codec->ticks_per_frame, den * (int64_t)st->time_base.num);
509  }
510  }
511 
512  if (pkt->pts == AV_NOPTS_VALUE && pkt->dts != AV_NOPTS_VALUE && delay == 0)
513  pkt->pts = pkt->dts;
514 
515  //XXX/FIXME this is a temporary hack until all encoders output pts
516  if ((pkt->pts == 0 || pkt->pts == AV_NOPTS_VALUE) && pkt->dts == AV_NOPTS_VALUE && !delay) {
517  static int warned;
518  if (!warned) {
519  av_log(s, AV_LOG_WARNING, "Encoder did not produce proper pts, making some up.\n");
520  warned = 1;
521  }
522  pkt->dts =
523 // pkt->pts= st->cur_dts;
524  pkt->pts = st->priv_pts->val;
525  }
526 
527  //calculate dts from pts
528  if (pkt->pts != AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) {
529  st->pts_buffer[0] = pkt->pts;
530  for (i = 1; i < delay + 1 && st->pts_buffer[i] == AV_NOPTS_VALUE; i++)
531  st->pts_buffer[i] = pkt->pts + (i - delay - 1) * pkt->duration;
532  for (i = 0; i<delay && st->pts_buffer[i] > st->pts_buffer[i + 1]; i++)
533  FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i + 1]);
534 
535  pkt->dts = st->pts_buffer[0];
536  }
537 
538  if (st->cur_dts && st->cur_dts != AV_NOPTS_VALUE &&
539  ((!(s->oformat->flags & AVFMT_TS_NONSTRICT) &&
541  st->cur_dts >= pkt->dts) || st->cur_dts > pkt->dts)) {
542  av_log(s, AV_LOG_ERROR,
543  "Application provided invalid, non monotonically increasing dts to muxer in stream %d: %s >= %s\n",
544  st->index, av_ts2str(st->cur_dts), av_ts2str(pkt->dts));
545  return AVERROR(EINVAL);
546  }
547  if (pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts < pkt->dts) {
548  av_log(s, AV_LOG_ERROR,
549  "pts (%s) < dts (%s) in stream %d\n",
550  av_ts2str(pkt->pts), av_ts2str(pkt->dts),
551  st->index);
552  return AVERROR(EINVAL);
553  }
554 
555  if (s->debug & FF_FDEBUG_TS)
556  av_log(s, AV_LOG_TRACE, "av_write_frame: pts2:%s dts2:%s\n",
557  av_ts2str(pkt->pts), av_ts2str(pkt->dts));
558 
559  st->cur_dts = pkt->dts;
560  st->priv_pts->val = pkt->dts;
561 
562  /* update pts */
563  switch (st->codec->codec_type) {
564  case AVMEDIA_TYPE_AUDIO:
565  frame_size = (pkt->flags & AV_PKT_FLAG_UNCODED_FRAME) ?
566  ((AVFrame *)pkt->data)->nb_samples :
568 
569  /* HACK/FIXME, we skip the initial 0 size packets as they are most
570  * likely equal to the encoder delay, but it would be better if we
571  * had the real timestamps from the encoder */
572  if (frame_size >= 0 && (pkt->size || st->priv_pts->num != st->priv_pts->den >> 1 || st->priv_pts->val)) {
573  frac_add(st->priv_pts, (int64_t)st->time_base.den * frame_size);
574  }
575  break;
576  case AVMEDIA_TYPE_VIDEO:
577  frac_add(st->priv_pts, (int64_t)st->time_base.den * st->codec->time_base.num);
578  break;
579  }
580  return 0;
581 }
582 
583 /**
584  * Make timestamps non negative, move side data from payload to internal struct, call muxer, and restore
585  * sidedata.
586  *
587  * FIXME: this function should NEVER get undefined pts/dts beside when the
588  * AVFMT_NOTIMESTAMPS is set.
589  * Those additional safety checks should be dropped once the correct checks
590  * are set in the callers.
591  */
593 {
594  int ret, did_split;
595 
596  if (s->output_ts_offset) {
597  AVStream *st = s->streams[pkt->stream_index];
599 
600  if (pkt->dts != AV_NOPTS_VALUE)
601  pkt->dts += offset;
602  if (pkt->pts != AV_NOPTS_VALUE)
603  pkt->pts += offset;
604  }
605 
606  if (s->avoid_negative_ts > 0) {
607  AVStream *st = s->streams[pkt->stream_index];
608  int64_t offset = st->mux_ts_offset;
609  int64_t ts = s->internal->avoid_negative_ts_use_pts ? pkt->pts : pkt->dts;
610 
611  if (s->internal->offset == AV_NOPTS_VALUE && ts != AV_NOPTS_VALUE &&
612  (ts < 0 || s->avoid_negative_ts == AVFMT_AVOID_NEG_TS_MAKE_ZERO)) {
613  s->internal->offset = -ts;
615  }
616 
617  if (s->internal->offset != AV_NOPTS_VALUE && !offset) {
618  offset = st->mux_ts_offset =
621  st->time_base,
622  AV_ROUND_UP);
623  }
624 
625  if (pkt->dts != AV_NOPTS_VALUE)
626  pkt->dts += offset;
627  if (pkt->pts != AV_NOPTS_VALUE)
628  pkt->pts += offset;
629 
631  if (pkt->pts != AV_NOPTS_VALUE && pkt->pts < 0) {
632  av_log(s, AV_LOG_WARNING, "failed to avoid negative "
633  "pts %s in stream %d.\n"
634  "Try -avoid_negative_ts 1 as a possible workaround.\n",
635  av_ts2str(pkt->dts),
636  pkt->stream_index
637  );
638  }
639  } else {
640  av_assert2(pkt->dts == AV_NOPTS_VALUE || pkt->dts >= 0 || s->max_interleave_delta > 0);
641  if (pkt->dts != AV_NOPTS_VALUE && pkt->dts < 0) {
643  "Packets poorly interleaved, failed to avoid negative "
644  "timestamp %s in stream %d.\n"
645  "Try -max_interleave_delta 0 as a possible workaround.\n",
646  av_ts2str(pkt->dts),
647  pkt->stream_index
648  );
649  }
650  }
651  }
652 
653  did_split = av_packet_split_side_data(pkt);
654  if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
655  AVFrame *frame = (AVFrame *)pkt->data;
657  ret = s->oformat->write_uncoded_frame(s, pkt->stream_index, &frame, 0);
658  av_frame_free(&frame);
659  } else {
660  ret = s->oformat->write_packet(s, pkt);
661  }
662 
663  if (s->flush_packets && s->pb && ret >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS)
664  avio_flush(s->pb);
665 
666  if (did_split)
668 
669  return ret;
670 }
671 
673 {
674  if (!pkt)
675  return 0;
676 
677  if (pkt->stream_index < 0 || pkt->stream_index >= s->nb_streams) {
678  av_log(s, AV_LOG_ERROR, "Invalid packet stream index: %d\n",
679  pkt->stream_index);
680  return AVERROR(EINVAL);
681  }
682 
684  av_log(s, AV_LOG_ERROR, "Received a packet for an attachment stream.\n");
685  return AVERROR(EINVAL);
686  }
687 
688  return 0;
689 }
690 
692 {
693  int ret;
694 
695  ret = check_packet(s, pkt);
696  if (ret < 0)
697  return ret;
698 
699  if (!pkt) {
700  if (s->oformat->flags & AVFMT_ALLOW_FLUSH) {
701  ret = s->oformat->write_packet(s, NULL);
702  if (s->flush_packets && s->pb && s->pb->error >= 0 && s->flags & AVFMT_FLAG_FLUSH_PACKETS)
703  avio_flush(s->pb);
704  if (ret >= 0 && s->pb && s->pb->error < 0)
705  ret = s->pb->error;
706  return ret;
707  }
708  return 1;
709  }
710 
711  ret = compute_pkt_fields2(s, s->streams[pkt->stream_index], pkt);
712 
713  if (ret < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
714  return ret;
715 
716  ret = write_packet(s, pkt);
717  if (ret >= 0 && s->pb && s->pb->error < 0)
718  ret = s->pb->error;
719 
720  if (ret >= 0)
721  s->streams[pkt->stream_index]->nb_frames++;
722  return ret;
723 }
724 
725 #define CHUNK_START 0x1000
726 
728  int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
729 {
730  int ret;
731  AVPacketList **next_point, *this_pktl;
732  AVStream *st = s->streams[pkt->stream_index];
733  int chunked = s->max_chunk_size || s->max_chunk_duration;
734 
735  this_pktl = av_mallocz(sizeof(AVPacketList));
736  if (!this_pktl)
737  return AVERROR(ENOMEM);
738  this_pktl->pkt = *pkt;
739 #if FF_API_DESTRUCT_PACKET
741  pkt->destruct = NULL; // do not free original but only the copy
743 #endif
744  pkt->buf = NULL;
745  pkt->side_data = NULL;
746  pkt->side_data_elems = 0;
747  if ((pkt->flags & AV_PKT_FLAG_UNCODED_FRAME)) {
749  av_assert0(((AVFrame *)pkt->data)->buf);
750  } else {
751  // Duplicate the packet if it uses non-allocated memory
752  if ((ret = av_dup_packet(&this_pktl->pkt)) < 0) {
753  av_free(this_pktl);
754  return ret;
755  }
756  }
757 
759  next_point = &(st->last_in_packet_buffer->next);
760  } else {
761  next_point = &s->internal->packet_buffer;
762  }
763 
764  if (chunked) {
766  st->interleaver_chunk_size += pkt->size;
769  || (max && st->interleaver_chunk_duration > max)) {
770  st->interleaver_chunk_size = 0;
771  this_pktl->pkt.flags |= CHUNK_START;
772  if (max && st->interleaver_chunk_duration > max) {
773  int64_t syncoffset = (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)*max/2;
774  int64_t syncto = av_rescale(pkt->dts + syncoffset, 1, max)*max - syncoffset;
775 
776  st->interleaver_chunk_duration += (pkt->dts - syncto)/8 - max;
777  } else
779  }
780  }
781  if (*next_point) {
782  if (chunked && !(this_pktl->pkt.flags & CHUNK_START))
783  goto next_non_null;
784 
785  if (compare(s, &s->internal->packet_buffer_end->pkt, pkt)) {
786  while ( *next_point
787  && ((chunked && !((*next_point)->pkt.flags&CHUNK_START))
788  || !compare(s, &(*next_point)->pkt, pkt)))
789  next_point = &(*next_point)->next;
790  if (*next_point)
791  goto next_non_null;
792  } else {
793  next_point = &(s->internal->packet_buffer_end->next);
794  }
795  }
796  av_assert1(!*next_point);
797 
798  s->internal->packet_buffer_end = this_pktl;
799 next_non_null:
800 
801  this_pktl->next = *next_point;
802 
804  *next_point = this_pktl;
805 
806  return 0;
807 }
808 
810  AVPacket *pkt)
811 {
812  AVStream *st = s->streams[pkt->stream_index];
813  AVStream *st2 = s->streams[next->stream_index];
814  int comp = av_compare_ts(next->dts, st2->time_base, pkt->dts,
815  st->time_base);
817  int64_t ts = av_rescale_q(pkt ->dts, st ->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st ->codec->codec_type == AVMEDIA_TYPE_AUDIO);
818  int64_t ts2= av_rescale_q(next->dts, st2->time_base, AV_TIME_BASE_Q) - s->audio_preload*(st2->codec->codec_type == AVMEDIA_TYPE_AUDIO);
819  if (ts == ts2) {
820  ts= ( pkt ->dts* st->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st ->codec->codec_type == AVMEDIA_TYPE_AUDIO)* st->time_base.den)*st2->time_base.den
821  -( next->dts*st2->time_base.num*AV_TIME_BASE - s->audio_preload*(int64_t)(st2->codec->codec_type == AVMEDIA_TYPE_AUDIO)*st2->time_base.den)* st->time_base.den;
822  ts2=0;
823  }
824  comp= (ts>ts2) - (ts<ts2);
825  }
826 
827  if (comp == 0)
828  return pkt->stream_index < next->stream_index;
829  return comp > 0;
830 }
831 
833  AVPacket *pkt, int flush)
834 {
835  AVPacketList *pktl;
836  int stream_count = 0;
837  int noninterleaved_count = 0;
838  int i, ret;
839 
840  if (pkt) {
841  if ((ret = ff_interleave_add_packet(s, pkt, interleave_compare_dts)) < 0)
842  return ret;
843  }
844 
845  for (i = 0; i < s->nb_streams; i++) {
846  if (s->streams[i]->last_in_packet_buffer) {
847  ++stream_count;
848  } else if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
849  s->streams[i]->codec->codec_id != AV_CODEC_ID_VP8 &&
850  s->streams[i]->codec->codec_id != AV_CODEC_ID_VP9) {
851  ++noninterleaved_count;
852  }
853  }
854 
855  if (s->internal->nb_interleaved_streams == stream_count)
856  flush = 1;
857 
858  if (s->max_interleave_delta > 0 &&
859  s->internal->packet_buffer &&
860  !flush &&
861  s->internal->nb_interleaved_streams == stream_count+noninterleaved_count
862  ) {
863  AVPacket *top_pkt = &s->internal->packet_buffer->pkt;
864  int64_t delta_dts = INT64_MIN;
865  int64_t top_dts = av_rescale_q(top_pkt->dts,
866  s->streams[top_pkt->stream_index]->time_base,
868 
869  for (i = 0; i < s->nb_streams; i++) {
870  int64_t last_dts;
871  const AVPacketList *last = s->streams[i]->last_in_packet_buffer;
872 
873  if (!last)
874  continue;
875 
876  last_dts = av_rescale_q(last->pkt.dts,
877  s->streams[i]->time_base,
879  delta_dts = FFMAX(delta_dts, last_dts - top_dts);
880  }
881 
882  if (delta_dts > s->max_interleave_delta) {
883  av_log(s, AV_LOG_DEBUG,
884  "Delay between the first packet and last packet in the "
885  "muxing queue is %"PRId64" > %"PRId64": forcing output\n",
886  delta_dts, s->max_interleave_delta);
887  flush = 1;
888  }
889  }
890 
891  if (stream_count && flush) {
892  AVStream *st;
893  pktl = s->internal->packet_buffer;
894  *out = pktl->pkt;
895  st = s->streams[out->stream_index];
896 
897  s->internal->packet_buffer = pktl->next;
898  if (!s->internal->packet_buffer)
900 
901  if (st->last_in_packet_buffer == pktl)
903  av_freep(&pktl);
904 
905  return 1;
906  } else {
907  av_init_packet(out);
908  return 0;
909  }
910 }
911 
912 /**
913  * Interleave an AVPacket correctly so it can be muxed.
914  * @param out the interleaved packet will be output here
915  * @param in the input packet
916  * @param flush 1 if no further packets are available as input and all
917  * remaining packets should be output
918  * @return 1 if a packet was output, 0 if no packet could be output,
919  * < 0 if an error occurred
920  */
922 {
923  if (s->oformat->interleave_packet) {
924  int ret = s->oformat->interleave_packet(s, out, in, flush);
925  if (in)
926  av_free_packet(in);
927  return ret;
928  } else
929  return ff_interleave_packet_per_dts(s, out, in, flush);
930 }
931 
933 {
934  int ret, flush = 0;
935 
936  ret = check_packet(s, pkt);
937  if (ret < 0)
938  goto fail;
939 
940  if (pkt) {
941  AVStream *st = s->streams[pkt->stream_index];
942 
943  if (s->debug & FF_FDEBUG_TS)
944  av_log(s, AV_LOG_TRACE, "av_interleaved_write_frame size:%d dts:%s pts:%s\n",
945  pkt->size, av_ts2str(pkt->dts), av_ts2str(pkt->pts));
946 
947  if ((ret = compute_pkt_fields2(s, st, pkt)) < 0 && !(s->oformat->flags & AVFMT_NOTIMESTAMPS))
948  goto fail;
949 
950  if (pkt->dts == AV_NOPTS_VALUE && !(s->oformat->flags & AVFMT_NOTIMESTAMPS)) {
951  ret = AVERROR(EINVAL);
952  goto fail;
953  }
954  } else {
955  av_log(s, AV_LOG_TRACE, "av_interleaved_write_frame FLUSH\n");
956  flush = 1;
957  }
958 
959  for (;; ) {
960  AVPacket opkt;
961  int ret = interleave_packet(s, &opkt, pkt, flush);
962  if (pkt) {
963  memset(pkt, 0, sizeof(*pkt));
964  av_init_packet(pkt);
965  pkt = NULL;
966  }
967  if (ret <= 0) //FIXME cleanup needed for ret<0 ?
968  return ret;
969 
970  ret = write_packet(s, &opkt);
971  if (ret >= 0)
972  s->streams[opkt.stream_index]->nb_frames++;
973 
974  av_free_packet(&opkt);
975 
976  if (ret < 0)
977  return ret;
978  if(s->pb && s->pb->error)
979  return s->pb->error;
980  }
981 fail:
982  av_packet_unref(pkt);
983  return ret;
984 }
985 
987 {
988  int ret, i;
989 
990  for (;; ) {
991  AVPacket pkt;
992  ret = interleave_packet(s, &pkt, NULL, 1);
993  if (ret < 0)
994  goto fail;
995  if (!ret)
996  break;
997 
998  ret = write_packet(s, &pkt);
999  if (ret >= 0)
1000  s->streams[pkt.stream_index]->nb_frames++;
1001 
1002  av_free_packet(&pkt);
1003 
1004  if (ret < 0)
1005  goto fail;
1006  if(s->pb && s->pb->error)
1007  goto fail;
1008  }
1009 
1010 fail:
1011  if (s->oformat->write_trailer)
1012  if (ret >= 0) {
1013  ret = s->oformat->write_trailer(s);
1014  } else {
1015  s->oformat->write_trailer(s);
1016  }
1017 
1018  if (s->pb)
1019  avio_flush(s->pb);
1020  if (ret == 0)
1021  ret = s->pb ? s->pb->error : 0;
1022  for (i = 0; i < s->nb_streams; i++) {
1023  av_freep(&s->streams[i]->priv_data);
1024  av_freep(&s->streams[i]->index_entries);
1025  }
1026  if (s->oformat->priv_class)
1027  av_opt_free(s->priv_data);
1028  av_freep(&s->priv_data);
1029  return ret;
1030 }
1031 
1032 int av_get_output_timestamp(struct AVFormatContext *s, int stream,
1033  int64_t *dts, int64_t *wall)
1034 {
1035  if (!s->oformat || !s->oformat->get_output_timestamp)
1036  return AVERROR(ENOSYS);
1037  s->oformat->get_output_timestamp(s, stream, dts, wall);
1038  return 0;
1039 }
1040 
1041 int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
1043 {
1044  AVPacket local_pkt;
1045  int ret;
1046 
1047  local_pkt = *pkt;
1048  local_pkt.stream_index = dst_stream;
1049  if (pkt->pts != AV_NOPTS_VALUE)
1050  local_pkt.pts = av_rescale_q(pkt->pts,
1051  src->streams[pkt->stream_index]->time_base,
1052  dst->streams[dst_stream]->time_base);
1053  if (pkt->dts != AV_NOPTS_VALUE)
1054  local_pkt.dts = av_rescale_q(pkt->dts,
1055  src->streams[pkt->stream_index]->time_base,
1056  dst->streams[dst_stream]->time_base);
1057  if (pkt->duration)
1058  local_pkt.duration = av_rescale_q(pkt->duration,
1059  src->streams[pkt->stream_index]->time_base,
1060  dst->streams[dst_stream]->time_base);
1061 
1062  if (interleave) ret = av_interleaved_write_frame(dst, &local_pkt);
1063  else ret = av_write_frame(dst, &local_pkt);
1064  pkt->buf = local_pkt.buf;
1065  pkt->side_data = local_pkt.side_data;
1066  pkt->side_data_elems = local_pkt.side_data_elems;
1067 #if FF_API_DESTRUCT_PACKET
1069  pkt->destruct = local_pkt.destruct;
1071 #endif
1072  return ret;
1073 }
1074 
1075 static int av_write_uncoded_frame_internal(AVFormatContext *s, int stream_index,
1076  AVFrame *frame, int interleaved)
1077 {
1078  AVPacket pkt, *pktp;
1079 
1080  av_assert0(s->oformat);
1081  if (!s->oformat->write_uncoded_frame)
1082  return AVERROR(ENOSYS);
1083 
1084  if (!frame) {
1085  pktp = NULL;
1086  } else {
1087  pktp = &pkt;
1088  av_init_packet(&pkt);
1089  pkt.data = (void *)frame;
1091  pkt.pts =
1092  pkt.dts = frame->pts;
1093  pkt.duration = av_frame_get_pkt_duration(frame);
1094  pkt.stream_index = stream_index;
1096  }
1097 
1098  return interleaved ? av_interleaved_write_frame(s, pktp) :
1099  av_write_frame(s, pktp);
1100 }
1101 
1102 int av_write_uncoded_frame(AVFormatContext *s, int stream_index,
1103  AVFrame *frame)
1104 {
1105  return av_write_uncoded_frame_internal(s, stream_index, frame, 0);
1106 }
1107 
1109  AVFrame *frame)
1110 {
1111  return av_write_uncoded_frame_internal(s, stream_index, frame, 1);
1112 }
1113 
1115 {
1116  av_assert0(s->oformat);
1117  if (!s->oformat->write_uncoded_frame)
1118  return AVERROR(ENOSYS);
1119  return s->oformat->write_uncoded_frame(s, stream_index, NULL,
1121 }
static float compare(const AVFrame *haystack, const AVFrame *obj, int offx, int offy)
Definition: vf_find_rect.c:105
int64_t interleaver_chunk_size
Definition: avformat.h:1070
#define NULL
Definition: coverity.c:32
const char const char void * val
Definition: avisynth_c.h:634
int audio_preload
Audio preload in microseconds.
Definition: avformat.h:1593
const char * s
Definition: avisynth_c.h:631
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
int64_t av_frame_get_pkt_duration(const AVFrame *frame)
static int check_packet(AVFormatContext *s, AVPacket *pkt)
Definition: mux.c:672
enum AVCodecID id
Definition: internal.h:43
void av_free_packet(AVPacket *pkt)
Free a packet.
Definition: avpacket.c:280
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2129
mpeg2/4 4:2:0, h264 default for 4:2:0
Definition: pixfmt.h:561
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
Definition: mux.c:932
static void flush(AVCodecContext *avctx)
int flush_packets
Flush the I/O context after each packet.
Definition: avformat.h:1660
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
Definition: mux.c:447
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
Definition: mux.c:691
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
void avpriv_set_pts_info(AVStream *s, int pts_wrap_bits, unsigned int pts_num, unsigned int pts_den)
Set the time base and wrapping info for a given stream.
Definition: utils.c:4083
int64_t pts_buffer[MAX_REORDER_DELAY+1]
Definition: avformat.h:1043
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...
Definition: avcodec.h:1780
struct FFFrac * priv_pts
Definition: avformat.h:1182
void av_opt_set_defaults(void *s)
Set the values of all AVOption fields to their default values.
Definition: opt.c:1178
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:914
int num
numerator
Definition: rational.h:44
int index
stream index in AVFormatContext
Definition: avformat.h:843
int size
Definition: avcodec.h:1424
int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
Interleave a packet per dts in an output media file.
Definition: mux.c:832
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
Definition: avformat.h:1045
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1698
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
Definition: avcodec.h:1902
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1722
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
Definition: rational.h:66
int av_get_output_timestamp(struct AVFormatContext *s, int stream, int64_t *dts, int64_t *wall)
Get timing information for the data currently output.
Definition: mux.c:1032
int64_t offset
Offset to remap timestamps to be non-negative.
Definition: internal.h:106
void * priv_data
Definition: avformat.h:862
size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag)
Put a string representing the codec tag codec_tag in buf.
Definition: utils.c:3055
static av_always_inline void interleave(IDWTELEM *dst, IDWTELEM *src0, IDWTELEM *src1, int w2, int add, int shift)
Definition: dirac_dwt.c:40
int avoid_negative_ts_use_pts
Definition: internal.h:115
int(* write_packet)(struct AVFormatContext *, AVPacket *pkt)
Write a packet.
Definition: avformat.h:564
static AVPacket pkt
int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index)
Test whether a muxer supports uncoded frame.
Definition: mux.c:1114
int av_dup_packet(AVPacket *pkt)
Definition: avpacket.c:248
#define AVFMT_ALLOW_FLUSH
Format allows flushing.
Definition: avformat.h:481
static int av_write_uncoded_frame_internal(AVFormatContext *s, int stream_index, AVFrame *frame, int interleaved)
Definition: mux.c:1075
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
Definition: avcodec.h:2299
int strict_std_compliance
Allow non-standard and experimental extension.
Definition: avformat.h:1553
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:80
#define AVFMT_TS_NONSTRICT
Format does not require strictly increasing timestamps, but they must still be monotonic.
Definition: avformat.h:483
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.
Definition: mux.c:1041
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1631
Format I/O context.
Definition: avformat.h:1273
int64_t output_ts_offset
Output timestamp offset, in microseconds.
Definition: avformat.h:1763
int64_t cur_dts
Definition: avformat.h:1019
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
internal metadata API header see avformat.h or the public API!
#define CHUNK_START
Definition: mux.c:725
Public dictionary API.
int flags
can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_RAWPICTURE, AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, AVFMT_TS_NONSTRICT
Definition: avformat.h:532
Round toward +infinity.
Definition: mathematics.h:74
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
Definition: avassert.h:63
AVOptions.
timestamp utils, mostly useful for debugging/logging purposes
attribute_deprecated void(* destruct)(struct AVPacket *)
Definition: avcodec.h:1444
Query whether the feature is possible on this stream.
Definition: internal.h:502
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
Definition: log.h:202
AVPacket pkt
Definition: avformat.h:1856
int priv_data_size
size of private data so that it can be allocated in the wrapper
Definition: avformat.h:554
The exact value of the fractional number is: 'val + num / den'.
Definition: internal.h:59
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:257
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1341
static AVFrame * frame
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:111
#define MAX_REORDER_DELAY
Definition: avformat.h:1042
void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt)
Return the frame duration in seconds.
Definition: utils.c:750
static double av_q2d(AVRational a)
Convert rational to double.
Definition: rational.h:80
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:39
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1384
uint8_t * data
Definition: avcodec.h:1423
int64_t max_interleave_delta
Maximum buffering duration for interleaving.
Definition: avformat.h:1547
uint32_t tag
Definition: movenc.c:1334
struct AVPacketList * packet_buffer
This buffer is only needed when packets were already buffered but not decoded, for example to get the...
Definition: internal.h:76
static int interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *in, int flush)
Interleave an AVPacket correctly so it can be muxed.
Definition: mux.c:921
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1401
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: avcodec.h:1441
const OptionDef options[]
Definition: ffserver.c:3807
void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
Definition: dict.c:213
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:2244
int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat, const char *format, const char *filename)
Allocate an AVFormatContext for an output format.
Definition: mux.c:148
#define av_log(a,...)
struct AVOutputFormat * oformat
The output container format.
Definition: avformat.h:1292
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:140
#define AVFMT_FLAG_FLUSH_PACKETS
Flush the AVIOContext every packet.
Definition: avformat.h:1394
int(* write_uncoded_frame)(struct AVFormatContext *, int stream_index, AVFrame **frame, unsigned flags)
Write an uncoded AVFrame.
Definition: avformat.h:596
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: avcodec.h:102
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
int has_b_frames
Size of the frame reordering buffer in the decoder.
Definition: avcodec.h:1812
AVDictionary * metadata
Metadata that applies to the whole file.
Definition: avformat.h:1485
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition: utils.c:3392
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
Definition: mux.c:201
#define AVERROR(e)
Definition: error.h:43
#define AV_PKT_FLAG_UNCODED_FRAME
Definition: mux.c:478
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:148
int(* write_header)(struct AVFormatContext *)
Definition: avformat.h:556
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
#define FF_COMPLIANCE_NORMAL
Definition: avcodec.h:2823
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
Definition: dict.c:199
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
Definition: avcodec.h:1406
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:1597
simple assert() macros that are a bit more flexible than ISO C assert().
int side_data_elems
Definition: avcodec.h:1435
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
#define FFMAX(a, b)
Definition: common.h:79
int64_t val
Definition: internal.h:60
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.
Definition: avstring.c:83
#define fail()
Definition: checkasm.h:57
int flags
A combination of AV_PKT_FLAG values.
Definition: avcodec.h:1429
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare 2 timestamps each in its own timebases.
Definition: mathematics.c:145
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:861
int av_packet_merge_side_data(AVPacket *pkt)
Definition: avpacket.c:364
static int write_packet(AVFormatContext *s, AVPacket *pkt)
Make timestamps non negative, move side data from payload to internal struct, call muxer...
Definition: mux.c:592
common internal API header
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1329
#define LIBAVFORMAT_IDENT
Definition: version.h:44
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.
Definition: mathematics.c:132
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:198
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:788
char filename[1024]
input or output filename
Definition: avformat.h:1349
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:127
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:246
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:611
int width
picture width / height.
Definition: avcodec.h:1681
#define AVFMT_GLOBALHEADER
Format wants global header.
Definition: avformat.h:471
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:563
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:68
int avoid_negative_ts
Avoid negative timestamps during muxing.
Definition: avformat.h:1576
static void frac_init(FFFrac *f, int64_t val, int64_t num, int64_t den)
f = val + (num / den) + 0.5.
Definition: mux.c:64
int n
Definition: avisynth_c.h:547
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...
Definition: format.c:94
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Definition: avcodec.h:1640
static int init_muxer(AVFormatContext *s, AVDictionary **options)
Definition: mux.c:235
Opaque data information usually sparse.
Definition: avutil.h:197
int64_t num
Definition: internal.h:60
void(* get_output_timestamp)(struct AVFormatContext *s, int stream, int64_t *dts, int64_t *wall)
Definition: avformat.h:580
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:541
int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags)
Set all the options from a given dictionary on an object.
Definition: opt.c:1452
preferred ID for MPEG-1/2 video decoding
Definition: avcodec.h:107
int av_packet_split_side_data(AVPacket *pkt)
Definition: avpacket.c:404
Stream structure.
Definition: avformat.h:842
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:472
#define FF_FDEBUG_TS
Definition: avformat.h:1529
int frame_size
Definition: mxfenc.c:1805
AVS_Value src
Definition: avisynth_c.h:482
enum AVMediaType codec_type
Definition: avcodec.h:1510
int debug
Flags to enable debugging.
Definition: avformat.h:1528
enum AVCodecID codec_id
Definition: avcodec.h:1519
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:252
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
Definition: opt.c:1476
int sample_rate
samples per second
Definition: avcodec.h:2262
AVIOContext * pb
I/O context.
Definition: avformat.h:1315
const struct AVCodecTag *const * codec_tag
List of supported codec_id-codec_tag pairs, ordered by "better choice first".
Definition: avformat.h:538
int64_t den
Definition: internal.h:60
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
main external API structure.
Definition: avcodec.h:1502
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:550
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:1534
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:69
#define UNCODED_FRAME_PACKET_SIZE
Definition: mux.c:484
int nb_interleaved_streams
Number of streams relevant for interleaving.
Definition: internal.h:69
Describe the class of an AVClass context structure.
Definition: log.h:67
unsigned int avpriv_toupper4(unsigned int x)
Definition: utils.c:3754
rational number numerator/denominator
Definition: rational.h:43
int(* interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush)
Currently only used to set pixel format if not YUV420P.
Definition: avformat.h:569
enum AVChromaLocation ff_choose_chroma_location(AVFormatContext *s, AVStream *st)
Chooses a timebase for muxing the specified stream.
Definition: mux.c:118
AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precision)
Chooses a timebase for muxing the specified stream.
Definition: mux.c:102
#define AVFMT_AVOID_NEG_TS_AUTO
Enabled when required by target format.
Definition: avformat.h:1577
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: utils.c:3686
int error
contains the error code or 0 if no error happened
Definition: avio.h:145
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
Definition: utils.c:3410
misc parsing utilities
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
Definition: avcodec.h:784
unsigned int tag
Definition: internal.h:44
AVRational offset_timebase
Timebase for the timestamp offset.
Definition: internal.h:111
int64_t interleaver_chunk_duration
Definition: avformat.h:1071
#define AVFMT_AVOID_NEG_TS_MAKE_ZERO
Shift timestamps so that they start at 0.
Definition: avformat.h:1579
Main libavformat public API header.
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
Definition: avcodec.h:1434
int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt, int(*compare)(AVFormatContext *, AVPacket *, AVPacket *))
Add packet to AVFormatContext->packet_buffer list, determining its interleaved position using compare...
Definition: mux.c:727
void av_opt_free(void *obj)
Free all allocated objects in obj.
Definition: opt.c:1432
#define FF_DISABLE_DEPRECATION_WARNINGS
Definition: internal.h:79
int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write a uncoded frame to an output media file.
Definition: mux.c:1108
common internal api header.
struct AVPacketList * next
Definition: avformat.h:1857
if(ret< 0)
Definition: vf_mcdeint.c:280
#define AVFMT_NOSTREAMS
Format does not require any streams.
Definition: avformat.h:477
int max_chunk_size
Max chunk size in bytes Note, not all formats support this and unpredictable things may happen if it ...
Definition: avformat.h:1609
static void frac_add(FFFrac *f, int64_t incr)
Fractional addition to f: f = f + (incr / f->den).
Definition: mux.c:82
static int init_pts(AVFormatContext *s)
Definition: mux.c:410
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
Definition: avpacket.c:49
int64_t nb_frames
number of frames in this stream if known or 0
Definition: avformat.h:903
char * key
Definition: dict.h:87
int den
denominator
Definition: rational.h:45
int av_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame)
Write a uncoded frame to an output media file.
Definition: mux.c:1102
int64_t mux_ts_offset
Timestamp offset added to timestamps before muxing NOT PART OF PUBLIC API.
Definition: avformat.h:1126
#define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE
Shift timestamps so they are non negative.
Definition: avformat.h:1578
struct AVPacketList * packet_buffer_end
Definition: internal.h:77
#define av_free(p)
static int interleave_compare_dts(AVFormatContext *s, AVPacket *next, AVPacket *pkt)
Definition: mux.c:809
#define FF_ENABLE_DEPRECATION_WARNINGS
Definition: internal.h:80
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:54
int channels
number of audio channels
Definition: avcodec.h:2263
int max_chunk_duration
Max chunk time in microseconds.
Definition: avformat.h:1601
void * priv_data
Format private data.
Definition: avformat.h:1301
#define AVFMT_NODIMENSIONS
Format does not need width/height.
Definition: avformat.h:476
static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt)
Definition: mux.c:488
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
Definition: avcodec.h:1422
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
Definition: mux.c:986
#define av_freep(p)
static void comp(unsigned char *dst, int dst_stride, unsigned char *src, int src_stride, int add)
Definition: eamad.c:83
enum AVFieldOrder field_order
Field order.
Definition: avcodec.h:2259
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
Definition: dict.h:72
AVChromaLocation
Location of chroma samples.
Definition: pixfmt.h:559
unbuffered private I/O API
mpeg1 4:2:0, jpeg 4:2:0, h263 4:2:0
Definition: pixfmt.h:562
#define FFSWAP(type, a, b)
Definition: common.h:84
int stream_index
Definition: avcodec.h:1425
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:884
#define MKTAG(a, b, c, d)
Definition: common.h:330
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 AVFMT_TS_NEGATIVE
Format allows muxing negative timestamps.
Definition: avformat.h:490
This structure stores compressed data.
Definition: avcodec.h:1400
int(* write_trailer)(struct AVFormatContext *)
Definition: avformat.h:565
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:252
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: avcodec.h:1416
struct AVPacketList * last_in_packet_buffer
last packet in packet_buffer for this stream when muxing.
Definition: avformat.h:1040
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:240