FFmpeg
ffmpeg_demux.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <float.h>
20 #include <stdint.h>
21 
22 #include "ffmpeg.h"
23 #include "ffmpeg_sched.h"
24 #include "ffmpeg_utils.h"
25 
26 #include "libavutil/avassert.h"
27 #include "libavutil/avstring.h"
28 #include "libavutil/display.h"
29 #include "libavutil/error.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/opt.h"
32 #include "libavutil/parseutils.h"
33 #include "libavutil/pixdesc.h"
34 #include "libavutil/time.h"
35 #include "libavutil/timestamp.h"
36 
37 #include "libavcodec/bsf.h"
38 #include "libavcodec/packet.h"
39 
40 #include "libavformat/avformat.h"
41 
42 typedef struct DemuxStream {
44 
45  // name used for logging
46  char log_name[32];
47 
50 
51  double ts_scale;
52 
53  /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
55 #define DECODING_FOR_OST 1
56 #define DECODING_FOR_FILTER 2
57 
58  /* true if stream data should be discarded */
59  int discard;
60 
61  // scheduler returned EOF for this stream
62  int finished;
63 
67 
70  ///< dts of the first packet read for this stream (in AV_TIME_BASE units)
71  int64_t first_dts;
72 
73  /* predicted dts of the next packet read for this stream or (when there are
74  * several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
75  int64_t next_dts;
76  ///< dts of the last packet read for this stream (in AV_TIME_BASE units)
77  int64_t dts;
78 
80 
83  char dec_name[16];
84  // decoded media properties, as estimated by opening the decoder
86 
88 
89  /* number of packets successfully read for this stream */
90  uint64_t nb_packets;
91  // combined size of all the packets read
92  uint64_t data_size;
93 } DemuxStream;
94 
95 typedef struct Demuxer {
97 
98  // name used for logging
99  char log_name[32];
100 
102 
103  /**
104  * Extra timestamp offset added by discontinuity handling.
105  */
107  int64_t last_ts;
108 
109  int64_t recording_time;
111 
112  /* number of times input stream should be looped */
113  int loop;
115  /* duration of the looped segment of the input file */
117  /* pts with the smallest/largest values ever seen */
120 
121  /* number of streams that the user was warned of */
123 
124  float readrate;
126 
128 
130 
134 } Demuxer;
135 
136 typedef struct DemuxThreadContext {
137  // packet used for reading from the demuxer
139  // packet for reading from BSFs
142 
144 {
145  return (DemuxStream*)ist;
146 }
147 
149 {
150  return (Demuxer*)f;
151 }
152 
154 {
155  for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
156  DemuxStream *ds = ds_from_ist(ist);
157  if (ist->par->codec_type == type && ds->discard &&
158  ist->user_set_discard != AVDISCARD_ALL)
159  return ist;
160  }
161  return NULL;
162 }
163 
164 static void report_new_stream(Demuxer *d, const AVPacket *pkt)
165 {
166  const AVStream *st = d->f.ctx->streams[pkt->stream_index];
167 
168  if (pkt->stream_index < d->nb_streams_warn)
169  return;
171  "New %s stream with index %d at pos:%"PRId64" and DTS:%ss\n",
174  d->nb_streams_warn = pkt->stream_index + 1;
175 }
176 
177 static int seek_to_start(Demuxer *d, Timestamp end_pts)
178 {
179  InputFile *ifile = &d->f;
180  AVFormatContext *is = ifile->ctx;
181  int ret;
182 
183  ret = avformat_seek_file(is, -1, INT64_MIN, is->start_time, is->start_time, 0);
184  if (ret < 0)
185  return ret;
186 
187  if (end_pts.ts != AV_NOPTS_VALUE &&
188  (d->max_pts.ts == AV_NOPTS_VALUE ||
189  av_compare_ts(d->max_pts.ts, d->max_pts.tb, end_pts.ts, end_pts.tb) < 0))
190  d->max_pts = end_pts;
191 
192  if (d->max_pts.ts != AV_NOPTS_VALUE) {
193  int64_t min_pts = d->min_pts.ts == AV_NOPTS_VALUE ? 0 : d->min_pts.ts;
194  d->duration.ts = d->max_pts.ts - av_rescale_q(min_pts, d->min_pts.tb, d->max_pts.tb);
195  }
196  d->duration.tb = d->max_pts.tb;
197 
198  if (d->loop > 0)
199  d->loop--;
200 
201  return ret;
202 }
203 
205  AVPacket *pkt)
206 {
207  InputFile *ifile = &d->f;
208  DemuxStream *ds = ds_from_ist(ist);
209  const int fmt_is_discont = ifile->ctx->iformat->flags & AVFMT_TS_DISCONT;
210  int disable_discontinuity_correction = copy_ts;
211  int64_t pkt_dts = av_rescale_q_rnd(pkt->dts, pkt->time_base, AV_TIME_BASE_Q,
213 
214  if (copy_ts && ds->next_dts != AV_NOPTS_VALUE &&
215  fmt_is_discont && ist->st->pts_wrap_bits < 60) {
216  int64_t wrap_dts = av_rescale_q_rnd(pkt->dts + (1LL<<ist->st->pts_wrap_bits),
219  if (FFABS(wrap_dts - ds->next_dts) < FFABS(pkt_dts - ds->next_dts)/10)
220  disable_discontinuity_correction = 0;
221  }
222 
223  if (ds->next_dts != AV_NOPTS_VALUE && !disable_discontinuity_correction) {
224  int64_t delta = pkt_dts - ds->next_dts;
225  if (fmt_is_discont) {
226  if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE ||
227  pkt_dts + AV_TIME_BASE/10 < ds->dts) {
228  d->ts_offset_discont -= delta;
229  av_log(ist, AV_LOG_WARNING,
230  "timestamp discontinuity "
231  "(stream id=%d): %"PRId64", new offset= %"PRId64"\n",
232  ist->st->id, delta, d->ts_offset_discont);
234  if (pkt->pts != AV_NOPTS_VALUE)
236  }
237  } else {
238  if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) {
240  "DTS %"PRId64", next:%"PRId64" st:%d invalid dropping\n",
241  pkt->dts, ds->next_dts, pkt->stream_index);
243  }
244  if (pkt->pts != AV_NOPTS_VALUE){
245  int64_t pkt_pts = av_rescale_q(pkt->pts, pkt->time_base, AV_TIME_BASE_Q);
246  delta = pkt_pts - ds->next_dts;
247  if (FFABS(delta) > 1LL * dts_error_threshold * AV_TIME_BASE) {
249  "PTS %"PRId64", next:%"PRId64" invalid dropping st:%d\n",
250  pkt->pts, ds->next_dts, pkt->stream_index);
252  }
253  }
254  }
255  } else if (ds->next_dts == AV_NOPTS_VALUE && !copy_ts &&
256  fmt_is_discont && d->last_ts != AV_NOPTS_VALUE) {
257  int64_t delta = pkt_dts - d->last_ts;
258  if (FFABS(delta) > 1LL * dts_delta_threshold * AV_TIME_BASE) {
259  d->ts_offset_discont -= delta;
261  "Inter stream timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
262  delta, d->ts_offset_discont);
264  if (pkt->pts != AV_NOPTS_VALUE)
266  }
267  }
268 
269  d->last_ts = av_rescale_q(pkt->dts, pkt->time_base, AV_TIME_BASE_Q);
270 }
271 
273  AVPacket *pkt)
274 {
275  int64_t offset = av_rescale_q(d->ts_offset_discont, AV_TIME_BASE_Q,
276  pkt->time_base);
277 
278  // apply previously-detected timestamp-discontinuity offset
279  // (to all streams, not just audio/video)
280  if (pkt->dts != AV_NOPTS_VALUE)
281  pkt->dts += offset;
282  if (pkt->pts != AV_NOPTS_VALUE)
283  pkt->pts += offset;
284 
285  // detect timestamp discontinuities for audio/video
286  if ((ist->par->codec_type == AVMEDIA_TYPE_VIDEO ||
287  ist->par->codec_type == AVMEDIA_TYPE_AUDIO) &&
288  pkt->dts != AV_NOPTS_VALUE)
290 }
291 
293 {
294  InputStream *ist = &ds->ist;
295  const AVCodecParameters *par = ist->par;
296 
297  if (!ds->saw_first_ts) {
298  ds->first_dts =
299  ds->dts = ist->st->avg_frame_rate.num ? - ist->par->video_delay * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
300  if (pkt->pts != AV_NOPTS_VALUE) {
301  ds->first_dts =
303  }
304  ds->saw_first_ts = 1;
305  }
306 
307  if (ds->next_dts == AV_NOPTS_VALUE)
308  ds->next_dts = ds->dts;
309 
310  if (pkt->dts != AV_NOPTS_VALUE)
312 
313  ds->dts = ds->next_dts;
314  switch (par->codec_type) {
315  case AVMEDIA_TYPE_AUDIO:
316  av_assert1(pkt->duration >= 0);
317  if (par->sample_rate) {
318  ds->next_dts += ((int64_t)AV_TIME_BASE * par->frame_size) /
319  par->sample_rate;
320  } else {
322  }
323  break;
324  case AVMEDIA_TYPE_VIDEO:
325  if (ist->framerate.num) {
326  // TODO: Remove work-around for c99-to-c89 issue 7
327  AVRational time_base_q = AV_TIME_BASE_Q;
328  int64_t next_dts = av_rescale_q(ds->next_dts, time_base_q, av_inv_q(ist->framerate));
329  ds->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q);
330  } else if (pkt->duration) {
332  } else if (ist->par->framerate.num != 0) {
333  AVRational field_rate = av_mul_q(ist->par->framerate,
334  (AVRational){ 2, 1 });
335  int fields = 2;
336 
337  if (ds->codec_desc &&
339  av_stream_get_parser(ist->st))
341 
342  ds->next_dts += av_rescale_q(fields, av_inv_q(field_rate), AV_TIME_BASE_Q);
343  }
344  break;
345  }
346 
347  fd->dts_est = ds->dts;
348 
349  return 0;
350 }
351 
352 static int ts_fixup(Demuxer *d, AVPacket *pkt, FrameData *fd)
353 {
354  InputFile *ifile = &d->f;
355  InputStream *ist = ifile->streams[pkt->stream_index];
356  DemuxStream *ds = ds_from_ist(ist);
357  const int64_t start_time = ifile->start_time_effective;
358  int64_t duration;
359  int ret;
360 
361  pkt->time_base = ist->st->time_base;
362 
363 #define SHOW_TS_DEBUG(tag_) \
364  if (debug_ts) { \
365  av_log(ist, AV_LOG_INFO, "%s -> ist_index:%d:%d type:%s " \
366  "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s\n", \
367  tag_, ifile->index, pkt->stream_index, \
368  av_get_media_type_string(ist->st->codecpar->codec_type), \
369  av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &pkt->time_base), \
370  av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &pkt->time_base), \
371  av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &pkt->time_base)); \
372  }
373 
374  SHOW_TS_DEBUG("demuxer");
375 
377  ist->st->pts_wrap_bits < 64) {
378  int64_t stime, stime2;
379 
381  stime2= stime + (1ULL<<ist->st->pts_wrap_bits);
382  ds->wrap_correction_done = 1;
383 
384  if(stime2 > stime && pkt->dts != AV_NOPTS_VALUE && pkt->dts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
385  pkt->dts -= 1ULL<<ist->st->pts_wrap_bits;
386  ds->wrap_correction_done = 0;
387  }
388  if(stime2 > stime && pkt->pts != AV_NOPTS_VALUE && pkt->pts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
389  pkt->pts -= 1ULL<<ist->st->pts_wrap_bits;
390  ds->wrap_correction_done = 0;
391  }
392  }
393 
394  if (pkt->dts != AV_NOPTS_VALUE)
396  if (pkt->pts != AV_NOPTS_VALUE)
398 
399  if (pkt->pts != AV_NOPTS_VALUE)
400  pkt->pts *= ds->ts_scale;
401  if (pkt->dts != AV_NOPTS_VALUE)
402  pkt->dts *= ds->ts_scale;
403 
404  duration = av_rescale_q(d->duration.ts, d->duration.tb, pkt->time_base);
405  if (pkt->pts != AV_NOPTS_VALUE) {
406  // audio decoders take precedence for estimating total file duration
407  int64_t pkt_duration = d->have_audio_dec ? 0 : pkt->duration;
408 
409  pkt->pts += duration;
410 
411  // update max/min pts that will be used to compute total file duration
412  // when using -stream_loop
413  if (d->max_pts.ts == AV_NOPTS_VALUE ||
414  av_compare_ts(d->max_pts.ts, d->max_pts.tb,
415  pkt->pts + pkt_duration, pkt->time_base) < 0) {
416  d->max_pts = (Timestamp){ .ts = pkt->pts + pkt_duration,
417  .tb = pkt->time_base };
418  }
419  if (d->min_pts.ts == AV_NOPTS_VALUE ||
420  av_compare_ts(d->min_pts.ts, d->min_pts.tb,
421  pkt->pts, pkt->time_base) > 0) {
422  d->min_pts = (Timestamp){ .ts = pkt->pts,
423  .tb = pkt->time_base };
424  }
425  }
426 
427  if (pkt->dts != AV_NOPTS_VALUE)
428  pkt->dts += duration;
429 
430  SHOW_TS_DEBUG("demuxer+tsfixup");
431 
432  // detect and try to correct for timestamp discontinuities
434 
435  // update estimated/predicted dts
436  ret = ist_dts_update(ds, pkt, fd);
437  if (ret < 0)
438  return ret;
439 
440  return 0;
441 }
442 
443 static int input_packet_process(Demuxer *d, AVPacket *pkt, unsigned *send_flags)
444 {
445  InputFile *f = &d->f;
446  InputStream *ist = f->streams[pkt->stream_index];
447  DemuxStream *ds = ds_from_ist(ist);
448  FrameData *fd;
449  int ret = 0;
450 
451  fd = packet_data(pkt);
452  if (!fd)
453  return AVERROR(ENOMEM);
454 
455  ret = ts_fixup(d, pkt, fd);
456  if (ret < 0)
457  return ret;
458 
459  if (d->recording_time != INT64_MAX) {
460  int64_t start_time = 0;
461  if (copy_ts) {
462  start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0;
463  start_time += start_at_zero ? 0 : f->start_time_effective;
464  }
465  if (ds->dts >= d->recording_time + start_time)
466  *send_flags |= DEMUX_SEND_STREAMCOPY_EOF;
467  }
468 
469  ds->data_size += pkt->size;
470  ds->nb_packets++;
471 
473 
474  if (debug_ts) {
475  av_log(NULL, AV_LOG_INFO, "demuxer+ffmpeg -> ist_index:%d:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s off:%s off_time:%s\n",
476  f->index, pkt->stream_index,
481  av_ts2str(f->ts_offset), av_ts2timestr(f->ts_offset, &AV_TIME_BASE_Q));
482  }
483 
484  return 0;
485 }
486 
487 static void readrate_sleep(Demuxer *d)
488 {
489  InputFile *f = &d->f;
490  int64_t file_start = copy_ts * (
491  (f->start_time_effective != AV_NOPTS_VALUE ? f->start_time_effective * !start_at_zero : 0) +
492  (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0)
493  );
494  int64_t burst_until = AV_TIME_BASE * d->readrate_initial_burst;
495  for (int i = 0; i < f->nb_streams; i++) {
496  InputStream *ist = f->streams[i];
497  DemuxStream *ds = ds_from_ist(ist);
498  int64_t stream_ts_offset, pts, now;
499  stream_ts_offset = FFMAX(ds->first_dts != AV_NOPTS_VALUE ? ds->first_dts : 0, file_start);
500  pts = av_rescale(ds->dts, 1000000, AV_TIME_BASE);
501  now = (av_gettime_relative() - d->wallclock_start) * d->readrate + stream_ts_offset;
502  if (pts - burst_until > now)
503  av_usleep(pts - burst_until - now);
504  }
505 }
506 
507 static int do_send(Demuxer *d, DemuxStream *ds, AVPacket *pkt, unsigned flags,
508  const char *pkt_desc)
509 {
510  int ret;
511 
513 
514  ret = sch_demux_send(d->sch, d->f.index, pkt, flags);
515  if (ret == AVERROR_EOF) {
517 
518  av_log(ds, AV_LOG_VERBOSE, "All consumers of this stream are done\n");
519  ds->finished = 1;
520 
521  if (++d->nb_streams_finished == d->nb_streams_used) {
522  av_log(d, AV_LOG_VERBOSE, "All consumers are done\n");
523  return AVERROR_EOF;
524  }
525  } else if (ret < 0) {
526  if (ret != AVERROR_EXIT)
528  "Unable to send %s packet to consumers: %s\n",
529  pkt_desc, av_err2str(ret));
530  return ret;
531  }
532 
533  return 0;
534 }
535 
537  AVPacket *pkt, unsigned flags)
538 {
539  InputFile *f = &d->f;
540  int ret;
541 
542  // pkt can be NULL only when flushing BSFs
543  av_assert0(ds->bsf || pkt);
544 
545  // send heartbeat for sub2video streams
546  if (d->pkt_heartbeat && pkt && pkt->pts != AV_NOPTS_VALUE) {
547  for (int i = 0; i < f->nb_streams; i++) {
548  DemuxStream *ds1 = ds_from_ist(f->streams[i]);
549 
550  if (ds1->finished || !ds1->have_sub2video)
551  continue;
552 
553  d->pkt_heartbeat->pts = pkt->pts;
554  d->pkt_heartbeat->time_base = pkt->time_base;
555  d->pkt_heartbeat->opaque = (void*)(intptr_t)PKT_OPAQUE_SUB_HEARTBEAT;
556 
557  ret = do_send(d, ds1, d->pkt_heartbeat, 0, "heartbeat");
558  if (ret < 0)
559  return ret;
560  }
561  }
562 
563  if (ds->bsf) {
564  if (pkt)
566 
567  ret = av_bsf_send_packet(ds->bsf, pkt);
568  if (ret < 0) {
569  if (pkt)
571  av_log(ds, AV_LOG_ERROR, "Error submitting a packet for filtering: %s\n",
572  av_err2str(ret));
573  return ret;
574  }
575 
576  while (1) {
577  ret = av_bsf_receive_packet(ds->bsf, dt->pkt_bsf);
578  if (ret == AVERROR(EAGAIN))
579  return 0;
580  else if (ret < 0) {
581  if (ret != AVERROR_EOF)
582  av_log(ds, AV_LOG_ERROR,
583  "Error applying bitstream filters to a packet: %s\n",
584  av_err2str(ret));
585  return ret;
586  }
587 
588  dt->pkt_bsf->time_base = ds->bsf->time_base_out;
589 
590  ret = do_send(d, ds, dt->pkt_bsf, 0, "filtered");
591  if (ret < 0) {
593  return ret;
594  }
595  }
596  } else {
597  ret = do_send(d, ds, pkt, flags, "demuxed");
598  if (ret < 0)
599  return ret;
600  }
601 
602  return 0;
603 }
604 
606 {
607  InputFile *f = &d->f;
608  int ret;
609 
610  for (unsigned i = 0; i < f->nb_streams; i++) {
611  DemuxStream *ds = ds_from_ist(f->streams[i]);
612 
613  if (!ds->bsf)
614  continue;
615 
616  ret = demux_send(d, dt, ds, NULL, 0);
617  ret = (ret == AVERROR_EOF) ? 0 : (ret < 0) ? ret : AVERROR_BUG;
618  if (ret < 0) {
619  av_log(ds, AV_LOG_ERROR, "Error flushing BSFs: %s\n",
620  av_err2str(ret));
621  return ret;
622  }
623 
624  av_bsf_flush(ds->bsf);
625  }
626 
627  return 0;
628 }
629 
631 {
632  for (int j = 0; j < ifile->ctx->nb_programs; j++) {
633  AVProgram *p = ifile->ctx->programs[j];
634  int discard = AVDISCARD_ALL;
635 
636  for (int k = 0; k < p->nb_stream_indexes; k++) {
637  DemuxStream *ds = ds_from_ist(ifile->streams[p->stream_index[k]]);
638 
639  if (!ds->discard) {
640  discard = AVDISCARD_DEFAULT;
641  break;
642  }
643  }
644  p->discard = discard;
645  }
646 }
647 
649 {
650  char name[16];
651  snprintf(name, sizeof(name), "dmx%d:%s", f->index, f->ctx->iformat->name);
653 }
654 
656 {
658  av_packet_free(&dt->pkt_bsf);
659 
660  memset(dt, 0, sizeof(*dt));
661 }
662 
664 {
665  memset(dt, 0, sizeof(*dt));
666 
667  dt->pkt_demux = av_packet_alloc();
668  if (!dt->pkt_demux)
669  return AVERROR(ENOMEM);
670 
671  dt->pkt_bsf = av_packet_alloc();
672  if (!dt->pkt_bsf)
673  return AVERROR(ENOMEM);
674 
675  return 0;
676 }
677 
678 static int input_thread(void *arg)
679 {
680  Demuxer *d = arg;
681  InputFile *f = &d->f;
682 
684 
685  int ret = 0;
686 
687  ret = demux_thread_init(&dt);
688  if (ret < 0)
689  goto finish;
690 
692 
694 
695  d->read_started = 1;
696  d->wallclock_start = av_gettime_relative();
697 
698  while (1) {
699  DemuxStream *ds;
700  unsigned send_flags = 0;
701 
702  ret = av_read_frame(f->ctx, dt.pkt_demux);
703 
704  if (ret == AVERROR(EAGAIN)) {
705  av_usleep(10000);
706  continue;
707  }
708  if (ret < 0) {
709  int ret_bsf;
710 
711  if (ret == AVERROR_EOF)
712  av_log(d, AV_LOG_VERBOSE, "EOF while reading input\n");
713  else {
714  av_log(d, AV_LOG_ERROR, "Error during demuxing: %s\n",
715  av_err2str(ret));
716  ret = exit_on_error ? ret : 0;
717  }
718 
719  ret_bsf = demux_bsf_flush(d, &dt);
720  ret = err_merge(ret == AVERROR_EOF ? 0 : ret, ret_bsf);
721 
722  if (d->loop) {
723  /* signal looping to our consumers */
724  dt.pkt_demux->stream_index = -1;
725  ret = sch_demux_send(d->sch, f->index, dt.pkt_demux, 0);
726  if (ret >= 0)
727  ret = seek_to_start(d, (Timestamp){ .ts = dt.pkt_demux->pts,
728  .tb = dt.pkt_demux->time_base });
729  if (ret >= 0)
730  continue;
731 
732  /* fallthrough to the error path */
733  }
734 
735  break;
736  }
737 
738  if (do_pkt_dump) {
740  f->ctx->streams[dt.pkt_demux->stream_index]);
741  }
742 
743  /* the following test is needed in case new streams appear
744  dynamically in stream : we ignore them */
745  ds = dt.pkt_demux->stream_index < f->nb_streams ?
746  ds_from_ist(f->streams[dt.pkt_demux->stream_index]) : NULL;
747  if (!ds || ds->discard || ds->finished) {
750  continue;
751  }
752 
753  if (dt.pkt_demux->flags & AV_PKT_FLAG_CORRUPT) {
755  "corrupt input packet in stream %d\n",
756  dt.pkt_demux->stream_index);
757  if (exit_on_error) {
760  break;
761  }
762  }
763 
764  ret = input_packet_process(d, dt.pkt_demux, &send_flags);
765  if (ret < 0)
766  break;
767 
768  if (d->readrate)
769  readrate_sleep(d);
770 
771  ret = demux_send(d, &dt, ds, dt.pkt_demux, send_flags);
772  if (ret < 0)
773  break;
774  }
775 
776  // EOF/EXIT is normal termination
777  if (ret == AVERROR_EOF || ret == AVERROR_EXIT)
778  ret = 0;
779 
780 finish:
781  demux_thread_uninit(&dt);
782 
783  return ret;
784 }
785 
787 {
788  InputFile *f = &d->f;
789  uint64_t total_packets = 0, total_size = 0;
790 
791  av_log(f, AV_LOG_VERBOSE, "Input file #%d (%s):\n",
792  f->index, f->ctx->url);
793 
794  for (int j = 0; j < f->nb_streams; j++) {
795  InputStream *ist = f->streams[j];
796  DemuxStream *ds = ds_from_ist(ist);
797  enum AVMediaType type = ist->par->codec_type;
798 
799  if (ds->discard || type == AVMEDIA_TYPE_ATTACHMENT)
800  continue;
801 
802  total_size += ds->data_size;
803  total_packets += ds->nb_packets;
804 
805  av_log(f, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ",
806  f->index, j, av_get_media_type_string(type));
807  av_log(f, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ",
808  ds->nb_packets, ds->data_size);
809 
810  if (ds->decoding_needed) {
812  "%"PRIu64" frames decoded; %"PRIu64" decode errors",
814  if (type == AVMEDIA_TYPE_AUDIO)
815  av_log(f, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->decoder->samples_decoded);
816  av_log(f, AV_LOG_VERBOSE, "; ");
817  }
818 
819  av_log(f, AV_LOG_VERBOSE, "\n");
820  }
821 
822  av_log(f, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n",
823  total_packets, total_size);
824 }
825 
826 static void ist_free(InputStream **pist)
827 {
828  InputStream *ist = *pist;
829  DemuxStream *ds;
830 
831  if (!ist)
832  return;
833  ds = ds_from_ist(ist);
834 
835  dec_free(&ist->decoder);
836 
838  av_freep(&ist->filters);
839  av_freep(&ist->outputs);
841 
843 
845 
846  av_bsf_free(&ds->bsf);
847 
848  av_freep(pist);
849 }
850 
852 {
853  InputFile *f = *pf;
855 
856  if (!f)
857  return;
858 
859  if (d->read_started)
861 
862  for (int i = 0; i < f->nb_streams; i++)
863  ist_free(&f->streams[i]);
864  av_freep(&f->streams);
865 
866  avformat_close_input(&f->ctx);
867 
868  av_packet_free(&d->pkt_heartbeat);
869 
870  av_freep(pf);
871 }
872 
873 static int ist_use(InputStream *ist, int decoding_needed)
874 {
875  Demuxer *d = demuxer_from_ifile(ist->file);
876  DemuxStream *ds = ds_from_ist(ist);
877  int ret;
878 
879  if (ist->user_set_discard == AVDISCARD_ALL) {
880  av_log(ist, AV_LOG_ERROR, "Cannot %s a disabled input stream\n",
881  decoding_needed ? "decode" : "streamcopy");
882  return AVERROR(EINVAL);
883  }
884 
885  if (decoding_needed && !ist->dec) {
886  av_log(ist, AV_LOG_ERROR,
887  "Decoding requested, but no decoder found for: %s\n",
888  avcodec_get_name(ist->par->codec_id));
889  return AVERROR(EINVAL);
890  }
891 
892  if (ds->sch_idx_stream < 0) {
893  ret = sch_add_demux_stream(d->sch, d->f.index);
894  if (ret < 0)
895  return ret;
896  ds->sch_idx_stream = ret;
897  }
898 
899  if (ds->discard) {
900  ds->discard = 0;
901  d->nb_streams_used++;
902  }
903 
904  ist->st->discard = ist->user_set_discard;
905  ds->decoding_needed |= decoding_needed;
906  ds->streamcopy_needed |= !decoding_needed;
907 
908  if (decoding_needed && ds->sch_idx_dec < 0) {
909  int is_audio = ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO;
910 
912  (!!(d->f.ctx->iformat->flags & AVFMT_NOTIMESTAMPS) * DECODER_FLAG_TS_UNRELIABLE) |
913  (!!(d->loop && is_audio) * DECODER_FLAG_SEND_END_TS)
914 #if FFMPEG_OPT_TOP
916 #endif
917  ;
918 
919  if (ist->framerate.num) {
921  ds->dec_opts.framerate = ist->framerate;
922  } else
923  ds->dec_opts.framerate = ist->st->avg_frame_rate;
924 
925  if (ist->dec->id == AV_CODEC_ID_DVB_SUBTITLE &&
927  av_dict_set(&ds->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE);
929  av_log(ist, AV_LOG_WARNING,
930  "Warning using DVB subtitles for filtering and output at the "
931  "same time is not fully supported, also see -compute_edt [0|1]\n");
932  }
933 
934  snprintf(ds->dec_name, sizeof(ds->dec_name), "%d:%d", ist->file->index, ist->index);
935  ds->dec_opts.name = ds->dec_name;
936 
937  ds->dec_opts.codec = ist->dec;
938  ds->dec_opts.par = ist->par;
939 
940  ds->dec_opts.log_parent = ist;
941 
943  if (!ds->decoded_params)
944  return AVERROR(ENOMEM);
945 
946  ret = dec_init(&ist->decoder, d->sch,
947  &ds->decoder_opts, &ds->dec_opts, ds->decoded_params);
948  if (ret < 0)
949  return ret;
950  ds->sch_idx_dec = ret;
951 
952  ret = sch_connect(d->sch, SCH_DSTREAM(d->f.index, ds->sch_idx_stream),
953  SCH_DEC(ds->sch_idx_dec));
954  if (ret < 0)
955  return ret;
956 
957  d->have_audio_dec |= is_audio;
958  }
959 
960  return 0;
961 }
962 
964 {
965  DemuxStream *ds = ds_from_ist(ist);
966  int ret;
967 
968  ret = ist_use(ist, ost->enc ? DECODING_FOR_OST : 0);
969  if (ret < 0)
970  return ret;
971 
972  ret = GROW_ARRAY(ist->outputs, ist->nb_outputs);
973  if (ret < 0)
974  return ret;
975 
976  ist->outputs[ist->nb_outputs - 1] = ost;
977 
978  return ost->enc ? ds->sch_idx_dec : ds->sch_idx_stream;
979 }
980 
981 int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple,
983 {
984  Demuxer *d = demuxer_from_ifile(ist->file);
985  DemuxStream *ds = ds_from_ist(ist);
986  int64_t tsoffset = 0;
987  int ret;
988 
989  ret = ist_use(ist, is_simple ? DECODING_FOR_OST : DECODING_FOR_FILTER);
990  if (ret < 0)
991  return ret;
992 
993  ret = GROW_ARRAY(ist->filters, ist->nb_filters);
994  if (ret < 0)
995  return ret;
996 
997  ist->filters[ist->nb_filters - 1] = ifilter;
998 
999  if (ist->par->codec_type == AVMEDIA_TYPE_VIDEO) {
1000  if (ist->framerate.num > 0 && ist->framerate.den > 0) {
1001  opts->framerate = ist->framerate;
1002  opts->flags |= IFILTER_FLAG_CFR;
1003  } else
1004  opts->framerate = av_guess_frame_rate(d->f.ctx, ist->st, NULL);
1005  } else if (ist->par->codec_type == AVMEDIA_TYPE_SUBTITLE) {
1006  /* Compute the size of the canvas for the subtitles stream.
1007  If the subtitles codecpar has set a size, use it. Otherwise use the
1008  maximum dimensions of the video streams in the same file. */
1009  opts->sub2video_width = ist->par->width;
1010  opts->sub2video_height = ist->par->height;
1011  if (!(opts->sub2video_width && opts->sub2video_height)) {
1012  for (int j = 0; j < d->f.nb_streams; j++) {
1013  AVCodecParameters *par1 = d->f.streams[j]->par;
1014  if (par1->codec_type == AVMEDIA_TYPE_VIDEO) {
1015  opts->sub2video_width = FFMAX(opts->sub2video_width, par1->width);
1016  opts->sub2video_height = FFMAX(opts->sub2video_height, par1->height);
1017  }
1018  }
1019  }
1020 
1021  if (!(opts->sub2video_width && opts->sub2video_height)) {
1022  opts->sub2video_width = FFMAX(opts->sub2video_width, 720);
1023  opts->sub2video_height = FFMAX(opts->sub2video_height, 576);
1024  }
1025 
1026  if (!d->pkt_heartbeat) {
1027  d->pkt_heartbeat = av_packet_alloc();
1028  if (!d->pkt_heartbeat)
1029  return AVERROR(ENOMEM);
1030  }
1031  ds->have_sub2video = 1;
1032  }
1033 
1034  ret = av_frame_copy_props(opts->fallback, ds->decoded_params);
1035  if (ret < 0)
1036  return ret;
1037  opts->fallback->format = ds->decoded_params->format;
1038  opts->fallback->width = ds->decoded_params->width;
1039  opts->fallback->height = ds->decoded_params->height;
1040 
1041  ret = av_channel_layout_copy(&opts->fallback->ch_layout, &ds->decoded_params->ch_layout);
1042  if (ret < 0)
1043  return ret;
1044 
1045  if (copy_ts) {
1046  tsoffset = d->f.start_time == AV_NOPTS_VALUE ? 0 : d->f.start_time;
1047  if (!start_at_zero && d->f.ctx->start_time != AV_NOPTS_VALUE)
1048  tsoffset += d->f.ctx->start_time;
1049  }
1050  opts->trim_start_us = ((d->f.start_time == AV_NOPTS_VALUE) || !d->accurate_seek) ?
1051  AV_NOPTS_VALUE : tsoffset;
1052  opts->trim_end_us = d->recording_time;
1053 
1054  opts->name = av_strdup(ds->dec_name);
1055  if (!opts->name)
1056  return AVERROR(ENOMEM);
1057 
1058  opts->flags |= IFILTER_FLAG_AUTOROTATE * !!(ist->autorotate) |
1060 
1061  return ds->sch_idx_dec;
1062 }
1063 
1065  enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type,
1066  const AVCodec **pcodec)
1067 
1068 {
1069  char *codec_name = NULL;
1070 
1071  MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
1072  if (codec_name) {
1073  int ret = find_codec(NULL, codec_name, st->codecpar->codec_type, 0, pcodec);
1074  if (ret < 0)
1075  return ret;
1076  st->codecpar->codec_id = (*pcodec)->id;
1077  if (recast_media && st->codecpar->codec_type != (*pcodec)->type)
1078  st->codecpar->codec_type = (*pcodec)->type;
1079  return 0;
1080  } else {
1081  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
1082  hwaccel_id == HWACCEL_GENERIC &&
1083  hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
1084  const AVCodec *c;
1085  void *i = NULL;
1086 
1087  while ((c = av_codec_iterate(&i))) {
1088  const AVCodecHWConfig *config;
1089 
1090  if (c->id != st->codecpar->codec_id ||
1092  continue;
1093 
1094  for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
1095  if (config->device_type == hwaccel_device_type) {
1096  av_log(NULL, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n",
1097  c->name, av_hwdevice_get_type_name(hwaccel_device_type));
1098  *pcodec = c;
1099  return 0;
1100  }
1101  }
1102  }
1103  }
1104 
1105  *pcodec = avcodec_find_decoder(st->codecpar->codec_id);
1106  return 0;
1107  }
1108 }
1109 
1111  int guess_layout_max)
1112 {
1113  if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) {
1114  char layout_name[256];
1115 
1116  if (par->ch_layout.nb_channels > guess_layout_max)
1117  return 0;
1120  return 0;
1121  av_channel_layout_describe(&par->ch_layout, layout_name, sizeof(layout_name));
1122  av_log(ist, AV_LOG_WARNING, "Guessed Channel Layout: %s\n", layout_name);
1123  }
1124  return 1;
1125 }
1126 
1129 {
1130  AVStream *st = ist->st;
1131  AVPacketSideData *sd;
1132  double rotation = DBL_MAX;
1133  int hflip = -1, vflip = -1;
1134  int hflip_set = 0, vflip_set = 0, rotation_set = 0;
1135  int32_t *buf;
1136 
1137  MATCH_PER_STREAM_OPT(display_rotations, dbl, rotation, ctx, st);
1138  MATCH_PER_STREAM_OPT(display_hflips, i, hflip, ctx, st);
1139  MATCH_PER_STREAM_OPT(display_vflips, i, vflip, ctx, st);
1140 
1141  rotation_set = rotation != DBL_MAX;
1142  hflip_set = hflip != -1;
1143  vflip_set = vflip != -1;
1144 
1145  if (!rotation_set && !hflip_set && !vflip_set)
1146  return 0;
1147 
1151  sizeof(int32_t) * 9, 0);
1152  if (!sd) {
1153  av_log(ist, AV_LOG_FATAL, "Failed to generate a display matrix!\n");
1154  return AVERROR(ENOMEM);
1155  }
1156 
1157  buf = (int32_t *)sd->data;
1159  rotation_set ? -(rotation) : -0.0f);
1160 
1162  hflip_set ? hflip : 0,
1163  vflip_set ? vflip : 0);
1164 
1165  return 0;
1166 }
1167 
1168 static const char *input_stream_item_name(void *obj)
1169 {
1170  const DemuxStream *ds = obj;
1171 
1172  return ds->log_name;
1173 }
1174 
1175 static const AVClass input_stream_class = {
1176  .class_name = "InputStream",
1177  .version = LIBAVUTIL_VERSION_INT,
1178  .item_name = input_stream_item_name,
1179  .category = AV_CLASS_CATEGORY_DEMUXER,
1180 };
1181 
1183 {
1184  const char *type_str = av_get_media_type_string(st->codecpar->codec_type);
1185  InputFile *f = &d->f;
1186  DemuxStream *ds;
1187 
1188  ds = allocate_array_elem(&f->streams, sizeof(*ds), &f->nb_streams);
1189  if (!ds)
1190  return NULL;
1191 
1192  ds->sch_idx_stream = -1;
1193  ds->sch_idx_dec = -1;
1194 
1195  ds->ist.st = st;
1196  ds->ist.file = f;
1197  ds->ist.index = st->index;
1198  ds->ist.class = &input_stream_class;
1199 
1200  snprintf(ds->log_name, sizeof(ds->log_name), "%cist#%d:%d/%s",
1201  type_str ? *type_str : '?', d->f.index, st->index,
1203 
1204  return ds;
1205 }
1206 
1207 static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
1208 {
1209  AVFormatContext *ic = d->f.ctx;
1210  AVCodecParameters *par = st->codecpar;
1211  DemuxStream *ds;
1212  InputStream *ist;
1213  char *framerate = NULL, *hwaccel_device = NULL;
1214  const char *hwaccel = NULL;
1215  char *hwaccel_output_format = NULL;
1216  char *codec_tag = NULL;
1217  char *bsfs = NULL;
1218  char *next;
1219  char *discard_str = NULL;
1220  int ret;
1221 
1222  ds = demux_stream_alloc(d, st);
1223  if (!ds)
1224  return AVERROR(ENOMEM);
1225 
1226  ist = &ds->ist;
1227 
1228  ds->discard = 1;
1229  st->discard = AVDISCARD_ALL;
1230  ds->first_dts = AV_NOPTS_VALUE;
1231  ds->next_dts = AV_NOPTS_VALUE;
1232 
1233  ds->dec_opts.time_base = st->time_base;
1234 
1235  ds->ts_scale = 1.0;
1236  MATCH_PER_STREAM_OPT(ts_scale, dbl, ds->ts_scale, ic, st);
1237 
1238  ist->autorotate = 1;
1239  MATCH_PER_STREAM_OPT(autorotate, i, ist->autorotate, ic, st);
1240 
1241  MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
1242  if (codec_tag) {
1243  uint32_t tag = strtol(codec_tag, &next, 0);
1244  if (*next) {
1245  uint8_t buf[4] = { 0 };
1246  memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
1247  tag = AV_RL32(buf);
1248  }
1249 
1250  st->codecpar->codec_tag = tag;
1251  }
1252 
1253  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
1254  ret = add_display_matrix_to_stream(o, ic, ist);
1255  if (ret < 0)
1256  return ret;
1257 
1258  MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
1259  MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
1260  hwaccel_output_format, ic, st);
1261 
1262  if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
1263  av_log(ist, AV_LOG_WARNING,
1264  "WARNING: defaulting hwaccel_output_format to cuda for compatibility "
1265  "with old commandlines. This behaviour is DEPRECATED and will be removed "
1266  "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n");
1268  } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "qsv")) {
1269  av_log(ist, AV_LOG_WARNING,
1270  "WARNING: defaulting hwaccel_output_format to qsv for compatibility "
1271  "with old commandlines. This behaviour is DEPRECATED and will be removed "
1272  "in the future. Please explicitly set \"-hwaccel_output_format qsv\".\n");
1274  } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "mediacodec")) {
1275  // There is no real AVHWFrameContext implementation. Set
1276  // hwaccel_output_format to avoid av_hwframe_transfer_data error.
1278  } else if (hwaccel_output_format) {
1279  ds->dec_opts.hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
1281  av_log(ist, AV_LOG_FATAL, "Unrecognised hwaccel output "
1282  "format: %s", hwaccel_output_format);
1283  }
1284  } else {
1286  }
1287 
1288  if (hwaccel) {
1289  // The NVDEC hwaccels use a CUDA device, so remap the name here.
1290  if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid"))
1291  hwaccel = "cuda";
1292 
1293  if (!strcmp(hwaccel, "none"))
1295  else if (!strcmp(hwaccel, "auto"))
1297  else {
1299  if (type != AV_HWDEVICE_TYPE_NONE) {
1302  }
1303 
1304  if (!ds->dec_opts.hwaccel_id) {
1305  av_log(ist, AV_LOG_FATAL, "Unrecognized hwaccel: %s.\n",
1306  hwaccel);
1307  av_log(ist, AV_LOG_FATAL, "Supported hwaccels: ");
1309  while ((type = av_hwdevice_iterate_types(type)) !=
1311  av_log(ist, AV_LOG_FATAL, "%s ",
1313  av_log(ist, AV_LOG_FATAL, "\n");
1314  return AVERROR(EINVAL);
1315  }
1316  }
1317  }
1318 
1319  MATCH_PER_STREAM_OPT(hwaccel_devices, str, hwaccel_device, ic, st);
1320  if (hwaccel_device) {
1321  ds->dec_opts.hwaccel_device = av_strdup(hwaccel_device);
1322  if (!ds->dec_opts.hwaccel_device)
1323  return AVERROR(ENOMEM);
1324  }
1325  }
1326 
1327  ret = choose_decoder(o, ic, st, ds->dec_opts.hwaccel_id,
1328  ds->dec_opts.hwaccel_device_type, &ist->dec);
1329  if (ret < 0)
1330  return ret;
1331 
1333  ic, st, ist->dec, &ds->decoder_opts);
1334  if (ret < 0)
1335  return ret;
1336 
1337  ds->reinit_filters = -1;
1338  MATCH_PER_STREAM_OPT(reinit_filters, i, ds->reinit_filters, ic, st);
1339 
1341 
1342  if ((o->video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ||
1347 
1348  MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
1349  if (discard_str) {
1350  ret = av_opt_set(ist->st, "discard", discard_str, 0);
1351  if (ret < 0) {
1352  av_log(ist, AV_LOG_ERROR, "Error parsing discard %s.\n", discard_str);
1353  return ret;
1354  }
1355  ist->user_set_discard = ist->st->discard;
1356  }
1357 
1358  if (o->bitexact)
1359  av_dict_set(&ds->decoder_opts, "flags", "+bitexact", AV_DICT_MULTIKEY);
1360 
1361  /* Attached pics are sparse, therefore we would not want to delay their decoding
1362  * till EOF. */
1364  av_dict_set(&ds->decoder_opts, "thread_type", "-frame", 0);
1365 
1366  switch (par->codec_type) {
1367  case AVMEDIA_TYPE_VIDEO:
1368  MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
1369  if (framerate) {
1371  if (ret < 0) {
1372  av_log(ist, AV_LOG_ERROR, "Error parsing framerate %s.\n",
1373  framerate);
1374  return ret;
1375  }
1376  }
1377 
1378 #if FFMPEG_OPT_TOP
1379  ist->top_field_first = -1;
1380  MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
1381 #endif
1382 
1383  break;
1384  case AVMEDIA_TYPE_AUDIO: {
1385  int guess_layout_max = INT_MAX;
1386  MATCH_PER_STREAM_OPT(guess_layout_max, i, guess_layout_max, ic, st);
1387  guess_input_channel_layout(ist, par, guess_layout_max);
1388  break;
1389  }
1390  case AVMEDIA_TYPE_DATA:
1391  case AVMEDIA_TYPE_SUBTITLE: {
1392  char *canvas_size = NULL;
1393  MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st);
1394  MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st);
1395  if (canvas_size) {
1396  ret = av_parse_video_size(&par->width, &par->height,
1397  canvas_size);
1398  if (ret < 0) {
1399  av_log(ist, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size);
1400  return ret;
1401  }
1402  }
1403  break;
1404  }
1406  case AVMEDIA_TYPE_UNKNOWN:
1407  break;
1408  default: av_assert0(0);
1409  }
1410 
1411  ist->par = avcodec_parameters_alloc();
1412  if (!ist->par)
1413  return AVERROR(ENOMEM);
1414 
1415  ret = avcodec_parameters_copy(ist->par, par);
1416  if (ret < 0) {
1417  av_log(ist, AV_LOG_ERROR, "Error exporting stream parameters.\n");
1418  return ret;
1419  }
1420 
1421  if (ist->st->sample_aspect_ratio.num)
1423 
1424  MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, ic, st);
1425  if (bsfs) {
1426  ret = av_bsf_list_parse_str(bsfs, &ds->bsf);
1427  if (ret < 0) {
1428  av_log(ist, AV_LOG_ERROR,
1429  "Error parsing bitstream filter sequence '%s': %s\n",
1430  bsfs, av_err2str(ret));
1431  return ret;
1432  }
1433 
1434  ret = avcodec_parameters_copy(ds->bsf->par_in, ist->par);
1435  if (ret < 0)
1436  return ret;
1437  ds->bsf->time_base_in = ist->st->time_base;
1438 
1439  ret = av_bsf_init(ds->bsf);
1440  if (ret < 0) {
1441  av_log(ist, AV_LOG_ERROR, "Error initializing bitstream filters: %s\n",
1442  av_err2str(ret));
1443  return ret;
1444  }
1445 
1446  ret = avcodec_parameters_copy(ist->par, ds->bsf->par_out);
1447  if (ret < 0)
1448  return ret;
1449  }
1450 
1452 
1453  return 0;
1454 }
1455 
1456 static int dump_attachment(InputStream *ist, const char *filename)
1457 {
1458  AVStream *st = ist->st;
1459  int ret;
1460  AVIOContext *out = NULL;
1461  const AVDictionaryEntry *e;
1462 
1463  if (!st->codecpar->extradata_size) {
1464  av_log(ist, AV_LOG_WARNING, "No extradata to dump.\n");
1465  return 0;
1466  }
1467  if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0)))
1468  filename = e->value;
1469  if (!*filename) {
1470  av_log(ist, AV_LOG_FATAL, "No filename specified and no 'filename' tag");
1471  return AVERROR(EINVAL);
1472  }
1473 
1474  ret = assert_file_overwrite(filename);
1475  if (ret < 0)
1476  return ret;
1477 
1478  if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) {
1479  av_log(ist, AV_LOG_FATAL, "Could not open file %s for writing.\n",
1480  filename);
1481  return ret;
1482  }
1483 
1485  ret = avio_close(out);
1486 
1487  if (ret >= 0)
1488  av_log(ist, AV_LOG_INFO, "Wrote attachment (%d bytes) to '%s'\n",
1489  st->codecpar->extradata_size, filename);
1490 
1491  return ret;
1492 }
1493 
1494 static const char *input_file_item_name(void *obj)
1495 {
1496  const Demuxer *d = obj;
1497 
1498  return d->log_name;
1499 }
1500 
1501 static const AVClass input_file_class = {
1502  .class_name = "InputFile",
1503  .version = LIBAVUTIL_VERSION_INT,
1504  .item_name = input_file_item_name,
1505  .category = AV_CLASS_CATEGORY_DEMUXER,
1506 };
1507 
1508 static Demuxer *demux_alloc(void)
1509 {
1511 
1512  if (!d)
1513  return NULL;
1514 
1515  d->f.class = &input_file_class;
1516  d->f.index = nb_input_files - 1;
1517 
1518  snprintf(d->log_name, sizeof(d->log_name), "in#%d", d->f.index);
1519 
1520  return d;
1521 }
1522 
1523 int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
1524 {
1525  Demuxer *d;
1526  InputFile *f;
1527  AVFormatContext *ic;
1528  const AVInputFormat *file_iformat = NULL;
1529  int err, i, ret = 0;
1530  int64_t timestamp;
1531  AVDictionary *unused_opts = NULL;
1532  const AVDictionaryEntry *e = NULL;
1533  const char* video_codec_name = NULL;
1534  const char* audio_codec_name = NULL;
1535  const char* subtitle_codec_name = NULL;
1536  const char* data_codec_name = NULL;
1537  int scan_all_pmts_set = 0;
1538 
1539  int64_t start_time = o->start_time;
1540  int64_t start_time_eof = o->start_time_eof;
1541  int64_t stop_time = o->stop_time;
1542  int64_t recording_time = o->recording_time;
1543 
1544  d = demux_alloc();
1545  if (!d)
1546  return AVERROR(ENOMEM);
1547 
1548  f = &d->f;
1549 
1550  ret = sch_add_demux(sch, input_thread, d);
1551  if (ret < 0)
1552  return ret;
1553  d->sch = sch;
1554 
1555  if (stop_time != INT64_MAX && recording_time != INT64_MAX) {
1556  stop_time = INT64_MAX;
1557  av_log(d, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n");
1558  }
1559 
1560  if (stop_time != INT64_MAX && recording_time == INT64_MAX) {
1561  int64_t start = start_time == AV_NOPTS_VALUE ? 0 : start_time;
1562  if (stop_time <= start) {
1563  av_log(d, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");
1564  return AVERROR(EINVAL);
1565  } else {
1566  recording_time = stop_time - start;
1567  }
1568  }
1569 
1570  if (o->format) {
1571  if (!(file_iformat = av_find_input_format(o->format))) {
1572  av_log(d, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
1573  return AVERROR(EINVAL);
1574  }
1575  }
1576 
1577  if (!strcmp(filename, "-"))
1578  filename = "fd:";
1579 
1580  stdin_interaction &= strncmp(filename, "pipe:", 5) &&
1581  strcmp(filename, "fd:") &&
1582  strcmp(filename, "/dev/stdin");
1583 
1584  /* get default parameters from command line */
1585  ic = avformat_alloc_context();
1586  if (!ic)
1587  return AVERROR(ENOMEM);
1588  if (o->audio_sample_rate.nb_opt) {
1589  av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate.opt[o->audio_sample_rate.nb_opt - 1].u.i, 0);
1590  }
1591  if (o->audio_channels.nb_opt) {
1592  const AVClass *priv_class;
1593  if (file_iformat && (priv_class = file_iformat->priv_class) &&
1594  av_opt_find(&priv_class, "ch_layout", NULL, 0,
1596  char buf[32];
1597  snprintf(buf, sizeof(buf), "%dC", o->audio_channels.opt[o->audio_channels.nb_opt - 1].u.i);
1598  av_dict_set(&o->g->format_opts, "ch_layout", buf, 0);
1599  }
1600  }
1601  if (o->audio_ch_layouts.nb_opt) {
1602  const AVClass *priv_class;
1603  if (file_iformat && (priv_class = file_iformat->priv_class) &&
1604  av_opt_find(&priv_class, "ch_layout", NULL, 0,
1606  av_dict_set(&o->g->format_opts, "ch_layout", o->audio_ch_layouts.opt[o->audio_ch_layouts.nb_opt - 1].u.str, 0);
1607  }
1608  }
1609  if (o->frame_rates.nb_opt) {
1610  const AVClass *priv_class;
1611  /* set the format-level framerate option;
1612  * this is important for video grabbers, e.g. x11 */
1613  if (file_iformat && (priv_class = file_iformat->priv_class) &&
1614  av_opt_find(&priv_class, "framerate", NULL, 0,
1616  av_dict_set(&o->g->format_opts, "framerate",
1617  o->frame_rates.opt[o->frame_rates.nb_opt - 1].u.str, 0);
1618  }
1619  }
1620  if (o->frame_sizes.nb_opt) {
1621  av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes.opt[o->frame_sizes.nb_opt - 1].u.str, 0);
1622  }
1623  if (o->frame_pix_fmts.nb_opt)
1624  av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts.opt[o->frame_pix_fmts.nb_opt - 1].u.str, 0);
1625 
1629  data_codec_name = opt_match_per_type_str(&o->codec_names, 'd');
1630 
1631  if (video_codec_name)
1633  &ic->video_codec));
1634  if (audio_codec_name)
1636  &ic->audio_codec));
1637  if (subtitle_codec_name)
1639  &ic->subtitle_codec));
1640  if (data_codec_name)
1641  ret = err_merge(ret, find_codec(NULL, data_codec_name , AVMEDIA_TYPE_DATA, 0,
1642  &ic->data_codec));
1643  if (ret < 0) {
1645  return ret;
1646  }
1647 
1651  ic->data_codec_id = data_codec_name ? ic->data_codec->id : AV_CODEC_ID_NONE;
1652 
1653  ic->flags |= AVFMT_FLAG_NONBLOCK;
1654  if (o->bitexact)
1655  ic->flags |= AVFMT_FLAG_BITEXACT;
1656  ic->interrupt_callback = int_cb;
1657 
1658  if (!av_dict_get(o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
1659  av_dict_set(&o->g->format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
1660  scan_all_pmts_set = 1;
1661  }
1662  /* open the input file with generic avformat function */
1663  err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts);
1664  if (err < 0) {
1666  "Error opening input: %s\n", av_err2str(err));
1667  if (err == AVERROR_PROTOCOL_NOT_FOUND)
1668  av_log(d, AV_LOG_ERROR, "Did you mean file:%s?\n", filename);
1669  return err;
1670  }
1671  f->ctx = ic;
1672 
1673  av_strlcat(d->log_name, "/", sizeof(d->log_name));
1674  av_strlcat(d->log_name, ic->iformat->name, sizeof(d->log_name));
1675 
1676  if (scan_all_pmts_set)
1677  av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
1679 
1681  if (ret < 0)
1682  return ret;
1683 
1684  /* apply forced codec ids */
1685  for (i = 0; i < ic->nb_streams; i++) {
1686  const AVCodec *dummy;
1688  &dummy);
1689  if (ret < 0)
1690  return ret;
1691  }
1692 
1693  if (o->find_stream_info) {
1694  AVDictionary **opts;
1695  int orig_nb_streams = ic->nb_streams;
1696 
1698  if (ret < 0)
1699  return ret;
1700 
1701  /* If not enough info to get the stream parameters, we decode the
1702  first frames to get it. (used in mpeg case for example) */
1704 
1705  for (i = 0; i < orig_nb_streams; i++)
1706  av_dict_free(&opts[i]);
1707  av_freep(&opts);
1708 
1709  if (ret < 0) {
1710  av_log(d, AV_LOG_FATAL, "could not find codec parameters\n");
1711  if (ic->nb_streams == 0)
1712  return ret;
1713  }
1714  }
1715 
1716  if (start_time != AV_NOPTS_VALUE && start_time_eof != AV_NOPTS_VALUE) {
1717  av_log(d, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss\n");
1718  start_time_eof = AV_NOPTS_VALUE;
1719  }
1720 
1721  if (start_time_eof != AV_NOPTS_VALUE) {
1722  if (start_time_eof >= 0) {
1723  av_log(d, AV_LOG_ERROR, "-sseof value must be negative; aborting\n");
1724  return AVERROR(EINVAL);
1725  }
1726  if (ic->duration > 0) {
1727  start_time = start_time_eof + ic->duration;
1728  if (start_time < 0) {
1729  av_log(d, AV_LOG_WARNING, "-sseof value seeks to before start of file; ignored\n");
1731  }
1732  } else
1733  av_log(d, AV_LOG_WARNING, "Cannot use -sseof, file duration not known\n");
1734  }
1735  timestamp = (start_time == AV_NOPTS_VALUE) ? 0 : start_time;
1736  /* add the stream start time */
1737  if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE)
1738  timestamp += ic->start_time;
1739 
1740  /* if seeking requested, we execute it */
1741  if (start_time != AV_NOPTS_VALUE) {
1742  int64_t seek_timestamp = timestamp;
1743 
1744  if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) {
1745  int dts_heuristic = 0;
1746  for (i=0; i<ic->nb_streams; i++) {
1747  const AVCodecParameters *par = ic->streams[i]->codecpar;
1748  if (par->video_delay) {
1749  dts_heuristic = 1;
1750  break;
1751  }
1752  }
1753  if (dts_heuristic) {
1754  seek_timestamp -= 3*AV_TIME_BASE / 23;
1755  }
1756  }
1757  ret = avformat_seek_file(ic, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0);
1758  if (ret < 0) {
1759  av_log(d, AV_LOG_WARNING, "could not seek to position %0.3f\n",
1760  (double)timestamp / AV_TIME_BASE);
1761  }
1762  }
1763 
1764  f->start_time = start_time;
1765  d->recording_time = recording_time;
1766  f->input_sync_ref = o->input_sync_ref;
1767  f->input_ts_offset = o->input_ts_offset;
1768  f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);
1769  d->accurate_seek = o->accurate_seek;
1770  d->loop = o->loop;
1771  d->nb_streams_warn = ic->nb_streams;
1772 
1773  d->duration = (Timestamp){ .ts = 0, .tb = (AVRational){ 1, 1 } };
1774  d->min_pts = (Timestamp){ .ts = AV_NOPTS_VALUE, .tb = (AVRational){ 1, 1 } };
1775  d->max_pts = (Timestamp){ .ts = AV_NOPTS_VALUE, .tb = (AVRational){ 1, 1 } };
1776 
1777  d->readrate = o->readrate ? o->readrate : 0.0;
1778  if (d->readrate < 0.0f) {
1779  av_log(d, AV_LOG_ERROR, "Option -readrate is %0.3f; it must be non-negative.\n", d->readrate);
1780  return AVERROR(EINVAL);
1781  }
1782  if (o->rate_emu) {
1783  if (d->readrate) {
1784  av_log(d, AV_LOG_WARNING, "Both -readrate and -re set. Using -readrate %0.3f.\n", d->readrate);
1785  } else
1786  d->readrate = 1.0f;
1787  }
1788 
1789  if (d->readrate) {
1790  d->readrate_initial_burst = o->readrate_initial_burst ? o->readrate_initial_burst : 0.5;
1791  if (d->readrate_initial_burst < 0.0) {
1793  "Option -readrate_initial_burst is %0.3f; it must be non-negative.\n",
1794  d->readrate_initial_burst);
1795  return AVERROR(EINVAL);
1796  }
1797  } else if (o->readrate_initial_burst) {
1798  av_log(d, AV_LOG_WARNING, "Option -readrate_initial_burst ignored "
1799  "since neither -readrate nor -re were given\n");
1800  }
1801 
1802  /* Add all the streams from the given input file to the demuxer */
1803  for (int i = 0; i < ic->nb_streams; i++) {
1804  ret = ist_add(o, d, ic->streams[i]);
1805  if (ret < 0)
1806  return ret;
1807  }
1808 
1809  /* dump the file content */
1810  av_dump_format(ic, f->index, filename, 0);
1811 
1812  /* check if all codec options have been used */
1813  unused_opts = strip_specifiers(o->g->codec_opts);
1814  for (i = 0; i < f->nb_streams; i++) {
1815  DemuxStream *ds = ds_from_ist(f->streams[i]);
1816  e = NULL;
1817  while ((e = av_dict_iterate(ds->decoder_opts, e)))
1818  av_dict_set(&unused_opts, e->key, NULL, 0);
1819  }
1820 
1821  e = NULL;
1822  while ((e = av_dict_iterate(unused_opts, e))) {
1823  const AVClass *class = avcodec_get_class();
1824  const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
1826  const AVClass *fclass = avformat_get_class();
1827  const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
1829  if (!option || foption)
1830  continue;
1831 
1832 
1833  if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) {
1834  av_log(d, AV_LOG_ERROR, "Codec AVOption %s (%s) is not a decoding "
1835  "option.\n", e->key, option->help ? option->help : "");
1836  return AVERROR(EINVAL);
1837  }
1838 
1839  av_log(d, AV_LOG_WARNING, "Codec AVOption %s (%s) has not been used "
1840  "for any stream. The most likely reason is either wrong type "
1841  "(e.g. a video option with no video streams) or that it is a "
1842  "private option of some decoder which was not actually used "
1843  "for any stream.\n", e->key, option->help ? option->help : "");
1844  }
1845  av_dict_free(&unused_opts);
1846 
1847  for (i = 0; i < o->dump_attachment.nb_opt; i++) {
1848  int j;
1849 
1850  for (j = 0; j < f->nb_streams; j++) {
1851  InputStream *ist = f->streams[j];
1852 
1853  if (check_stream_specifier(ic, ist->st, o->dump_attachment.opt[i].specifier) == 1) {
1855  if (ret < 0)
1856  return ret;
1857  }
1858  }
1859  }
1860 
1861  return 0;
1862 }
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:522
OptionsContext::readrate
float readrate
Definition: ffmpeg.h:145
AV_PKT_DATA_DISPLAYMATRIX
@ AV_PKT_DATA_DISPLAYMATRIX
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
Definition: packet.h:109
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:427
AVCodec
AVCodec.
Definition: codec.h:187
OptionsContext::input_ts_offset
int64_t input_ts_offset
Definition: ffmpeg.h:142
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
DemuxStream::ist
InputStream ist
Definition: ffmpeg_demux.c:43
av_gettime_relative
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
Definition: time.c:56
AVBSFContext::par_in
AVCodecParameters * par_in
Parameters of the input stream.
Definition: bsf.h:90
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:186
AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:260
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:69
name
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
Definition: writing_filters.txt:88
OptionsContext::stop_time
int64_t stop_time
Definition: ffmpeg.h:168
demux_final_stats
static void demux_final_stats(Demuxer *d)
Definition: ffmpeg_demux.c:786
err_merge
static int err_merge(int err0, int err1)
Merge two return codes - return one of the error codes if at least one of them was negative,...
Definition: ffmpeg_utils.h:41
AVERROR
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
nb_input_files
int nb_input_files
Definition: ffmpeg.c:126
opt.h
MATCH_PER_STREAM_OPT
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)
Definition: ffmpeg.h:831
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:51
input_stream_class
static const AVClass input_stream_class
Definition: ffmpeg_demux.c:1175
av_compare_ts
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.
Definition: mathematics.c:147
FrameData
Definition: ffmpeg.h:593
ist_output_add
int ist_output_add(InputStream *ist, OutputStream *ost)
Definition: ffmpeg_demux.c:963
AVProgram::nb_stream_indexes
unsigned int nb_stream_indexes
Definition: avformat.h:1184
out
FILE * out
Definition: movenc.c:54
DecoderOpts
Definition: ffmpeg.h:309
is
The official guide to swscale for confused that is
Definition: swscale.txt:28
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:47
DECODER_FLAG_SEND_END_TS
@ DECODER_FLAG_SEND_END_TS
Definition: ffmpeg.h:306
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AV_DISPOSITION_ATTACHED_PIC
#define AV_DISPOSITION_ATTACHED_PIC
The stream is stored in the file as an attached picture/"cover art" (e.g.
Definition: avformat.h:674
AVStream::discard
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:814
FrameData::dts_est
int64_t dts_est
Definition: ffmpeg.h:596
sch_add_demux
int sch_add_demux(Scheduler *sch, SchThreadFunc func, void *ctx)
Add a demuxer to the scheduler.
Definition: ffmpeg_sched.c:739
input_packet_process
static int input_packet_process(Demuxer *d, AVPacket *pkt, unsigned *send_flags)
Definition: ffmpeg_demux.c:443
demux_thread_init
static int demux_thread_init(DemuxThreadContext *dt)
Definition: ffmpeg_demux.c:663
remove_avoptions
void remove_avoptions(AVDictionary **a, AVDictionary *b)
Definition: ffmpeg.c:497
InputStream::outputs
struct OutputStream ** outputs
Definition: ffmpeg.h:385
SCH_DSTREAM
#define SCH_DSTREAM(file, stream)
Definition: ffmpeg_sched.h:107
AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:479
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
InputStream::user_set_discard
int user_set_discard
Definition: ffmpeg.h:354
DemuxStream::sch_idx_stream
int sch_idx_stream
Definition: ffmpeg_demux.c:48
avformat_get_class
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:196
OptionsContext::audio_ch_layouts
SpecifierOptList audio_ch_layouts
Definition: ffmpeg.h:133
ist_iter
InputStream * ist_iter(InputStream *prev)
Definition: ffmpeg.c:396
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
DemuxStream::finished
int finished
Definition: ffmpeg_demux.c:62
InputFile::index
int index
Definition: ffmpeg.h:392
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:375
pixdesc.h
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1323
AVFrame::width
int width
Definition: frame.h:447
DECODER_FLAG_FRAMERATE_FORCED
@ DECODER_FLAG_FRAMERATE_FORCED
Definition: ffmpeg.h:302
AVPacketSideData
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
Definition: packet.h:373
DecoderOpts::par
const AVCodecParameters * par
Definition: ffmpeg.h:316
ifile_close
void ifile_close(InputFile **pf)
Definition: ffmpeg_demux.c:851
DemuxStream::streamcopy_needed
int streamcopy_needed
Definition: ffmpeg_demux.c:64
av_display_matrix_flip
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
Definition: display.c:66
subtitle_codec_name
static const char * subtitle_codec_name
Definition: ffplay.c:343
AV_HWDEVICE_TYPE_NONE
@ AV_HWDEVICE_TYPE_NONE
Definition: hwcontext.h:28
OptionsContext::subtitle_disable
int subtitle_disable
Definition: ffmpeg.h:178
demux_stream_alloc
static DemuxStream * demux_stream_alloc(Demuxer *d, AVStream *st)
Definition: ffmpeg_demux.c:1182
AVOption
AVOption.
Definition: opt.h:346
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:832
DecoderOpts::hwaccel_id
enum HWAccelID hwaccel_id
Definition: ffmpeg.h:319
InputStream::nb_filters
int nb_filters
Definition: ffmpeg.h:378
AVCodecParameters::framerate
AVRational framerate
Video only.
Definition: codec_par.h:156
av_hwdevice_find_type_by_name
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
Definition: hwcontext.c:102
ffmpeg.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
float.h
DemuxStream::decoder_opts
AVDictionary * decoder_opts
Definition: ffmpeg_demux.c:81
AVFormatContext::programs
AVProgram ** programs
Definition: avformat.h:1456
av_hwdevice_iterate_types
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)
Iterate over supported device types.
Definition: hwcontext.c:121
OptionsContext::bitexact
int bitexact
Definition: ffmpeg.h:174
autorotate
static int autorotate
Definition: ffplay.c:351
av_display_rotation_set
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure clockwise rotation by the specified angle (in de...
Definition: display.c:51
AVPacket::duration
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
Definition: packet.h:540
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:59
AVDictionary
Definition: dict.c:34
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:308
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
av_read_frame
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
Definition: demux.c:1525
AVFormatContext::video_codec_id
enum AVCodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:1462
IFILTER_FLAG_AUTOROTATE
@ IFILTER_FLAG_AUTOROTATE
Definition: ffmpeg.h:239
OptionsContext::format
const char * format
Definition: ffmpeg.h:130
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:313
av_bsf_free
void av_bsf_free(AVBSFContext **pctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
Definition: bsf.c:52
Timestamp::ts
int64_t ts
Definition: ffmpeg_utils.h:31
ost
static AVStream * ost
Definition: vaapi_transcode.c:42
tf_sess_config.config
config
Definition: tf_sess_config.py:33
file_iformat
static const AVInputFormat * file_iformat
Definition: ffplay.c:308
av_packet_free
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition: avpacket.c:74
OptionsContext::frame_pix_fmts
SpecifierOptList frame_pix_fmts
Definition: ffmpeg.h:139
AVBSFContext
The bitstream filter state.
Definition: bsf.h:68
InputStream::nb_outputs
int nb_outputs
Definition: ffmpeg.h:386
Demuxer::wallclock_start
int64_t wallclock_start
Definition: ffmpeg_demux.c:101
SpecifierOpt::i
int i
Definition: cmdutils.h:109
InputStream
Definition: ffmpeg.h:345
DecoderOpts::hwaccel_output_format
enum AVPixelFormat hwaccel_output_format
Definition: ffmpeg.h:322
debug_ts
int debug_ts
Definition: ffmpeg_opt.c:76
avformat_close_input
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: demux.c:362
AVFormatContext::interrupt_callback
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
Definition: avformat.h:1528
Demuxer
Definition: ffmpeg_demux.c:95
OptionsContext::rate_emu
int rate_emu
Definition: ffmpeg.h:144
dts_delta_threshold
float dts_delta_threshold
Definition: ffmpeg_opt.c:62
DemuxStream::data_size
uint64_t data_size
Definition: ffmpeg_demux.c:92
finish
static void finish(void)
Definition: movenc.c:342
bsf.h
AVFMT_SEEK_TO_PTS
#define AVFMT_SEEK_TO_PTS
Seeking is based on PTS.
Definition: avformat.h:503
OptionsContext::g
OptionGroup * g
Definition: ffmpeg.h:124
Demuxer::log_name
char log_name[32]
Definition: ffmpeg_demux.c:99
Decoder::frames_decoded
uint64_t frames_decoded
Definition: ffmpeg.h:340
Demuxer::nb_streams_finished
int nb_streams_finished
Definition: ffmpeg_demux.c:133
dummy
int dummy
Definition: motion.c:66
AVProgram::discard
enum AVDiscard discard
selects which program to discard and which to feed to the caller
Definition: avformat.h:1182
DecoderOpts::log_parent
void * log_parent
Definition: ffmpeg.h:313
input_file_item_name
static const char * input_file_item_name(void *obj)
Definition: ffmpeg_demux.c:1494
AVDISCARD_NONE
@ AVDISCARD_NONE
discard nothing
Definition: defs.h:213
AVFrame::ch_layout
AVChannelLayout ch_layout
Channel layout of the audio data.
Definition: frame.h:776
type
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 type
Definition: writing_filters.txt:86
pts
static int64_t pts
Definition: transcode_aac.c:643
OptionsContext
Definition: ffmpeg.h:123
AVBSFContext::par_out
AVCodecParameters * par_out
Parameters of the output stream.
Definition: bsf.h:96
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:738
do_pkt_dump
int do_pkt_dump
Definition: ffmpeg_opt.c:72
Demuxer::ts_offset_discont
int64_t ts_offset_discont
Extra timestamp offset added by discontinuity handling.
Definition: ffmpeg_demux.c:106
AVRational::num
int num
Numerator.
Definition: rational.h:59
Demuxer::f
InputFile f
Definition: ffmpeg_demux.c:96
Decoder::samples_decoded
uint64_t samples_decoded
Definition: ffmpeg.h:341
InputFile
Definition: ffmpeg.h:389
DemuxStream::nb_packets
uint64_t nb_packets
Definition: ffmpeg_demux.c:90
Demuxer::nb_streams_used
int nb_streams_used
Definition: ffmpeg_demux.c:132
OptionsContext::recording_time
int64_t recording_time
Definition: ffmpeg.h:167
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:148
AV_CODEC_ID_DVB_SUBTITLE
@ AV_CODEC_ID_DVB_SUBTITLE
Definition: codec_id.h:550
LATENCY_PROBE_DEMUX
@ LATENCY_PROBE_DEMUX
Definition: ffmpeg.h:99
OptionsContext::audio_disable
int audio_disable
Definition: ffmpeg.h:177
check_stream_specifier
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
Definition: cmdutils.c:982
avassert.h
pkt
AVPacket * pkt
Definition: movenc.c:59
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
ifile_open
int ifile_open(const OptionsContext *o, const char *filename, Scheduler *sch)
Definition: ffmpeg_demux.c:1523
AVInputFormat
Definition: avformat.h:548
AV_PKT_FLAG_CORRUPT
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition: packet.h:578
OptionGroup::codec_opts
AVDictionary * codec_opts
Definition: cmdutils.h:278
av_dump_format
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate,...
Definition: dump.c:760
SpecifierOptList::nb_opt
int nb_opt
Definition: cmdutils.h:119
duration
int64_t duration
Definition: movenc.c:64
avformat_open_input
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: demux.c:214
AVCodecParameters::frame_size
int frame_size
Audio only.
Definition: codec_par.h:195
av_dict_get
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:62
av_channel_layout_describe
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
Definition: channel_layout.c:644
HWACCEL_GENERIC
@ HWACCEL_GENERIC
Definition: ffmpeg.h:84
assert_file_overwrite
int assert_file_overwrite(const char *filename)
Definition: ffmpeg_opt.c:614
SpecifierOpt::specifier
char * specifier
stream/chapter/program/...
Definition: cmdutils.h:106
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
intreadwrite.h
AVFormatContext::video_codec
const struct AVCodec * video_codec
Forced video codec.
Definition: avformat.h:1778
s
#define s(width, name)
Definition: cbs_vp9.c:198
DemuxStream::first_dts
int64_t first_dts
Definition: ffmpeg_demux.c:71
Demuxer::readrate
float readrate
Definition: ffmpeg_demux.c:124
av_bsf_flush
void av_bsf_flush(AVBSFContext *ctx)
Reset the internal bitstream filter state.
Definition: bsf.c:190
InputStream::framerate
AVRational framerate
Definition: ffmpeg.h:366
AVFormatContext::flags
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1406
AVCodecParameters::sample_aspect_ratio
AVRational sample_aspect_ratio
Video only.
Definition: codec_par.h:144
AVFormatContext::nb_programs
unsigned int nb_programs
Definition: avformat.h:1455
AVInputFormat::name
const char * name
A comma separated list of short names for the format.
Definition: avformat.h:553
dec_init
int dec_init(Decoder **pdec, Scheduler *sch, AVDictionary **dec_opts, const DecoderOpts *o, AVFrame *param_out)
Definition: ffmpeg_dec.c:1253
AVFormatContext::iformat
const struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:1267
AVDictionaryEntry::key
char * key
Definition: dict.h:90
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
AVCodecParameters::width
int width
Video only.
Definition: codec_par.h:134
AV_CHANNEL_ORDER_UNSPEC
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
Definition: channel_layout.h:112
sch_add_demux_stream
int sch_add_demux_stream(Scheduler *sch, unsigned demux_idx)
Add a demuxed stream for a previously added demuxer.
Definition: ffmpeg_sched.c:766
av_q2d
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
Demuxer::readrate_initial_burst
double readrate_initial_burst
Definition: ffmpeg_demux.c:125
InputFilter
Definition: ffmpeg.h:266
DemuxStream::ts_scale
double ts_scale
Definition: ffmpeg_demux.c:51
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:618
setup_find_stream_info_opts
int setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts, AVDictionary ***dst)
Setup AVCodecContext options for avformat_find_stream_info().
Definition: cmdutils.c:1055
discard_unused_programs
static void discard_unused_programs(InputFile *ifile)
Definition: ffmpeg_demux.c:630
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
AVPacketSideData::data
uint8_t * data
Definition: packet.h:374
DemuxThreadContext
Definition: ffmpeg_demux.c:136
ist_add
static int ist_add(const OptionsContext *o, Demuxer *d, AVStream *st)
Definition: ffmpeg_demux.c:1207
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AVBSFContext::time_base_in
AVRational time_base_in
The timebase used for the timestamps of the input packets.
Definition: bsf.h:102
InputStream::filters
InputFilter ** filters
Definition: ffmpeg.h:377
demux_send
static int demux_send(Demuxer *d, DemuxThreadContext *dt, DemuxStream *ds, AVPacket *pkt, unsigned flags)
Definition: ffmpeg_demux.c:536
Demuxer::nb_streams_warn
int nb_streams_warn
Definition: ffmpeg_demux.c:122
av_rescale_q
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
Definition: mathematics.c:142
DecoderOpts::hwaccel_device
char * hwaccel_device
Definition: ffmpeg.h:321
input_stream_item_name
static const char * input_stream_item_name(void *obj)
Definition: ffmpeg_demux.c:1168
ffmpeg_utils.h
av_hwdevice_get_type_name
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
Definition: hwcontext.c:112
OptionsContext::accurate_seek
int accurate_seek
Definition: ffmpeg.h:147
filter_codec_opts
int filter_codec_opts(const AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec, AVDictionary **dst)
Filter out options for given codec.
Definition: cmdutils.c:990
av_usleep
int av_usleep(unsigned usec)
Sleep for a period of time.
Definition: time.c:84
AVCodecParameters::nb_coded_side_data
int nb_coded_side_data
Amount of entries in coded_side_data.
Definition: codec_par.h:86
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
AVFormatContext::data_codec
const struct AVCodec * data_codec
Forced data codec.
Definition: avformat.h:1802
Demuxer::duration
Timestamp duration
Definition: ffmpeg_demux.c:116
DemuxThreadContext::pkt_demux
AVPacket * pkt_demux
Definition: ffmpeg_demux.c:138
AV_PIX_FMT_MEDIACODEC
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
Definition: pixfmt.h:316
arg
const char * arg
Definition: jacosubdec.c:67
AV_CLASS_CATEGORY_DEMUXER
@ AV_CLASS_CATEGORY_DEMUXER
Definition: log.h:33
ist_filter_add
int ist_filter_add(InputStream *ist, InputFilter *ifilter, int is_simple, InputFilterOptions *opts)
Definition: ffmpeg_demux.c:981
AVCodecDescriptor::props
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
Definition: codec_desc.h:54
fields
the definition of that something depends on the semantic of the filter The callback must examine the status of the filter s links and proceed accordingly The status of output links is stored in the status_in and status_out fields and tested by the then the processing requires a frame on this link and the filter is expected to make efforts in that direction The status of input links is stored by the fifo and status_out fields
Definition: filter_design.txt:155
FFABS
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
Definition: common.h:72
if
if(ret)
Definition: filter_design.txt:179
option
option
Definition: libkvazaar.c:320
AVCodecParserContext::repeat_pict
int repeat_pict
This field is used for proper frame duration computation in lavf.
Definition: avcodec.h:2725
OptionsContext::start_time
int64_t start_time
Definition: ffmpeg.h:127
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:219
AVFormatContext
Format I/O context.
Definition: avformat.h:1255
DECODING_FOR_OST
#define DECODING_FOR_OST
Definition: ffmpeg_demux.c:55
AVFormatContext::audio_codec_id
enum AVCodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:1468
OptionGroup::format_opts
AVDictionary * format_opts
Definition: cmdutils.h:279
opts
AVDictionary * opts
Definition: movenc.c:50
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:766
framerate
float framerate
Definition: av1_levels.c:29
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
av_bsf_init
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
Definition: bsf.c:149
demuxer_from_ifile
static Demuxer * demuxer_from_ifile(InputFile *f)
Definition: ffmpeg_demux.c:148
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
avcodec_get_class
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
Definition: options.c:185
ist_use
static int ist_use(InputStream *ist, int decoding_needed)
Definition: ffmpeg_demux.c:873
AVStream::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avformat.h:782
NULL
#define NULL
Definition: coverity.c:32
Decoder::decode_errors
uint64_t decode_errors
Definition: ffmpeg.h:342
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:709
InputStream::top_field_first
int top_field_first
Definition: ffmpeg.h:368
InputStream::st
AVStream * st
Definition: ffmpeg.h:353
AV_DICT_MULTIKEY
#define AV_DICT_MULTIKEY
Allow to store several equal keys in the dictionary.
Definition: dict.h:84
avcodec_parameters_free
void avcodec_parameters_free(AVCodecParameters **ppar)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
Definition: codec_par.c:66
av_bsf_receive_packet
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
Definition: bsf.c:230
OptionsContext::audio_channels
SpecifierOptList audio_channels
Definition: ffmpeg.h:134
InputFile::start_time_effective
int64_t start_time_effective
Effective format start time based on enabled streams.
Definition: ffmpeg.h:400
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
Demuxer::recording_time
int64_t recording_time
Definition: ffmpeg_demux.c:109
parseutils.h
AVProgram::stream_index
unsigned int * stream_index
Definition: avformat.h:1183
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:823
AV_ROUND_NEAR_INF
@ AV_ROUND_NEAR_INF
Round to nearest and halfway cases away from zero.
Definition: mathematics.h:135
AV_OPT_SEARCH_FAKE_OBJ
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required poin...
Definition: opt.h:530
OptionsContext::dump_attachment
SpecifierOptList dump_attachment
Definition: ffmpeg.h:153
InputStream::fix_sub_duration
int fix_sub_duration
Definition: ffmpeg.h:373
FrameData::wallclock
int64_t wallclock[LATENCY_PROBE_NB]
Definition: ffmpeg.h:610
AV_DICT_DONT_OVERWRITE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition: dict.h:81
time.h
DEMUX_SEND_STREAMCOPY_EOF
@ DEMUX_SEND_STREAMCOPY_EOF
Treat the packet as an EOF for SCH_NODE_TYPE_MUX destinations send normally to other types.
Definition: ffmpeg_sched.h:324
DemuxThreadContext::pkt_bsf
AVPacket * pkt_bsf
Definition: ffmpeg_demux.c:140
InputFilterOptions
Definition: ffmpeg.h:244
AV_PIX_FMT_QSV
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition: pixfmt.h:247
Demuxer::read_started
int read_started
Definition: ffmpeg_demux.c:131
AVCodecParameters::ch_layout
AVChannelLayout ch_layout
Audio only.
Definition: codec_par.h:180
OptionsContext::input_sync_ref
int input_sync_ref
Definition: ffmpeg.h:149
report_new_stream
static void report_new_stream(Demuxer *d, const AVPacket *pkt)
Definition: ffmpeg_demux.c:164
guess_input_channel_layout
static int guess_input_channel_layout(InputStream *ist, AVCodecParameters *par, int guess_layout_max)
Definition: ffmpeg_demux.c:1110
DECODER_FLAG_FIX_SUB_DURATION
@ DECODER_FLAG_FIX_SUB_DURATION
Definition: ffmpeg.h:297
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AVCodecParameters::sample_rate
int sample_rate
Audio only.
Definition: codec_par.h:184
Demuxer::sch
Scheduler * sch
Definition: ffmpeg_demux.c:127
choose_decoder
static int choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type, const AVCodec **pcodec)
Definition: ffmpeg_demux.c:1064
find_codec
int find_codec(void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **codec)
Definition: ffmpeg_opt.c:581
AVFormatContext::audio_codec
const struct AVCodec * audio_codec
Forced audio codec.
Definition: avformat.h:1786
InputStream::par
AVCodecParameters * par
Codec parameters - to be used by the decoding/streamcopy code.
Definition: ffmpeg.h:361
input_files
InputFile ** input_files
Definition: ffmpeg.c:125
error.h
Scheduler
Definition: ffmpeg_sched.c:263
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:971
recast_media
int recast_media
Definition: ffmpeg_opt.c:93
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:73
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1311
DemuxStream::dts
int64_t dts
Definition: ffmpeg_demux.c:77
av_codec_is_decoder
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:86
avformat_find_stream_info
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: demux.c:2499
av_opt_find
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
Definition: opt.c:1950
IFILTER_FLAG_REINIT
@ IFILTER_FLAG_REINIT
Definition: ffmpeg.h:240
f
f
Definition: af_crystalizer.c:121
AVIOContext
Bytestream IO Context.
Definition: avio.h:160
av_ts2timestr
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:83
seek_to_start
static int seek_to_start(Demuxer *d, Timestamp end_pts)
Definition: ffmpeg_demux.c:177
AVMediaType
AVMediaType
Definition: avutil.h:199
AVPacket::size
int size
Definition: packet.h:523
avformat_alloc_context
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:160
AVDISCARD_DEFAULT
@ AVDISCARD_DEFAULT
discard useless packets like 0 size packets in avi
Definition: defs.h:214
FFMPEG_OPT_TOP
#define FFMPEG_OPT_TOP
Definition: ffmpeg.h:57
DemuxStream::have_sub2video
int have_sub2video
Definition: ffmpeg_demux.c:65
av_bsf_send_packet
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
Definition: bsf.c:202
av_err2str
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: error.h:121
start_time
static int64_t start_time
Definition: ffplay.c:329
Demuxer::pkt_heartbeat
AVPacket * pkt_heartbeat
Definition: ffmpeg_demux.c:129
DemuxStream::decoding_needed
int decoding_needed
Definition: ffmpeg_demux.c:54
demux_thread_uninit
static void demux_thread_uninit(DemuxThreadContext *dt)
Definition: ffmpeg_demux.c:655
copy_ts
int copy_ts
Definition: ffmpeg_opt.c:73
avformat_seek_file
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
Definition: seek.c:662
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
check_avoptions
int check_avoptions(AVDictionary *m)
Definition: ffmpeg.c:506
AV_CODEC_PROP_FIELDS
#define AV_CODEC_PROP_FIELDS
Video codec supports separate coding of fields in interlaced frames.
Definition: codec_desc.h:97
OptionsContext::seek_timestamp
int seek_timestamp
Definition: ffmpeg.h:129
input_file_class
static const AVClass input_file_class
Definition: ffmpeg_demux.c:1501
DECODING_FOR_FILTER
#define DECODING_FOR_FILTER
Definition: ffmpeg_demux.c:56
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:462
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
DemuxStream::bsf
AVBSFContext * bsf
Definition: ffmpeg_demux.c:87
AVStream::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
Definition: avformat.h:821
OptionsContext::readrate_initial_burst
double readrate_initial_burst
Definition: ffmpeg.h:146
allocate_array_elem
void * allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
Atomically add a new element to an array of pointers, i.e.
Definition: cmdutils.c:1104
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:521
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:200
OptionsContext::find_stream_info
int find_stream_info
Definition: ffmpeg.h:150
DemuxStream::sch_idx_dec
int sch_idx_dec
Definition: ffmpeg_demux.c:49
strip_specifiers
AVDictionary * strip_specifiers(const AVDictionary *dict)
Definition: ffmpeg_opt.c:162
SpecifierOptList::opt
SpecifierOpt * opt
Definition: cmdutils.h:118
SCH_DEC
#define SCH_DEC(decoder)
Definition: ffmpeg_sched.h:113
offset
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
Definition: writing_filters.txt:86
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:528
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:63
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:223
av_parse_video_size
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
Definition: parseutils.c:150
av_packet_rescale_ts
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.
Definition: avpacket.c:531
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
video_codec_name
static const char * video_codec_name
Definition: ffplay.c:344
DemuxStream::next_dts
int64_t next_dts
dts of the last packet read for this stream (in AV_TIME_BASE units)
Definition: ffmpeg_demux.c:75
AVCodec::id
enum AVCodecID id
Definition: codec.h:201
av_channel_layout_default
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
Definition: channel_layout.c:830
avcodec_parameters_alloc
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
Definition: codec_par.c:56
avcodec_get_name
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
Definition: utils.c:406
HWACCEL_AUTO
@ HWACCEL_AUTO
Definition: ffmpeg.h:83
DemuxStream
Definition: ffmpeg_demux.c:42
av_parse_video_rate
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
Definition: parseutils.c:181
DemuxStream::dec_name
char dec_name[16]
Definition: ffmpeg_demux.c:83
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:255
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:515
OptionsContext::frame_rates
SpecifierOptList frame_rates
Definition: ffmpeg.h:136
OptionsContext::codec_names
SpecifierOptList codec_names
Definition: ffmpeg.h:132
packet.h
demux_bsf_flush
static int demux_bsf_flush(Demuxer *d, DemuxThreadContext *dt)
Definition: ffmpeg_demux.c:605
AVFormatContext::subtitle_codec
const struct AVCodec * subtitle_codec
Forced subtitle codec.
Definition: avformat.h:1794
AVCodecParameters::height
int height
Definition: codec_par.h:135
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
DecoderOpts::time_base
AVRational time_base
Definition: ffmpeg.h:324
SHOW_TS_DEBUG
#define SHOW_TS_DEBUG(tag_)
OptionsContext::start_time_eof
int64_t start_time_eof
Definition: ffmpeg.h:128
display.h
exit_on_error
int exit_on_error
Definition: ffmpeg_opt.c:77
Demuxer::have_audio_dec
int have_audio_dec
Definition: ffmpeg_demux.c:114
av_assert1
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:56
delta
float delta
Definition: vorbis_enc_data.h:430
AVMEDIA_TYPE_ATTACHMENT
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition: avutil.h:205
InputFile::ctx
AVFormatContext * ctx
Definition: ffmpeg.h:394
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVProgram
New fields can be added to the end with minor version bumps.
Definition: avformat.h:1179
av_inv_q
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition: rational.h:159
av_rescale
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:129
int_cb
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:327
AVBSFContext::time_base_out
AVRational time_base_out
The timebase used for the timestamps of the output packets.
Definition: bsf.h:108
AVCodecParameters::coded_side_data
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
Definition: codec_par.h:81
DemuxStream::discard
int discard
Definition: ffmpeg_demux.c:59
AVFMT_FLAG_NONBLOCK
#define AVFMT_FLAG_NONBLOCK
Do not block when reading packets from input.
Definition: avformat.h:1409
av_codec_iterate
const AVCodec * av_codec_iterate(void **opaque)
Iterate over all registered codecs.
Definition: allcodecs.c:922
sch_connect
int sch_connect(Scheduler *sch, SchedulerNode src, SchedulerNode dst)
Definition: ffmpeg_sched.c:960
ist_find_unused
InputStream * ist_find_unused(enum AVMediaType type)
Find an unused input stream of given type.
Definition: ffmpeg_demux.c:153
Timestamp::tb
AVRational tb
Definition: ffmpeg_utils.h:32
InputStream::decoder
Decoder * decoder
Definition: ffmpeg.h:362
AVStream::disposition
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
Definition: avformat.h:812
DemuxStream::codec_desc
const AVCodecDescriptor * codec_desc
Definition: ffmpeg_demux.c:79
ts_discontinuity_process
static void ts_discontinuity_process(Demuxer *d, InputStream *ist, AVPacket *pkt)
Definition: ffmpeg_demux.c:272
tag
uint32_t tag
Definition: movenc.c:1786
AVStream::id
int id
Format-specific stream ID.
Definition: avformat.h:755
AVFMT_FLAG_BITEXACT
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1423
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:743
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
dec_free
void dec_free(Decoder **pdec)
Definition: ffmpeg_dec.c:98
av_guess_frame_rate
AVRational av_guess_frame_rate(AVFormatContext *format, AVStream *st, AVFrame *frame)
Guess the frame rate, based on both the container and codec information.
Definition: avformat.c:750
DemuxStream::wrap_correction_done
int wrap_correction_done
Definition: ffmpeg_demux.c:68
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
av_strlcat
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
Definition: avstring.c:95
Demuxer::loop
int loop
Definition: ffmpeg_demux.c:113
InputFile::streams
InputStream ** streams
Definition: ffmpeg.h:408
add_display_matrix_to_stream
static int add_display_matrix_to_stream(const OptionsContext *o, AVFormatContext *ctx, InputStream *ist)
Definition: ffmpeg_demux.c:1127
hwaccel
static const char * hwaccel
Definition: ffplay.c:356
DECODER_FLAG_TOP_FIELD_FIRST
@ DECODER_FLAG_TOP_FIELD_FIRST
Definition: ffmpeg.h:304
Demuxer::accurate_seek
int accurate_seek
Definition: ffmpeg_demux.c:110
avformat.h
HWAccelID
HWAccelID
Definition: ffmpeg.h:81
av_packet_side_data_new
AVPacketSideData * av_packet_side_data_new(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, size_t size, int flags)
Allocate a new packet side data.
Definition: avpacket.c:704
AV_DICT_MATCH_CASE
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
Definition: dict.h:74
AV_RL32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
Definition: bytestream.h:92
av_get_pix_fmt
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
Definition: pixdesc.c:2894
AVFormatContext::data_codec_id
enum AVCodecID data_codec_id
Forced Data codec_id.
Definition: avformat.h:1480
av_get_media_type_string
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
Definition: utils.c:28
AVFrame::height
int height
Definition: frame.h:447
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:749
OptionsContext::audio_sample_rate
SpecifierOptList audio_sample_rate
Definition: ffmpeg.h:135
audio_codec_name
static const char * audio_codec_name
Definition: ffplay.c:342
sch_demux_send
int sch_demux_send(Scheduler *sch, unsigned demux_idx, AVPacket *pkt, unsigned flags)
Called by demuxer tasks to communicate with their downstreams.
Definition: ffmpeg_sched.c:2014
ts_discontinuity_detect
static void ts_discontinuity_detect(Demuxer *d, InputStream *ist, AVPacket *pkt)
Definition: ffmpeg_demux.c:204
PKT_OPAQUE_SUB_HEARTBEAT
@ PKT_OPAQUE_SUB_HEARTBEAT
Definition: ffmpeg.h:94
AVInputFormat::flags
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_NOTIMESTAMPS,...
Definition: avformat.h:567
AVRational::den
int den
Denominator.
Definition: rational.h:60
InputStream::file
struct InputFile * file
Definition: ffmpeg.h:349
SpecifierOpt::str
uint8_t * str
Definition: cmdutils.h:108
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
avformat_free_context
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
Definition: avformat.c:141
IFILTER_FLAG_CFR
@ IFILTER_FLAG_CFR
Definition: ffmpeg.h:241
OptionsContext::frame_sizes
SpecifierOptList frame_sizes
Definition: ffmpeg.h:138
OptionsContext::video_disable
int video_disable
Definition: ffmpeg.h:176
ds_from_ist
static DemuxStream * ds_from_ist(InputStream *ist)
Definition: ffmpeg_demux.c:143
av_find_input_format
const AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
Definition: format.c:145
demux_alloc
static Demuxer * demux_alloc(void)
Definition: ffmpeg_demux.c:1508
AVFormatContext::duration
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1390
av_mul_q
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
Definition: rational.c:80
AVPacket::stream_index
int stream_index
Definition: packet.h:524
GROW_ARRAY
#define GROW_ARRAY(array, nb_elems)
Definition: cmdutils.h:465
HWACCEL_NONE
@ HWACCEL_NONE
Definition: ffmpeg.h:82
avcodec_get_hw_config
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
Definition: utils.c:838
ist_dts_update
static int ist_dts_update(DemuxStream *ds, AVPacket *pkt, FrameData *fd)
Definition: ffmpeg_demux.c:292
InputFile::ts_offset
int64_t ts_offset
Definition: ffmpeg.h:401
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:439
av_dict_set_int
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
Definition: dict.c:167
DecoderOpts::flags
int flags
Definition: ffmpeg.h:310
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
AV_OPT_FLAG_DECODING_PARAM
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
Definition: opt.h:273
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
av_bsf_list_parse_str
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
Parse string describing list of bitstream filters and create single AVBSFContext describing the whole...
Definition: bsf.c:526
start_at_zero
int start_at_zero
Definition: ffmpeg_opt.c:74
AVFMT_TS_DISCONT
#define AVFMT_TS_DISCONT
Format allows timestamp discontinuities.
Definition: avformat.h:481
SpecifierOpt::u
union SpecifierOpt::@0 u
avio_open2
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: avio.c:490
DECODER_FLAG_TS_UNRELIABLE
@ DECODER_FLAG_TS_UNRELIABLE
Definition: ffmpeg.h:299
AVCodecParameters::video_delay
int video_delay
Video only.
Definition: codec_par.h:175
DemuxStream::log_name
char log_name[32]
Definition: ffmpeg_demux.c:46
DecoderOpts::codec
const AVCodec * codec
Definition: ffmpeg.h:315
InputStream::class
const AVClass * class
Definition: ffmpeg.h:346
InputStream::index
int index
Definition: ffmpeg.h:351
readrate_sleep
static void readrate_sleep(Demuxer *d)
Definition: ffmpeg_demux.c:487
ffmpeg_sched.h
AVDictionaryEntry
Definition: dict.h:89
Demuxer::max_pts
Timestamp max_pts
Definition: ffmpeg_demux.c:119
DemuxStream::dec_opts
DecoderOpts dec_opts
Definition: ffmpeg_demux.c:82
stdin_interaction
int stdin_interaction
Definition: ffmpeg_opt.c:80
do_hex_dump
int do_hex_dump
Definition: ffmpeg_opt.c:71
AV_ROUND_PASS_MINMAX
@ AV_ROUND_PASS_MINMAX
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
Definition: mathematics.h:159
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:55
AVPacket
This structure stores compressed data.
Definition: packet.h:499
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_set
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:88
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:542
packet_data
FrameData * packet_data(AVPacket *pkt)
Definition: ffmpeg.c:485
OptionsContext::data_disable
int data_disable
Definition: ffmpeg.h:179
d
d
Definition: ffmpeg_filter.c:409
int32_t
int32_t
Definition: audioconvert.c:56
ist_free
static void ist_free(InputStream **pist)
Definition: ffmpeg_demux.c:826
DemuxStream::reinit_filters
int reinit_filters
Definition: ffmpeg_demux.c:66
timestamp.h
OutputStream
Definition: mux.c:53
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:474
Demuxer::min_pts
Timestamp min_pts
Definition: ffmpeg_demux.c:118
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
ts_fixup
static int ts_fixup(Demuxer *d, AVPacket *pkt, FrameData *fd)
Definition: ffmpeg_demux.c:352
avio_close
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Definition: avio.c:615
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
AVFormatContext::start_time
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1380
DecoderOpts::framerate
AVRational framerate
Definition: ffmpeg.h:328
dts_error_threshold
float dts_error_threshold
Definition: ffmpeg_opt.c:63
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
av_ts2str
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
Definition: timestamp.h:54
av_stream_get_parser
struct AVCodecParserContext * av_stream_get_parser(const AVStream *s)
Definition: demux_utils.c:32
AVCodecHWConfig
Definition: codec.h:334
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
av_pkt_dump_log2
void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload, const AVStream *st)
Send a nice dump of a packet to the log.
Definition: dump.c:120
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3727
do_send
static int do_send(Demuxer *d, DemuxStream *ds, AVPacket *pkt, unsigned flags, const char *pkt_desc)
Definition: ffmpeg_demux.c:507
Demuxer::last_ts
int64_t last_ts
Definition: ffmpeg_demux.c:107
DemuxStream::decoded_params
AVFrame * decoded_params
Definition: ffmpeg_demux.c:85
AVDictionaryEntry::value
char * value
Definition: dict.h:91
avstring.h
Timestamp
Definition: ffmpeg_utils.h:30
opt_match_per_type_str
const char * opt_match_per_type_str(const SpecifierOptList *sol, char mediatype)
Definition: ffmpeg_opt.c:179
DemuxStream::saw_first_ts
int saw_first_ts
dts of the first packet read for this stream (in AV_TIME_BASE units)
Definition: ffmpeg_demux.c:69
AVStream::pts_wrap_bits
int pts_wrap_bits
Number of bits in timestamps.
Definition: avformat.h:918
dump_attachment
static int dump_attachment(InputStream *ist, const char *filename)
Definition: ffmpeg_demux.c:1456
AVERROR_PROTOCOL_NOT_FOUND
#define AVERROR_PROTOCOL_NOT_FOUND
Protocol not found.
Definition: error.h:65
InputStream::dec
const AVCodec * dec
Definition: ffmpeg.h:363
snprintf
#define snprintf
Definition: snprintf.h:34
DecoderOpts::hwaccel_device_type
enum AVHWDeviceType hwaccel_device_type
Definition: ffmpeg.h:320
av_rescale_q_rnd
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:134
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:44
input_thread
static int input_thread(void *arg)
Definition: ffmpeg_demux.c:678
AVInputFormat::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:578
avcodec_parameters_copy
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
Definition: codec_par.c:106
AVPacket::time_base
AVRational time_base
Time base of the packet's timestamps.
Definition: packet.h:566
OptionsContext::loop
int loop
Definition: ffmpeg.h:143
InputStream::autorotate
int autorotate
Definition: ffmpeg.h:371
thread_set_name
static void thread_set_name(InputFile *f)
Definition: ffmpeg_demux.c:648
ff_thread_setname
static int ff_thread_setname(const char *name)
Definition: thread.h:216
AVFormatContext::subtitle_codec_id
enum AVCodecID subtitle_codec_id
Forced subtitle codec_id.
Definition: avformat.h:1474
DecoderOpts::name
char * name
Definition: ffmpeg.h:312