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 
24 #include "libavutil/avassert.h"
25 #include "libavutil/avstring.h"
26 #include "libavutil/display.h"
27 #include "libavutil/error.h"
28 #include "libavutil/intreadwrite.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/parseutils.h"
31 #include "libavutil/pixdesc.h"
32 #include "libavutil/time.h"
33 #include "libavutil/timestamp.h"
34 #include "libavutil/thread.h"
36 
37 #include "libavcodec/packet.h"
38 
39 #include "libavformat/avformat.h"
40 
41 static const char *const opt_name_discard[] = {"discard", NULL};
42 static const char *const opt_name_reinit_filters[] = {"reinit_filter", NULL};
43 static const char *const opt_name_fix_sub_duration[] = {"fix_sub_duration", NULL};
44 static const char *const opt_name_canvas_sizes[] = {"canvas_size", NULL};
45 static const char *const opt_name_guess_layout_max[] = {"guess_layout_max", NULL};
46 static const char *const opt_name_ts_scale[] = {"itsscale", NULL};
47 static const char *const opt_name_hwaccels[] = {"hwaccel", NULL};
48 static const char *const opt_name_hwaccel_devices[] = {"hwaccel_device", NULL};
49 static const char *const opt_name_hwaccel_output_formats[] = {"hwaccel_output_format", NULL};
50 static const char *const opt_name_autorotate[] = {"autorotate", NULL};
51 static const char *const opt_name_display_rotations[] = {"display_rotation", NULL};
52 static const char *const opt_name_display_hflips[] = {"display_hflip", NULL};
53 static const char *const opt_name_display_vflips[] = {"display_vflip", NULL};
54 
55 typedef struct Demuxer {
57 
58  /* number of times input stream should be looped */
59  int loop;
60  /* actual duration of the longest stream in a file at the moment when
61  * looping happens */
62  int64_t duration;
63  /* time base of the duration */
65 
66  /* number of streams that the user was warned of */
68 
73 } Demuxer;
74 
75 typedef struct DemuxMsg {
77  int looping;
78 
79  // repeat_pict from the demuxer-internal parser
81 } DemuxMsg;
82 
84 {
85  return (Demuxer*)f;
86 }
87 
88 static void report_new_stream(Demuxer *d, const AVPacket *pkt)
89 {
90  AVStream *st = d->f.ctx->streams[pkt->stream_index];
91 
92  if (pkt->stream_index < d->nb_streams_warn)
93  return;
95  "New %s stream %d:%d at pos:%"PRId64" and DTS:%ss\n",
97  d->f.index, pkt->stream_index,
98  pkt->pos, av_ts2timestr(pkt->dts, &st->time_base));
99  d->nb_streams_warn = pkt->stream_index + 1;
100 }
101 
103  int64_t last_duration)
104 {
105  /* the total duration of the stream, max_pts - min_pts is
106  * the duration of the stream without the last frame */
107  if (ist->max_pts > ist->min_pts &&
108  ist->max_pts - (uint64_t)ist->min_pts < INT64_MAX - last_duration)
109  last_duration += ist->max_pts - ist->min_pts;
110 
111  if (!d->duration ||
112  av_compare_ts(d->duration, d->time_base,
113  last_duration, ist->st->time_base) < 0) {
114  d->duration = last_duration;
115  d->time_base = ist->st->time_base;
116  }
117 }
118 
119 static int seek_to_start(Demuxer *d)
120 {
121  InputFile *ifile = &d->f;
122  AVFormatContext *is = ifile->ctx;
123  InputStream *ist;
124  int ret;
125 
126  ret = avformat_seek_file(is, -1, INT64_MIN, is->start_time, is->start_time, 0);
127  if (ret < 0)
128  return ret;
129 
130  if (ifile->audio_duration_queue_size) {
131  /* duration is the length of the last frame in a stream
132  * when audio stream is present we don't care about
133  * last video frame length because it's not defined exactly */
134  int got_durations = 0;
135 
136  while (got_durations < ifile->audio_duration_queue_size) {
137  LastFrameDuration dur;
138  ret = av_thread_message_queue_recv(ifile->audio_duration_queue, &dur, 0);
139  if (ret < 0)
140  return ret;
141  got_durations++;
142 
143  ist = ifile->streams[dur.stream_idx];
144  ifile_duration_update(d, ist, dur.duration);
145  }
146  } else {
147  for (int i = 0; i < ifile->nb_streams; i++) {
148  int64_t duration = 0;
149  ist = ifile->streams[i];
150 
151  if (ist->framerate.num) {
152  duration = av_rescale_q(1, av_inv_q(ist->framerate), ist->st->time_base);
153  } else if (ist->st->avg_frame_rate.num) {
155  } else {
156  duration = 1;
157  }
158 
160  }
161  }
162 
163  if (d->loop > 0)
164  d->loop--;
165 
166  return ret;
167 }
168 
169 static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict)
170 {
171  InputFile *ifile = &d->f;
172  InputStream *ist = ifile->streams[pkt->stream_index];
173  const int64_t start_time = ifile->start_time_effective;
174  int64_t duration;
175 
176  if (debug_ts) {
177  av_log(NULL, AV_LOG_INFO, "demuxer -> ist_index:%d:%d type:%s "
178  "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s duration:%s duration_time:%s\n",
179  ifile->index, pkt->stream_index,
184  }
185 
187  ist->st->pts_wrap_bits < 64) {
188  int64_t stime, stime2;
189 
191  stime2= stime + (1ULL<<ist->st->pts_wrap_bits);
192  ist->wrap_correction_done = 1;
193 
194  if(stime2 > stime && pkt->dts != AV_NOPTS_VALUE && pkt->dts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
195  pkt->dts -= 1ULL<<ist->st->pts_wrap_bits;
196  ist->wrap_correction_done = 0;
197  }
198  if(stime2 > stime && pkt->pts != AV_NOPTS_VALUE && pkt->pts > stime + (1LL<<(ist->st->pts_wrap_bits-1))) {
199  pkt->pts -= 1ULL<<ist->st->pts_wrap_bits;
200  ist->wrap_correction_done = 0;
201  }
202  }
203 
204  if (pkt->dts != AV_NOPTS_VALUE)
205  pkt->dts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
206  if (pkt->pts != AV_NOPTS_VALUE)
207  pkt->pts += av_rescale_q(ifile->ts_offset, AV_TIME_BASE_Q, ist->st->time_base);
208 
209  if (pkt->pts != AV_NOPTS_VALUE)
210  pkt->pts *= ist->ts_scale;
211  if (pkt->dts != AV_NOPTS_VALUE)
212  pkt->dts *= ist->ts_scale;
213 
214  duration = av_rescale_q(d->duration, d->time_base, ist->st->time_base);
215  if (pkt->pts != AV_NOPTS_VALUE) {
216  pkt->pts += duration;
217  ist->max_pts = FFMAX(pkt->pts, ist->max_pts);
218  ist->min_pts = FFMIN(pkt->pts, ist->min_pts);
219  }
220 
221  if (pkt->dts != AV_NOPTS_VALUE)
222  pkt->dts += duration;
223 
224  *repeat_pict = -1;
225  if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
226  av_stream_get_parser(ist->st))
227  *repeat_pict = av_stream_get_parser(ist->st)->repeat_pict;
228 }
229 
231 {
232  char name[16];
233  snprintf(name, sizeof(name), "dmx%d:%s", f->index, f->ctx->iformat->name);
235 }
236 
237 static void *input_thread(void *arg)
238 {
239  Demuxer *d = arg;
240  InputFile *f = &d->f;
241  AVPacket *pkt;
242  unsigned flags = d->non_blocking ? AV_THREAD_MESSAGE_NONBLOCK : 0;
243  int ret = 0;
244 
245  pkt = av_packet_alloc();
246  if (!pkt) {
247  ret = AVERROR(ENOMEM);
248  goto finish;
249  }
250 
252 
253  while (1) {
254  DemuxMsg msg = { NULL };
255 
256  ret = av_read_frame(f->ctx, pkt);
257 
258  if (ret == AVERROR(EAGAIN)) {
259  av_usleep(10000);
260  continue;
261  }
262  if (ret < 0) {
263  if (d->loop) {
264  /* signal looping to the consumer thread */
265  msg.looping = 1;
266  ret = av_thread_message_queue_send(d->in_thread_queue, &msg, 0);
267  if (ret >= 0)
268  ret = seek_to_start(d);
269  if (ret >= 0)
270  continue;
271 
272  /* fallthrough to the error path */
273  }
274 
275  if (ret == AVERROR_EOF)
276  av_log(NULL, AV_LOG_VERBOSE, "EOF in input file %d\n", f->index);
277  else
278  av_log(NULL, AV_LOG_ERROR, "Error demuxing input file %d: %s\n",
279  f->index, av_err2str(ret));
280 
281  break;
282  }
283 
284  if (do_pkt_dump) {
286  f->ctx->streams[pkt->stream_index]);
287  }
288 
289  /* the following test is needed in case new streams appear
290  dynamically in stream : we ignore them */
291  if (pkt->stream_index >= f->nb_streams) {
294  continue;
295  }
296 
297  if (pkt->flags & AV_PKT_FLAG_CORRUPT) {
299  "%s: corrupt input packet in stream %d\n",
300  f->ctx->url, pkt->stream_index);
301  if (exit_on_error) {
304  break;
305  }
306  }
307 
308  ts_fixup(d, pkt, &msg.repeat_pict);
309 
310  msg.pkt = av_packet_alloc();
311  if (!msg.pkt) {
313  ret = AVERROR(ENOMEM);
314  break;
315  }
316  av_packet_move_ref(msg.pkt, pkt);
317  ret = av_thread_message_queue_send(d->in_thread_queue, &msg, flags);
318  if (flags && ret == AVERROR(EAGAIN)) {
319  flags = 0;
320  ret = av_thread_message_queue_send(d->in_thread_queue, &msg, flags);
321  av_log(f->ctx, AV_LOG_WARNING,
322  "Thread message queue blocking; consider raising the "
323  "thread_queue_size option (current value: %d)\n",
324  d->thread_queue_size);
325  }
326  if (ret < 0) {
327  if (ret != AVERROR_EOF)
328  av_log(f->ctx, AV_LOG_ERROR,
329  "Unable to send packet to main thread: %s\n",
330  av_err2str(ret));
331  av_packet_free(&msg.pkt);
332  break;
333  }
334  }
335 
336 finish:
337  av_assert0(ret < 0);
338  av_thread_message_queue_set_err_recv(d->in_thread_queue, ret);
339 
341 
342  av_log(NULL, AV_LOG_VERBOSE, "Terminating demuxer thread %d\n", f->index);
343 
344  return NULL;
345 }
346 
347 static void thread_stop(Demuxer *d)
348 {
349  InputFile *f = &d->f;
350  DemuxMsg msg;
351 
352  if (!d->in_thread_queue)
353  return;
355  while (av_thread_message_queue_recv(d->in_thread_queue, &msg, 0) >= 0)
356  av_packet_free(&msg.pkt);
357 
358  pthread_join(d->thread, NULL);
359  av_thread_message_queue_free(&d->in_thread_queue);
360  av_thread_message_queue_free(&f->audio_duration_queue);
361 }
362 
363 static int thread_start(Demuxer *d)
364 {
365  int ret;
366  InputFile *f = &d->f;
367 
368  if (d->thread_queue_size <= 0)
369  d->thread_queue_size = (nb_input_files > 1 ? 8 : 1);
370 
371  if (nb_input_files > 1 &&
372  (f->ctx->pb ? !f->ctx->pb->seekable :
373  strcmp(f->ctx->iformat->name, "lavfi")))
374  d->non_blocking = 1;
375  ret = av_thread_message_queue_alloc(&d->in_thread_queue,
376  d->thread_queue_size, sizeof(DemuxMsg));
377  if (ret < 0)
378  return ret;
379 
380  if (d->loop) {
381  int nb_audio_dec = 0;
382 
383  for (int i = 0; i < f->nb_streams; i++) {
384  InputStream *ist = f->streams[i];
385  nb_audio_dec += !!(ist->decoding_needed &&
387  }
388 
389  if (nb_audio_dec) {
390  ret = av_thread_message_queue_alloc(&f->audio_duration_queue,
391  nb_audio_dec, sizeof(LastFrameDuration));
392  if (ret < 0)
393  goto fail;
394  f->audio_duration_queue_size = nb_audio_dec;
395  }
396  }
397 
398  if ((ret = pthread_create(&d->thread, NULL, input_thread, d))) {
399  av_log(NULL, AV_LOG_ERROR, "pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret));
400  ret = AVERROR(ret);
401  goto fail;
402  }
403 
404  return 0;
405 fail:
406  av_thread_message_queue_free(&d->in_thread_queue);
407  return ret;
408 }
409 
411 {
413  InputStream *ist;
414  DemuxMsg msg;
415  int ret;
416 
417  if (!d->in_thread_queue) {
418  ret = thread_start(d);
419  if (ret < 0)
420  return ret;
421  }
422 
423  if (f->readrate || f->rate_emu) {
424  int i;
425  int64_t file_start = copy_ts * (
426  (f->start_time_effective != AV_NOPTS_VALUE ? f->start_time_effective * !start_at_zero : 0) +
427  (f->start_time != AV_NOPTS_VALUE ? f->start_time : 0)
428  );
429  float scale = f->rate_emu ? 1.0 : f->readrate;
430  for (i = 0; i < f->nb_streams; i++) {
431  InputStream *ist = f->streams[i];
432  int64_t stream_ts_offset, pts, now;
433  if (!ist->nb_packets || (ist->decoding_needed && !ist->got_output)) continue;
434  stream_ts_offset = FFMAX(ist->first_dts != AV_NOPTS_VALUE ? ist->first_dts : 0, file_start);
435  pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
436  now = (av_gettime_relative() - ist->start) * scale + stream_ts_offset;
437  if (pts > now)
438  return AVERROR(EAGAIN);
439  }
440  }
441 
442  ret = av_thread_message_queue_recv(d->in_thread_queue, &msg,
443  d->non_blocking ?
445  if (ret < 0)
446  return ret;
447  if (msg.looping)
448  return 1;
449 
450  ist = f->streams[msg.pkt->stream_index];
452 
453  *pkt = msg.pkt;
454  return 0;
455 }
456 
457 static void ist_free(InputStream **pist)
458 {
459  InputStream *ist = *pist;
460 
461  if (!ist)
462  return;
463 
465  av_packet_free(&ist->pkt);
466  av_dict_free(&ist->decoder_opts);
469  av_freep(&ist->filters);
470  av_freep(&ist->hwaccel_device);
471  av_freep(&ist->dts_buffer);
472 
475 
476  av_freep(pist);
477 }
478 
480 {
481  InputFile *f = *pf;
483 
484  if (!f)
485  return;
486 
487  thread_stop(d);
488 
489  for (int i = 0; i < f->nb_streams; i++)
490  ist_free(&f->streams[i]);
491  av_freep(&f->streams);
492 
493  avformat_close_input(&f->ctx);
494 
495  av_freep(pf);
496 }
497 
499  enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type)
500 
501 {
502  char *codec_name = NULL;
503 
504  MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st);
505  if (codec_name) {
506  const AVCodec *codec = find_codec_or_die(NULL, codec_name, st->codecpar->codec_type, 0);
507  st->codecpar->codec_id = codec->id;
508  if (recast_media && st->codecpar->codec_type != codec->type)
509  st->codecpar->codec_type = codec->type;
510  return codec;
511  } else {
512  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
513  hwaccel_id == HWACCEL_GENERIC &&
514  hwaccel_device_type != AV_HWDEVICE_TYPE_NONE) {
515  const AVCodec *c;
516  void *i = NULL;
517 
518  while ((c = av_codec_iterate(&i))) {
519  const AVCodecHWConfig *config;
520 
521  if (c->id != st->codecpar->codec_id ||
523  continue;
524 
525  for (int j = 0; config = avcodec_get_hw_config(c, j); j++) {
526  if (config->device_type == hwaccel_device_type) {
527  av_log(NULL, AV_LOG_VERBOSE, "Selecting decoder '%s' because of requested hwaccel method %s\n",
528  c->name, av_hwdevice_get_type_name(hwaccel_device_type));
529  return c;
530  }
531  }
532  }
533  }
534 
536  }
537 }
538 
540 {
541  AVCodecContext *dec = ist->dec_ctx;
542 
544  char layout_name[256];
545 
546  if (dec->ch_layout.nb_channels > ist->guess_layout_max)
547  return 0;
550  return 0;
551  av_channel_layout_describe(&dec->ch_layout, layout_name, sizeof(layout_name));
552  av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream "
553  "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name);
554  }
555  return 1;
556 }
557 
560 {
561  double rotation = DBL_MAX;
562  int hflip = -1, vflip = -1;
563  int hflip_set = 0, vflip_set = 0, rotation_set = 0;
564  int32_t *buf;
565 
566  MATCH_PER_STREAM_OPT(display_rotations, dbl, rotation, ctx, st);
567  MATCH_PER_STREAM_OPT(display_hflips, i, hflip, ctx, st);
568  MATCH_PER_STREAM_OPT(display_vflips, i, vflip, ctx, st);
569 
570  rotation_set = rotation != DBL_MAX;
571  hflip_set = hflip != -1;
572  vflip_set = vflip != -1;
573 
574  if (!rotation_set && !hflip_set && !vflip_set)
575  return;
576 
578  if (!buf) {
579  av_log(NULL, AV_LOG_FATAL, "Failed to generate a display matrix!\n");
580  exit_program(1);
581  }
582 
584  rotation_set ? -(rotation) : -0.0f);
585 
587  hflip_set ? hflip : 0,
588  vflip_set ? vflip : 0);
589 }
590 
591 /* Add all the streams from the given input file to the demuxer */
592 static void add_input_streams(const OptionsContext *o, Demuxer *d)
593 {
594  InputFile *f = &d->f;
595  AVFormatContext *ic = f->ctx;
596  int i, ret;
597 
598  for (i = 0; i < ic->nb_streams; i++) {
599  AVStream *st = ic->streams[i];
600  AVCodecParameters *par = st->codecpar;
601  InputStream *ist;
602  char *framerate = NULL, *hwaccel_device = NULL;
603  const char *hwaccel = NULL;
604  char *hwaccel_output_format = NULL;
605  char *codec_tag = NULL;
606  char *next;
607  char *discard_str = NULL;
608  const AVClass *cc = avcodec_get_class();
609  const AVOption *discard_opt = av_opt_find(&cc, "skip_frame", NULL,
611 
612  ist = ALLOC_ARRAY_ELEM(f->streams, f->nb_streams);
613  ist->st = st;
614  ist->file_index = f->index;
615  ist->discard = 1;
616  st->discard = AVDISCARD_ALL;
617  ist->nb_samples = 0;
618  ist->first_dts = AV_NOPTS_VALUE;
619  ist->min_pts = INT64_MAX;
620  ist->max_pts = INT64_MIN;
621 
622  ist->ts_scale = 1.0;
623  MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
624 
625  ist->autorotate = 1;
627 
628  MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
629  if (codec_tag) {
630  uint32_t tag = strtol(codec_tag, &next, 0);
631  if (*next)
632  tag = AV_RL32(codec_tag);
633  st->codecpar->codec_tag = tag;
634  }
635 
636  if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
637  add_display_matrix_to_stream(o, ic, st);
638 
639  MATCH_PER_STREAM_OPT(hwaccels, str, hwaccel, ic, st);
640  MATCH_PER_STREAM_OPT(hwaccel_output_formats, str,
641  hwaccel_output_format, ic, st);
642 
643  if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "cuvid")) {
645  "WARNING: defaulting hwaccel_output_format to cuda for compatibility "
646  "with old commandlines. This behaviour is DEPRECATED and will be removed "
647  "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n");
649  } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "qsv")) {
651  "WARNING: defaulting hwaccel_output_format to qsv for compatibility "
652  "with old commandlines. This behaviour is DEPRECATED and will be removed "
653  "in the future. Please explicitly set \"-hwaccel_output_format qsv\".\n");
655  } else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel, "mediacodec")) {
656  // There is no real AVHWFrameContext implementation. Set
657  // hwaccel_output_format to avoid av_hwframe_transfer_data error.
659  } else if (hwaccel_output_format) {
660  ist->hwaccel_output_format = av_get_pix_fmt(hwaccel_output_format);
662  av_log(NULL, AV_LOG_FATAL, "Unrecognised hwaccel output "
663  "format: %s", hwaccel_output_format);
664  }
665  } else {
667  }
668 
669  if (hwaccel) {
670  // The NVDEC hwaccels use a CUDA device, so remap the name here.
671  if (!strcmp(hwaccel, "nvdec") || !strcmp(hwaccel, "cuvid"))
672  hwaccel = "cuda";
673 
674  if (!strcmp(hwaccel, "none"))
675  ist->hwaccel_id = HWACCEL_NONE;
676  else if (!strcmp(hwaccel, "auto"))
677  ist->hwaccel_id = HWACCEL_AUTO;
678  else {
680  if (type != AV_HWDEVICE_TYPE_NONE) {
682  ist->hwaccel_device_type = type;
683  }
684 
685  if (!ist->hwaccel_id) {
686  av_log(NULL, AV_LOG_FATAL, "Unrecognized hwaccel: %s.\n",
687  hwaccel);
688  av_log(NULL, AV_LOG_FATAL, "Supported hwaccels: ");
690  while ((type = av_hwdevice_iterate_types(type)) !=
692  av_log(NULL, AV_LOG_FATAL, "%s ",
694  av_log(NULL, AV_LOG_FATAL, "\n");
695  exit_program(1);
696  }
697  }
698  }
699 
700  MATCH_PER_STREAM_OPT(hwaccel_devices, str, hwaccel_device, ic, st);
701  if (hwaccel_device) {
702  ist->hwaccel_device = av_strdup(hwaccel_device);
703  if (!ist->hwaccel_device)
704  report_and_exit(AVERROR(ENOMEM));
705  }
706 
708  }
709 
710  ist->dec = choose_decoder(o, ic, st, ist->hwaccel_id, ist->hwaccel_device_type);
711  ist->decoder_opts = filter_codec_opts(o->g->codec_opts, ist->st->codecpar->codec_id, ic, st, ist->dec);
712 
713  ist->reinit_filters = -1;
714  MATCH_PER_STREAM_OPT(reinit_filters, i, ist->reinit_filters, ic, st);
715 
716  MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
718 
719  if ((o->video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ||
724 
725  if (discard_str && av_opt_eval_int(&cc, discard_opt, discard_str, &ist->user_set_discard) < 0) {
726  av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
727  discard_str);
728  exit_program(1);
729  }
730 
733 
734  ist->dec_ctx = avcodec_alloc_context3(ist->dec);
735  if (!ist->dec_ctx)
736  report_and_exit(AVERROR(ENOMEM));
737 
739  if (ret < 0) {
740  av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder context.\n");
741  exit_program(1);
742  }
743 
744  ist->decoded_frame = av_frame_alloc();
745  if (!ist->decoded_frame)
746  report_and_exit(AVERROR(ENOMEM));
747 
748  ist->pkt = av_packet_alloc();
749  if (!ist->pkt)
750  report_and_exit(AVERROR(ENOMEM));
751 
752  if (o->bitexact)
754 
755  switch (par->codec_type) {
756  case AVMEDIA_TYPE_VIDEO:
757  // avformat_find_stream_info() doesn't set this for us anymore.
758  ist->dec_ctx->framerate = st->avg_frame_rate;
759 
760  MATCH_PER_STREAM_OPT(frame_rates, str, framerate, ic, st);
762  framerate) < 0) {
763  av_log(NULL, AV_LOG_ERROR, "Error parsing framerate %s.\n",
764  framerate);
765  exit_program(1);
766  }
767 
768  ist->top_field_first = -1;
769  MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, st);
770 
772 
773  break;
774  case AVMEDIA_TYPE_AUDIO:
775  ist->guess_layout_max = INT_MAX;
776  MATCH_PER_STREAM_OPT(guess_layout_max, i, ist->guess_layout_max, ic, st);
778  break;
779  case AVMEDIA_TYPE_DATA:
780  case AVMEDIA_TYPE_SUBTITLE: {
781  char *canvas_size = NULL;
782  MATCH_PER_STREAM_OPT(fix_sub_duration, i, ist->fix_sub_duration, ic, st);
783  MATCH_PER_STREAM_OPT(canvas_sizes, str, canvas_size, ic, st);
784  if (canvas_size &&
785  av_parse_video_size(&ist->dec_ctx->width, &ist->dec_ctx->height, canvas_size) < 0) {
786  av_log(NULL, AV_LOG_FATAL, "Invalid canvas size: %s.\n", canvas_size);
787  exit_program(1);
788  }
789  break;
790  }
793  break;
794  default:
795  abort();
796  }
797 
798  ist->par = avcodec_parameters_alloc();
799  if (!ist->par)
800  report_and_exit(AVERROR(ENOMEM));
801 
803  if (ret < 0) {
804  av_log(NULL, AV_LOG_ERROR, "Error initializing the decoder context.\n");
805  exit_program(1);
806  }
807  }
808 }
809 
810 static void dump_attachment(AVStream *st, const char *filename)
811 {
812  int ret;
813  AVIOContext *out = NULL;
814  const AVDictionaryEntry *e;
815 
816  if (!st->codecpar->extradata_size) {
817  av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream #%d:%d.\n",
818  nb_input_files - 1, st->index);
819  return;
820  }
821  if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0)))
822  filename = e->value;
823  if (!*filename) {
824  av_log(NULL, AV_LOG_FATAL, "No filename specified and no 'filename' tag"
825  "in stream #%d:%d.\n", nb_input_files - 1, st->index);
826  exit_program(1);
827  }
828 
829  assert_file_overwrite(filename);
830 
831  if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) {
832  av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n",
833  filename);
834  exit_program(1);
835  }
836 
838  avio_flush(out);
839  avio_close(out);
840 }
841 
842 int ifile_open(const OptionsContext *o, const char *filename)
843 {
844  Demuxer *d;
845  InputFile *f;
846  AVFormatContext *ic;
848  int err, i, ret;
849  int64_t timestamp;
850  AVDictionary *unused_opts = NULL;
851  const AVDictionaryEntry *e = NULL;
852  char * video_codec_name = NULL;
853  char * audio_codec_name = NULL;
854  char *subtitle_codec_name = NULL;
855  char * data_codec_name = NULL;
856  int scan_all_pmts_set = 0;
857 
858  int64_t start_time = o->start_time;
859  int64_t start_time_eof = o->start_time_eof;
860  int64_t stop_time = o->stop_time;
861  int64_t recording_time = o->recording_time;
862 
863  if (stop_time != INT64_MAX && recording_time != INT64_MAX) {
864  stop_time = INT64_MAX;
865  av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; using -t.\n");
866  }
867 
868  if (stop_time != INT64_MAX && recording_time == INT64_MAX) {
869  int64_t start = start_time == AV_NOPTS_VALUE ? 0 : start_time;
870  if (stop_time <= start) {
871  av_log(NULL, AV_LOG_ERROR, "-to value smaller than -ss; aborting.\n");
872  exit_program(1);
873  } else {
874  recording_time = stop_time - start;
875  }
876  }
877 
878  if (o->format) {
880  av_log(NULL, AV_LOG_FATAL, "Unknown input format: '%s'\n", o->format);
881  exit_program(1);
882  }
883  }
884 
885  if (!strcmp(filename, "-"))
886  filename = "fd:";
887 
888  stdin_interaction &= strncmp(filename, "pipe:", 5) &&
889  strcmp(filename, "fd:") &&
890  strcmp(filename, "/dev/stdin");
891 
892  /* get default parameters from command line */
893  ic = avformat_alloc_context();
894  if (!ic)
895  report_and_exit(AVERROR(ENOMEM));
896  if (o->nb_audio_sample_rate) {
897  av_dict_set_int(&o->g->format_opts, "sample_rate", o->audio_sample_rate[o->nb_audio_sample_rate - 1].u.i, 0);
898  }
899  if (o->nb_audio_channels) {
900  const AVClass *priv_class;
901  if (file_iformat && (priv_class = file_iformat->priv_class) &&
902  av_opt_find(&priv_class, "ch_layout", NULL, 0,
904  char buf[32];
905  snprintf(buf, sizeof(buf), "%dC", o->audio_channels[o->nb_audio_channels - 1].u.i);
906  av_dict_set(&o->g->format_opts, "ch_layout", buf, 0);
907  }
908  }
909  if (o->nb_audio_ch_layouts) {
910  const AVClass *priv_class;
911  if (file_iformat && (priv_class = file_iformat->priv_class) &&
912  av_opt_find(&priv_class, "ch_layout", NULL, 0,
914  av_dict_set(&o->g->format_opts, "ch_layout", o->audio_ch_layouts[o->nb_audio_ch_layouts - 1].u.str, 0);
915  }
916  }
917  if (o->nb_frame_rates) {
918  const AVClass *priv_class;
919  /* set the format-level framerate option;
920  * this is important for video grabbers, e.g. x11 */
921  if (file_iformat && (priv_class = file_iformat->priv_class) &&
922  av_opt_find(&priv_class, "framerate", NULL, 0,
924  av_dict_set(&o->g->format_opts, "framerate",
925  o->frame_rates[o->nb_frame_rates - 1].u.str, 0);
926  }
927  }
928  if (o->nb_frame_sizes) {
929  av_dict_set(&o->g->format_opts, "video_size", o->frame_sizes[o->nb_frame_sizes - 1].u.str, 0);
930  }
931  if (o->nb_frame_pix_fmts)
932  av_dict_set(&o->g->format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
933 
934  MATCH_PER_TYPE_OPT(codec_names, str, video_codec_name, ic, "v");
935  MATCH_PER_TYPE_OPT(codec_names, str, audio_codec_name, ic, "a");
936  MATCH_PER_TYPE_OPT(codec_names, str, subtitle_codec_name, ic, "s");
937  MATCH_PER_TYPE_OPT(codec_names, str, data_codec_name, ic, "d");
938 
939  if (video_codec_name)
941  if (audio_codec_name)
945  if (data_codec_name)
946  ic->data_codec = find_codec_or_die(NULL, data_codec_name , AVMEDIA_TYPE_DATA , 0);
947 
951  ic->data_codec_id = data_codec_name ? ic->data_codec->id : AV_CODEC_ID_NONE;
952 
953  ic->flags |= AVFMT_FLAG_NONBLOCK;
954  if (o->bitexact)
955  ic->flags |= AVFMT_FLAG_BITEXACT;
957 
958  if (!av_dict_get(o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE)) {
959  av_dict_set(&o->g->format_opts, "scan_all_pmts", "1", AV_DICT_DONT_OVERWRITE);
960  scan_all_pmts_set = 1;
961  }
962  /* open the input file with generic avformat function */
963  err = avformat_open_input(&ic, filename, file_iformat, &o->g->format_opts);
964  if (err < 0) {
965  print_error(filename, err);
966  if (err == AVERROR_PROTOCOL_NOT_FOUND)
967  av_log(NULL, AV_LOG_ERROR, "Did you mean file:%s?\n", filename);
968  exit_program(1);
969  }
970  if (scan_all_pmts_set)
971  av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
974 
975  /* apply forced codec ids */
976  for (i = 0; i < ic->nb_streams; i++)
978 
979  if (o->find_stream_info) {
981  int orig_nb_streams = ic->nb_streams;
982 
983  /* If not enough info to get the stream parameters, we decode the
984  first frames to get it. (used in mpeg case for example) */
986 
987  for (i = 0; i < orig_nb_streams; i++)
988  av_dict_free(&opts[i]);
989  av_freep(&opts);
990 
991  if (ret < 0) {
992  av_log(NULL, AV_LOG_FATAL, "%s: could not find codec parameters\n", filename);
993  if (ic->nb_streams == 0) {
995  exit_program(1);
996  }
997  }
998  }
999 
1000  if (start_time != AV_NOPTS_VALUE && start_time_eof != AV_NOPTS_VALUE) {
1001  av_log(NULL, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss for %s\n", filename);
1002  start_time_eof = AV_NOPTS_VALUE;
1003  }
1004 
1005  if (start_time_eof != AV_NOPTS_VALUE) {
1006  if (start_time_eof >= 0) {
1007  av_log(NULL, AV_LOG_ERROR, "-sseof value must be negative; aborting\n");
1008  exit_program(1);
1009  }
1010  if (ic->duration > 0) {
1011  start_time = start_time_eof + ic->duration;
1012  if (start_time < 0) {
1013  av_log(NULL, AV_LOG_WARNING, "-sseof value seeks to before start of file %s; ignored\n", filename);
1015  }
1016  } else
1017  av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename);
1018  }
1019  timestamp = (start_time == AV_NOPTS_VALUE) ? 0 : start_time;
1020  /* add the stream start time */
1021  if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE)
1022  timestamp += ic->start_time;
1023 
1024  /* if seeking requested, we execute it */
1025  if (start_time != AV_NOPTS_VALUE) {
1026  int64_t seek_timestamp = timestamp;
1027 
1028  if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) {
1029  int dts_heuristic = 0;
1030  for (i=0; i<ic->nb_streams; i++) {
1031  const AVCodecParameters *par = ic->streams[i]->codecpar;
1032  if (par->video_delay) {
1033  dts_heuristic = 1;
1034  break;
1035  }
1036  }
1037  if (dts_heuristic) {
1038  seek_timestamp -= 3*AV_TIME_BASE / 23;
1039  }
1040  }
1041  ret = avformat_seek_file(ic, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0);
1042  if (ret < 0) {
1043  av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",
1044  filename, (double)timestamp / AV_TIME_BASE);
1045  }
1046  }
1047 
1049  f = &d->f;
1050 
1051  f->ctx = ic;
1052  f->index = nb_input_files - 1;
1053  f->start_time = start_time;
1054  f->recording_time = recording_time;
1055  f->input_sync_ref = o->input_sync_ref;
1056  f->input_ts_offset = o->input_ts_offset;
1057  f->ts_offset = o->input_ts_offset - (copy_ts ? (start_at_zero && ic->start_time != AV_NOPTS_VALUE ? ic->start_time : 0) : timestamp);
1058  f->rate_emu = o->rate_emu;
1059  f->accurate_seek = o->accurate_seek;
1060  d->loop = o->loop;
1061  d->duration = 0;
1062  d->time_base = (AVRational){ 1, 1 };
1063 
1064  f->readrate = o->readrate ? o->readrate : 0.0;
1065  if (f->readrate < 0.0f) {
1066  av_log(NULL, AV_LOG_ERROR, "Option -readrate for Input #%d is %0.3f; it must be non-negative.\n", f->index, f->readrate);
1067  exit_program(1);
1068  }
1069  if (f->readrate && f->rate_emu) {
1070  av_log(NULL, AV_LOG_WARNING, "Both -readrate and -re set for Input #%d. Using -readrate %0.3f.\n", f->index, f->readrate);
1071  f->rate_emu = 0;
1072  }
1073 
1074  d->thread_queue_size = o->thread_queue_size;
1075 
1076  /* update the current parameters so that they match the one of the input stream */
1077  add_input_streams(o, d);
1078 
1079  /* dump the file content */
1080  av_dump_format(ic, f->index, filename, 0);
1081 
1082  /* check if all codec options have been used */
1083  unused_opts = strip_specifiers(o->g->codec_opts);
1084  for (i = 0; i < f->nb_streams; i++) {
1085  e = NULL;
1086  while ((e = av_dict_iterate(f->streams[i]->decoder_opts, e)))
1087  av_dict_set(&unused_opts, e->key, NULL, 0);
1088  }
1089 
1090  e = NULL;
1091  while ((e = av_dict_iterate(unused_opts, e))) {
1092  const AVClass *class = avcodec_get_class();
1093  const AVOption *option = av_opt_find(&class, e->key, NULL, 0,
1095  const AVClass *fclass = avformat_get_class();
1096  const AVOption *foption = av_opt_find(&fclass, e->key, NULL, 0,
1098  if (!option || foption)
1099  continue;
1100 
1101 
1102  if (!(option->flags & AV_OPT_FLAG_DECODING_PARAM)) {
1103  av_log(NULL, AV_LOG_ERROR, "Codec AVOption %s (%s) specified for "
1104  "input file #%d (%s) is not a decoding option.\n", e->key,
1105  option->help ? option->help : "", f->index,
1106  filename);
1107  exit_program(1);
1108  }
1109 
1110  av_log(NULL, AV_LOG_WARNING, "Codec AVOption %s (%s) specified for "
1111  "input file #%d (%s) has not been used for any stream. The most "
1112  "likely reason is either wrong type (e.g. a video option with "
1113  "no video streams) or that it is a private option of some decoder "
1114  "which was not actually used for any stream.\n", e->key,
1115  option->help ? option->help : "", f->index, filename);
1116  }
1117  av_dict_free(&unused_opts);
1118 
1119  for (i = 0; i < o->nb_dump_attachment; i++) {
1120  int j;
1121 
1122  for (j = 0; j < ic->nb_streams; j++) {
1123  AVStream *st = ic->streams[j];
1124 
1125  if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1)
1127  }
1128  }
1129 
1130  return 0;
1131 }
OptionsContext::readrate
float readrate
Definition: ffmpeg.h:126
input_thread
static void * input_thread(void *arg)
Definition: ffmpeg_demux.c:237
av_packet_unref
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
Definition: avpacket.c:422
AVCodec
AVCodec.
Definition: codec.h:184
OptionsContext::input_ts_offset
int64_t input_ts_offset
Definition: ffmpeg.h:123
pthread_join
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
Definition: os2threads.h:94
AVMEDIA_TYPE_SUBTITLE
@ AVMEDIA_TYPE_SUBTITLE
Definition: avutil.h:204
av_gettime_relative
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
Definition: time.c:56
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:253
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:76
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:158
InputStream::hwaccel_device
char * hwaccel_device
Definition: ffmpeg.h:424
OptionsContext::dump_attachment
SpecifierOpt * dump_attachment
Definition: ffmpeg.h:134
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:144
opt.h
OptionsContext::nb_audio_sample_rate
int nb_audio_sample_rate
Definition: ffmpeg.h:112
MATCH_PER_STREAM_OPT
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)
Definition: ffmpeg.h:873
AVCodecParameters::codec_type
enum AVMediaType codec_type
General type of the encoded data.
Definition: codec_par.h:58
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
InputStream::framerate_guessed
AVRational framerate_guessed
Definition: ffmpeg.h:358
avio_close
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Definition: aviobuf.c:1247
out
FILE * out
Definition: movenc.c:54
ifile_open
int ifile_open(const OptionsContext *o, const char *filename)
Definition: ffmpeg_demux.c:842
is
The official guide to swscale for confused that is
Definition: swscale.txt:28
OptionsContext::nb_audio_ch_layouts
int nb_audio_ch_layouts
Definition: ffmpeg.h:108
AVCodecParameters
This struct describes the properties of an encoded stream.
Definition: codec_par.h:54
ALLOC_ARRAY_ELEM
#define ALLOC_ARRAY_ELEM(array, nb_elems)
Definition: cmdutils.h:445
thread.h
ifile_duration_update
static void ifile_duration_update(Demuxer *d, InputStream *ist, int64_t last_duration)
Definition: ffmpeg_demux.c:102
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVStream::discard
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
Definition: avformat.h:909
MATCH_PER_TYPE_OPT
#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)
Definition: ffmpeg.h:890
avcodec_parameters_from_context
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
Definition: codec_par.c:99
remove_avoptions
void remove_avoptions(AVDictionary **a, AVDictionary *b)
Definition: ffmpeg.c:620
InputStream::dec_ctx
AVCodecContext * dec_ctx
Definition: ffmpeg.h:353
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:260
InputStream::user_set_discard
int user_set_discard
Definition: ffmpeg.h:339
avformat_get_class
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
Definition: options.c:203
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:99
AV_THREAD_MESSAGE_NONBLOCK
@ AV_THREAD_MESSAGE_NONBLOCK
Perform non-blocking operation.
Definition: threadmessage.h:31
pixdesc.h
AVFormatContext::streams
AVStream ** streams
A list of all streams in the file.
Definition: avformat.h:1172
ifile_close
void ifile_close(InputFile **pf)
Definition: ffmpeg_demux.c:479
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:345
AV_HWDEVICE_TYPE_NONE
@ AV_HWDEVICE_TYPE_NONE
Definition: hwcontext.h:28
LastFrameDuration::stream_idx
int stream_idx
Definition: ffmpeg.h:446
OptionsContext::subtitle_disable
int subtitle_disable
Definition: ffmpeg.h:168
AVOption
AVOption.
Definition: opt.h:251
ts_fixup
static void ts_fixup(Demuxer *d, AVPacket *pkt, int *repeat_pict)
Definition: ffmpeg_demux.c:169
AVStream::avg_frame_rate
AVRational avg_frame_rate
Average framerate.
Definition: avformat.h:927
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:83
ffmpeg.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
float.h
av_hwdevice_iterate_types
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)
Iterate over supported device types.
Definition: hwcontext.c:102
OptionsContext::bitexact
int bitexact
Definition: ffmpeg.h:164
autorotate
static int autorotate
Definition: ffplay.c:355
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:392
OptionsContext::audio_channels
SpecifierOpt * audio_channels
Definition: ffmpeg.h:109
DemuxMsg::pkt
AVPacket * pkt
Definition: ffmpeg_demux.c:76
OptionsContext::nb_frame_rates
int nb_frame_rates
Definition: ffmpeg.h:114
AVCodecParameters::codec_tag
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
Definition: codec_par.h:66
AVDictionary
Definition: dict.c:32
AVChannelLayout::order
enum AVChannelOrder order
Channel order used in this layout.
Definition: channel_layout.h:306
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:1439
AVFormatContext::video_codec_id
enum AVCodecID video_codec_id
Forced video codec_id.
Definition: avformat.h:1276
InputStream::decoding_needed
int decoding_needed
Definition: ffmpeg.h:340
LastFrameDuration
Definition: ffmpeg.h:445
OptionsContext::format
const char * format
Definition: ffmpeg.h:103
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:311
tf_sess_config.config
config
Definition: tf_sess_config.py:33
file_iformat
static const AVInputFormat * file_iformat
Definition: ffplay.c:310
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:73
choose_decoder
static const AVCodec * choose_decoder(const OptionsContext *o, AVFormatContext *s, AVStream *st, enum HWAccelID hwaccel_id, enum AVHWDeviceType hwaccel_device_type)
Definition: ffmpeg_demux.c:498
exit_program
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
Definition: cmdutils.c:99
SpecifierOpt::i
int i
Definition: cmdutils.h:138
InputStream
Definition: ffmpeg.h:335
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:1750
debug_ts
int debug_ts
Definition: ffmpeg_opt.c:79
framerate
int framerate
Definition: h264_levels.c:65
avformat_close_input
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: demux.c:369
AVFormatContext::interrupt_callback
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
Definition: avformat.h:1368
Demuxer
Definition: ffmpeg_demux.c:55
OptionsContext::rate_emu
int rate_emu
Definition: ffmpeg.h:125
opt_name_fix_sub_duration
static const char *const opt_name_fix_sub_duration[]
Definition: ffmpeg_demux.c:43
print_error
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
Definition: cmdutils.c:799
avio_open2
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: aviobuf.c:1241
finish
static void finish(void)
Definition: movenc.c:342
assert_file_overwrite
void assert_file_overwrite(const char *filename)
Definition: ffmpeg_opt.c:656
AVFMT_SEEK_TO_PTS
#define AVFMT_SEEK_TO_PTS
Seeking is based on PTS.
Definition: avformat.h:501
opt_name_display_vflips
static const char *const opt_name_display_vflips[]
Definition: ffmpeg_demux.c:53
OptionsContext::nb_dump_attachment
int nb_dump_attachment
Definition: ffmpeg.h:135
OptionsContext::g
OptionGroup * g
Definition: ffmpeg.h:97
AVCodecContext::ch_layout
AVChannelLayout ch_layout
Audio channel layout.
Definition: avcodec.h:2054
report_and_exit
void report_and_exit(int ret)
Reports an error corresponding to the provided AVERROR code and calls exit_program() with the corresp...
Definition: cmdutils.c:93
InputStream::sub2video
struct InputStream::sub2video sub2video
fail
#define fail()
Definition: checkasm.h:134
opt_name_hwaccel_output_formats
static const char *const opt_name_hwaccel_output_formats[]
Definition: ffmpeg_demux.c:49
InputStream::decoder_opts
AVDictionary * decoder_opts
Definition: ffmpeg.h:391
opt_name_autorotate
static const char *const opt_name_autorotate[]
Definition: ffmpeg_demux.c:50
InputStream::filter_in_rescale_delta_last
int64_t filter_in_rescale_delta_last
Definition: ffmpeg.h:378
AVDISCARD_NONE
@ AVDISCARD_NONE
discard nothing
Definition: defs.h:70
AVCodecContext::flags
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:506
InputStream::nb_packets
uint64_t nb_packets
Definition: ffmpeg.h:434
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
opt_name_display_hflips
static const char *const opt_name_display_hflips[]
Definition: ffmpeg_demux.c:52
scale
static av_always_inline float scale(float x, float s)
Definition: vf_v360.c:1389
pts
static int64_t pts
Definition: transcode_aac.c:653
av_thread_message_queue_recv
int av_thread_message_queue_recv(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Receive a message from the queue.
Definition: threadmessage.c:174
OptionsContext
Definition: ffmpeg.h:96
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
do_pkt_dump
int do_pkt_dump
Definition: ffmpeg_opt.c:75
AVRational::num
int num
Numerator.
Definition: rational.h:59
Demuxer::f
InputFile f
Definition: ffmpeg_demux.c:56
InputFile
Definition: ffmpeg.h:450
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:409
ifile_get_packet
int ifile_get_packet(InputFile *f, AVPacket **pkt)
Get next input packet from the demuxer.
Definition: ffmpeg_demux.c:410
OptionsContext::recording_time
int64_t recording_time
Definition: ffmpeg.h:157
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:87
InputStream::last_pkt_repeat_pict
int last_pkt_repeat_pict
Definition: ffmpeg.h:376
OptionsContext::audio_disable
int audio_disable
Definition: ffmpeg.h:167
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:887
InputStream::first_dts
int64_t first_dts
dts of the first packet read for this stream (in AV_TIME_BASE units)
Definition: ffmpeg.h:365
InputStream::hwaccel_pix_fmt
enum AVPixelFormat hwaccel_pix_fmt
Definition: ffmpeg.h:428
avassert.h
InputStream::dts
int64_t dts
dts of the last packet read for this stream (in AV_TIME_BASE units)
Definition: ffmpeg.h:366
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
opt_name_display_rotations
static const char *const opt_name_display_rotations[]
Definition: ffmpeg_demux.c:51
AVInputFormat
Definition: avformat.h:546
AVFormatContext::subtitle_codec
const AVCodec * subtitle_codec
Forced subtitle codec.
Definition: avformat.h:1586
AV_PKT_FLAG_CORRUPT
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
Definition: packet.h:430
OptionGroup::codec_opts
AVDictionary * codec_opts
Definition: cmdutils.h:257
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:629
av_thread_message_queue_send
int av_thread_message_queue_send(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Send a message on the queue.
Definition: threadmessage.c:158
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:221
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:60
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:778
HWACCEL_GENERIC
@ HWACCEL_GENERIC
Definition: ffmpeg.h:72
dump_attachment
static void dump_attachment(AVStream *st, const char *filename)
Definition: ffmpeg_demux.c:810
avcodec_alloc_context3
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
Definition: options.c:153
opt_name_discard
static const char *const opt_name_discard[]
Definition: ffmpeg_demux.c:41
SpecifierOpt::specifier
char * specifier
stream/chapter/program/...
Definition: cmdutils.h:135
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:256
InputStream::framerate
AVRational framerate
Definition: ffmpeg.h:392
opt_name_hwaccel_devices
static const char *const opt_name_hwaccel_devices[]
Definition: ffmpeg_demux.c:48
AVFormatContext::flags
int flags
Flags modifying the (de)muxer behaviour.
Definition: avformat.h:1222
AVFormatContext::iformat
const struct AVInputFormat * iformat
The input container format.
Definition: avformat.h:1116
AVDictionaryEntry::key
char * key
Definition: dict.h:90
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
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
OptionsContext::audio_ch_layouts
SpecifierOpt * audio_ch_layouts
Definition: ffmpeg.h:107
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
AVHWDeviceType
AVHWDeviceType
Definition: hwcontext.h:27
AVIO_FLAG_WRITE
#define AVIO_FLAG_WRITE
write-only
Definition: avio.h:624
ctx
AVFormatContext * ctx
Definition: movenc.c:48
InputStream::filters
InputFilter ** filters
Definition: ffmpeg.h:416
Demuxer::nb_streams_warn
int nb_streams_warn
Definition: ffmpeg_demux.c:67
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
opt_name_canvas_sizes
static const char *const opt_name_canvas_sizes[]
Definition: ffmpeg_demux.c:44
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:93
AVThreadMessageQueue
Definition: threadmessage.c:27
OptionsContext::accurate_seek
int accurate_seek
Definition: ffmpeg.h:127
av_usleep
int av_usleep(unsigned usec)
Sleep for a period of time.
Definition: time.c:84
AVMEDIA_TYPE_DATA
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
Definition: avutil.h:203
opt_name_ts_scale
static const char *const opt_name_ts_scale[]
Definition: ffmpeg_demux.c:46
assert_avoptions
void assert_avoptions(AVDictionary *m)
Definition: ffmpeg.c:629
AV_PIX_FMT_MEDIACODEC
@ AV_PIX_FMT_MEDIACODEC
hardware decoding through MediaCodec
Definition: pixfmt.h:313
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:1772
arg
const char * arg
Definition: jacosubdec.c:67
pthread_create
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
Definition: os2threads.h:80
option
option
Definition: libkvazaar.c:312
avio_flush
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:244
AVCodecParserContext::repeat_pict
int repeat_pict
This field is used for proper frame duration computation in lavf.
Definition: avcodec.h:2830
OptionsContext::start_time
int64_t start_time
Definition: ffmpeg.h:100
AVDISCARD_ALL
@ AVDISCARD_ALL
discard all
Definition: defs.h:76
AVFormatContext
Format I/O context.
Definition: avformat.h:1104
AVFormatContext::audio_codec_id
enum AVCodecID audio_codec_id
Forced audio codec_id.
Definition: avformat.h:1282
opts
AVDictionary * opts
Definition: movenc.c:50
OptionGroup::format_opts
AVDictionary * format_opts
Definition: cmdutils.h:258
opt_name_guess_layout_max
static const char *const opt_name_guess_layout_max[]
Definition: ffmpeg_demux.c:45
AVStream::codecpar
AVCodecParameters * codecpar
Codec parameters associated with this stream.
Definition: avformat.h:861
demuxer_from_ifile
static Demuxer * demuxer_from_ifile(InputFile *f)
Definition: ffmpeg_demux.c:83
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:187
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:877
NULL
#define NULL
Definition: coverity.c:32
InputStream::top_field_first
int top_field_first
Definition: ffmpeg.h:393
InputStream::st
AVStream * st
Definition: ffmpeg.h:337
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:63
OptionsContext::frame_sizes
SpecifierOpt * frame_sizes
Definition: ffmpeg.h:117
AVCodec::type
enum AVMediaType type
Definition: codec.h:197
avcodec_free_context
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
Definition: options.c:168
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
parseutils.h
InputStream::hwaccel_id
enum HWAccelID hwaccel_id
Definition: ffmpeg.h:422
AVStream::metadata
AVDictionary * metadata
Definition: avformat.h:918
InputStream::fix_sub_duration
int fix_sub_duration
Definition: ffmpeg.h:398
InputStream::hwaccel_output_format
enum AVPixelFormat hwaccel_output_format
Definition: ffmpeg.h:425
AV_DICT_DONT_OVERWRITE
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Definition: dict.h:81
time.h
AV_PIX_FMT_QSV
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
Definition: pixfmt.h:240
AVFormatContext::audio_codec
const AVCodec * audio_codec
Forced audio codec.
Definition: avformat.h:1578
OptionsContext::input_sync_ref
int input_sync_ref
Definition: ffmpeg.h:129
av_packet_move_ref
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
Definition: avpacket.c:479
InputStream::min_pts
int64_t min_pts
Definition: ffmpeg.h:380
report_new_stream
static void report_new_stream(Demuxer *d, const AVPacket *pkt)
Definition: ffmpeg_demux.c:88
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
InputStream::par
AVCodecParameters * par
Codec parameters - to be used by the decoding/streamcopy code.
Definition: ffmpeg.h:352
input_files
InputFile ** input_files
Definition: ffmpeg.c:143
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:571
error.h
avcodec_find_decoder
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
Definition: allcodecs.c:964
recast_media
int recast_media
Definition: ffmpeg_opt.c:100
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:80
AVFormatContext::nb_streams
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
Definition: avformat.h:1160
av_codec_is_decoder
int av_codec_is_decoder(const AVCodec *codec)
Definition: utils.c:83
AVFormatContext::data_codec
const AVCodec * data_codec
Forced data codec.
Definition: avformat.h:1594
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:2425
f
f
Definition: af_crystalizer.c:122
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
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:76
InputStream::hwaccel_device_type
enum AVHWDeviceType hwaccel_device_type
Definition: ffmpeg.h:423
OptionsContext::thread_queue_size
int thread_queue_size
Definition: ffmpeg.h:128
InputStream::decoded_frame
AVFrame * decoded_frame
Definition: ffmpeg.h:355
InputStream::wrap_correction_done
int wrap_correction_done
Definition: ffmpeg.h:370
InputStream::start
int64_t start
Definition: ffmpeg.h:361
avformat_alloc_context
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
Definition: options.c:166
threadmessage.h
InputStream::file_index
int file_index
Definition: ffmpeg.h:336
opt_name_hwaccels
static const char *const opt_name_hwaccels[]
Definition: ffmpeg_demux.c:47
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:331
InputStream::pkt
AVPacket * pkt
Definition: ffmpeg.h:356
InputStream::got_output
int got_output
Definition: ffmpeg.h:400
copy_ts
int copy_ts
Definition: ffmpeg_opt.c:76
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:659
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
OptionsContext::seek_timestamp
int seek_timestamp
Definition: ffmpeg.h:102
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:679
setup_find_stream_info_opts
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
Definition: cmdutils.c:953
Demuxer::thread
pthread_t thread
Definition: ffmpeg_demux.c:71
AVMEDIA_TYPE_UNKNOWN
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
Definition: avutil.h:200
Demuxer::thread_queue_size
int thread_queue_size
Definition: ffmpeg_demux.c:70
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:987
AV_OPT_SEARCH_CHILDREN
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
Definition: opt.h:563
AVPacket::dts
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
Definition: packet.h:373
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:222
OptionsContext::find_stream_info
int find_stream_info
Definition: ffmpeg.h:130
strip_specifiers
AVDictionary * strip_specifiers(const AVDictionary *dict)
Definition: ffmpeg_opt.c:167
InputStream::max_pts
int64_t max_pts
Definition: ffmpeg.h:381
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:380
av_packet_alloc
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition: avpacket.c:62
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
pthread_t
Definition: os2threads.h:44
OptionsContext::frame_rates
SpecifierOpt * frame_rates
Definition: ffmpeg.h:113
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:346
av_thread_message_queue_alloc
int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, unsigned nelem, unsigned elsize)
Allocate a new message queue.
Definition: threadmessage.c:42
AVCodec::id
enum AVCodecID id
Definition: codec.h:198
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:962
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:53
Demuxer::non_blocking
int non_blocking
Definition: ffmpeg_demux.c:72
HWACCEL_AUTO
@ HWACCEL_AUTO
Definition: ffmpeg.h:71
InputStream::guess_layout_max
int guess_layout_max
Definition: ffmpeg.h:394
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
DemuxMsg::looping
int looping
Definition: ffmpeg_demux.c:77
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:269
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:367
packet.h
avcodec_parameters_to_context
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
Definition: codec_par.c:182
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
find_codec_or_die
const AVCodec * find_codec_or_die(void *logctx, const char *name, enum AVMediaType type, int encoder)
Definition: ffmpeg_opt.c:626
OptionsContext::audio_sample_rate
SpecifierOpt * audio_sample_rate
Definition: ffmpeg.h:111
OptionsContext::start_time_eof
int64_t start_time_eof
Definition: ffmpeg.h:101
display.h
av_thread_message_queue_set_err_send
void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, int err)
Set the sending error code.
Definition: threadmessage.c:190
exit_on_error
int exit_on_error
Definition: ffmpeg_opt.c:80
OptionsContext::nb_frame_pix_fmts
int nb_frame_pix_fmts
Definition: ffmpeg.h:120
filter_codec_opts
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec)
Filter out options for given codec.
Definition: cmdutils.c:895
AVMEDIA_TYPE_ATTACHMENT
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
Definition: avutil.h:205
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:282
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
thread_start
static int thread_start(Demuxer *d)
Definition: ffmpeg_demux.c:363
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:500
AVCodecContext::height
int height
Definition: avcodec.h:598
AVFMT_FLAG_NONBLOCK
#define AVFMT_FLAG_NONBLOCK
Do not block when reading packets from input.
Definition: avformat.h:1225
av_codec_iterate
const AVCodec * av_codec_iterate(void **opaque)
Iterate over all registered codecs.
Definition: allcodecs.c:915
add_input_streams
static void add_input_streams(const OptionsContext *o, Demuxer *d)
Definition: ffmpeg_demux.c:592
tag
uint32_t tag
Definition: movenc.c:1641
AVFMT_FLAG_BITEXACT
#define AVFMT_FLAG_BITEXACT
When muxing, try to avoid writing any random/volatile data to the output.
Definition: avformat.h:1239
ret
ret
Definition: filter_design.txt:187
AVStream
Stream structure.
Definition: avformat.h:838
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
normalize.ifile
ifile
Definition: normalize.py:6
av_opt_eval_int
int av_opt_eval_int(void *obj, const AVOption *o, const char *val, int *int_out)
Demuxer::loop
int loop
Definition: ffmpeg_demux.c:59
InputStream::reinit_filters
int reinit_filters
Definition: ffmpeg.h:419
avformat.h
HWAccelID
HWAccelID
Definition: ffmpeg.h:69
Demuxer::duration
int64_t duration
Definition: ffmpeg_demux.c:62
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:2820
AVFormatContext::data_codec_id
enum AVCodecID data_codec_id
Forced Data codec_id.
Definition: avformat.h:1632
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
AVCodecContext
main external API structure.
Definition: avcodec.h:426
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:844
Demuxer::in_thread_queue
AVThreadMessageQueue * in_thread_queue
Definition: ffmpeg_demux.c:69
audio_codec_name
static const char * audio_codec_name
Definition: ffplay.c:344
OptionsContext::nb_audio_channels
int nb_audio_channels
Definition: ffmpeg.h:110
InputStream::prev_pkt_pts
int64_t prev_pkt_pts
Definition: ffmpeg.h:360
AVInputFormat::flags
int flags
Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, AVFMT_NOTIMESTAMPS,...
Definition: avformat.h:565
SpecifierOpt::str
uint8_t * str
Definition: cmdutils.h:137
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
OptionsContext::video_disable
int video_disable
Definition: ffmpeg.h:166
InputStream::prev_sub
struct InputStream::@3 prev_sub
InputStream::nb_samples
int64_t nb_samples
Definition: ffmpeg.h:387
OptionsContext::frame_pix_fmts
SpecifierOpt * frame_pix_fmts
Definition: ffmpeg.h:119
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:118
AVFormatContext::duration
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:1206
AVPacket::stream_index
int stream_index
Definition: packet.h:376
HWACCEL_NONE
@ HWACCEL_NONE
Definition: ffmpeg.h:70
seek_to_start
static int seek_to_start(Demuxer *d)
Definition: ffmpeg_demux.c:119
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:884
OptionsContext::nb_frame_sizes
int nb_frame_sizes
Definition: ffmpeg.h:118
InputStream::discard
int discard
Definition: ffmpeg.h:338
InputStream::sub2video::frame
AVFrame * frame
Definition: ffmpeg.h:409
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
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
start_at_zero
int start_at_zero
Definition: ffmpeg_opt.c:77
guess_input_channel_layout
static int guess_input_channel_layout(InputStream *ist)
Definition: ffmpeg_demux.c:539
SpecifierOpt::u
union SpecifierOpt::@0 u
AV_CODEC_FLAG_BITEXACT
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
Definition: avcodec.h:321
AVCodecParameters::video_delay
int video_delay
Video only.
Definition: codec_par.h:157
thread_stop
static void thread_stop(Demuxer *d)
Definition: ffmpeg_demux.c:347
AVDictionaryEntry
Definition: dict.h:89
stdin_interaction
int stdin_interaction
Definition: ffmpeg_opt.c:84
do_hex_dump
int do_hex_dump
Definition: ffmpeg_opt.c:74
AVCodecParameters::codec_id
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
Definition: codec_par.h:62
LastFrameDuration::duration
int64_t duration
Definition: ffmpeg.h:447
InputStream::ts_scale
double ts_scale
Definition: ffmpeg.h:389
AVPacket
This structure stores compressed data.
Definition: packet.h:351
DemuxMsg
Definition: ffmpeg_demux.c:75
av_thread_message_queue_free
void av_thread_message_queue_free(AVThreadMessageQueue **mq)
Free a message queue.
Definition: threadmessage.c:93
add_display_matrix_to_stream
static void add_display_matrix_to_stream(const OptionsContext *o, AVFormatContext *ctx, AVStream *st)
Definition: ffmpeg_demux.c:558
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:86
AVPacket::pos
int64_t pos
byte position in stream, -1 if unknown
Definition: packet.h:394
opt_name_reinit_filters
static const char *const opt_name_reinit_filters[]
Definition: ffmpeg_demux.c:42
OptionsContext::data_disable
int data_disable
Definition: ffmpeg.h:169
InputStream::dts_buffer
int64_t * dts_buffer
Definition: ffmpeg.h:439
av_stream_new_side_data
uint8_t * av_stream_new_side_data(AVStream *st, enum AVPacketSideDataType type, size_t size)
Allocate new information from stream.
Definition: avformat.c:191
d
d
Definition: ffmpeg_filter.c:156
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:598
int32_t
int32_t
Definition: audioconvert.c:56
ist_free
static void ist_free(InputStream **pist)
Definition: ffmpeg_demux.c:457
convert_header.str
string str
Definition: convert_header.py:20
timestamp.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
av_thread_message_queue_set_err_recv
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
Definition: threadmessage.c:201
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:1196
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:61
av_stream_get_parser
struct AVCodecParserContext * av_stream_get_parser(const AVStream *s)
Definition: demux_utils.c:32
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
AVCodecHWConfig
Definition: codec.h:338
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:117
AVDictionaryEntry::value
char * value
Definition: dict.h:91
avstring.h
AVStream::pts_wrap_bits
int pts_wrap_bits
Number of bits in timestamps.
Definition: avformat.h:1005
AVERROR_PROTOCOL_NOT_FOUND
#define AVERROR_PROTOCOL_NOT_FOUND
Protocol not found.
Definition: error.h:65
InputStream::dec
const AVCodec * dec
Definition: ffmpeg.h:354
snprintf
#define snprintf
Definition: snprintf.h:34
Demuxer::time_base
AVRational time_base
Definition: ffmpeg_demux.c:64
InputStream::subtitle
AVSubtitle subtitle
Definition: ffmpeg.h:402
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:42
AVInputFormat::priv_class
const AVClass * priv_class
AVClass for the private context.
Definition: avformat.h:576
DemuxMsg::repeat_pict
int repeat_pict
Definition: ffmpeg_demux.c:80
OptionsContext::loop
int loop
Definition: ffmpeg.h:124
InputStream::autorotate
int autorotate
Definition: ffmpeg.h:396
AVFormatContext::video_codec
const AVCodec * video_codec
Forced video codec.
Definition: avformat.h:1570
thread_set_name
static void thread_set_name(InputFile *f)
Definition: ffmpeg_demux.c:230
ff_thread_setname
static int ff_thread_setname(const char *name)
Definition: thread.h:195
AVFormatContext::subtitle_codec_id
enum AVCodecID subtitle_codec_id
Forced subtitle codec_id.
Definition: avformat.h:1288