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_sched.h"
103 #include "ffmpeg_utils.h"
104 #include "sync_queue.h"
105 
106 const char program_name[] = "ffmpeg";
107 const int program_birth_year = 2000;
108 
110 
111 typedef struct BenchmarkTimeStamps {
112  int64_t real_usec;
113  int64_t user_usec;
114  int64_t sys_usec;
116 
118 static int64_t getmaxrss(void);
119 
121 
124 
127 
130 
133 
134 #if HAVE_TERMIOS_H
135 
136 /* init terminal so that we can grab keys */
137 static struct termios oldtty;
138 static int restore_tty;
139 #endif
140 
141 static void term_exit_sigsafe(void)
142 {
143 #if HAVE_TERMIOS_H
144  if(restore_tty)
145  tcsetattr (0, TCSANOW, &oldtty);
146 #endif
147 }
148 
149 void term_exit(void)
150 {
151  av_log(NULL, AV_LOG_QUIET, "%s", "");
153 }
154 
155 static volatile int received_sigterm = 0;
156 static volatile int received_nb_signals = 0;
158 static volatile int ffmpeg_exited = 0;
160 
161 static void
163 {
164  int ret;
165  received_sigterm = sig;
168  if(received_nb_signals > 3) {
169  ret = write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n",
170  strlen("Received > 3 system signals, hard exiting\n"));
171  if (ret < 0) { /* Do nothing */ };
172  exit(123);
173  }
174 }
175 
176 #if HAVE_SETCONSOLECTRLHANDLER
177 static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
178 {
179  av_log(NULL, AV_LOG_DEBUG, "\nReceived windows signal %ld\n", fdwCtrlType);
180 
181  switch (fdwCtrlType)
182  {
183  case CTRL_C_EVENT:
184  case CTRL_BREAK_EVENT:
185  sigterm_handler(SIGINT);
186  return TRUE;
187 
188  case CTRL_CLOSE_EVENT:
189  case CTRL_LOGOFF_EVENT:
190  case CTRL_SHUTDOWN_EVENT:
191  sigterm_handler(SIGTERM);
192  /* Basically, with these 3 events, when we return from this method the
193  process is hard terminated, so stall as long as we need to
194  to try and let the main thread(s) clean up and gracefully terminate
195  (we have at most 5 seconds, but should be done far before that). */
196  while (!ffmpeg_exited) {
197  Sleep(0);
198  }
199  return TRUE;
200 
201  default:
202  av_log(NULL, AV_LOG_ERROR, "Received unknown windows signal %ld\n", fdwCtrlType);
203  return FALSE;
204  }
205 }
206 #endif
207 
208 #ifdef __linux__
209 #define SIGNAL(sig, func) \
210  do { \
211  action.sa_handler = func; \
212  sigaction(sig, &action, NULL); \
213  } while (0)
214 #else
215 #define SIGNAL(sig, func) \
216  signal(sig, func)
217 #endif
218 
219 void term_init(void)
220 {
221 #if defined __linux__
222  struct sigaction action = {0};
223  action.sa_handler = sigterm_handler;
224 
225  /* block other interrupts while processing this one */
226  sigfillset(&action.sa_mask);
227 
228  /* restart interruptible functions (i.e. don't fail with EINTR) */
229  action.sa_flags = SA_RESTART;
230 #endif
231 
232 #if HAVE_TERMIOS_H
233  if (stdin_interaction) {
234  struct termios tty;
235  if (tcgetattr (0, &tty) == 0) {
236  oldtty = tty;
237  restore_tty = 1;
238 
239  tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
240  |INLCR|IGNCR|ICRNL|IXON);
241  tty.c_oflag |= OPOST;
242  tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
243  tty.c_cflag &= ~(CSIZE|PARENB);
244  tty.c_cflag |= CS8;
245  tty.c_cc[VMIN] = 1;
246  tty.c_cc[VTIME] = 0;
247 
248  tcsetattr (0, TCSANOW, &tty);
249  }
250  SIGNAL(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
251  }
252 #endif
253 
254  SIGNAL(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
255  SIGNAL(SIGTERM, sigterm_handler); /* Termination (ANSI). */
256 #ifdef SIGXCPU
257  SIGNAL(SIGXCPU, sigterm_handler);
258 #endif
259 #ifdef SIGPIPE
260  signal(SIGPIPE, SIG_IGN); /* Broken pipe (POSIX). */
261 #endif
262 #if HAVE_SETCONSOLECTRLHANDLER
263  SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
264 #endif
265 }
266 
267 /* read a key without blocking */
268 static int read_key(void)
269 {
270  unsigned char ch;
271 #if HAVE_TERMIOS_H
272  int n = 1;
273  struct timeval tv;
274  fd_set rfds;
275 
276  FD_ZERO(&rfds);
277  FD_SET(0, &rfds);
278  tv.tv_sec = 0;
279  tv.tv_usec = 0;
280  n = select(1, &rfds, NULL, NULL, &tv);
281  if (n > 0) {
282  n = read(0, &ch, 1);
283  if (n == 1)
284  return ch;
285 
286  return n;
287  }
288 #elif HAVE_KBHIT
289 # if HAVE_PEEKNAMEDPIPE && HAVE_GETSTDHANDLE
290  static int is_pipe;
291  static HANDLE input_handle;
292  DWORD dw, nchars;
293  if(!input_handle){
294  input_handle = GetStdHandle(STD_INPUT_HANDLE);
295  is_pipe = !GetConsoleMode(input_handle, &dw);
296  }
297 
298  if (is_pipe) {
299  /* When running under a GUI, you will end here. */
300  if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL)) {
301  // input pipe may have been closed by the program that ran ffmpeg
302  return -1;
303  }
304  //Read it
305  if(nchars != 0) {
306  read(0, &ch, 1);
307  return ch;
308  }else{
309  return -1;
310  }
311  }
312 # endif
313  if(kbhit())
314  return(getch());
315 #endif
316  return -1;
317 }
318 
319 static int decode_interrupt_cb(void *ctx)
320 {
322 }
323 
325 
326 static void ffmpeg_cleanup(int ret)
327 {
328  int i;
329 
330  if (do_benchmark) {
331  int maxrss = getmaxrss() / 1024;
332  av_log(NULL, AV_LOG_INFO, "bench: maxrss=%iKiB\n", maxrss);
333  }
334 
335  for (i = 0; i < nb_filtergraphs; i++)
338 
339  for (i = 0; i < nb_output_files; i++)
341 
342  for (i = 0; i < nb_input_files; i++)
344 
345  if (vstats_file) {
346  if (fclose(vstats_file))
348  "Error closing vstats file, loss of information possible: %s\n",
349  av_err2str(AVERROR(errno)));
350  }
353 
355 
357 
360 
361  uninit_opts();
362 
364 
365  if (received_sigterm) {
366  av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n",
367  (int) received_sigterm);
368  } else if (ret && atomic_load(&transcode_init_done)) {
369  av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
370  }
371  term_exit();
372  ffmpeg_exited = 1;
373 }
374 
376 {
377  int of_idx = prev ? prev->file->index : 0;
378  int ost_idx = prev ? prev->index + 1 : 0;
379 
380  for (; of_idx < nb_output_files; of_idx++) {
381  OutputFile *of = output_files[of_idx];
382  if (ost_idx < of->nb_streams)
383  return of->streams[ost_idx];
384 
385  ost_idx = 0;
386  }
387 
388  return NULL;
389 }
390 
392 {
393  int if_idx = prev ? prev->file->index : 0;
394  int ist_idx = prev ? prev->index + 1 : 0;
395 
396  for (; if_idx < nb_input_files; if_idx++) {
397  InputFile *f = input_files[if_idx];
398  if (ist_idx < f->nb_streams)
399  return f->streams[ist_idx];
400 
401  ist_idx = 0;
402  }
403 
404  return NULL;
405 }
406 
407 static int frame_data_ensure(AVBufferRef **dst, int writable)
408 {
409  if (!*dst) {
410  FrameData *fd;
411 
412  *dst = av_buffer_allocz(sizeof(*fd));
413  if (!*dst)
414  return AVERROR(ENOMEM);
415  fd = (FrameData*)((*dst)->data);
416 
417  fd->dec.frame_num = UINT64_MAX;
418  fd->dec.pts = AV_NOPTS_VALUE;
419 
420  for (unsigned i = 0; i < FF_ARRAY_ELEMS(fd->wallclock); i++)
421  fd->wallclock[i] = INT64_MIN;
422  } else if (writable)
423  return av_buffer_make_writable(dst);
424 
425  return 0;
426 }
427 
429 {
431  return ret < 0 ? NULL : (FrameData*)frame->opaque_ref->data;
432 }
433 
435 {
437  return ret < 0 ? NULL : (const FrameData*)frame->opaque_ref->data;
438 }
439 
441 {
442  int ret = frame_data_ensure(&pkt->opaque_ref, 1);
443  return ret < 0 ? NULL : (FrameData*)pkt->opaque_ref->data;
444 }
445 
447 {
448  int ret = frame_data_ensure(&pkt->opaque_ref, 0);
449  return ret < 0 ? NULL : (const FrameData*)pkt->opaque_ref->data;
450 }
451 
453 {
454  const AVDictionaryEntry *t = NULL;
455 
456  while ((t = av_dict_iterate(b, t))) {
458  }
459 }
460 
462 {
463  const AVDictionaryEntry *t;
464  if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
465  av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
467  }
468 
469  return 0;
470 }
471 
472 void update_benchmark(const char *fmt, ...)
473 {
474  if (do_benchmark_all) {
476  va_list va;
477  char buf[1024];
478 
479  if (fmt) {
480  va_start(va, fmt);
481  vsnprintf(buf, sizeof(buf), fmt, va);
482  va_end(va);
484  "bench: %8" PRIu64 " user %8" PRIu64 " sys %8" PRIu64 " real %s \n",
487  t.real_usec - current_time.real_usec, buf);
488  }
489  current_time = t;
490  }
491 }
492 
493 static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time, int64_t pts)
494 {
495  AVBPrint buf, buf_script;
496  int64_t total_size = of_filesize(output_files[0]);
497  int vid;
498  double bitrate;
499  double speed;
500  static int64_t last_time = -1;
501  static int first_report = 1;
502  uint64_t nb_frames_dup = 0, nb_frames_drop = 0;
503  int mins, secs, us;
504  int64_t hours;
505  const char *hours_sign;
506  int ret;
507  float t;
508 
509  if (!print_stats && !is_last_report && !progress_avio)
510  return;
511 
512  if (!is_last_report) {
513  if (last_time == -1) {
514  last_time = cur_time;
515  }
516  if (((cur_time - last_time) < stats_period && !first_report) ||
517  (first_report && atomic_load(&nb_output_dumped) < nb_output_files))
518  return;
519  last_time = cur_time;
520  }
521 
522  t = (cur_time-timer_start) / 1000000.0;
523 
524  vid = 0;
526  av_bprint_init(&buf_script, 0, AV_BPRINT_SIZE_AUTOMATIC);
527  for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
528  const float q = ost->enc ? atomic_load(&ost->quality) / (float) FF_QP2LAMBDA : -1;
529 
530  if (vid && ost->type == AVMEDIA_TYPE_VIDEO) {
531  av_bprintf(&buf, "q=%2.1f ", q);
532  av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
533  ost->file->index, ost->index, q);
534  }
535  if (!vid && ost->type == AVMEDIA_TYPE_VIDEO && ost->filter) {
536  float fps;
537  uint64_t frame_number = atomic_load(&ost->packets_written);
538 
539  fps = t > 1 ? frame_number / t : 0;
540  av_bprintf(&buf, "frame=%5"PRId64" fps=%3.*f q=%3.1f ",
541  frame_number, fps < 9.95, fps, q);
542  av_bprintf(&buf_script, "frame=%"PRId64"\n", frame_number);
543  av_bprintf(&buf_script, "fps=%.2f\n", fps);
544  av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
545  ost->file->index, ost->index, q);
546  if (is_last_report)
547  av_bprintf(&buf, "L");
548 
549  nb_frames_dup = atomic_load(&ost->filter->nb_frames_dup);
550  nb_frames_drop = atomic_load(&ost->filter->nb_frames_drop);
551 
552  vid = 1;
553  }
554  }
555 
556  if (copy_ts) {
557  if (copy_ts_first_pts == AV_NOPTS_VALUE && pts > 1)
561  }
562 
564  secs = FFABS64U(pts) / AV_TIME_BASE % 60;
565  mins = FFABS64U(pts) / AV_TIME_BASE / 60 % 60;
566  hours = FFABS64U(pts) / AV_TIME_BASE / 3600;
567  hours_sign = (pts < 0) ? "-" : "";
568 
569  bitrate = pts != AV_NOPTS_VALUE && pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
570  speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
571 
572  if (total_size < 0) av_bprintf(&buf, "size=N/A time=");
573  else av_bprintf(&buf, "size=%8.0fKiB time=", total_size / 1024.0);
574  if (pts == AV_NOPTS_VALUE) {
575  av_bprintf(&buf, "N/A ");
576  } else {
577  av_bprintf(&buf, "%s%02"PRId64":%02d:%02d.%02d ",
578  hours_sign, hours, mins, secs, (100 * us) / AV_TIME_BASE);
579  }
580 
581  if (bitrate < 0) {
582  av_bprintf(&buf, "bitrate=N/A");
583  av_bprintf(&buf_script, "bitrate=N/A\n");
584  }else{
585  av_bprintf(&buf, "bitrate=%6.1fkbits/s", bitrate);
586  av_bprintf(&buf_script, "bitrate=%6.1fkbits/s\n", bitrate);
587  }
588 
589  if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n");
590  else av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size);
591  if (pts == AV_NOPTS_VALUE) {
592  av_bprintf(&buf_script, "out_time_us=N/A\n");
593  av_bprintf(&buf_script, "out_time_ms=N/A\n");
594  av_bprintf(&buf_script, "out_time=N/A\n");
595  } else {
596  av_bprintf(&buf_script, "out_time_us=%"PRId64"\n", pts);
597  av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts);
598  av_bprintf(&buf_script, "out_time=%s%02"PRId64":%02d:%02d.%06d\n",
599  hours_sign, hours, mins, secs, us);
600  }
601 
602  if (nb_frames_dup || nb_frames_drop)
603  av_bprintf(&buf, " dup=%"PRId64" drop=%"PRId64, nb_frames_dup, nb_frames_drop);
604  av_bprintf(&buf_script, "dup_frames=%"PRId64"\n", nb_frames_dup);
605  av_bprintf(&buf_script, "drop_frames=%"PRId64"\n", nb_frames_drop);
606 
607  if (speed < 0) {
608  av_bprintf(&buf, " speed=N/A");
609  av_bprintf(&buf_script, "speed=N/A\n");
610  } else {
611  av_bprintf(&buf, " speed=%4.3gx", speed);
612  av_bprintf(&buf_script, "speed=%4.3gx\n", speed);
613  }
614 
615  if (print_stats || is_last_report) {
616  const char end = is_last_report ? '\n' : '\r';
617  if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
618  fprintf(stderr, "%s %c", buf.str, end);
619  } else
620  av_log(NULL, AV_LOG_INFO, "%s %c", buf.str, end);
621 
622  fflush(stderr);
623  }
624  av_bprint_finalize(&buf, NULL);
625 
626  if (progress_avio) {
627  av_bprintf(&buf_script, "progress=%s\n",
628  is_last_report ? "end" : "continue");
629  avio_write(progress_avio, buf_script.str,
630  FFMIN(buf_script.len, buf_script.size - 1));
632  av_bprint_finalize(&buf_script, NULL);
633  if (is_last_report) {
634  if ((ret = avio_closep(&progress_avio)) < 0)
636  "Error closing progress log, loss of information possible: %s\n", av_err2str(ret));
637  }
638  }
639 
640  first_report = 0;
641 }
642 
643 static void print_stream_maps(void)
644 {
645  av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
646  for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
647  for (int j = 0; j < ist->nb_filters; j++) {
648  if (!filtergraph_is_simple(ist->filters[j]->graph)) {
649  av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
650  ist->file->index, ist->index, ist->dec ? ist->dec->name : "?",
651  ist->filters[j]->name);
652  if (nb_filtergraphs > 1)
653  av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
654  av_log(NULL, AV_LOG_INFO, "\n");
655  }
656  }
657  }
658 
659  for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
660  if (ost->attachment_filename) {
661  /* an attached file */
662  av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n",
663  ost->attachment_filename, ost->file->index, ost->index);
664  continue;
665  }
666 
667  if (ost->filter && !filtergraph_is_simple(ost->filter->graph)) {
668  /* output from a complex graph */
669  av_log(NULL, AV_LOG_INFO, " %s", ost->filter->name);
670  if (nb_filtergraphs > 1)
671  av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
672 
673  av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file->index,
674  ost->index, ost->enc_ctx->codec->name);
675  continue;
676  }
677 
678  av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
679  ost->ist->file->index,
680  ost->ist->index,
681  ost->file->index,
682  ost->index);
683  if (ost->enc_ctx) {
684  const AVCodec *in_codec = ost->ist->dec;
685  const AVCodec *out_codec = ost->enc_ctx->codec;
686  const char *decoder_name = "?";
687  const char *in_codec_name = "?";
688  const char *encoder_name = "?";
689  const char *out_codec_name = "?";
690  const AVCodecDescriptor *desc;
691 
692  if (in_codec) {
693  decoder_name = in_codec->name;
694  desc = avcodec_descriptor_get(in_codec->id);
695  if (desc)
696  in_codec_name = desc->name;
697  if (!strcmp(decoder_name, in_codec_name))
698  decoder_name = "native";
699  }
700 
701  if (out_codec) {
702  encoder_name = out_codec->name;
703  desc = avcodec_descriptor_get(out_codec->id);
704  if (desc)
705  out_codec_name = desc->name;
706  if (!strcmp(encoder_name, out_codec_name))
707  encoder_name = "native";
708  }
709 
710  av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))",
711  in_codec_name, decoder_name,
712  out_codec_name, encoder_name);
713  } else
714  av_log(NULL, AV_LOG_INFO, " (copy)");
715  av_log(NULL, AV_LOG_INFO, "\n");
716  }
717 }
718 
719 static void set_tty_echo(int on)
720 {
721 #if HAVE_TERMIOS_H
722  struct termios tty;
723  if (tcgetattr(0, &tty) == 0) {
724  if (on) tty.c_lflag |= ECHO;
725  else tty.c_lflag &= ~ECHO;
726  tcsetattr(0, TCSANOW, &tty);
727  }
728 #endif
729 }
730 
731 static int check_keyboard_interaction(int64_t cur_time)
732 {
733  int i, key;
734  static int64_t last_time;
736  return AVERROR_EXIT;
737  /* read_key() returns 0 on EOF */
738  if (cur_time - last_time >= 100000) {
739  key = read_key();
740  last_time = cur_time;
741  }else
742  key = -1;
743  if (key == 'q') {
744  av_log(NULL, AV_LOG_INFO, "\n\n[q] command received. Exiting.\n\n");
745  return AVERROR_EXIT;
746  }
747  if (key == '+') av_log_set_level(av_log_get_level()+10);
748  if (key == '-') av_log_set_level(av_log_get_level()-10);
749  if (key == 'c' || key == 'C'){
750  char buf[4096], target[64], command[256], arg[256] = {0};
751  double time;
752  int k, n = 0;
753  fprintf(stderr, "\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
754  i = 0;
755  set_tty_echo(1);
756  while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
757  if (k > 0)
758  buf[i++] = k;
759  buf[i] = 0;
760  set_tty_echo(0);
761  fprintf(stderr, "\n");
762  if (k > 0 &&
763  (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
764  av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
765  target, time, command, arg);
766  for (i = 0; i < nb_filtergraphs; i++)
767  fg_send_command(filtergraphs[i], time, target, command, arg,
768  key == 'C');
769  } else {
771  "Parse error, at least 3 arguments were expected, "
772  "only %d given in string '%s'\n", n, buf);
773  }
774  }
775  if (key == '?'){
776  fprintf(stderr, "key function\n"
777  "? show this help\n"
778  "+ increase verbosity\n"
779  "- decrease verbosity\n"
780  "c Send command to first matching filter supporting it\n"
781  "C Send/Queue command to all matching filters\n"
782  "h dump packets/hex press to cycle through the 3 states\n"
783  "q quit\n"
784  "s Show QP histogram\n"
785  );
786  }
787  return 0;
788 }
789 
790 /*
791  * The following code is the main loop of the file converter
792  */
793 static int transcode(Scheduler *sch)
794 {
795  int ret = 0, i;
796  int64_t timer_start, transcode_ts = 0;
797 
799 
801 
802  ret = sch_start(sch);
803  if (ret < 0)
804  return ret;
805 
806  if (stdin_interaction) {
807  av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
808  }
809 
810  timer_start = av_gettime_relative();
811 
812  while (!sch_wait(sch, stats_period, &transcode_ts)) {
813  int64_t cur_time= av_gettime_relative();
814 
815  /* if 'q' pressed, exits */
816  if (stdin_interaction)
817  if (check_keyboard_interaction(cur_time) < 0)
818  break;
819 
820  /* dump report by using the output first video and audio streams */
821  print_report(0, timer_start, cur_time, transcode_ts);
822  }
823 
824  ret = sch_stop(sch, &transcode_ts);
825 
826  /* write the trailer if needed */
827  for (i = 0; i < nb_output_files; i++) {
828  int err = of_write_trailer(output_files[i]);
829  ret = err_merge(ret, err);
830  }
831 
832  term_exit();
833 
834  /* dump report by using the first video and audio streams */
835  print_report(1, timer_start, av_gettime_relative(), transcode_ts);
836 
837  return ret;
838 }
839 
841 {
842  BenchmarkTimeStamps time_stamps = { av_gettime_relative() };
843 #if HAVE_GETRUSAGE
844  struct rusage rusage;
845 
846  getrusage(RUSAGE_SELF, &rusage);
847  time_stamps.user_usec =
848  (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
849  time_stamps.sys_usec =
850  (rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec;
851 #elif HAVE_GETPROCESSTIMES
852  HANDLE proc;
853  FILETIME c, e, k, u;
854  proc = GetCurrentProcess();
855  GetProcessTimes(proc, &c, &e, &k, &u);
856  time_stamps.user_usec =
857  ((int64_t)u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
858  time_stamps.sys_usec =
859  ((int64_t)k.dwHighDateTime << 32 | k.dwLowDateTime) / 10;
860 #else
861  time_stamps.user_usec = time_stamps.sys_usec = 0;
862 #endif
863  return time_stamps;
864 }
865 
866 static int64_t getmaxrss(void)
867 {
868 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
869  struct rusage rusage;
870  getrusage(RUSAGE_SELF, &rusage);
871  return (int64_t)rusage.ru_maxrss * 1024;
872 #elif HAVE_GETPROCESSMEMORYINFO
873  HANDLE proc;
874  PROCESS_MEMORY_COUNTERS memcounters;
875  proc = GetCurrentProcess();
876  memcounters.cb = sizeof(memcounters);
877  GetProcessMemoryInfo(proc, &memcounters, sizeof(memcounters));
878  return memcounters.PeakPagefileUsage;
879 #else
880  return 0;
881 #endif
882 }
883 
884 int main(int argc, char **argv)
885 {
886  Scheduler *sch = NULL;
887 
888  int ret;
890 
891  init_dynload();
892 
893  setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
894 
896  parse_loglevel(argc, argv, options);
897 
898 #if CONFIG_AVDEVICE
900 #endif
902 
903  show_banner(argc, argv, options);
904 
905  sch = sch_alloc();
906  if (!sch) {
907  ret = AVERROR(ENOMEM);
908  goto finish;
909  }
910 
911  /* parse options and open all input/output files */
912  ret = ffmpeg_parse_options(argc, argv, sch);
913  if (ret < 0)
914  goto finish;
915 
916  if (nb_output_files <= 0 && nb_input_files == 0) {
917  show_usage();
918  av_log(NULL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name);
919  ret = 1;
920  goto finish;
921  }
922 
923  if (nb_output_files <= 0) {
924  av_log(NULL, AV_LOG_FATAL, "At least one output file must be specified\n");
925  ret = 1;
926  goto finish;
927  }
928 
930  ret = transcode(sch);
931  if (ret >= 0 && do_benchmark) {
932  int64_t utime, stime, rtime;
934  utime = current_time.user_usec - ti.user_usec;
935  stime = current_time.sys_usec - ti.sys_usec;
936  rtime = current_time.real_usec - ti.real_usec;
938  "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
939  utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);
940  }
941 
942  ret = received_nb_signals ? 255 :
943  (ret == FFMPEG_ERROR_RATE_EXCEEDED) ? 69 : ret;
944 
945 finish:
946  if (ret == AVERROR_EXIT)
947  ret = 0;
948 
950 
951  sch_free(&sch);
952 
953  return ret;
954 }
AVCodec
AVCodec.
Definition: codec.h:187
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
atomic_store
#define atomic_store(object, desired)
Definition: stdatomic.h:85
err_merge
static int err_merge(int err0, int err1)
Merge two return codes - return one of the error codes if at least one of them was negative,...
Definition: ffmpeg_utils.h:41
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
nb_input_files
int nb_input_files
Definition: ffmpeg.c:126
opt.h
ffmpeg_exited
static volatile int ffmpeg_exited
Definition: ffmpeg.c:158
libm.h
FrameData
Definition: ffmpeg.h:616
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
thread.h
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
fg_free
void fg_free(FilterGraph **pfg)
Definition: ffmpeg_filter.c:875
remove_avoptions
void remove_avoptions(AVDictionary **a, AVDictionary *b)
Definition: ffmpeg.c:452
BenchmarkTimeStamps::user_usec
int64_t user_usec
Definition: ffmpeg.c:113
ist_iter
InputStream * ist_iter(InputStream *prev)
Definition: ffmpeg.c:391
InputFile::index
int index
Definition: ffmpeg.h:403
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:340
pixdesc.h
of_filesize
int64_t of_filesize(OutputFile *of)
Definition: ffmpeg_mux.c:881
sync_queue.h
current_time
static BenchmarkTimeStamps current_time
Definition: ffmpeg.c:122
OutputStream::index
int index
Definition: ffmpeg.h:514
ATOMIC_VAR_INIT
#define ATOMIC_VAR_INIT(value)
Definition: stdatomic.h:31
b
#define b
Definition: input.c:41
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
ffmpeg.h
BenchmarkTimeStamps::sys_usec
int64_t sys_usec
Definition: ffmpeg.c:114
progress_avio
AVIOContext * progress_avio
Definition: ffmpeg.c:123
show_usage
void show_usage(void)
Definition: ffmpeg_opt.c:1294
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:107
ost
static AVStream * ost
Definition: vaapi_transcode.c:42
term_exit_sigsafe
static void term_exit_sigsafe(void)
Definition: ffmpeg.c:141
OutputStream::file
struct OutputFile * file
Definition: ffmpeg.h:512
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
FrameData::frame_num
uint64_t frame_num
Definition: ffmpeg.h:623
AVFrame::opaque_ref
AVBufferRef * opaque_ref
Frame owner's private data.
Definition: frame.h:768
InputStream
Definition: ffmpeg.h:356
filter_nbthreads
char * filter_nbthreads
Definition: ffmpeg_opt.c:82
stats_period
int64_t stats_period
Definition: ffmpeg_opt.c:86
fifo.h
finish
static void finish(void)
Definition: movenc.c:342
sch_stop
int sch_stop(Scheduler *sch, int64_t *finish_ts)
Definition: ffmpeg_sched.c:453
AVPacket::opaque_ref
AVBufferRef * opaque_ref
AVBufferRef for free use by the API user.
Definition: packet.h:558
samplefmt.h
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
packet_data_c
const FrameData * packet_data_c(AVPacket *pkt)
Definition: ffmpeg.c:446
update_benchmark
void update_benchmark(const char *fmt,...)
Definition: ffmpeg.c:472
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
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:2886
avformat_network_init
int avformat_network_init(void)
Do global initialization of network libraries.
Definition: utils.c:558
InputFile
Definition: ffmpeg.h:400
transcode
static int transcode(Scheduler *sch)
Definition: ffmpeg.c:793
ffmpeg_cleanup
static void ffmpeg_cleanup(int ret)
Definition: ffmpeg.c:326
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
sch_free
void sch_free(Scheduler **psch)
Definition: ffmpeg_sched.c:506
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
BenchmarkTimeStamps::real_usec
int64_t real_usec
Definition: ffmpeg.c:112
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
float
float
Definition: af_crystalizer.c:121
of_free
void of_free(OutputFile **pof)
Definition: ffmpeg_mux.c:855
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:840
vstats_filename
char * vstats_filename
Definition: ffmpeg_opt.c:59
sch_alloc
Scheduler * sch_alloc(void)
Definition: ffmpeg_sched.c:613
copy_ts_first_pts
static int64_t copy_ts_first_pts
Definition: ffmpeg.c:159
bitrate
int64_t bitrate
Definition: av1_levels.c:47
AVDictionaryEntry::key
char * key
Definition: dict.h:90
term_init
void term_init(void)
Definition: ffmpeg.c:219
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
FrameData::dec
struct FrameData::@4 dec
ctx
AVFormatContext * ctx
Definition: movenc.c:48
limits.h
nb_streams
static int nb_streams
Definition: ffprobe.c:328
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:149
ffmpeg_utils.h
key
const char * key
Definition: hwcontext_opencl.c:174
atomic_load
#define atomic_load(object)
Definition: stdatomic.h:93
command
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Definition: vf_drawtext.c:1191
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:196
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:78
NULL
#define NULL
Definition: coverity.c:32
main
int main(int argc, char **argv)
Definition: ffmpeg.c:884
nb_output_dumped
atomic_uint nb_output_dumped
Definition: ffmpeg.c:120
getmaxrss
static int64_t getmaxrss(void)
Definition: ffmpeg.c:866
check_keyboard_interaction
static int check_keyboard_interaction(int64_t cur_time)
Definition: ffmpeg.c:731
av_log_set_flags
void av_log_set_flags(int arg)
Definition: log.c:452
parseutils.h
print_stream_maps
static void print_stream_maps(void)
Definition: ffmpeg.c:643
vstats_file
FILE * vstats_file
Definition: ffmpeg.c:109
ost_iter
OutputStream * ost_iter(OutputStream *prev)
Definition: ffmpeg.c:375
FrameData::wallclock
int64_t wallclock[LATENCY_PROBE_NB]
Definition: ffmpeg.h:633
double
double
Definition: af_crystalizer.c:131
time.h
received_nb_signals
static volatile int received_nb_signals
Definition: ffmpeg.c:156
do_benchmark_all
int do_benchmark_all
Definition: ffmpeg_opt.c:70
OutputFile::index
int index
Definition: ffmpeg.h:600
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
input_files
InputFile ** input_files
Definition: ffmpeg.c:125
OutputFile::streams
OutputStream ** streams
Definition: ffmpeg.h:605
Scheduler
Definition: ffmpeg_sched.c:259
FilterGraph
Definition: ffmpeg.h:299
print_stats
int print_stats
Definition: ffmpeg_opt.c:79
decode_interrupt_cb
static int decode_interrupt_cb(void *ctx)
Definition: ffmpeg.c:319
options
const OptionDef options[]
print_report
static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time, int64_t pts)
Definition: ffmpeg.c:493
f
f
Definition: af_crystalizer.c:121
AVIOContext
Bytestream IO Context.
Definition: avio.h:166
av_bprint_finalize
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
Definition: bprint.c:240
threadmessage.h
output_files
OutputFile ** output_files
Definition: ffmpeg.c:128
SIGNAL
#define SIGNAL(sig, func)
Definition: ffmpeg.c:215
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
received_sigterm
static volatile int received_sigterm
Definition: ffmpeg.c:155
filtergraph_is_simple
int filtergraph_is_simple(const FilterGraph *fg)
Definition: ffmpeg_filter.c:1876
uninit_opts
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents.
Definition: cmdutils.c:65
copy_ts
int copy_ts
Definition: ffmpeg_opt.c:73
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
check_avoptions
int check_avoptions(AVDictionary *m)
Definition: ffmpeg.c:461
frame_data
FrameData * frame_data(AVFrame *frame)
Get our axiliary frame data attached to the frame, allocating it if needed.
Definition: ffmpeg.c:428
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
show_banner
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
Definition: opt_common.c:237
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:625
do_benchmark
int do_benchmark
Definition: ffmpeg_opt.c:69
AV_LOG_INFO
#define AV_LOG_INFO
Standard information.
Definition: log.h:191
AVCodec::id
enum AVCodecID id
Definition: codec.h:201
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:1368
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
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
sigterm_handler
static void sigterm_handler(int sig)
Definition: ffmpeg.c:162
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
filtergraphs
FilterGraph ** filtergraphs
Definition: ffmpeg.c:131
int_cb
const AVIOInterruptCB int_cb
Definition: ffmpeg.c:324
nb_output_files
int nb_output_files
Definition: ffmpeg.c:129
frame_data_ensure
static int frame_data_ensure(AVBufferRef **dst, int writable)
Definition: ffmpeg.c:407
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:545
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
hw_device_free_all
void hw_device_free_all(void)
Definition: ffmpeg_hw.c:288
avformat.h
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:847
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:157
BenchmarkTimeStamps
Definition: ffmpeg.c:111
channel_layout.h
InputStream::file
struct InputFile * file
Definition: ffmpeg.h:360
atomic_uint
intptr_t atomic_uint
Definition: stdatomic.h:56
program_name
const char program_name[]
program name, defined by the program for show_version().
Definition: ffmpeg.c:106
ffmpeg_parse_options
int ffmpeg_parse_options(int argc, char **argv, Scheduler *sch)
desc
const char * desc
Definition: libsvtav1.c:83
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
InputStream::index
int index
Definition: ffmpeg.h:362
ffmpeg_sched.h
sch_wait
int sch_wait(Scheduler *sch, uint64_t timeout_us, int64_t *transcode_ts)
Wait until transcoding terminates or the specified timeout elapses.
Definition: ffmpeg_sched.c:1438
FFMPEG_ERROR_RATE_EXCEEDED
#define FFMPEG_ERROR_RATE_EXCEEDED
Definition: ffmpeg.h:67
AVDictionaryEntry
Definition: dict.h:89
stdin_interaction
int stdin_interaction
Definition: ffmpeg_opt.c:80
AVPacket
This structure stores compressed data.
Definition: packet.h:499
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
av_dict_set
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Definition: dict.c:88
cmdutils.h
packet_data
FrameData * packet_data(AVPacket *pkt)
Definition: ffmpeg.c:440
nb_filtergraphs
int nb_filtergraphs
Definition: ffmpeg.c:132
imgutils.h
sch_start
int sch_start(Scheduler *sch)
Definition: ffmpeg_sched.c:1288
timestamp.h
OutputStream
Definition: mux.c:53
hwcontext.h
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
FFABS64U
#define FFABS64U(a)
Definition: common.h:90
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:719
avstring.h
FF_QP2LAMBDA
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
Definition: avutil.h:227
frame_data_c
const FrameData * frame_data_c(AVFrame *frame)
Definition: ffmpeg.c:434
read_key
static int read_key(void)
Definition: ffmpeg.c:268
of_write_trailer
int of_write_trailer(OutputFile *of)
Definition: ffmpeg_mux.c:738
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
OutputFile
Definition: ffmpeg.h:597
avdevice_register_all
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
Definition: alldevices.c:65