FFmpeg
ffmpeg.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2000-2003 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * multimedia converter based on the FFmpeg libraries
24  */
25 
26 #include "config.h"
27 
28 #include <errno.h>
29 #include <limits.h>
30 #include <stdatomic.h>
31 #include <stdint.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <time.h>
35 
36 #if HAVE_IO_H
37 #include <io.h>
38 #endif
39 #if HAVE_UNISTD_H
40 #include <unistd.h>
41 #endif
42 
43 #if HAVE_SYS_RESOURCE_H
44 #include <sys/time.h>
45 #include <sys/types.h>
46 #include <sys/resource.h>
47 #elif HAVE_GETPROCESSTIMES
48 #include <windows.h>
49 #endif
50 #if HAVE_GETPROCESSMEMORYINFO
51 #include <windows.h>
52 #include <psapi.h>
53 #endif
54 #if HAVE_SETCONSOLECTRLHANDLER
55 #include <windows.h>
56 #endif
57 
58 #if HAVE_SYS_SELECT_H
59 #include <sys/select.h>
60 #endif
61 
62 #if HAVE_TERMIOS_H
63 #include <fcntl.h>
64 #include <sys/ioctl.h>
65 #include <sys/time.h>
66 #include <termios.h>
67 #elif HAVE_KBHIT
68 #include <conio.h>
69 #endif
70 
71 #include "libavutil/avassert.h"
72 #include "libavutil/avstring.h"
73 #include "libavutil/bprint.h"
75 #include "libavutil/dict.h"
76 #include "libavutil/display.h"
77 #include "libavutil/fifo.h"
78 #include "libavutil/hwcontext.h"
79 #include "libavutil/imgutils.h"
80 #include "libavutil/intreadwrite.h"
81 #include "libavutil/libm.h"
82 #include "libavutil/mathematics.h"
83 #include "libavutil/opt.h"
84 #include "libavutil/parseutils.h"
85 #include "libavutil/pixdesc.h"
86 #include "libavutil/samplefmt.h"
87 #include "libavutil/thread.h"
89 #include "libavutil/time.h"
90 #include "libavutil/timestamp.h"
91 
92 #include "libavcodec/version.h"
93 
94 #include "libavformat/avformat.h"
95 
96 #include "libavdevice/avdevice.h"
97 
99 
100 #include "cmdutils.h"
101 #include "ffmpeg.h"
102 #include "ffmpeg_utils.h"
103 #include "sync_queue.h"
104 
105 const char program_name[] = "ffmpeg";
106 const int program_birth_year = 2000;
107 
109 
110 typedef struct BenchmarkTimeStamps {
111  int64_t real_usec;
112  int64_t user_usec;
113  int64_t sys_usec;
115 
117 static int64_t getmaxrss(void);
118 
119 unsigned nb_output_dumped = 0;
120 
123 
126 
129 
132 
133 #if HAVE_TERMIOS_H
134 
135 /* init terminal so that we can grab keys */
136 static struct termios oldtty;
137 static int restore_tty;
138 #endif
139 
140 /* sub2video hack:
141  Convert subtitles to video with alpha to insert them in filter graphs.
142  This is a temporary solution until libavfilter gets real subtitles support.
143  */
144 
145 static void sub2video_heartbeat(InputFile *infile, int64_t pts, AVRational tb)
146 {
147  /* When a frame is read from a file, examine all sub2video streams in
148  the same file and send the sub2video frame again. Otherwise, decoded
149  video frames could be accumulating in the filter graph while a filter
150  (possibly overlay) is desperately waiting for a subtitle frame. */
151  for (int i = 0; i < infile->nb_streams; i++) {
152  InputStream *ist = infile->streams[i];
153 
155  continue;
156 
157  for (int j = 0; j < ist->nb_filters; j++)
159  }
160 }
161 
162 /* end of sub2video hack */
163 
164 static void term_exit_sigsafe(void)
165 {
166 #if HAVE_TERMIOS_H
167  if(restore_tty)
168  tcsetattr (0, TCSANOW, &oldtty);
169 #endif
170 }
171 
172 void term_exit(void)
173 {
174  av_log(NULL, AV_LOG_QUIET, "%s", "");
176 }
177 
178 static volatile int received_sigterm = 0;
179 static volatile int received_nb_signals = 0;
181 static volatile int ffmpeg_exited = 0;
183 
184 static void
186 {
187  int ret;
188  received_sigterm = sig;
191  if(received_nb_signals > 3) {
192  ret = write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n",
193  strlen("Received > 3 system signals, hard exiting\n"));
194  if (ret < 0) { /* Do nothing */ };
195  exit(123);
196  }
197 }
198 
199 #if HAVE_SETCONSOLECTRLHANDLER
200 static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
201 {
202  av_log(NULL, AV_LOG_DEBUG, "\nReceived windows signal %ld\n", fdwCtrlType);
203 
204  switch (fdwCtrlType)
205  {
206  case CTRL_C_EVENT:
207  case CTRL_BREAK_EVENT:
208  sigterm_handler(SIGINT);
209  return TRUE;
210 
211  case CTRL_CLOSE_EVENT:
212  case CTRL_LOGOFF_EVENT:
213  case CTRL_SHUTDOWN_EVENT:
214  sigterm_handler(SIGTERM);
215  /* Basically, with these 3 events, when we return from this method the
216  process is hard terminated, so stall as long as we need to
217  to try and let the main thread(s) clean up and gracefully terminate
218  (we have at most 5 seconds, but should be done far before that). */
219  while (!ffmpeg_exited) {
220  Sleep(0);
221  }
222  return TRUE;
223 
224  default:
225  av_log(NULL, AV_LOG_ERROR, "Received unknown windows signal %ld\n", fdwCtrlType);
226  return FALSE;
227  }
228 }
229 #endif
230 
231 #ifdef __linux__
232 #define SIGNAL(sig, func) \
233  do { \
234  action.sa_handler = func; \
235  sigaction(sig, &action, NULL); \
236  } while (0)
237 #else
238 #define SIGNAL(sig, func) \
239  signal(sig, func)
240 #endif
241 
242 void term_init(void)
243 {
244 #if defined __linux__
245  struct sigaction action = {0};
246  action.sa_handler = sigterm_handler;
247 
248  /* block other interrupts while processing this one */
249  sigfillset(&action.sa_mask);
250 
251  /* restart interruptible functions (i.e. don't fail with EINTR) */
252  action.sa_flags = SA_RESTART;
253 #endif
254 
255 #if HAVE_TERMIOS_H
256  if (stdin_interaction) {
257  struct termios tty;
258  if (tcgetattr (0, &tty) == 0) {
259  oldtty = tty;
260  restore_tty = 1;
261 
262  tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
263  |INLCR|IGNCR|ICRNL|IXON);
264  tty.c_oflag |= OPOST;
265  tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
266  tty.c_cflag &= ~(CSIZE|PARENB);
267  tty.c_cflag |= CS8;
268  tty.c_cc[VMIN] = 1;
269  tty.c_cc[VTIME] = 0;
270 
271  tcsetattr (0, TCSANOW, &tty);
272  }
273  SIGNAL(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
274  }
275 #endif
276 
277  SIGNAL(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
278  SIGNAL(SIGTERM, sigterm_handler); /* Termination (ANSI). */
279 #ifdef SIGXCPU
280  SIGNAL(SIGXCPU, sigterm_handler);
281 #endif
282 #ifdef SIGPIPE
283  signal(SIGPIPE, SIG_IGN); /* Broken pipe (POSIX). */
284 #endif
285 #if HAVE_SETCONSOLECTRLHANDLER
286  SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
287 #endif
288 }
289 
290 /* read a key without blocking */
291 static int read_key(void)
292 {
293  unsigned char ch;
294 #if HAVE_TERMIOS_H
295  int n = 1;
296  struct timeval tv;
297  fd_set rfds;
298 
299  FD_ZERO(&rfds);
300  FD_SET(0, &rfds);
301  tv.tv_sec = 0;
302  tv.tv_usec = 0;
303  n = select(1, &rfds, NULL, NULL, &tv);
304  if (n > 0) {
305  n = read(0, &ch, 1);
306  if (n == 1)
307  return ch;
308 
309  return n;
310  }
311 #elif HAVE_KBHIT
312 # if HAVE_PEEKNAMEDPIPE && HAVE_GETSTDHANDLE
313  static int is_pipe;
314  static HANDLE input_handle;
315  DWORD dw, nchars;
316  if(!input_handle){
317  input_handle = GetStdHandle(STD_INPUT_HANDLE);
318  is_pipe = !GetConsoleMode(input_handle, &dw);
319  }
320 
321  if (is_pipe) {
322  /* When running under a GUI, you will end here. */
323  if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL)) {
324  // input pipe may have been closed by the program that ran ffmpeg
325  return -1;
326  }
327  //Read it
328  if(nchars != 0) {
329  read(0, &ch, 1);
330  return ch;
331  }else{
332  return -1;
333  }
334  }
335 # endif
336  if(kbhit())
337  return(getch());
338 #endif
339  return -1;
340 }
341 
342 static int decode_interrupt_cb(void *ctx)
343 {
345 }
346 
348 
349 static void ffmpeg_cleanup(int ret)
350 {
351  int i;
352 
353  if (do_benchmark) {
354  int maxrss = getmaxrss() / 1024;
355  av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss);
356  }
357 
358  for (i = 0; i < nb_filtergraphs; i++)
361 
362  for (i = 0; i < nb_output_files; i++)
364 
365  for (i = 0; i < nb_input_files; i++)
367 
368  if (vstats_file) {
369  if (fclose(vstats_file))
371  "Error closing vstats file, loss of information possible: %s\n",
372  av_err2str(AVERROR(errno)));
373  }
376 
378 
380 
383 
384  uninit_opts();
385 
387 
388  if (received_sigterm) {
389  av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n",
390  (int) received_sigterm);
391  } else if (ret && atomic_load(&transcode_init_done)) {
392  av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
393  }
394  term_exit();
395  ffmpeg_exited = 1;
396 }
397 
399 {
400  int of_idx = prev ? prev->file_index : 0;
401  int ost_idx = prev ? prev->index + 1 : 0;
402 
403  for (; of_idx < nb_output_files; of_idx++) {
404  OutputFile *of = output_files[of_idx];
405  if (ost_idx < of->nb_streams)
406  return of->streams[ost_idx];
407 
408  ost_idx = 0;
409  }
410 
411  return NULL;
412 }
413 
415 {
416  int if_idx = prev ? prev->file_index : 0;
417  int ist_idx = prev ? prev->index + 1 : 0;
418 
419  for (; if_idx < nb_input_files; if_idx++) {
420  InputFile *f = input_files[if_idx];
421  if (ist_idx < f->nb_streams)
422  return f->streams[ist_idx];
423 
424  ist_idx = 0;
425  }
426 
427  return NULL;
428 }
429 
430 static int frame_data_ensure(AVFrame *frame, int writable)
431 {
432  if (!frame->opaque_ref) {
433  FrameData *fd;
434 
435  frame->opaque_ref = av_buffer_allocz(sizeof(*fd));
436  if (!frame->opaque_ref)
437  return AVERROR(ENOMEM);
438  fd = (FrameData*)frame->opaque_ref->data;
439 
440  fd->dec.frame_num = UINT64_MAX;
441  fd->dec.pts = AV_NOPTS_VALUE;
442  } else if (writable)
444 
445  return 0;
446 }
447 
449 {
450  int ret = frame_data_ensure(frame, 1);
451  return ret < 0 ? NULL : (FrameData*)frame->opaque_ref->data;
452 }
453 
455 {
456  int ret = frame_data_ensure(frame, 0);
457  return ret < 0 ? NULL : (const FrameData*)frame->opaque_ref->data;
458 }
459 
461 {
462  const AVDictionaryEntry *t = NULL;
463 
464  while ((t = av_dict_iterate(b, t))) {
466  }
467 }
468 
470 {
471  const AVDictionaryEntry *t;
472  if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
473  av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
475  }
476 
477  return 0;
478 }
479 
480 void update_benchmark(const char *fmt, ...)
481 {
482  if (do_benchmark_all) {
484  va_list va;
485  char buf[1024];
486 
487  if (fmt) {
488  va_start(va, fmt);
489  vsnprintf(buf, sizeof(buf), fmt, va);
490  va_end(va);
492  "bench: %8" PRIu64 " user %8" PRIu64 " sys %8" PRIu64 " real %s \n",
495  t.real_usec - current_time.real_usec, buf);
496  }
497  current_time = t;
498  }
499 }
500 
502 {
503  OutputFile *of = output_files[ost->file_index];
504  ost->finished |= ENCODER_FINISHED;
505 
506  if (ost->sq_idx_encode >= 0)
507  sq_send(of->sq_encode, ost->sq_idx_encode, SQFRAME(NULL));
508 }
509 
510 static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time)
511 {
512  AVBPrint buf, buf_script;
513  int64_t total_size = of_filesize(output_files[0]);
514  int vid;
515  double bitrate;
516  double speed;
517  int64_t pts = AV_NOPTS_VALUE;
518  static int64_t last_time = -1;
519  static int first_report = 1;
520  uint64_t nb_frames_dup = 0, nb_frames_drop = 0;
521  int mins, secs, us;
522  int64_t hours;
523  const char *hours_sign;
524  int ret;
525  float t;
526 
527  if (!print_stats && !is_last_report && !progress_avio)
528  return;
529 
530  if (!is_last_report) {
531  if (last_time == -1) {
532  last_time = cur_time;
533  }
534  if (((cur_time - last_time) < stats_period && !first_report) ||
535  (first_report && nb_output_dumped < nb_output_files))
536  return;
537  last_time = cur_time;
538  }
539 
540  t = (cur_time-timer_start) / 1000000.0;
541 
542  vid = 0;
544  av_bprint_init(&buf_script, 0, AV_BPRINT_SIZE_AUTOMATIC);
545  for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
546  const float q = ost->enc ? ost->quality / (float) FF_QP2LAMBDA : -1;
547 
548  if (vid && ost->type == AVMEDIA_TYPE_VIDEO) {
549  av_bprintf(&buf, "q=%2.1f ", q);
550  av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
551  ost->file_index, ost->index, q);
552  }
553  if (!vid && ost->type == AVMEDIA_TYPE_VIDEO && ost->filter) {
554  float fps;
555  uint64_t frame_number = atomic_load(&ost->packets_written);
556 
557  fps = t > 1 ? frame_number / t : 0;
558  av_bprintf(&buf, "frame=%5"PRId64" fps=%3.*f q=%3.1f ",
559  frame_number, fps < 9.95, fps, q);
560  av_bprintf(&buf_script, "frame=%"PRId64"\n", frame_number);
561  av_bprintf(&buf_script, "fps=%.2f\n", fps);
562  av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
563  ost->file_index, ost->index, q);
564  if (is_last_report)
565  av_bprintf(&buf, "L");
566 
567  nb_frames_dup = ost->filter->nb_frames_dup;
568  nb_frames_drop = ost->filter->nb_frames_drop;
569 
570  vid = 1;
571  }
572  /* compute min output value */
573  if (ost->last_mux_dts != AV_NOPTS_VALUE) {
574  if (pts == AV_NOPTS_VALUE || ost->last_mux_dts > pts)
575  pts = ost->last_mux_dts;
576  if (copy_ts) {
577  if (copy_ts_first_pts == AV_NOPTS_VALUE && pts > 1)
581  }
582  }
583  }
584 
586  secs = FFABS64U(pts) / AV_TIME_BASE % 60;
587  mins = FFABS64U(pts) / AV_TIME_BASE / 60 % 60;
588  hours = FFABS64U(pts) / AV_TIME_BASE / 3600;
589  hours_sign = (pts < 0) ? "-" : "";
590 
591  bitrate = pts != AV_NOPTS_VALUE && pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
592  speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
593 
594  if (total_size < 0) av_bprintf(&buf, "size=N/A time=");
595  else av_bprintf(&buf, "size=%8.0fkB time=", total_size / 1024.0);
596  if (pts == AV_NOPTS_VALUE) {
597  av_bprintf(&buf, "N/A ");
598  } else {
599  av_bprintf(&buf, "%s%02"PRId64":%02d:%02d.%02d ",
600  hours_sign, hours, mins, secs, (100 * us) / AV_TIME_BASE);
601  }
602 
603  if (bitrate < 0) {
604  av_bprintf(&buf, "bitrate=N/A");
605  av_bprintf(&buf_script, "bitrate=N/A\n");
606  }else{
607  av_bprintf(&buf, "bitrate=%6.1fkbits/s", bitrate);
608  av_bprintf(&buf_script, "bitrate=%6.1fkbits/s\n", bitrate);
609  }
610 
611  if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n");
612  else av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size);
613  if (pts == AV_NOPTS_VALUE) {
614  av_bprintf(&buf_script, "out_time_us=N/A\n");
615  av_bprintf(&buf_script, "out_time_ms=N/A\n");
616  av_bprintf(&buf_script, "out_time=N/A\n");
617  } else {
618  av_bprintf(&buf_script, "out_time_us=%"PRId64"\n", pts);
619  av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts);
620  av_bprintf(&buf_script, "out_time=%s%02"PRId64":%02d:%02d.%06d\n",
621  hours_sign, hours, mins, secs, us);
622  }
623 
624  if (nb_frames_dup || nb_frames_drop)
625  av_bprintf(&buf, " dup=%"PRId64" drop=%"PRId64, nb_frames_dup, nb_frames_drop);
626  av_bprintf(&buf_script, "dup_frames=%"PRId64"\n", nb_frames_dup);
627  av_bprintf(&buf_script, "drop_frames=%"PRId64"\n", nb_frames_drop);
628 
629  if (speed < 0) {
630  av_bprintf(&buf, " speed=N/A");
631  av_bprintf(&buf_script, "speed=N/A\n");
632  } else {
633  av_bprintf(&buf, " speed=%4.3gx", speed);
634  av_bprintf(&buf_script, "speed=%4.3gx\n", speed);
635  }
636 
637  if (print_stats || is_last_report) {
638  const char end = is_last_report ? '\n' : '\r';
639  if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
640  fprintf(stderr, "%s %c", buf.str, end);
641  } else
642  av_log(NULL, AV_LOG_INFO, "%s %c", buf.str, end);
643 
644  fflush(stderr);
645  }
646  av_bprint_finalize(&buf, NULL);
647 
648  if (progress_avio) {
649  av_bprintf(&buf_script, "progress=%s\n",
650  is_last_report ? "end" : "continue");
651  avio_write(progress_avio, buf_script.str,
652  FFMIN(buf_script.len, buf_script.size - 1));
654  av_bprint_finalize(&buf_script, NULL);
655  if (is_last_report) {
656  if ((ret = avio_closep(&progress_avio)) < 0)
658  "Error closing progress log, loss of information possible: %s\n", av_err2str(ret));
659  }
660  }
661 
662  first_report = 0;
663 }
664 
666 {
667  int ret = AVERROR_BUG;
668  AVSubtitle tmp = {
669  .format = src->format,
670  .start_display_time = src->start_display_time,
671  .end_display_time = src->end_display_time,
672  .num_rects = 0,
673  .rects = NULL,
674  .pts = src->pts
675  };
676 
677  if (!src->num_rects)
678  goto success;
679 
680  if (!(tmp.rects = av_calloc(src->num_rects, sizeof(*tmp.rects))))
681  return AVERROR(ENOMEM);
682 
683  for (int i = 0; i < src->num_rects; i++) {
684  AVSubtitleRect *src_rect = src->rects[i];
685  AVSubtitleRect *dst_rect;
686 
687  if (!(dst_rect = tmp.rects[i] = av_mallocz(sizeof(*tmp.rects[0])))) {
688  ret = AVERROR(ENOMEM);
689  goto cleanup;
690  }
691 
692  tmp.num_rects++;
693 
694  dst_rect->type = src_rect->type;
695  dst_rect->flags = src_rect->flags;
696 
697  dst_rect->x = src_rect->x;
698  dst_rect->y = src_rect->y;
699  dst_rect->w = src_rect->w;
700  dst_rect->h = src_rect->h;
701  dst_rect->nb_colors = src_rect->nb_colors;
702 
703  if (src_rect->text)
704  if (!(dst_rect->text = av_strdup(src_rect->text))) {
705  ret = AVERROR(ENOMEM);
706  goto cleanup;
707  }
708 
709  if (src_rect->ass)
710  if (!(dst_rect->ass = av_strdup(src_rect->ass))) {
711  ret = AVERROR(ENOMEM);
712  goto cleanup;
713  }
714 
715  for (int j = 0; j < 4; j++) {
716  // SUBTITLE_BITMAP images are special in the sense that they
717  // are like PAL8 images. first pointer to data, second to
718  // palette. This makes the size calculation match this.
719  size_t buf_size = src_rect->type == SUBTITLE_BITMAP && j == 1 ?
721  src_rect->h * src_rect->linesize[j];
722 
723  if (!src_rect->data[j])
724  continue;
725 
726  if (!(dst_rect->data[j] = av_memdup(src_rect->data[j], buf_size))) {
727  ret = AVERROR(ENOMEM);
728  goto cleanup;
729  }
730  dst_rect->linesize[j] = src_rect->linesize[j];
731  }
732  }
733 
734 success:
735  *dst = tmp;
736 
737  return 0;
738 
739 cleanup:
741 
742  return ret;
743 }
744 
745 static void subtitle_free(void *opaque, uint8_t *data)
746 {
747  AVSubtitle *sub = (AVSubtitle*)data;
748  avsubtitle_free(sub);
749  av_free(sub);
750 }
751 
753 {
754  AVBufferRef *buf;
755  AVSubtitle *sub;
756  int ret;
757 
758  if (copy) {
759  sub = av_mallocz(sizeof(*sub));
760  ret = sub ? copy_av_subtitle(sub, subtitle) : AVERROR(ENOMEM);
761  if (ret < 0) {
762  av_freep(&sub);
763  return ret;
764  }
765  } else {
766  sub = av_memdup(subtitle, sizeof(*subtitle));
767  if (!sub)
768  return AVERROR(ENOMEM);
769  memset(subtitle, 0, sizeof(*subtitle));
770  }
771 
772  buf = av_buffer_create((uint8_t*)sub, sizeof(*sub),
773  subtitle_free, NULL, 0);
774  if (!buf) {
775  avsubtitle_free(sub);
776  av_freep(&sub);
777  return AVERROR(ENOMEM);
778  }
779 
780  frame->buf[0] = buf;
781 
782  return 0;
783 }
784 
786 {
787  OutputFile *of = output_files[ost->file_index];
788  int64_t signal_pts = av_rescale_q(pkt->pts, pkt->time_base,
790 
791  if (!ost->fix_sub_duration_heartbeat || !(pkt->flags & AV_PKT_FLAG_KEY))
792  // we are only interested in heartbeats on streams configured, and
793  // only on random access points.
794  return 0;
795 
796  for (int i = 0; i < of->nb_streams; i++) {
797  OutputStream *iter_ost = of->streams[i];
798  InputStream *ist = iter_ost->ist;
799  int ret = AVERROR_BUG;
800 
801  if (iter_ost == ost || !ist || !ist->decoding_needed ||
803  // We wish to skip the stream that causes the heartbeat,
804  // output streams without an input stream, streams not decoded
805  // (as fix_sub_duration is only done for decoded subtitles) as
806  // well as non-subtitle streams.
807  continue;
808 
809  if ((ret = fix_sub_duration_heartbeat(ist, signal_pts)) < 0)
810  return ret;
811  }
812 
813  return 0;
814 }
815 
816 /* pkt = NULL means EOF (needed to flush decoder buffers) */
817 static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
818 {
820  int64_t dts_est = AV_NOPTS_VALUE;
821  int ret = 0;
822  int eof_reached = 0;
823 
824  if (ist->decoding_needed) {
825  ret = dec_packet(ist, pkt, no_eof);
826  if (ret < 0 && ret != AVERROR_EOF)
827  return ret;
828  }
829  if (ret == AVERROR_EOF || (!pkt && !ist->decoding_needed))
830  eof_reached = 1;
831 
832  if (pkt && pkt->opaque_ref) {
834  dts_est = pd->dts_est;
835  }
836 
837  if (f->recording_time != INT64_MAX) {
838  int64_t start_time = 0;
839  if (copy_ts) {
840  start_time += f->start_time != AV_NOPTS_VALUE ? f->start_time : 0;
841  start_time += start_at_zero ? 0 : f->start_time_effective;
842  }
843  if (dts_est >= f->recording_time + start_time)
844  pkt = NULL;
845  }
846 
847  for (int oidx = 0; oidx < ist->nb_outputs; oidx++) {
848  OutputStream *ost = ist->outputs[oidx];
849  if (ost->enc || (!pkt && no_eof))
850  continue;
851 
852  ret = of_streamcopy(ost, pkt, dts_est);
853  if (ret < 0)
854  return ret;
855  }
856 
857  return !eof_reached;
858 }
859 
860 static void print_stream_maps(void)
861 {
862  av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
863  for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
864  for (int j = 0; j < ist->nb_filters; j++) {
865  if (!filtergraph_is_simple(ist->filters[j]->graph)) {
866  av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
867  ist->file_index, ist->index, ist->dec ? ist->dec->name : "?",
868  ist->filters[j]->name);
869  if (nb_filtergraphs > 1)
870  av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
871  av_log(NULL, AV_LOG_INFO, "\n");
872  }
873  }
874  }
875 
876  for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
877  if (ost->attachment_filename) {
878  /* an attached file */
879  av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n",
880  ost->attachment_filename, ost->file_index, ost->index);
881  continue;
882  }
883 
884  if (ost->filter && !filtergraph_is_simple(ost->filter->graph)) {
885  /* output from a complex graph */
886  av_log(NULL, AV_LOG_INFO, " %s", ost->filter->name);
887  if (nb_filtergraphs > 1)
888  av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
889 
890  av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index,
891  ost->index, ost->enc_ctx->codec->name);
892  continue;
893  }
894 
895  av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
896  ost->ist->file_index,
897  ost->ist->index,
898  ost->file_index,
899  ost->index);
900  if (ost->enc_ctx) {
901  const AVCodec *in_codec = ost->ist->dec;
902  const AVCodec *out_codec = ost->enc_ctx->codec;
903  const char *decoder_name = "?";
904  const char *in_codec_name = "?";
905  const char *encoder_name = "?";
906  const char *out_codec_name = "?";
907  const AVCodecDescriptor *desc;
908 
909  if (in_codec) {
910  decoder_name = in_codec->name;
911  desc = avcodec_descriptor_get(in_codec->id);
912  if (desc)
913  in_codec_name = desc->name;
914  if (!strcmp(decoder_name, in_codec_name))
915  decoder_name = "native";
916  }
917 
918  if (out_codec) {
919  encoder_name = out_codec->name;
920  desc = avcodec_descriptor_get(out_codec->id);
921  if (desc)
922  out_codec_name = desc->name;
923  if (!strcmp(encoder_name, out_codec_name))
924  encoder_name = "native";
925  }
926 
927  av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))",
928  in_codec_name, decoder_name,
929  out_codec_name, encoder_name);
930  } else
931  av_log(NULL, AV_LOG_INFO, " (copy)");
932  av_log(NULL, AV_LOG_INFO, "\n");
933  }
934 }
935 
936 /**
937  * Select the output stream to process.
938  *
939  * @retval 0 an output stream was selected
940  * @retval AVERROR(EAGAIN) need to wait until more input is available
941  * @retval AVERROR_EOF no more streams need output
942  */
943 static int choose_output(OutputStream **post)
944 {
945  int64_t opts_min = INT64_MAX;
946  OutputStream *ost_min = NULL;
947 
948  for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
949  int64_t opts;
950 
951  if (ost->filter && ost->filter->last_pts != AV_NOPTS_VALUE) {
952  opts = ost->filter->last_pts;
953  } else {
954  opts = ost->last_mux_dts == AV_NOPTS_VALUE ?
955  INT64_MIN : ost->last_mux_dts;
956  }
957 
958  if (!ost->initialized && !ost->finished) {
959  ost_min = ost;
960  break;
961  }
962  if (!ost->finished && opts < opts_min) {
963  opts_min = opts;
964  ost_min = ost;
965  }
966  }
967  if (!ost_min)
968  return AVERROR_EOF;
969  *post = ost_min;
970  return ost_min->unavailable ? AVERROR(EAGAIN) : 0;
971 }
972 
973 static void set_tty_echo(int on)
974 {
975 #if HAVE_TERMIOS_H
976  struct termios tty;
977  if (tcgetattr(0, &tty) == 0) {
978  if (on) tty.c_lflag |= ECHO;
979  else tty.c_lflag &= ~ECHO;
980  tcsetattr(0, TCSANOW, &tty);
981  }
982 #endif
983 }
984 
985 static int check_keyboard_interaction(int64_t cur_time)
986 {
987  int i, key;
988  static int64_t last_time;
990  return AVERROR_EXIT;
991  /* read_key() returns 0 on EOF */
992  if (cur_time - last_time >= 100000) {
993  key = read_key();
994  last_time = cur_time;
995  }else
996  key = -1;
997  if (key == 'q') {
998  av_log(NULL, AV_LOG_INFO, "\n\n[q] command received. Exiting.\n\n");
999  return AVERROR_EXIT;
1000  }
1001  if (key == '+') av_log_set_level(av_log_get_level()+10);
1002  if (key == '-') av_log_set_level(av_log_get_level()-10);
1003  if (key == 'c' || key == 'C'){
1004  char buf[4096], target[64], command[256], arg[256] = {0};
1005  double time;
1006  int k, n = 0;
1007  fprintf(stderr, "\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
1008  i = 0;
1009  set_tty_echo(1);
1010  while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
1011  if (k > 0)
1012  buf[i++] = k;
1013  buf[i] = 0;
1014  set_tty_echo(0);
1015  fprintf(stderr, "\n");
1016  if (k > 0 &&
1017  (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
1018  av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
1019  target, time, command, arg);
1020  for (i = 0; i < nb_filtergraphs; i++)
1021  fg_send_command(filtergraphs[i], time, target, command, arg,
1022  key == 'C');
1023  } else {
1025  "Parse error, at least 3 arguments were expected, "
1026  "only %d given in string '%s'\n", n, buf);
1027  }
1028  }
1029  if (key == '?'){
1030  fprintf(stderr, "key function\n"
1031  "? show this help\n"
1032  "+ increase verbosity\n"
1033  "- decrease verbosity\n"
1034  "c Send command to first matching filter supporting it\n"
1035  "C Send/Queue command to all matching filters\n"
1036  "h dump packets/hex press to cycle through the 3 states\n"
1037  "q quit\n"
1038  "s Show QP histogram\n"
1039  );
1040  }
1041  return 0;
1042 }
1043 
1044 static void reset_eagain(void)
1045 {
1046  int i;
1047  for (i = 0; i < nb_input_files; i++)
1048  input_files[i]->eagain = 0;
1049  for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost))
1050  ost->unavailable = 0;
1051 }
1052 
1053 static void decode_flush(InputFile *ifile)
1054 {
1055  for (int i = 0; i < ifile->nb_streams; i++) {
1056  InputStream *ist = ifile->streams[i];
1057 
1058  if (ist->discard || !ist->decoding_needed)
1059  continue;
1060 
1061  dec_packet(ist, NULL, 1);
1062  }
1063 }
1064 
1065 /*
1066  * Return
1067  * - 0 -- one packet was read and processed
1068  * - AVERROR(EAGAIN) -- no packets were available for selected file,
1069  * this function should be called again
1070  * - AVERROR_EOF -- this function should not be called again
1071  */
1072 static int process_input(int file_index)
1073 {
1074  InputFile *ifile = input_files[file_index];
1075  InputStream *ist;
1076  AVPacket *pkt;
1077  int ret, i;
1078 
1079  ret = ifile_get_packet(ifile, &pkt);
1080 
1081  if (ret == AVERROR(EAGAIN)) {
1082  ifile->eagain = 1;
1083  return ret;
1084  }
1085  if (ret == 1) {
1086  /* the input file is looped: flush the decoders */
1087  decode_flush(ifile);
1088  return AVERROR(EAGAIN);
1089  }
1090  if (ret < 0) {
1091  if (ret != AVERROR_EOF) {
1092  av_log(ifile, AV_LOG_ERROR,
1093  "Error retrieving a packet from demuxer: %s\n", av_err2str(ret));
1094  if (exit_on_error)
1095  return ret;
1096  }
1097 
1098  for (i = 0; i < ifile->nb_streams; i++) {
1099  ist = ifile->streams[i];
1100  if (!ist->discard) {
1101  ret = process_input_packet(ist, NULL, 0);
1102  if (ret>0)
1103  return 0;
1104  else if (ret < 0)
1105  return ret;
1106  }
1107 
1108  /* mark all outputs that don't go through lavfi as finished */
1109  for (int oidx = 0; oidx < ist->nb_outputs; oidx++) {
1110  OutputStream *ost = ist->outputs[oidx];
1111  OutputFile *of = output_files[ost->file_index];
1112 
1113  ret = of_output_packet(of, ost, NULL);
1114  if (ret < 0)
1115  return ret;
1116  }
1117  }
1118 
1119  ifile->eof_reached = 1;
1120  return AVERROR(EAGAIN);
1121  }
1122 
1123  reset_eagain();
1124 
1125  ist = ifile->streams[pkt->stream_index];
1126 
1128 
1129  ret = process_input_packet(ist, pkt, 0);
1130 
1131  av_packet_free(&pkt);
1132 
1133  return ret < 0 ? ret : 0;
1134 }
1135 
1136 /**
1137  * Run a single step of transcoding.
1138  *
1139  * @return 0 for success, <0 for error
1140  */
1142 {
1143  InputStream *ist = NULL;
1144  int ret;
1145 
1146  if (ost->filter) {
1147  if ((ret = fg_transcode_step(ost->filter->graph, &ist)) < 0)
1148  return ret;
1149  if (!ist)
1150  return 0;
1151  } else {
1152  ist = ost->ist;
1153  av_assert0(ist);
1154  }
1155 
1156  ret = process_input(ist->file_index);
1157  if (ret == AVERROR(EAGAIN)) {
1158  if (input_files[ist->file_index]->eagain)
1159  ost->unavailable = 1;
1160  return 0;
1161  }
1162 
1163  if (ret < 0)
1164  return ret == AVERROR_EOF ? 0 : ret;
1165 
1166  // process_input() above might have caused output to become available
1167  // in multiple filtergraphs, so we process all of them
1168  for (int i = 0; i < nb_filtergraphs; i++) {
1169  ret = reap_filters(filtergraphs[i], 0);
1170  if (ret < 0)
1171  return ret;
1172  }
1173 
1174  return 0;
1175 }
1176 
1177 /*
1178  * The following code is the main loop of the file converter
1179  */
1180 static int transcode(int *err_rate_exceeded)
1181 {
1182  int ret = 0, i;
1183  InputStream *ist;
1184  int64_t timer_start;
1185 
1187 
1188  *err_rate_exceeded = 0;
1190 
1191  if (stdin_interaction) {
1192  av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
1193  }
1194 
1195  timer_start = av_gettime_relative();
1196 
1197  while (!received_sigterm) {
1198  OutputStream *ost;
1199  int64_t cur_time= av_gettime_relative();
1200 
1201  /* if 'q' pressed, exits */
1202  if (stdin_interaction)
1203  if (check_keyboard_interaction(cur_time) < 0)
1204  break;
1205 
1206  ret = choose_output(&ost);
1207  if (ret == AVERROR(EAGAIN)) {
1208  reset_eagain();
1209  av_usleep(10000);
1210  ret = 0;
1211  continue;
1212  } else if (ret < 0) {
1213  av_log(NULL, AV_LOG_VERBOSE, "No more output streams to write to, finishing.\n");
1214  ret = 0;
1215  break;
1216  }
1217 
1218  ret = transcode_step(ost);
1219  if (ret < 0 && ret != AVERROR_EOF) {
1220  av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret));
1221  break;
1222  }
1223 
1224  /* dump report by using the output first video and audio streams */
1225  print_report(0, timer_start, cur_time);
1226  }
1227 
1228  /* at the end of stream, we must flush the decoder buffers */
1229  for (ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
1230  float err_rate;
1231 
1232  if (!input_files[ist->file_index]->eof_reached) {
1233  int err = process_input_packet(ist, NULL, 0);
1234  ret = err_merge(ret, err);
1235  }
1236 
1237  err_rate = (ist->frames_decoded || ist->decode_errors) ?
1238  ist->decode_errors / (ist->frames_decoded + ist->decode_errors) : 0.f;
1239  if (err_rate > max_error_rate) {
1240  av_log(ist, AV_LOG_FATAL, "Decode error rate %g exceeds maximum %g\n",
1241  err_rate, max_error_rate);
1242  *err_rate_exceeded = 1;
1243  } else if (err_rate)
1244  av_log(ist, AV_LOG_VERBOSE, "Decode error rate %g\n", err_rate);
1245  }
1246  ret = err_merge(ret, enc_flush());
1247 
1248  term_exit();
1249 
1250  /* write the trailer if needed */
1251  for (i = 0; i < nb_output_files; i++) {
1252  int err = of_write_trailer(output_files[i]);
1253  ret = err_merge(ret, err);
1254  }
1255 
1256  /* dump report by using the first video and audio streams */
1257  print_report(1, timer_start, av_gettime_relative());
1258 
1259  return ret;
1260 }
1261 
1263 {
1264  BenchmarkTimeStamps time_stamps = { av_gettime_relative() };
1265 #if HAVE_GETRUSAGE
1266  struct rusage rusage;
1267 
1268  getrusage(RUSAGE_SELF, &rusage);
1269  time_stamps.user_usec =
1270  (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
1271  time_stamps.sys_usec =
1272  (rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec;
1273 #elif HAVE_GETPROCESSTIMES
1274  HANDLE proc;
1275  FILETIME c, e, k, u;
1276  proc = GetCurrentProcess();
1277  GetProcessTimes(proc, &c, &e, &k, &u);
1278  time_stamps.user_usec =
1279  ((int64_t)u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
1280  time_stamps.sys_usec =
1281  ((int64_t)k.dwHighDateTime << 32 | k.dwLowDateTime) / 10;
1282 #else
1283  time_stamps.user_usec = time_stamps.sys_usec = 0;
1284 #endif
1285  return time_stamps;
1286 }
1287 
1288 static int64_t getmaxrss(void)
1289 {
1290 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
1291  struct rusage rusage;
1292  getrusage(RUSAGE_SELF, &rusage);
1293  return (int64_t)rusage.ru_maxrss * 1024;
1294 #elif HAVE_GETPROCESSMEMORYINFO
1295  HANDLE proc;
1296  PROCESS_MEMORY_COUNTERS memcounters;
1297  proc = GetCurrentProcess();
1298  memcounters.cb = sizeof(memcounters);
1299  GetProcessMemoryInfo(proc, &memcounters, sizeof(memcounters));
1300  return memcounters.PeakPagefileUsage;
1301 #else
1302  return 0;
1303 #endif
1304 }
1305 
1306 int main(int argc, char **argv)
1307 {
1308  int ret, err_rate_exceeded;
1310 
1311  init_dynload();
1312 
1313  setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
1314 
1316  parse_loglevel(argc, argv, options);
1317 
1318 #if CONFIG_AVDEVICE
1320 #endif
1322 
1323  show_banner(argc, argv, options);
1324 
1325  /* parse options and open all input/output files */
1326  ret = ffmpeg_parse_options(argc, argv);
1327  if (ret < 0)
1328  goto finish;
1329 
1330  if (nb_output_files <= 0 && nb_input_files == 0) {
1331  show_usage();
1332  av_log(NULL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name);
1333  ret = 1;
1334  goto finish;
1335  }
1336 
1337  if (nb_output_files <= 0) {
1338  av_log(NULL, AV_LOG_FATAL, "At least one output file must be specified\n");
1339  ret = 1;
1340  goto finish;
1341  }
1342 
1344  ret = transcode(&err_rate_exceeded);
1345  if (ret >= 0 && do_benchmark) {
1346  int64_t utime, stime, rtime;
1348  utime = current_time.user_usec - ti.user_usec;
1349  stime = current_time.sys_usec - ti.sys_usec;
1350  rtime = current_time.real_usec - ti.real_usec;
1352  "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
1353  utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);
1354  }
1355 
1356  ret = received_nb_signals ? 255 :
1357  err_rate_exceeded ? 69 : ret;
1358 
1359 finish:
1360  if (ret == AVERROR_EXIT)
1361  ret = 0;
1362 
1364  return ret;
1365 }
AVSubtitle
Definition: avcodec.h:2269
AVCodec
AVCodec.
Definition: codec.h:187
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
of_streamcopy
int of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts)
Definition: ffmpeg_mux.c:407
atomic_store
#define atomic_store(object, desired)
Definition: stdatomic.h:85
reset_eagain
static void reset_eagain(void)
Definition: ffmpeg.c:1044
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:125
opt.h
ffmpeg_exited
static volatile int ffmpeg_exited
Definition: ffmpeg.c:181
libm.h
FrameData
Definition: ffmpeg.h:629
close_output_stream
void close_output_stream(OutputStream *ost)
Definition: ffmpeg.c:501
enc_flush
int enc_flush(void)
Definition: ffmpeg_enc.c:863
av_bprint_init
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
Definition: bprint.c:69
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:240
AV_LOG_QUIET
#define AV_LOG_QUIET
Print no output.
Definition: log.h:162
reap_filters
int reap_filters(FilterGraph *fg, int flush)
Get and encode new output from specified filtergraph, without causing activity.
Definition: ffmpeg_filter.c:2242
thread.h
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
fg_free
void fg_free(FilterGraph **pfg)
Definition: ffmpeg_filter.c:806
remove_avoptions
void remove_avoptions(AVDictionary **a, AVDictionary *b)
Definition: ffmpeg.c:460
InputStream::outputs
struct OutputStream ** outputs
Definition: ffmpeg.h:374
InputStream::dec_ctx
AVCodecContext * dec_ctx
Definition: ffmpeg.h:344
AV_TIME_BASE_Q
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
Definition: avutil.h:264
BenchmarkTimeStamps::user_usec
int64_t user_usec
Definition: ffmpeg.c:112
AVSubtitleRect
Definition: avcodec.h:2241
ist_iter
InputStream * ist_iter(InputStream *prev)
Definition: ffmpeg.c:414
SQFRAME
#define SQFRAME(frame)
Definition: sync_queue.h:38
ffmpeg_parse_options
int ffmpeg_parse_options(int argc, char **argv)
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
tmp
static uint8_t tmp[11]
Definition: aes_ctr.c:28
pixdesc.h
cleanup
static av_cold void cleanup(FlashSV2Context *s)
Definition: flashsv2enc.c:130
of_filesize
int64_t of_filesize(OutputFile *of)
Definition: ffmpeg_mux.c:948
OutputStream::unavailable
int unavailable
Definition: ffmpeg.h:574
sync_queue.h
current_time
static BenchmarkTimeStamps current_time
Definition: ffmpeg.c:121
OutputStream::index
int index
Definition: ffmpeg.h:513
ATOMIC_VAR_INIT
#define ATOMIC_VAR_INIT(value)
Definition: stdatomic.h:31
b
#define b
Definition: input.c:41
nb_output_dumped
unsigned nb_output_dumped
Definition: ffmpeg.c:119
data
const char data[16]
Definition: mxf.c:148
InputStream::nb_filters
int nb_filters
Definition: ffmpeg.h:367
atomic_int
intptr_t atomic_int
Definition: stdatomic.h:55
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:75
version.h
AVSubtitleRect::linesize
int linesize[4]
Definition: avcodec.h:2253
ffmpeg.h
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
BenchmarkTimeStamps::sys_usec
int64_t sys_usec
Definition: ffmpeg.c:113
progress_avio
AVIOContext * progress_avio
Definition: ffmpeg.c:122
show_usage
void show_usage(void)
Definition: ffmpeg_opt.c:1248
mathematics.h
AVDictionary
Definition: dict.c:34
program_birth_year
const int program_birth_year
program birth year, defined by the program for show_banner()
Definition: ffmpeg.c:106
InputStream::decoding_needed
int decoding_needed
Definition: ffmpeg.h:333
AVFrame::buf
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:590
ost
static AVStream * ost
Definition: vaapi_transcode.c:42
AV_PKT_FLAG_KEY
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
Definition: packet.h:546
OutputStream::ist
InputStream * ist
Definition: ffmpeg.h:524
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
term_exit_sigsafe
static void term_exit_sigsafe(void)
Definition: ffmpeg.c:164
ECHO
#define ECHO(name, type, min, max)
Definition: af_aecho.c:157
AVIOInterruptCB
Callback for checking whether to abort blocking functions.
Definition: avio.h:59
InputStream::nb_outputs
int nb_outputs
Definition: ffmpeg.h:375
FrameData::frame_num
uint64_t frame_num
Definition: ffmpeg.h:632
OutputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:617
av_memdup
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
Definition: mem.c:302
AVFrame::opaque_ref
AVBufferRef * opaque_ref
Frame owner's private data.
Definition: frame.h:768
InputFile::eof_reached
int eof_reached
Definition: ffmpeg.h:401
InputStream
Definition: ffmpeg.h:324
filter_nbthreads
char * filter_nbthreads
Definition: ffmpeg_opt.c:87
stats_period
int64_t stats_period
Definition: ffmpeg_opt.c:91
fifo.h
finish
static void finish(void)
Definition: movenc.c:342
AVPacket::opaque_ref
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: packet.h:527
samplefmt.h
AVSubtitleRect::x
int x
top left corner of pict, undefined when pict is not set
Definition: avcodec.h:2242
AVERROR_OPTION_NOT_FOUND
#define AVERROR_OPTION_NOT_FOUND
Option not found.
Definition: error.h:63
AV_BPRINT_SIZE_AUTOMATIC
#define AV_BPRINT_SIZE_AUTOMATIC
update_benchmark
void update_benchmark(const char *fmt,...)
Definition: ffmpeg.c:480
DemuxPktData
Definition: ffmpeg.h:104
pts
static int64_t pts
Definition: transcode_aac.c:643
us
#define us(width, name, range_min, range_max, subs,...)
Definition: cbs_h2645.c:252
trigger_fix_sub_duration_heartbeat
int trigger_fix_sub_duration_heartbeat(OutputStream *ost, const AVPacket *pkt)
Definition: ffmpeg.c:785
fg_send_command
void fg_send_command(FilterGraph *fg, double time, const char *target, const char *command, const char *arg, int all_filters)
Definition: ffmpeg_filter.c:1832
avformat_network_init
int avformat_network_init(void)
Do global initialization of network libraries.
Definition: utils.c:558
InputFile
Definition: ffmpeg.h:392
AVSubtitleRect::ass
char * ass
0 terminated ASS/SSA compatible event line.
Definition: avcodec.h:2264
avsubtitle_free
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
Definition: avcodec.c:413
ffmpeg_cleanup
static void ffmpeg_cleanup(int ret)
Definition: ffmpeg.c:349
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
decode_flush
static void decode_flush(InputFile *ifile)
Definition: ffmpeg.c:1053
BenchmarkTimeStamps::real_usec
int64_t real_usec
Definition: ffmpeg.c:111
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
fg_transcode_step
int fg_transcode_step(FilterGraph *graph, InputStream **best_ist)
Perform a step of transcoding for the specified filter graph.
Definition: ffmpeg_filter.c:2466
float
float
Definition: af_crystalizer.c:121
of_free
void of_free(OutputFile **pof)
Definition: ffmpeg_mux.c:921
AVCodecDescriptor
This struct describes the properties of a single codec described by an AVCodecID.
Definition: codec_desc.h:38
intreadwrite.h
get_benchmark_time_stamps
static BenchmarkTimeStamps get_benchmark_time_stamps(void)
Definition: ffmpeg.c:1262
vstats_filename
char * vstats_filename
Definition: ffmpeg_opt.c:65
copy_ts_first_pts
static int64_t copy_ts_first_pts
Definition: ffmpeg.c:182
ifilter_sub2video_heartbeat
void ifilter_sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational tb)
Definition: ffmpeg_filter.c:2262
bitrate
int64_t bitrate
Definition: av1_levels.c:47
AVDictionaryEntry::key
char * key
Definition: dict.h:90
ENCODER_FINISHED
@ ENCODER_FINISHED
Definition: ffmpeg.h:478
AVSubtitleRect::y
int y
top left corner of pict, undefined when pict is not set
Definition: avcodec.h:2243
subtitle_wrap_frame
int subtitle_wrap_frame(AVFrame *frame, AVSubtitle *subtitle, int copy)
Definition: ffmpeg.c:752
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
term_init
void term_init(void)
Definition: ffmpeg.c:242
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:48
InputStream::filters
InputFilter ** filters
Definition: ffmpeg.h:366
limits.h
nb_streams
static int nb_streams
Definition: ffprobe.c:328
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
max_error_rate
float max_error_rate
Definition: ffmpeg_opt.c:86
on
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going on
Definition: writing_filters.txt:34
term_exit
void term_exit(void)
Definition: ffmpeg.c:172
ffmpeg_utils.h
key
const char * key
Definition: hwcontext_opencl.c:174
av_usleep
int av_usleep(unsigned usec)
Sleep for a period of time.
Definition: time.c:84
atomic_load
#define atomic_load(object)
Definition: stdatomic.h:93
AVSubtitleRect::text
char * text
0 terminated plain UTF-8 text
Definition: avcodec.h:2257
process_input_packet
static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
Definition: ffmpeg.c:817
process_input
static int process_input(int file_index)
Definition: ffmpeg.c:1072
transcode
static int transcode(int *err_rate_exceeded)
Definition: ffmpeg.c:1180
frame
static AVFrame * frame
Definition: demux_decode.c:54
arg
const char * arg
Definition: jacosubdec.c:67
of_enc_stats_close
void of_enc_stats_close(void)
Definition: ffmpeg_mux_init.c:235
avio_flush
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
Definition: aviobuf.c:270
av_log_get_level
int av_log_get_level(void)
Get the current log level.
Definition: log.c:442
init_dynload
void init_dynload(void)
Initialize dynamic library loading.
Definition: cmdutils.c:77
opts
AVDictionary * opts
Definition: movenc.c:50
AVSubtitleRect::w
int w
width of pict, undefined when pict is not set
Definition: avcodec.h:2244
NULL
#define NULL
Definition: coverity.c:32
main
int main(int argc, char **argv)
Definition: ffmpeg.c:1306
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
getmaxrss
static int64_t getmaxrss(void)
Definition: ffmpeg.c:1288
AVPALETTE_SIZE
#define AVPALETTE_SIZE
Definition: pixfmt.h:32
check_keyboard_interaction
static int check_keyboard_interaction(int64_t cur_time)
Definition: ffmpeg.c:985
DemuxPktData::dts_est
int64_t dts_est
Definition: ffmpeg.h:107
av_log_set_flags
void av_log_set_flags(int arg)
Definition: log.c:452
AVSubtitleRect::data
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
Definition: avcodec.h:2252
transcode_step
static int transcode_step(OutputStream *ost)
Run a single step of transcoding.
Definition: ffmpeg.c:1141
parseutils.h
print_stream_maps
static void print_stream_maps(void)
Definition: ffmpeg.c:860
vstats_file
FILE * vstats_file
Definition: ffmpeg.c:108
ifile_get_packet
int ifile_get_packet(InputFile *f, AVPacket **pkt)
Get next input packet from the demuxer.
Definition: ffmpeg_demux.c:707
ost_iter
OutputStream * ost_iter(OutputStream *prev)
Definition: ffmpeg.c:398
double
double
Definition: af_crystalizer.c:131
time.h
sub2video_heartbeat
static void sub2video_heartbeat(InputFile *infile, int64_t pts, AVRational tb)
Definition: ffmpeg.c:145
received_nb_signals
static volatile int received_nb_signals
Definition: ffmpeg.c:179
do_benchmark_all
int do_benchmark_all
Definition: ffmpeg_opt.c:75
swresample.h
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
av_buffer_create
AVBufferRef * av_buffer_create(uint8_t *data, size_t size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
Definition: buffer.c:55
input_files
InputFile ** input_files
Definition: ffmpeg.c:124
OutputFile::streams
OutputStream ** streams
Definition: ffmpeg.h:616
InputStream::frames_decoded
uint64_t frames_decoded
Definition: ffmpeg.h:387
FilterGraph
Definition: ffmpeg.h:310
subtitle_free
static void subtitle_free(void *opaque, uint8_t *data)
Definition: ffmpeg.c:745
print_stats
int print_stats
Definition: ffmpeg_opt.c:84
decode_interrupt_cb
static int decode_interrupt_cb(void *ctx)
Definition: ffmpeg.c:342
options
const OptionDef options[]
f
f
Definition: af_crystalizer.c:121
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
copy
static void copy(const float *p1, float *p2, const int length)
Definition: vf_vaguedenoiser.c:185
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:240
threadmessage.h
InputStream::file_index
int file_index
Definition: ffmpeg.h:327
output_files
OutputFile ** output_files
Definition: ffmpeg.c:127
SIGNAL
#define SIGNAL(sig, func)
Definition: ffmpeg.c:238
FrameData::dec
struct FrameData::@3 dec
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
copy_av_subtitle
int copy_av_subtitle(AVSubtitle *dst, const AVSubtitle *src)
Definition: ffmpeg.c:665
received_sigterm
static volatile int received_sigterm
Definition: ffmpeg.c:178
start_time
static int64_t start_time
Definition: ffplay.c:329
filtergraph_is_simple
int filtergraph_is_simple(const FilterGraph *fg)
Definition: ffmpeg_filter.c:1826
sq_send
int sq_send(SyncQueue *sq, unsigned int stream_idx, SyncQueueFrame frame)
Submit a frame for the stream with index stream_idx.
Definition: sync_queue.c:343
uninit_opts
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
Definition: cmdutils.c:64
copy_ts
int copy_ts
Definition: ffmpeg_opt.c:78
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
check_avoptions
int check_avoptions(AVDictionary *m)
Definition: ffmpeg.c:469
frame_data
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
Definition: ffmpeg.c:448
av_buffer_make_writable
int av_buffer_make_writable(AVBufferRef **pbuf)
Create a writable reference from a given buffer reference, avoiding data copy if possible.
Definition: buffer.c:165
avdevice.h
AVSubtitleRect::type
enum AVSubtitleType type
Definition: avcodec.h:2255
show_banner
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
Definition: opt_common.c:237
fix_sub_duration_heartbeat
int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts)
Definition: ffmpeg_dec.c:455
avio_write
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:248
a
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Definition: undefined.txt:41
FrameData::pts
int64_t pts
Definition: ffmpeg.h:634
frame_data_ensure
static int frame_data_ensure(AVFrame *frame, int writable)
Definition: ffmpeg.c:430
AVPacket::flags
int flags
A combination of AV_PKT_FLAG values.
Definition: packet.h:497
do_benchmark
int do_benchmark
Definition: ffmpeg_opt.c:74
OutputFile::sq_encode
SyncQueue * sq_encode
Definition: ffmpeg.h:619
SUBTITLE_BITMAP
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
Definition: avcodec.h:2224
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVCodec::id
enum AVCodecID id
Definition: codec.h:201
AVSubtitleRect::flags
int flags
Definition: avcodec.h:2266
avio_closep
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
Definition: aviobuf.c:1304
of_output_packet
int of_output_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
Definition: ffmpeg_mux.c:350
av_log_set_level
void av_log_set_level(int level)
Set the log level.
Definition: log.c:447
bprint.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:245
AVPacket::pts
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
Definition: packet.h:484
AVSubtitleRect::nb_colors
int nb_colors
number of colors in pict, undefined when pict is not set
Definition: avcodec.h:2246
AV_TIME_BASE
#define AV_TIME_BASE
Internal time base represented as integer.
Definition: avutil.h:254
display.h
vsnprintf
#define vsnprintf
Definition: snprintf.h:36
exit_on_error
int exit_on_error
Definition: ffmpeg_opt.c:82
sigterm_handler
static void sigterm_handler(int sig)
Definition: ffmpeg.c:185
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
tb
#define tb
Definition: regdef.h:68
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:254
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
filtergraphs
FilterGraph ** filtergraphs
Definition: ffmpeg.c:130
int_cb
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:347
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:262
nb_output_files
int nb_output_files
Definition: ffmpeg.c:128
parse_loglevel
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
Definition: cmdutils.c:474
av_buffer_allocz
AVBufferRef * av_buffer_allocz(size_t size)
Same as av_buffer_alloc(), except the returned buffer will be initialized to zero.
Definition: buffer.c:93
ret
ret
Definition: filter_design.txt:187
AV_LOG_FATAL
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:174
AVSubtitleRect::h
int h
height of pict, undefined when pict is not set
Definition: avcodec.h:2245
dec_packet
int dec_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
Submit a packet for decoding.
Definition: ffmpeg_dec.c:767
InputFile::streams
InputStream ** streams
Definition: ffmpeg.h:416
hw_device_free_all
void hw_device_free_all(void)
Definition: ffmpeg_hw.c:288
avformat.h
InputFile::eagain
int eagain
Definition: ffmpeg.h:402
av_bprintf
void av_bprintf(AVBPrint *buf, const char *fmt,...)
Definition: bprint.c:99
dict.h
AV_LOG_SKIP_REPEATED
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
Definition: log.h:370
AV_DICT_MATCH_CASE
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
Definition: dict.h:74
ifile_close
void ifile_close(InputFile **f)
Definition: ffmpeg_demux.c:791
avformat_network_deinit
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
Definition: utils.c:570
AVStream::index
int index
stream index in AVFormatContext
Definition: avformat.h:847
transcode_init_done
static atomic_int transcode_init_done
Definition: ffmpeg.c:180
BenchmarkTimeStamps
Definition: ffmpeg.c:110
channel_layout.h
program_name
const char program_name[]
program name, defined by the program for show_version().
Definition: ffmpeg.c:105
AVPacket::stream_index
int stream_index
Definition: packet.h:493
InputStream::decode_errors
uint64_t decode_errors
Definition: ffmpeg.h:389
InputStream::discard
int discard
Definition: ffmpeg.h:331
print_report
static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time)
Definition: ffmpeg.c:510
AVCodecContext::codec_type
enum AVMediaType codec_type
Definition: avcodec.h:449
av_strdup
char * av_strdup(const char *s)
Duplicate a string.
Definition: mem.c:270
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
start_at_zero
int start_at_zero
Definition: ffmpeg_opt.c:79
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
OutputStream::file_index
int file_index
Definition: ffmpeg.h:512
InputStream::index
int index
Definition: ffmpeg.h:328
av_free
#define av_free(p)
Definition: tableprint_vlc.h:33
AVDictionaryEntry
Definition: dict.h:89
stdin_interaction
int stdin_interaction
Definition: ffmpeg_opt.c:85
AVPacket
This structure stores compressed data.
Definition: packet.h:468
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
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
cmdutils.h
nb_filtergraphs
int nb_filtergraphs
Definition: ffmpeg.c:131
imgutils.h
timestamp.h
OutputStream
Definition: mux.c:53
hwcontext.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FFABS64U
#define FFABS64U(a)
Definition: common.h:83
AVERROR_EXIT
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
Definition: error.h:58
avcodec_descriptor_get
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
Definition: codec_desc.c:3736
set_tty_echo
static void set_tty_echo(int on)
Definition: ffmpeg.c:973
avstring.h
FF_QP2LAMBDA
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
Definition: avutil.h:227
InputFile::nb_streams
int nb_streams
Definition: ffmpeg.h:417
frame_data_c
const FrameData * frame_data_c(AVFrame *frame)
Definition: ffmpeg.c:454
read_key
static int read_key(void)
Definition: ffmpeg.c:291
of_write_trailer
int of_write_trailer(OutputFile *of)
Definition: ffmpeg_mux.c:800
choose_output
static int choose_output(OutputStream **post)
Select the output stream to process.
Definition: ffmpeg.c:943
av_dict_iterate
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
Definition: dict.c:44
read
static uint32_t BS_FUNC() read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
Definition: bitstream_template.h:231
AVPacket::time_base
AVRational time_base
Time base of the packet's timestamps.
Definition: packet.h:535
OutputFile
Definition: ffmpeg.h:608
avdevice_register_all
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
Definition: alldevices.c:65