FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/fftools/ffmpeg.c
Date: 2025-06-23 20:06:14
Exec Total Coverage
Lines: 326 468 69.7%
Functions: 19 25 76.0%
Branches: 196 312 62.8%

Line Branch Exec Source
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/bprint.h"
72 #include "libavutil/dict.h"
73 #include "libavutil/mem.h"
74 #include "libavutil/time.h"
75
76 #include "libavformat/avformat.h"
77
78 #include "libavdevice/avdevice.h"
79
80 #include "cmdutils.h"
81 #include "ffmpeg.h"
82 #include "ffmpeg_sched.h"
83 #include "ffmpeg_utils.h"
84 #include "graph/graphprint.h"
85
86 const char program_name[] = "ffmpeg";
87 const int program_birth_year = 2000;
88
89 FILE *vstats_file;
90
91 typedef struct BenchmarkTimeStamps {
92 int64_t real_usec;
93 int64_t user_usec;
94 int64_t sys_usec;
95 } BenchmarkTimeStamps;
96
97 static BenchmarkTimeStamps get_benchmark_time_stamps(void);
98 static int64_t getmaxrss(void);
99
100 atomic_uint nb_output_dumped = 0;
101
102 static BenchmarkTimeStamps current_time;
103 AVIOContext *progress_avio = NULL;
104
105 InputFile **input_files = NULL;
106 int nb_input_files = 0;
107
108 OutputFile **output_files = NULL;
109 int nb_output_files = 0;
110
111 FilterGraph **filtergraphs;
112 int nb_filtergraphs;
113
114 Decoder **decoders;
115 int nb_decoders;
116
117 #if HAVE_TERMIOS_H
118
119 /* init terminal so that we can grab keys */
120 static struct termios oldtty;
121 static int restore_tty;
122 #endif
123
124 16521 static void term_exit_sigsafe(void)
125 {
126 #if HAVE_TERMIOS_H
127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16521 times.
16521 if(restore_tty)
128 tcsetattr (0, TCSANOW, &oldtty);
129 #endif
130 16521 }
131
132 16521 void term_exit(void)
133 {
134 16521 av_log(NULL, AV_LOG_QUIET, "%s", "");
135 16521 term_exit_sigsafe();
136 16521 }
137
138 static volatile int received_sigterm = 0;
139 static volatile int received_nb_signals = 0;
140 static atomic_int transcode_init_done = 0;
141 static volatile int ffmpeg_exited = 0;
142 static int64_t copy_ts_first_pts = AV_NOPTS_VALUE;
143
144 static void
145 sigterm_handler(int sig)
146 {
147 int ret;
148 received_sigterm = sig;
149 received_nb_signals++;
150 term_exit_sigsafe();
151 if(received_nb_signals > 3) {
152 ret = write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n",
153 strlen("Received > 3 system signals, hard exiting\n"));
154 if (ret < 0) { /* Do nothing */ };
155 exit(123);
156 }
157 }
158
159 #if HAVE_SETCONSOLECTRLHANDLER
160 static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
161 {
162 av_log(NULL, AV_LOG_DEBUG, "\nReceived windows signal %ld\n", fdwCtrlType);
163
164 switch (fdwCtrlType)
165 {
166 case CTRL_C_EVENT:
167 case CTRL_BREAK_EVENT:
168 sigterm_handler(SIGINT);
169 return TRUE;
170
171 case CTRL_CLOSE_EVENT:
172 case CTRL_LOGOFF_EVENT:
173 case CTRL_SHUTDOWN_EVENT:
174 sigterm_handler(SIGTERM);
175 /* Basically, with these 3 events, when we return from this method the
176 process is hard terminated, so stall as long as we need to
177 to try and let the main thread(s) clean up and gracefully terminate
178 (we have at most 5 seconds, but should be done far before that). */
179 while (!ffmpeg_exited) {
180 Sleep(0);
181 }
182 return TRUE;
183
184 default:
185 av_log(NULL, AV_LOG_ERROR, "Received unknown windows signal %ld\n", fdwCtrlType);
186 return FALSE;
187 }
188 }
189 #endif
190
191 #ifdef __linux__
192 #define SIGNAL(sig, func) \
193 do { \
194 action.sa_handler = func; \
195 sigaction(sig, &action, NULL); \
196 } while (0)
197 #else
198 #define SIGNAL(sig, func) \
199 signal(sig, func)
200 #endif
201
202 8260 void term_init(void)
203 {
204 #if defined __linux__
205 8260 struct sigaction action = {0};
206 8260 action.sa_handler = sigterm_handler;
207
208 /* block other interrupts while processing this one */
209 8260 sigfillset(&action.sa_mask);
210
211 /* restart interruptible functions (i.e. don't fail with EINTR) */
212 8260 action.sa_flags = SA_RESTART;
213 #endif
214
215 #if HAVE_TERMIOS_H
216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8260 times.
8260 if (stdin_interaction) {
217 struct termios tty;
218 if (tcgetattr (0, &tty) == 0) {
219 oldtty = tty;
220 restore_tty = 1;
221
222 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
223 |INLCR|IGNCR|ICRNL|IXON);
224 tty.c_oflag |= OPOST;
225 tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN);
226 tty.c_cflag &= ~(CSIZE|PARENB);
227 tty.c_cflag |= CS8;
228 tty.c_cc[VMIN] = 1;
229 tty.c_cc[VTIME] = 0;
230
231 tcsetattr (0, TCSANOW, &tty);
232 }
233 SIGNAL(SIGQUIT, sigterm_handler); /* Quit (POSIX). */
234 }
235 #endif
236
237 8260 SIGNAL(SIGINT , sigterm_handler); /* Interrupt (ANSI). */
238 8260 SIGNAL(SIGTERM, sigterm_handler); /* Termination (ANSI). */
239 #ifdef SIGXCPU
240 8260 SIGNAL(SIGXCPU, sigterm_handler);
241 #endif
242 #ifdef SIGPIPE
243 8260 signal(SIGPIPE, SIG_IGN); /* Broken pipe (POSIX). */
244 #endif
245 #if HAVE_SETCONSOLECTRLHANDLER
246 SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
247 #endif
248 8260 }
249
250 /* read a key without blocking */
251 static int read_key(void)
252 {
253 unsigned char ch;
254 #if HAVE_TERMIOS_H
255 int n = 1;
256 struct timeval tv;
257 fd_set rfds;
258
259 FD_ZERO(&rfds);
260 FD_SET(0, &rfds);
261 tv.tv_sec = 0;
262 tv.tv_usec = 0;
263 n = select(1, &rfds, NULL, NULL, &tv);
264 if (n > 0) {
265 n = read(0, &ch, 1);
266 if (n == 1)
267 return ch;
268
269 return n;
270 }
271 #elif HAVE_KBHIT
272 # if HAVE_PEEKNAMEDPIPE && HAVE_GETSTDHANDLE
273 static int is_pipe;
274 static HANDLE input_handle;
275 DWORD dw, nchars;
276 if(!input_handle){
277 input_handle = GetStdHandle(STD_INPUT_HANDLE);
278 is_pipe = !GetConsoleMode(input_handle, &dw);
279 }
280
281 if (is_pipe) {
282 /* When running under a GUI, you will end here. */
283 if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL)) {
284 // input pipe may have been closed by the program that ran ffmpeg
285 return -1;
286 }
287 //Read it
288 if(nchars != 0) {
289 if (read(0, &ch, 1) == 1)
290 return ch;
291 return 0;
292 }else{
293 return -1;
294 }
295 }
296 # endif
297 if(kbhit())
298 return(getch());
299 #endif
300 return -1;
301 }
302
303 786107 static int decode_interrupt_cb(void *ctx)
304 {
305 786107 return received_nb_signals > atomic_load(&transcode_init_done);
306 }
307
308 const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
309
310 8261 static void ffmpeg_cleanup(int ret)
311 {
312
2/6
✓ Branch 0 taken 8261 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8261 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
8261 if ((print_graphs || print_graphs_file) && nb_output_files > 0)
313 print_filtergraphs(filtergraphs, nb_filtergraphs, input_files, nb_input_files, output_files, nb_output_files);
314
315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8261 times.
8261 if (do_benchmark) {
316 int64_t maxrss = getmaxrss() / 1024;
317 av_log(NULL, AV_LOG_INFO, "bench: maxrss=%"PRId64"KiB\n", maxrss);
318 }
319
320
2/2
✓ Branch 0 taken 1204 times.
✓ Branch 1 taken 8261 times.
9465 for (int i = 0; i < nb_filtergraphs; i++)
321 1204 fg_free(&filtergraphs[i]);
322 8261 av_freep(&filtergraphs);
323
324
2/2
✓ Branch 0 taken 8262 times.
✓ Branch 1 taken 8261 times.
16523 for (int i = 0; i < nb_output_files; i++)
325 8262 of_free(&output_files[i]);
326
327
2/2
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 8261 times.
15472 for (int i = 0; i < nb_input_files; i++)
328 7211 ifile_close(&input_files[i]);
329
330
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8261 times.
8262 for (int i = 0; i < nb_decoders; i++)
331 1 dec_free(&decoders[i]);
332 8261 av_freep(&decoders);
333
334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8261 times.
8261 if (vstats_file) {
335 if (fclose(vstats_file))
336 av_log(NULL, AV_LOG_ERROR,
337 "Error closing vstats file, loss of information possible: %s\n",
338 av_err2str(AVERROR(errno)));
339 }
340 8261 av_freep(&vstats_filename);
341 8261 of_enc_stats_close();
342
343 8261 hw_device_free_all();
344
345 8261 av_freep(&filter_nbthreads);
346
347 8261 av_freep(&print_graphs_file);
348 8261 av_freep(&print_graphs_format);
349
350 8261 av_freep(&input_files);
351 8261 av_freep(&output_files);
352
353 8261 uninit_opts();
354
355 8261 avformat_network_deinit();
356
357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8261 times.
8261 if (received_sigterm) {
358 av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n",
359 (int) received_sigterm);
360
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8260 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
8261 } else if (ret && atomic_load(&transcode_init_done)) {
361 1 av_log(NULL, AV_LOG_INFO, "Conversion failed!\n");
362 }
363 8261 term_exit();
364 8261 ffmpeg_exited = 1;
365 8261 }
366
367 34065 OutputStream *ost_iter(OutputStream *prev)
368 {
369
2/2
✓ Branch 0 taken 17519 times.
✓ Branch 1 taken 16546 times.
34065 int of_idx = prev ? prev->file->index : 0;
370
2/2
✓ Branch 0 taken 17519 times.
✓ Branch 1 taken 16546 times.
34065 int ost_idx = prev ? prev->index + 1 : 0;
371
372
2/2
✓ Branch 0 taken 34069 times.
✓ Branch 1 taken 16546 times.
50615 for (; of_idx < nb_output_files; of_idx++) {
373 34069 OutputFile *of = output_files[of_idx];
374
2/2
✓ Branch 0 taken 17519 times.
✓ Branch 1 taken 16550 times.
34069 if (ost_idx < of->nb_streams)
375 17519 return of->streams[ost_idx];
376
377 16550 ost_idx = 0;
378 }
379
380 16546 return NULL;
381 }
382
383 16210 InputStream *ist_iter(InputStream *prev)
384 {
385
2/2
✓ Branch 0 taken 7827 times.
✓ Branch 1 taken 8383 times.
16210 int if_idx = prev ? prev->file->index : 0;
386
2/2
✓ Branch 0 taken 7827 times.
✓ Branch 1 taken 8383 times.
16210 int ist_idx = prev ? prev->index + 1 : 0;
387
388
2/2
✓ Branch 0 taken 15181 times.
✓ Branch 1 taken 8280 times.
23461 for (; if_idx < nb_input_files; if_idx++) {
389 15181 InputFile *f = input_files[if_idx];
390
2/2
✓ Branch 0 taken 7930 times.
✓ Branch 1 taken 7251 times.
15181 if (ist_idx < f->nb_streams)
391 7930 return f->streams[ist_idx];
392
393 7251 ist_idx = 0;
394 }
395
396 8280 return NULL;
397 }
398
399 1436927 static void frame_data_free(void *opaque, uint8_t *data)
400 {
401 1436927 FrameData *fd = (FrameData *)data;
402
403 1436927 avcodec_parameters_free(&fd->par_enc);
404
405 1436927 av_free(data);
406 1436927 }
407
408 2875128 static int frame_data_ensure(AVBufferRef **dst, int writable)
409 {
410 2875128 AVBufferRef *src = *dst;
411
412
6/6
✓ Branch 0 taken 2368209 times.
✓ Branch 1 taken 506919 times.
✓ Branch 2 taken 2361438 times.
✓ Branch 3 taken 6771 times.
✓ Branch 5 taken 930008 times.
✓ Branch 6 taken 1431430 times.
2875128 if (!src || (writable && !av_buffer_is_writable(src))) {
413 FrameData *fd;
414
415 1436927 fd = av_mallocz(sizeof(*fd));
416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436927 times.
1436927 if (!fd)
417 return AVERROR(ENOMEM);
418
419 1436927 *dst = av_buffer_create((uint8_t *)fd, sizeof(*fd),
420 frame_data_free, NULL, 0);
421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1436927 times.
1436927 if (!*dst) {
422 av_buffer_unref(&src);
423 av_freep(&fd);
424 return AVERROR(ENOMEM);
425 }
426
427
2/2
✓ Branch 0 taken 930008 times.
✓ Branch 1 taken 506919 times.
1436927 if (src) {
428 930008 const FrameData *fd_src = (const FrameData *)src->data;
429
430 930008 memcpy(fd, fd_src, sizeof(*fd));
431 930008 fd->par_enc = NULL;
432
433
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 930007 times.
930008 if (fd_src->par_enc) {
434 1 int ret = 0;
435
436 1 fd->par_enc = avcodec_parameters_alloc();
437 2 ret = fd->par_enc ?
438
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 avcodec_parameters_copy(fd->par_enc, fd_src->par_enc) :
439 AVERROR(ENOMEM);
440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (ret < 0) {
441 av_buffer_unref(dst);
442 av_buffer_unref(&src);
443 return ret;
444 }
445 }
446
447 930008 av_buffer_unref(&src);
448 } else {
449 506919 fd->dec.frame_num = UINT64_MAX;
450 506919 fd->dec.pts = AV_NOPTS_VALUE;
451
452
2/2
✓ Branch 0 taken 3548433 times.
✓ Branch 1 taken 506919 times.
4055352 for (unsigned i = 0; i < FF_ARRAY_ELEMS(fd->wallclock); i++)
453 3548433 fd->wallclock[i] = INT64_MIN;
454 }
455 }
456
457 2875128 return 0;
458 }
459
460 1590526 FrameData *frame_data(AVFrame *frame)
461 {
462 1590526 int ret = frame_data_ensure(&frame->opaque_ref, 1);
463
1/2
✓ Branch 0 taken 1590526 times.
✗ Branch 1 not taken.
1590526 return ret < 0 ? NULL : (FrameData*)frame->opaque_ref->data;
464 }
465
466 8003 const FrameData *frame_data_c(AVFrame *frame)
467 {
468 8003 int ret = frame_data_ensure(&frame->opaque_ref, 0);
469
1/2
✓ Branch 0 taken 8003 times.
✗ Branch 1 not taken.
8003 return ret < 0 ? NULL : (const FrameData*)frame->opaque_ref->data;
470 }
471
472 1276599 FrameData *packet_data(AVPacket *pkt)
473 {
474 1276599 int ret = frame_data_ensure(&pkt->opaque_ref, 1);
475
1/2
✓ Branch 0 taken 1276599 times.
✗ Branch 1 not taken.
1276599 return ret < 0 ? NULL : (FrameData*)pkt->opaque_ref->data;
476 }
477
478 const FrameData *packet_data_c(AVPacket *pkt)
479 {
480 int ret = frame_data_ensure(&pkt->opaque_ref, 0);
481 return ret < 0 ? NULL : (const FrameData*)pkt->opaque_ref->data;
482 }
483
484 15473 int check_avoptions_used(const AVDictionary *opts, const AVDictionary *opts_used,
485 void *logctx, int decode)
486 {
487 15473 const AVClass *class = avcodec_get_class();
488 15473 const AVClass *fclass = avformat_get_class();
489
490
2/2
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 8262 times.
15473 const int flag = decode ? AV_OPT_FLAG_DECODING_PARAM :
491 AV_OPT_FLAG_ENCODING_PARAM;
492 15473 const AVDictionaryEntry *e = NULL;
493
494
2/2
✓ Branch 1 taken 47943 times.
✓ Branch 2 taken 15473 times.
63416 while ((e = av_dict_iterate(opts, e))) {
495 const AVOption *option, *foption;
496 char *optname, *p;
497
498
2/2
✓ Branch 1 taken 47134 times.
✓ Branch 2 taken 809 times.
47943 if (av_dict_get(opts_used, e->key, NULL, 0))
499 47135 continue;
500
501 809 optname = av_strdup(e->key);
502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 809 times.
809 if (!optname)
503 return AVERROR(ENOMEM);
504
505 809 p = strchr(optname, ':');
506
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 798 times.
809 if (p)
507 11 *p = 0;
508
509 809 option = av_opt_find(&class, optname, NULL, 0,
510 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
511 809 foption = av_opt_find(&fclass, optname, NULL, 0,
512 AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ);
513 809 av_freep(&optname);
514
3/4
✓ Branch 0 taken 809 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 808 times.
809 if (!option || foption)
515 1 continue;
516
517
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 808 times.
808 if (!(option->flags & flag)) {
518 av_log(logctx, AV_LOG_ERROR, "Codec AVOption %s (%s) is not a %s "
519 "option.\n", e->key, option->help ? option->help : "",
520 decode ? "decoding" : "encoding");
521 return AVERROR(EINVAL);
522 }
523
524 808 av_log(logctx, AV_LOG_WARNING, "Codec AVOption %s (%s) has not been used "
525 "for any stream. The most likely reason is either wrong type "
526 "(e.g. a video option with no video streams) or that it is a "
527 "private option of some decoder which was not actually used "
528
2/2
✓ Branch 0 taken 804 times.
✓ Branch 1 taken 4 times.
1616 "for any stream.\n", e->key, option->help ? option->help : "");
529 }
530
531 15473 return 0;
532 }
533
534 2860337 void update_benchmark(const char *fmt, ...)
535 {
536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2860337 times.
2860337 if (do_benchmark_all) {
537 BenchmarkTimeStamps t = get_benchmark_time_stamps();
538 va_list va;
539 char buf[1024];
540
541 if (fmt) {
542 va_start(va, fmt);
543 vsnprintf(buf, sizeof(buf), fmt, va);
544 va_end(va);
545 av_log(NULL, AV_LOG_INFO,
546 "bench: %8" PRIu64 " user %8" PRIu64 " sys %8" PRIu64 " real %s \n",
547 t.user_usec - current_time.user_usec,
548 t.sys_usec - current_time.sys_usec,
549 t.real_usec - current_time.real_usec, buf);
550 }
551 current_time = t;
552 }
553 2860337 }
554
555 25667 static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time, int64_t pts)
556 {
557 AVBPrint buf, buf_script;
558 25667 int64_t total_size = of_filesize(output_files[0]);
559 int vid;
560 double bitrate;
561 double speed;
562 static int64_t last_time = -1;
563 static int first_report = 1;
564 25667 uint64_t nb_frames_dup = 0, nb_frames_drop = 0;
565 int mins, secs, ms, us;
566 int64_t hours;
567 const char *hours_sign;
568 int ret;
569 float t;
570
571
5/6
✓ Branch 0 taken 25614 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 17381 times.
✓ Branch 3 taken 8233 times.
✓ Branch 4 taken 17381 times.
✗ Branch 5 not taken.
25667 if (!print_stats && !is_last_report && !progress_avio)
572 17381 return;
573
574
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 8260 times.
8286 if (!is_last_report) {
575
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14 times.
26 if (last_time == -1) {
576 12 last_time = cur_time;
577 }
578
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
26 if (((cur_time - last_time) < stats_period && !first_report) ||
579
3/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
26 (first_report && atomic_load(&nb_output_dumped) < nb_output_files))
580 return;
581 26 last_time = cur_time;
582 }
583
584 8286 t = (cur_time-timer_start) / 1000000.0;
585
586 8286 vid = 0;
587 8286 av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
588 8286 av_bprint_init(&buf_script, 0, AV_BPRINT_SIZE_AUTOMATIC);
589
590
2/2
✓ Branch 2 taken 8773 times.
✓ Branch 3 taken 8286 times.
17059 for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
591
2/2
✓ Branch 0 taken 8071 times.
✓ Branch 1 taken 702 times.
8773 const float q = ost->enc ? atomic_load(&ost->quality) / (float) FF_QP2LAMBDA : -1;
592
593
4/4
✓ Branch 0 taken 274 times.
✓ Branch 1 taken 8499 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 197 times.
8773 if (vid && ost->type == AVMEDIA_TYPE_VIDEO) {
594 77 av_bprintf(&buf, "q=%2.1f ", q);
595 77 av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
596 77 ost->file->index, ost->index, q);
597 }
598
4/4
✓ Branch 0 taken 8499 times.
✓ Branch 1 taken 274 times.
✓ Branch 2 taken 6962 times.
✓ Branch 3 taken 1537 times.
8773 if (!vid && ost->type == AVMEDIA_TYPE_VIDEO) {
599 float fps;
600 6962 uint64_t frame_number = atomic_load(&ost->packets_written);
601
602
2/2
✓ Branch 0 taken 1926 times.
✓ Branch 1 taken 5036 times.
6962 fps = t > 1 ? frame_number / t : 0;
603 6962 av_bprintf(&buf, "frame=%5"PRId64" fps=%3.*f q=%3.1f ",
604 frame_number, fps < 9.95, fps, q);
605 6962 av_bprintf(&buf_script, "frame=%"PRId64"\n", frame_number);
606 6962 av_bprintf(&buf_script, "fps=%.2f\n", fps);
607 6962 av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
608 6962 ost->file->index, ost->index, q);
609
2/2
✓ Branch 0 taken 6961 times.
✓ Branch 1 taken 1 times.
6962 if (is_last_report)
610 6961 av_bprintf(&buf, "L");
611
612
2/2
✓ Branch 0 taken 6655 times.
✓ Branch 1 taken 307 times.
6962 if (ost->filter) {
613 6655 nb_frames_dup = atomic_load(&ost->filter->nb_frames_dup);
614 6655 nb_frames_drop = atomic_load(&ost->filter->nb_frames_drop);
615 }
616
617 6962 vid = 1;
618 }
619 }
620
621
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 8273 times.
8286 if (copy_ts) {
622
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if (copy_ts_first_pts == AV_NOPTS_VALUE && pts > 1)
623 13 copy_ts_first_pts = pts;
624
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if (copy_ts_first_pts != AV_NOPTS_VALUE)
625 13 pts -= copy_ts_first_pts;
626 }
627
628
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 8159 times.
8286 us = FFABS64U(pts) % AV_TIME_BASE;
629
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 8159 times.
8286 secs = FFABS64U(pts) / AV_TIME_BASE % 60;
630
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 8159 times.
8286 mins = FFABS64U(pts) / AV_TIME_BASE / 60 % 60;
631
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 8159 times.
8286 hours = FFABS64U(pts) / AV_TIME_BASE / 3600;
632
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 8175 times.
8286 hours_sign = (pts < 0) ? "-" : "";
633
634
6/6
✓ Branch 0 taken 8175 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 8159 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 8044 times.
✓ Branch 5 taken 115 times.
8286 bitrate = pts != AV_NOPTS_VALUE && pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
635
3/4
✓ Branch 0 taken 8175 times.
✓ Branch 1 taken 111 times.
✓ Branch 2 taken 8175 times.
✗ Branch 3 not taken.
8286 speed = pts != AV_NOPTS_VALUE && t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1;
636
637
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 8168 times.
8286 if (total_size < 0) av_bprintf(&buf, "size=N/A time=");
638 8168 else av_bprintf(&buf, "size=%8.0fKiB time=", total_size / 1024.0);
639
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 8175 times.
8286 if (pts == AV_NOPTS_VALUE) {
640 111 av_bprintf(&buf, "N/A ");
641 } else {
642 8175 av_bprintf(&buf, "%s%02"PRId64":%02d:%02d.%02d ",
643 hours_sign, hours, mins, secs, (100 * us) / AV_TIME_BASE);
644 }
645
646
2/2
✓ Branch 0 taken 242 times.
✓ Branch 1 taken 8044 times.
8286 if (bitrate < 0) {
647 242 av_bprintf(&buf, "bitrate=N/A");
648 242 av_bprintf(&buf_script, "bitrate=N/A\n");
649 }else{
650 8044 av_bprintf(&buf, "bitrate=%6.1fkbits/s", bitrate);
651 8044 av_bprintf(&buf_script, "bitrate=%6.1fkbits/s\n", bitrate);
652 }
653
654
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 8168 times.
8286 if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n");
655 8168 else av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size);
656
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 8175 times.
8286 if (pts == AV_NOPTS_VALUE) {
657 111 av_bprintf(&buf_script, "out_time_us=N/A\n");
658 111 av_bprintf(&buf_script, "out_time_ms=N/A\n");
659 111 av_bprintf(&buf_script, "out_time=N/A\n");
660 } else {
661 8175 av_bprintf(&buf_script, "out_time_us=%"PRId64"\n", pts);
662 8175 av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts);
663 8175 av_bprintf(&buf_script, "out_time=%s%02"PRId64":%02d:%02d.%06d\n",
664 hours_sign, hours, mins, secs, us);
665 }
666
667
4/4
✓ Branch 0 taken 8270 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 8264 times.
8286 if (nb_frames_dup || nb_frames_drop)
668 22 av_bprintf(&buf, " dup=%"PRId64" drop=%"PRId64, nb_frames_dup, nb_frames_drop);
669 8286 av_bprintf(&buf_script, "dup_frames=%"PRId64"\n", nb_frames_dup);
670 8286 av_bprintf(&buf_script, "drop_frames=%"PRId64"\n", nb_frames_drop);
671
672
2/2
✓ Branch 0 taken 111 times.
✓ Branch 1 taken 8175 times.
8286 if (speed < 0) {
673 111 av_bprintf(&buf, " speed=N/A");
674 111 av_bprintf(&buf_script, "speed=N/A\n");
675 } else {
676 8175 av_bprintf(&buf, " speed=%4.3gx", speed);
677 8175 av_bprintf(&buf_script, "speed=%4.3gx\n", speed);
678 }
679
680 8286 secs = (int)t;
681 8286 ms = (int)((t - secs) * 1000);
682 8286 mins = secs / 60;
683 8286 secs %= 60;
684 8286 hours = mins / 60;
685 8286 mins %= 60;
686
687 8286 av_bprintf(&buf, " elapsed=%"PRId64":%02d:%02d.%02d", hours, mins, secs, ms / 10);
688
689
3/4
✓ Branch 0 taken 8233 times.
✓ Branch 1 taken 53 times.
✓ Branch 2 taken 8233 times.
✗ Branch 3 not taken.
8286 if (print_stats || is_last_report) {
690
2/2
✓ Branch 0 taken 8260 times.
✓ Branch 1 taken 26 times.
8286 const char end = is_last_report ? '\n' : '\r';
691
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8286 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8286 if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) {
692 fprintf(stderr, "%s %c", buf.str, end);
693 } else
694 8286 av_log(NULL, AV_LOG_INFO, "%s %c", buf.str, end);
695
696 8286 fflush(stderr);
697 }
698 8286 av_bprint_finalize(&buf, NULL);
699
700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8286 times.
8286 if (progress_avio) {
701 av_bprintf(&buf_script, "progress=%s\n",
702 is_last_report ? "end" : "continue");
703 avio_write(progress_avio, buf_script.str,
704 FFMIN(buf_script.len, buf_script.size - 1));
705 avio_flush(progress_avio);
706 av_bprint_finalize(&buf_script, NULL);
707 if (is_last_report) {
708 if ((ret = avio_closep(&progress_avio)) < 0)
709 av_log(NULL, AV_LOG_ERROR,
710 "Error closing progress log, loss of information possible: %s\n", av_err2str(ret));
711 }
712 }
713
714 8286 first_report = 0;
715 }
716
717 8260 static void print_stream_maps(void)
718 {
719 8260 av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
720
2/2
✓ Branch 2 taken 7774 times.
✓ Branch 3 taken 8260 times.
16034 for (InputStream *ist = ist_iter(NULL); ist; ist = ist_iter(ist)) {
721
2/2
✓ Branch 0 taken 6821 times.
✓ Branch 1 taken 7774 times.
14595 for (int j = 0; j < ist->nb_filters; j++) {
722
2/2
✓ Branch 1 taken 149 times.
✓ Branch 2 taken 6672 times.
6821 if (!filtergraph_is_simple(ist->filters[j]->graph)) {
723 av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s",
724 149 ist->file->index, ist->index, ist->dec ? ist->dec->name : "?",
725
1/2
✓ Branch 0 taken 149 times.
✗ Branch 1 not taken.
149 ist->filters[j]->name);
726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149 times.
149 if (nb_filtergraphs > 1)
727 av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index);
728 149 av_log(NULL, AV_LOG_INFO, "\n");
729 }
730 }
731 }
732
733
2/2
✓ Branch 2 taken 8746 times.
✓ Branch 3 taken 8260 times.
17006 for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
734
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8745 times.
8746 if (ost->attachment_filename) {
735 /* an attached file */
736 1 av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n",
737 1 ost->attachment_filename, ost->file->index, ost->index);
738 1 continue;
739 }
740
741
4/4
✓ Branch 0 taken 8006 times.
✓ Branch 1 taken 739 times.
✓ Branch 3 taken 1334 times.
✓ Branch 4 taken 6672 times.
8745 if (ost->filter && !filtergraph_is_simple(ost->filter->graph)) {
742 /* output from a complex graph */
743 1334 av_log(NULL, AV_LOG_INFO, " %s", ost->filter->name);
744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1334 times.
1334 if (nb_filtergraphs > 1)
745 av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index);
746
747 1334 av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file->index,
748 1334 ost->index, ost->enc->enc_ctx->codec->name);
749 1334 continue;
750 }
751
752 7411 av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d",
753 7411 ost->ist->file->index,
754 7411 ost->ist->index,
755 7411 ost->file->index,
756 ost->index);
757
2/2
✓ Branch 0 taken 6710 times.
✓ Branch 1 taken 701 times.
7411 if (ost->enc) {
758 6710 const AVCodec *in_codec = ost->ist->dec;
759 6710 const AVCodec *out_codec = ost->enc->enc_ctx->codec;
760 6710 const char *decoder_name = "?";
761 6710 const char *in_codec_name = "?";
762 6710 const char *encoder_name = "?";
763 6710 const char *out_codec_name = "?";
764 const AVCodecDescriptor *desc;
765
766
1/2
✓ Branch 0 taken 6710 times.
✗ Branch 1 not taken.
6710 if (in_codec) {
767 6710 decoder_name = in_codec->name;
768 6710 desc = avcodec_descriptor_get(in_codec->id);
769
1/2
✓ Branch 0 taken 6710 times.
✗ Branch 1 not taken.
6710 if (desc)
770 6710 in_codec_name = desc->name;
771
2/2
✓ Branch 0 taken 6544 times.
✓ Branch 1 taken 166 times.
6710 if (!strcmp(decoder_name, in_codec_name))
772 6544 decoder_name = "native";
773 }
774
775
1/2
✓ Branch 0 taken 6710 times.
✗ Branch 1 not taken.
6710 if (out_codec) {
776 6710 encoder_name = out_codec->name;
777 6710 desc = avcodec_descriptor_get(out_codec->id);
778
1/2
✓ Branch 0 taken 6710 times.
✗ Branch 1 not taken.
6710 if (desc)
779 6710 out_codec_name = desc->name;
780
2/2
✓ Branch 0 taken 6600 times.
✓ Branch 1 taken 110 times.
6710 if (!strcmp(encoder_name, out_codec_name))
781 6600 encoder_name = "native";
782 }
783
784 6710 av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))",
785 in_codec_name, decoder_name,
786 out_codec_name, encoder_name);
787 } else
788 701 av_log(NULL, AV_LOG_INFO, " (copy)");
789 7411 av_log(NULL, AV_LOG_INFO, "\n");
790 }
791 8260 }
792
793 static void set_tty_echo(int on)
794 {
795 #if HAVE_TERMIOS_H
796 struct termios tty;
797 if (tcgetattr(0, &tty) == 0) {
798 if (on) tty.c_lflag |= ECHO;
799 else tty.c_lflag &= ~ECHO;
800 tcsetattr(0, TCSANOW, &tty);
801 }
802 #endif
803 }
804
805 static int check_keyboard_interaction(int64_t cur_time)
806 {
807 int i, key;
808 static int64_t last_time;
809 if (received_nb_signals)
810 return AVERROR_EXIT;
811 /* read_key() returns 0 on EOF */
812 if (cur_time - last_time >= 100000) {
813 key = read_key();
814 last_time = cur_time;
815 }else
816 key = -1;
817 if (key == 'q') {
818 av_log(NULL, AV_LOG_INFO, "\n\n[q] command received. Exiting.\n\n");
819 return AVERROR_EXIT;
820 }
821 if (key == '+') av_log_set_level(av_log_get_level()+10);
822 if (key == '-') av_log_set_level(av_log_get_level()-10);
823 if (key == 'c' || key == 'C'){
824 char buf[4096], target[64], command[256], arg[256] = {0};
825 double time;
826 int k, n = 0;
827 fprintf(stderr, "\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
828 i = 0;
829 set_tty_echo(1);
830 while ((k = read_key()) != '\n' && k != '\r' && i < sizeof(buf)-1)
831 if (k > 0)
832 buf[i++] = k;
833 buf[i] = 0;
834 set_tty_echo(0);
835 fprintf(stderr, "\n");
836 if (k > 0 &&
837 (n = sscanf(buf, "%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
838 av_log(NULL, AV_LOG_DEBUG, "Processing command target:%s time:%f command:%s arg:%s",
839 target, time, command, arg);
840 for (OutputStream *ost = ost_iter(NULL); ost; ost = ost_iter(ost)) {
841 if (ost->fg_simple)
842 fg_send_command(ost->fg_simple, time, target, command, arg,
843 key == 'C');
844 }
845 for (i = 0; i < nb_filtergraphs; i++)
846 fg_send_command(filtergraphs[i], time, target, command, arg,
847 key == 'C');
848 } else {
849 av_log(NULL, AV_LOG_ERROR,
850 "Parse error, at least 3 arguments were expected, "
851 "only %d given in string '%s'\n", n, buf);
852 }
853 }
854 if (key == '?'){
855 fprintf(stderr, "key function\n"
856 "? show this help\n"
857 "+ increase verbosity\n"
858 "- decrease verbosity\n"
859 "c Send command to first matching filter supporting it\n"
860 "C Send/Queue command to all matching filters\n"
861 "h dump packets/hex press to cycle through the 3 states\n"
862 "q quit\n"
863 "s Show QP histogram\n"
864 );
865 }
866 return 0;
867 }
868
869 /*
870 * The following code is the main loop of the file converter
871 */
872 8260 static int transcode(Scheduler *sch)
873 {
874 8260 int ret = 0;
875 8260 int64_t timer_start, transcode_ts = 0;
876
877 8260 print_stream_maps();
878
879 8260 atomic_store(&transcode_init_done, 1);
880
881 8260 ret = sch_start(sch);
882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8260 times.
8260 if (ret < 0)
883 return ret;
884
885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8260 times.
8260 if (stdin_interaction) {
886 av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
887 }
888
889 8260 timer_start = av_gettime_relative();
890
891
2/2
✓ Branch 1 taken 17407 times.
✓ Branch 2 taken 8260 times.
25667 while (!sch_wait(sch, stats_period, &transcode_ts)) {
892 17407 int64_t cur_time= av_gettime_relative();
893
894 /* if 'q' pressed, exits */
895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17407 times.
17407 if (stdin_interaction)
896 if (check_keyboard_interaction(cur_time) < 0)
897 break;
898
899 /* dump report by using the output first video and audio streams */
900 17407 print_report(0, timer_start, cur_time, transcode_ts);
901 }
902
903 8260 ret = sch_stop(sch, &transcode_ts);
904
905 /* write the trailer if needed */
906
2/2
✓ Branch 0 taken 8262 times.
✓ Branch 1 taken 8260 times.
16522 for (int i = 0; i < nb_output_files; i++) {
907 8262 int err = of_write_trailer(output_files[i]);
908 8262 ret = err_merge(ret, err);
909 }
910
911 8260 term_exit();
912
913 /* dump report by using the first video and audio streams */
914 8260 print_report(1, timer_start, av_gettime_relative(), transcode_ts);
915
916 8260 return ret;
917 }
918
919 8260 static BenchmarkTimeStamps get_benchmark_time_stamps(void)
920 {
921 8260 BenchmarkTimeStamps time_stamps = { av_gettime_relative() };
922 #if HAVE_GETRUSAGE
923 struct rusage rusage;
924
925 8260 getrusage(RUSAGE_SELF, &rusage);
926 8260 time_stamps.user_usec =
927 8260 (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
928 8260 time_stamps.sys_usec =
929 8260 (rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec;
930 #elif HAVE_GETPROCESSTIMES
931 HANDLE proc;
932 FILETIME c, e, k, u;
933 proc = GetCurrentProcess();
934 GetProcessTimes(proc, &c, &e, &k, &u);
935 time_stamps.user_usec =
936 ((int64_t)u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
937 time_stamps.sys_usec =
938 ((int64_t)k.dwHighDateTime << 32 | k.dwLowDateTime) / 10;
939 #else
940 time_stamps.user_usec = time_stamps.sys_usec = 0;
941 #endif
942 8260 return time_stamps;
943 }
944
945 static int64_t getmaxrss(void)
946 {
947 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
948 struct rusage rusage;
949 getrusage(RUSAGE_SELF, &rusage);
950 return (int64_t)rusage.ru_maxrss * 1024;
951 #elif HAVE_GETPROCESSMEMORYINFO
952 HANDLE proc;
953 PROCESS_MEMORY_COUNTERS memcounters;
954 proc = GetCurrentProcess();
955 memcounters.cb = sizeof(memcounters);
956 GetProcessMemoryInfo(proc, &memcounters, sizeof(memcounters));
957 return memcounters.PeakPagefileUsage;
958 #else
959 return 0;
960 #endif
961 }
962
963 8261 int main(int argc, char **argv)
964 {
965 8261 Scheduler *sch = NULL;
966
967 int ret;
968 BenchmarkTimeStamps ti;
969
970 8261 init_dynload();
971
972 8261 setvbuf(stderr,NULL,_IONBF,0); /* win32 runtime needs this */
973
974 8261 av_log_set_flags(AV_LOG_SKIP_REPEATED);
975 8261 parse_loglevel(argc, argv, options);
976
977 #if CONFIG_AVDEVICE
978 8261 avdevice_register_all();
979 #endif
980 8261 avformat_network_init();
981
982 8261 show_banner(argc, argv, options);
983
984 8261 sch = sch_alloc();
985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8261 times.
8261 if (!sch) {
986 ret = AVERROR(ENOMEM);
987 goto finish;
988 }
989
990 /* parse options and open all input/output files */
991 8261 ret = ffmpeg_parse_options(argc, argv, sch);
992
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8260 times.
8261 if (ret < 0)
993 1 goto finish;
994
995
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8260 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8260 if (nb_output_files <= 0 && nb_input_files == 0) {
996 show_usage();
997 av_log(NULL, AV_LOG_WARNING, "Use -h to get full help or, even better, run 'man %s'\n", program_name);
998 ret = 1;
999 goto finish;
1000 }
1001
1002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8260 times.
8260 if (nb_output_files <= 0) {
1003 av_log(NULL, AV_LOG_FATAL, "At least one output file must be specified\n");
1004 ret = 1;
1005 goto finish;
1006 }
1007
1008 8260 current_time = ti = get_benchmark_time_stamps();
1009 8260 ret = transcode(sch);
1010
3/4
✓ Branch 0 taken 8259 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8259 times.
8260 if (ret >= 0 && do_benchmark) {
1011 int64_t utime, stime, rtime;
1012 current_time = get_benchmark_time_stamps();
1013 utime = current_time.user_usec - ti.user_usec;
1014 stime = current_time.sys_usec - ti.sys_usec;
1015 rtime = current_time.real_usec - ti.real_usec;
1016 av_log(NULL, AV_LOG_INFO,
1017 "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
1018 utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);
1019 }
1020
1021
1/2
✓ Branch 0 taken 8260 times.
✗ Branch 1 not taken.
16520 ret = received_nb_signals ? 255 :
1022
2/2
✓ Branch 0 taken 8259 times.
✓ Branch 1 taken 1 times.
8260 (ret == FFMPEG_ERROR_RATE_EXCEEDED) ? 69 : ret;
1023
1024 8261 finish:
1025
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8260 times.
8261 if (ret == AVERROR_EXIT)
1026 1 ret = 0;
1027
1028 8261 ffmpeg_cleanup(ret);
1029
1030 8261 sch_free(&sch);
1031
1032 8261 av_log(NULL, AV_LOG_VERBOSE, "\n");
1033 8261 av_log(NULL, AV_LOG_VERBOSE, "Exiting with exit code %d\n", ret);
1034
1035 8261 return ret;
1036 }
1037