commit 8f760dbea42bd742677cb8dbdaa69f91603bc66d Author: xufuji456 <839789740@qq.com> Date: Tue Jan 23 15:38:35 2018 +0800 基于FFmpeg的音频处理 音频剪切、拼接、混音与转码 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..39fb081 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..7ac24c7 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,18 @@ + + + + + + \ No newline at end of file diff --git a/.idea/markdown-navigator.xml b/.idea/markdown-navigator.xml new file mode 100644 index 0000000..dbe0e46 --- /dev/null +++ b/.idea/markdown-navigator.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/markdown-navigator/profiles_settings.xml b/.idea/markdown-navigator/profiles_settings.xml new file mode 100644 index 0000000..57927c5 --- /dev/null +++ b/.idea/markdown-navigator/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ba7052b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..fb2aa17 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..97b39b1 --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# FFmpegAndroid +android端基于FFmpeg库在中的使用。
+基于ffmpeg3.2.4版本,编译生成libffmpeg.so文件。
+目前音视频相关处理:
+ +- #### 音频剪切、拼接 +- #### 音频混音 +- #### 音频转码 +*** + +后续会加上音视频编解码、合成与分离,视频水印、截图、转Gif动图、剪切、转码。 +

+ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt new file mode 100644 index 0000000..c58c10f --- /dev/null +++ b/app/CMakeLists.txt @@ -0,0 +1,45 @@ +# For more information about using CMake with Android Studio, read the +# documentation: https://d.android.com/studio/projects/add-native-code.html + +# Sets the minimum version of CMake required to build the native library. + +cmake_minimum_required(VERSION 3.4.1) + +# Creates and names a library, sets it as either STATIC +# or SHARED, and provides the relative paths to its source code. +# You can define multiple libraries, and CMake builds them for you. +# Gradle automatically packages shared libraries with your APK. + +add_library( # Sets the name of the library. + audio-handle + + # Sets the library as a shared library. + SHARED + + # Provides a relative path to your source file(s). + src/main/cpp/ffmpeg_cmd.c + src/main/cpp/cmdutils.c + src/main/cpp/ffmpeg.c + src/main/cpp/ffmpeg_filter.c + src/main/cpp/ffmpeg_opt.c) + +add_library( ffmpeg + SHARED + IMPORTED ) +set_target_properties( ffmpeg + PROPERTIES IMPORTED_LOCATION + ../../../../libs/armeabi-v7a/libffmpeg.so ) + +include_directories(src/main/cpp) +include_directories(src/main/cpp/include) + +find_library( # Sets the name of the path variable. + log-lib + log ) + +target_link_libraries( # Specifies the target library. + audio-handle + ffmpeg + # Links the target library to the log library + # included in the NDK. + ${log-lib} ) \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..58ef199 --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,50 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion "25.0.2" + defaultConfig { + applicationId "com.frank.ffmpeg" + minSdkVersion 17 + targetSdkVersion 22 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + externalNativeBuild { + cmake { + cppFlags "" + } + } + ndk { + abiFilters "armeabi-v7a" + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + externalNativeBuild { + cmake { + path "CMakeLists.txt" + } + } + sourceSets { + main { + jniLibs.srcDirs = ['libs'] + jni.srcDirs = [] + } + } +} + +dependencies { + compile fileTree(include: ['*.jar'], dir: 'libs') + androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { + exclude group: 'com.android.support', module: 'support-annotations' + }) + compile 'com.android.support:appcompat-v7:25.0.0' + testCompile 'junit:junit:4.12' +} diff --git a/app/libs/armeabi-v7a/libffmpeg.so b/app/libs/armeabi-v7a/libffmpeg.so new file mode 100644 index 0000000..f0f699c Binary files /dev/null and b/app/libs/armeabi-v7a/libffmpeg.so differ diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..7aa439a --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,25 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in D:\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/app/src/androidTest/java/com/frank/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/frank/ExampleInstrumentedTest.java new file mode 100644 index 0000000..0b689d4 --- /dev/null +++ b/app/src/androidTest/java/com/frank/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.frank; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumentation test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() throws Exception { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("codepig.ffmpegcldemo", appContext.getPackageName()); + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..99878b2 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/cpp/cmdutils.c b/app/src/main/cpp/cmdutils.c new file mode 100644 index 0000000..dc6b16a --- /dev/null +++ b/app/src/main/cpp/cmdutils.c @@ -0,0 +1,2241 @@ +/* + * Various utilities for command line tools + * Copyright (c) 2000-2003 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include +#include + +/* Include only the enabled headers since some compilers (namely, Sun + Studio) will not omit unused inline functions and create undefined + references to libraries that are not being built. */ + +#include "config.h" +#include "compat/va_copy.h" +#include "libavformat/avformat.h" +#include "libavfilter/avfilter.h" +#include "libavresample/avresample.h" +#include "libavdevice/avdevice.h" +#include "libswresample/swresample.h" +#include "libswscale/swscale.h" +#include "libpostproc/postprocess.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/bprint.h" +#include "libavutil/display.h" +#include "libavutil/mathematics.h" +#include "libavutil/imgutils.h" +#include "libavutil/libm.h" +#include "libavutil/parseutils.h" +#include "libavutil/pixdesc.h" +#include "libavutil/eval.h" +#include "libavutil/dict.h" +#include "libavutil/opt.h" +#include "libavutil/cpu.h" +#include "libavutil/version.h" +#include "cmdutils.h" +#if CONFIG_NETWORK +#include "libavformat/network.h" +#endif +#if HAVE_SYS_RESOURCE_H +#include +#include +#endif + +static int init_report(const char *env); + +AVDictionary *sws_dict; +AVDictionary *swr_opts; +AVDictionary *format_opts, *codec_opts, *resample_opts; + +static FILE *report_file; +static int report_file_level = AV_LOG_DEBUG; +int hide_banner = 0; + +void init_opts(void) +{ + av_dict_set(&sws_dict, "flags", "bicubic", 0); +} + +void uninit_opts(void) +{ + av_dict_free(&swr_opts); + av_dict_free(&sws_dict); + av_dict_free(&format_opts); + av_dict_free(&codec_opts); + av_dict_free(&resample_opts); +} + +void log_callback_help(void *ptr, int level, const char *fmt, va_list vl) +{ + vfprintf(stdout, fmt, vl); +} + +static void log_callback_report(void *ptr, int level, const char *fmt, va_list vl) +{ + va_list vl2; + char line[1024]; + static int print_prefix = 1; + + va_copy(vl2, vl); + av_log_default_callback(ptr, level, fmt, vl); + av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix); + va_end(vl2); + if (report_file_level >= level) { + fputs(line, report_file); + fflush(report_file); + } +} + +static void (*program_exit)(int ret); + +void register_exit(void (*cb)(int ret)) +{ + program_exit = cb; +} + +int exit_program(int ret) +{ + return ret; +} + +double parse_number_or_die(const char *context, const char *numstr, int type, + double min, double max) +{ + char *tail; + const char *error; + double d = av_strtod(numstr, &tail); + if (*tail) + error = "Expected number for %s but found: %s\n"; + else if (d < min || d > max) + error = "The value for %s was %s which is not within %f - %f\n"; + else if (type == OPT_INT64 && (int64_t)d != d) + error = "Expected int64 for %s but found %s\n"; + else if (type == OPT_INT && (int)d != d) + error = "Expected int for %s but found %s\n"; + else + return d; + av_log(NULL, AV_LOG_FATAL, error, context, numstr, min, max); + exit_program(1); + return 0; +} + +int64_t parse_time_or_die(const char *context, const char *timestr, + int is_duration) +{ + int64_t us; + if (av_parse_time(&us, timestr, is_duration) < 0) { + av_log(NULL, AV_LOG_FATAL, "Invalid %s specification for %s: %s\n", + is_duration ? "duration" : "date", context, timestr); + exit_program(1); + } + return us; +} + +void show_help_options(const OptionDef *options, const char *msg, int req_flags, + int rej_flags, int alt_flags) +{ + const OptionDef *po; + int first; + + first = 1; + for (po = options; po->name; po++) { + char buf[64]; + + if (((po->flags & req_flags) != req_flags) || + (alt_flags && !(po->flags & alt_flags)) || + (po->flags & rej_flags)) + continue; + + if (first) { + printf("%s\n", msg); + first = 0; + } + av_strlcpy(buf, po->name, sizeof(buf)); + if (po->argname) { + av_strlcat(buf, " ", sizeof(buf)); + av_strlcat(buf, po->argname, sizeof(buf)); + } + printf("-%-17s %s\n", buf, po->help); + } + printf("\n"); +} + +void show_help_children(const AVClass *class, int flags) +{ + const AVClass *child = NULL; + if (class->option) { + av_opt_show2(&class, NULL, flags, 0); + printf("\n"); + } + + while (child = av_opt_child_class_next(class, child)) + show_help_children(child, flags); +} + +static const OptionDef *find_option(const OptionDef *po, const char *name) +{ + const char *p = strchr(name, ':'); + int len = p ? p - name : strlen(name); + + while (po->name) { + if (!strncmp(name, po->name, len) && strlen(po->name) == len) + break; + po++; + } + return po; +} + +/* _WIN32 means using the windows libc - cygwin doesn't define that + * by default. HAVE_COMMANDLINETOARGVW is true on cygwin, while + * it doesn't provide the actual command line via GetCommandLineW(). */ +#if HAVE_COMMANDLINETOARGVW && defined(_WIN32) +#include +#include +/* Will be leaked on exit */ +static char** win32_argv_utf8 = NULL; +static int win32_argc = 0; + +/** + * Prepare command line arguments for executable. + * For Windows - perform wide-char to UTF-8 conversion. + * Input arguments should be main() function arguments. + * @param argc_ptr Arguments number (including executable) + * @param argv_ptr Arguments list. + */ +static void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) +{ + char *argstr_flat; + wchar_t **argv_w; + int i, buffsize = 0, offset = 0; + + if (win32_argv_utf8) { + *argc_ptr = win32_argc; + *argv_ptr = win32_argv_utf8; + return; + } + + win32_argc = 0; + argv_w = CommandLineToArgvW(GetCommandLineW(), &win32_argc); + if (win32_argc <= 0 || !argv_w) + return; + + /* determine the UTF-8 buffer size (including NULL-termination symbols) */ + for (i = 0; i < win32_argc; i++) + buffsize += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, + NULL, 0, NULL, NULL); + + win32_argv_utf8 = av_mallocz(sizeof(char *) * (win32_argc + 1) + buffsize); + argstr_flat = (char *)win32_argv_utf8 + sizeof(char *) * (win32_argc + 1); + if (!win32_argv_utf8) { + LocalFree(argv_w); + return; + } + + for (i = 0; i < win32_argc; i++) { + win32_argv_utf8[i] = &argstr_flat[offset]; + offset += WideCharToMultiByte(CP_UTF8, 0, argv_w[i], -1, + &argstr_flat[offset], + buffsize - offset, NULL, NULL); + } + win32_argv_utf8[i] = NULL; + LocalFree(argv_w); + + *argc_ptr = win32_argc; + *argv_ptr = win32_argv_utf8; +} +#else +static inline void prepare_app_arguments(int *argc_ptr, char ***argv_ptr) +{ + /* nothing to do */ +} +#endif /* HAVE_COMMANDLINETOARGVW */ + +static int write_option(void *optctx, const OptionDef *po, const char *opt, + const char *arg) +{ + /* new-style options contain an offset into optctx, old-style address of + * a global var*/ + void *dst = po->flags & (OPT_OFFSET | OPT_SPEC) ? + (uint8_t *)optctx + po->u.off : po->u.dst_ptr; + int *dstcount; + + if (po->flags & OPT_SPEC) { + SpecifierOpt **so = dst; + char *p = strchr(opt, ':'); + char *str; + + dstcount = (int *)(so + 1); + *so = grow_array(*so, sizeof(**so), dstcount, *dstcount + 1); + str = av_strdup(p ? p + 1 : ""); + if (!str) + return AVERROR(ENOMEM); + (*so)[*dstcount - 1].specifier = str; + dst = &(*so)[*dstcount - 1].u; + } + + if (po->flags & OPT_STRING) { + char *str; + str = av_strdup(arg); + av_freep(dst); + if (!str) + return AVERROR(ENOMEM); + *(char **)dst = str; + } else if (po->flags & OPT_BOOL || po->flags & OPT_INT) { + *(int *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT_MIN, INT_MAX); + } else if (po->flags & OPT_INT64) { + *(int64_t *)dst = parse_number_or_die(opt, arg, OPT_INT64, INT64_MIN, INT64_MAX); + } else if (po->flags & OPT_TIME) { + *(int64_t *)dst = parse_time_or_die(opt, arg, 1); + } else if (po->flags & OPT_FLOAT) { + *(float *)dst = parse_number_or_die(opt, arg, OPT_FLOAT, -INFINITY, INFINITY); + } else if (po->flags & OPT_DOUBLE) { + *(double *)dst = parse_number_or_die(opt, arg, OPT_DOUBLE, -INFINITY, INFINITY); + } else if (po->u.func_arg) { + int ret = po->u.func_arg(optctx, opt, arg); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, + "Failed to set value '%s' for option '%s': %s\n", + arg, opt, av_err2str(ret)); + return ret; + } + } + if (po->flags & OPT_EXIT) + exit_program(0); + + return 0; +} + +int parse_option(void *optctx, const char *opt, const char *arg, + const OptionDef *options) +{ + const OptionDef *po; + int ret; + + po = find_option(options, opt); + if (!po->name && opt[0] == 'n' && opt[1] == 'o') { + /* handle 'no' bool option */ + po = find_option(options, opt + 2); + if ((po->name && (po->flags & OPT_BOOL))) + arg = "0"; + } else if (po->flags & OPT_BOOL) + arg = "1"; + + if (!po->name) + po = find_option(options, "default"); + if (!po->name) { + av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'\n", opt); + return AVERROR(EINVAL); + } + if (po->flags & HAS_ARG && !arg) { + av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'\n", opt); + return AVERROR(EINVAL); + } + + ret = write_option(optctx, po, opt, arg); + if (ret < 0) + return ret; + + return !!(po->flags & HAS_ARG); +} + +void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, + void (*parse_arg_function)(void *, const char*)) +{ + const char *opt; + int optindex, handleoptions = 1, ret; + + /* perform system-dependent conversions for arguments list */ + prepare_app_arguments(&argc, &argv); + + /* parse options */ + optindex = 1; + while (optindex < argc) { + opt = argv[optindex++]; + + if (handleoptions && opt[0] == '-' && opt[1] != '\0') { + if (opt[1] == '-' && opt[2] == '\0') { + handleoptions = 0; + continue; + } + opt++; + + if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0) + exit_program(1); + optindex += ret; + } else { + if (parse_arg_function) + parse_arg_function(optctx, opt); + } + } +} + +int parse_optgroup(void *optctx, OptionGroup *g) +{ + int i, ret; + + av_log(NULL, AV_LOG_DEBUG, "Parsing a group of options: %s %s.\n", + g->group_def->name, g->arg); + + for (i = 0; i < g->nb_opts; i++) { + Option *o = &g->opts[i]; + + if (g->group_def->flags && + !(g->group_def->flags & o->opt->flags)) { + av_log(NULL, AV_LOG_ERROR, "Option %s (%s) cannot be applied to " + "%s %s -- you are trying to apply an input option to an " + "output file or vice versa. Move this option before the " + "file it belongs to.\n", o->key, o->opt->help, + g->group_def->name, g->arg); + return AVERROR(EINVAL); + } + + av_log(NULL, AV_LOG_DEBUG, "Applying option %s (%s) with argument %s.\n", + o->key, o->opt->help, o->val); + + ret = write_option(optctx, o->opt, o->key, o->val); + if (ret < 0) + return ret; + } + + av_log(NULL, AV_LOG_DEBUG, "Successfully parsed a group of options.\n"); + + return 0; +} + +int locate_option(int argc, char **argv, const OptionDef *options, + const char *optname) +{ + const OptionDef *po; + int i; + + for (i = 1; i < argc; i++) { + const char *cur_opt = argv[i]; + + if (*cur_opt++ != '-') + continue; + + po = find_option(options, cur_opt); + if (!po->name && cur_opt[0] == 'n' && cur_opt[1] == 'o') + po = find_option(options, cur_opt + 2); + + if ((!po->name && !strcmp(cur_opt, optname)) || + (po->name && !strcmp(optname, po->name))) + return i; + + if (!po->name || po->flags & HAS_ARG) + i++; + } + return 0; +} + +static void dump_argument(const char *a) +{ + const unsigned char *p; + + for (p = a; *p; p++) + if (!((*p >= '+' && *p <= ':') || (*p >= '@' && *p <= 'Z') || + *p == '_' || (*p >= 'a' && *p <= 'z'))) + break; + if (!*p) { + fputs(a, report_file); + return; + } + fputc('"', report_file); + for (p = a; *p; p++) { + if (*p == '\\' || *p == '"' || *p == '$' || *p == '`') + fprintf(report_file, "\\%c", *p); + else if (*p < ' ' || *p > '~') + fprintf(report_file, "\\x%02x", *p); + else + fputc(*p, report_file); + } + fputc('"', report_file); +} + +static void check_options(const OptionDef *po) +{ + while (po->name) { + if (po->flags & OPT_PERFILE) + av_assert0(po->flags & (OPT_INPUT | OPT_OUTPUT)); + po++; + } +} + +void parse_loglevel(int argc, char **argv, const OptionDef *options) +{ + int idx = locate_option(argc, argv, options, "loglevel"); + const char *env; + + check_options(options); + + if (!idx) + idx = locate_option(argc, argv, options, "v"); + if (idx && argv[idx + 1]) + opt_loglevel(NULL, "loglevel", argv[idx + 1]); + idx = locate_option(argc, argv, options, "report"); + if ((env = getenv("FFREPORT")) || idx) { + init_report(env); + if (report_file) { + int i; + fprintf(report_file, "Command line:\n"); + for (i = 0; i < argc; i++) { + dump_argument(argv[i]); + fputc(i < argc - 1 ? ' ' : '\n', report_file); + } + fflush(report_file); + } + } + idx = locate_option(argc, argv, options, "hide_banner"); + if (idx) + hide_banner = 1; +} + +static const AVOption *opt_find(void *obj, const char *name, const char *unit, + int opt_flags, int search_flags) +{ + const AVOption *o = av_opt_find(obj, name, unit, opt_flags, search_flags); + if(o && !o->flags) + return NULL; + return o; +} + +#define FLAGS (o->type == AV_OPT_TYPE_FLAGS && (arg[0]=='-' || arg[0]=='+')) ? AV_DICT_APPEND : 0 +int opt_default(void *optctx, const char *opt, const char *arg) +{ + const AVOption *o; + int consumed = 0; + char opt_stripped[128]; + const char *p; + const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); +#if CONFIG_AVRESAMPLE + const AVClass *rc = avresample_get_class(); +#endif +#if CONFIG_SWSCALE + const AVClass *sc = sws_get_class(); +#endif +#if CONFIG_SWRESAMPLE + const AVClass *swr_class = swr_get_class(); +#endif + + if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) + av_log_set_level(AV_LOG_DEBUG); + + if (!(p = strchr(opt, ':'))) + p = opt + strlen(opt); + av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); + + if ((o = opt_find(&cc, opt_stripped, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || + ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && + (o = opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) { + av_dict_set(&codec_opts, opt, arg, FLAGS); + consumed = 1; + } + if ((o = opt_find(&fc, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + av_dict_set(&format_opts, opt, arg, FLAGS); + if (consumed) + av_log(NULL, AV_LOG_VERBOSE, "Routing option %s to both codec and muxer layer\n", opt); + consumed = 1; + } +#if CONFIG_SWSCALE + if (!consumed && (o = opt_find(&sc, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + struct SwsContext *sws = sws_alloc_context(); + int ret = av_opt_set(sws, opt, arg, 0); + sws_freeContext(sws); + if (!strcmp(opt, "srcw") || !strcmp(opt, "srch") || + !strcmp(opt, "dstw") || !strcmp(opt, "dsth") || + !strcmp(opt, "src_format") || !strcmp(opt, "dst_format")) { + av_log(NULL, AV_LOG_ERROR, "Directly using swscale dimensions/format options is not supported, please use the -s or -pix_fmt options\n"); + return AVERROR(EINVAL); + } + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); + return ret; + } + + av_dict_set(&sws_dict, opt, arg, FLAGS); + + consumed = 1; + } +#else + if (!consumed && !strcmp(opt, "sws_flags")) { + av_log(NULL, AV_LOG_WARNING, "Ignoring %s %s, due to disabled swscale\n", opt, arg); + consumed = 1; + } +#endif +#if CONFIG_SWRESAMPLE + if (!consumed && (o=opt_find(&swr_class, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + struct SwrContext *swr = swr_alloc(); + int ret = av_opt_set(swr, opt, arg, 0); + swr_free(&swr); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); + return ret; + } + av_dict_set(&swr_opts, opt, arg, FLAGS); + consumed = 1; + } +#endif +#if CONFIG_AVRESAMPLE + if ((o=opt_find(&rc, opt, NULL, 0, + AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { + av_dict_set(&resample_opts, opt, arg, FLAGS); + consumed = 1; + } +#endif + + if (consumed) + return 0; + return AVERROR_OPTION_NOT_FOUND; +} + +/* + * Check whether given option is a group separator. + * + * @return index of the group definition that matched or -1 if none + */ +static int match_group_separator(const OptionGroupDef *groups, int nb_groups, + const char *opt) +{ + int i; + + for (i = 0; i < nb_groups; i++) { + const OptionGroupDef *p = &groups[i]; + if (p->sep && !strcmp(p->sep, opt)) + return i; + } + + return -1; +} + +/* + * Finish parsing an option group. + * + * @param group_idx which group definition should this group belong to + * @param arg argument of the group delimiting option + */ +static void finish_group(OptionParseContext *octx, int group_idx, + const char *arg) +{ + OptionGroupList *l = &octx->groups[group_idx]; + OptionGroup *g; + + GROW_ARRAY(l->groups, l->nb_groups); + g = &l->groups[l->nb_groups - 1]; + + *g = octx->cur_group; + g->arg = arg; + g->group_def = l->group_def; + g->sws_dict = sws_dict; + g->swr_opts = swr_opts; + g->codec_opts = codec_opts; + g->format_opts = format_opts; + g->resample_opts = resample_opts; + + codec_opts = NULL; + format_opts = NULL; + resample_opts = NULL; + sws_dict = NULL; + swr_opts = NULL; + init_opts(); + + memset(&octx->cur_group, 0, sizeof(octx->cur_group)); +} + +/* + * Add an option instance to currently parsed group. + */ +static void add_opt(OptionParseContext *octx, const OptionDef *opt, + const char *key, const char *val) +{ + int global = !(opt->flags & (OPT_PERFILE | OPT_SPEC | OPT_OFFSET)); + OptionGroup *g = global ? &octx->global_opts : &octx->cur_group; + + GROW_ARRAY(g->opts, g->nb_opts); + g->opts[g->nb_opts - 1].opt = opt; + g->opts[g->nb_opts - 1].key = key; + g->opts[g->nb_opts - 1].val = val; +} + +static void init_parse_context(OptionParseContext *octx, + const OptionGroupDef *groups, int nb_groups) +{ + static const OptionGroupDef global_group = { "global" }; + int i; + + memset(octx, 0, sizeof(*octx)); + + octx->nb_groups = nb_groups; + octx->groups = av_mallocz_array(octx->nb_groups, sizeof(*octx->groups)); + if (!octx->groups) + exit_program(1); + + for (i = 0; i < octx->nb_groups; i++) + octx->groups[i].group_def = &groups[i]; + + octx->global_opts.group_def = &global_group; + octx->global_opts.arg = ""; + + init_opts(); +} + +void uninit_parse_context(OptionParseContext *octx) +{ + int i, j; + + for (i = 0; i < octx->nb_groups; i++) { + OptionGroupList *l = &octx->groups[i]; + + for (j = 0; j < l->nb_groups; j++) { + av_freep(&l->groups[j].opts); + av_dict_free(&l->groups[j].codec_opts); + av_dict_free(&l->groups[j].format_opts); + av_dict_free(&l->groups[j].resample_opts); + + av_dict_free(&l->groups[j].sws_dict); + av_dict_free(&l->groups[j].swr_opts); + } + av_freep(&l->groups); + } + av_freep(&octx->groups); + + av_freep(&octx->cur_group.opts); + av_freep(&octx->global_opts.opts); + + uninit_opts(); +} + +int split_commandline(OptionParseContext *octx, int argc, char *argv[], + const OptionDef *options, + const OptionGroupDef *groups, int nb_groups) +{ + int optindex = 1; + int dashdash = -2; + + /* perform system-dependent conversions for arguments list */ + prepare_app_arguments(&argc, &argv); + + init_parse_context(octx, groups, nb_groups); + av_log(NULL, AV_LOG_DEBUG, "Splitting the commandline.\n"); + + while (optindex < argc) { + const char *opt = argv[optindex++], *arg; + const OptionDef *po; + int ret; + + av_log(NULL, AV_LOG_DEBUG, "Reading option '%s' ...", opt); + + if (opt[0] == '-' && opt[1] == '-' && !opt[2]) { + dashdash = optindex; + continue; + } + /* unnamed group separators, e.g. output filename */ + if (opt[0] != '-' || !opt[1] || dashdash+1 == optindex) { + finish_group(octx, 0, opt); + av_log(NULL, AV_LOG_DEBUG, " matched as %s.\n", groups[0].name); + continue; + } + opt++; + +#define GET_ARG(arg) \ +do { \ + arg = argv[optindex++]; \ + if (!arg) { \ + av_log(NULL, AV_LOG_ERROR, "Missing argument for option '%s'.\n", opt);\ + return AVERROR(EINVAL); \ + } \ +} while (0) + + /* named group separators, e.g. -i */ + if ((ret = match_group_separator(groups, nb_groups, opt)) >= 0) { + GET_ARG(arg); + finish_group(octx, ret, arg); + av_log(NULL, AV_LOG_DEBUG, " matched as %s with argument '%s'.\n", + groups[ret].name, arg); + continue; + } + + /* normal options */ + po = find_option(options, opt); + if (po->name) { + if (po->flags & OPT_EXIT) { + /* optional argument, e.g. -h */ + arg = argv[optindex++]; + } else if (po->flags & HAS_ARG) { + GET_ARG(arg); + } else { + arg = "1"; + } + + add_opt(octx, po, opt, arg); + av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with " + "argument '%s'.\n", po->name, po->help, arg); + continue; + } + + /* AVOptions */ + if (argv[optindex]) { + ret = opt_default(NULL, opt, argv[optindex]); + if (ret >= 0) { + av_log(NULL, AV_LOG_DEBUG, " matched as AVOption '%s' with " + "argument '%s'.\n", opt, argv[optindex]); + optindex++; + continue; + } else if (ret != AVERROR_OPTION_NOT_FOUND) { + av_log(NULL, AV_LOG_ERROR, "Error parsing option '%s' " + "with argument '%s'.\n", opt, argv[optindex]); + return ret; + } + } + + /* boolean -nofoo options */ + if (opt[0] == 'n' && opt[1] == 'o' && + (po = find_option(options, opt + 2)) && + po->name && po->flags & OPT_BOOL) { + add_opt(octx, po, opt, "0"); + av_log(NULL, AV_LOG_DEBUG, " matched as option '%s' (%s) with " + "argument 0.\n", po->name, po->help); + continue; + } + + av_log(NULL, AV_LOG_ERROR, "Unrecognized option '%s'.\n", opt); + return AVERROR_OPTION_NOT_FOUND; + } + + if (octx->cur_group.nb_opts || codec_opts || format_opts || resample_opts) + av_log(NULL, AV_LOG_WARNING, "Trailing options were found on the " + "commandline.\n"); + + av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n"); + + return 0; +} + +int opt_cpuflags(void *optctx, const char *opt, const char *arg) +{ + int ret; + unsigned flags = av_get_cpu_flags(); + + if ((ret = av_parse_cpu_caps(&flags, arg)) < 0) + return ret; + + av_force_cpu_flags(flags); + return 0; +} + +int opt_loglevel(void *optctx, const char *opt, const char *arg) +{ + const struct { const char *name; int level; } log_levels[] = { + { "quiet" , AV_LOG_QUIET }, + { "panic" , AV_LOG_PANIC }, + { "fatal" , AV_LOG_FATAL }, + { "error" , AV_LOG_ERROR }, + { "warning", AV_LOG_WARNING }, + { "info" , AV_LOG_INFO }, + { "verbose", AV_LOG_VERBOSE }, + { "debug" , AV_LOG_DEBUG }, + { "trace" , AV_LOG_TRACE }, + }; + char *tail; + int level; + int flags; + int i; + + flags = av_log_get_flags(); + tail = strstr(arg, "repeat"); + if (tail) + flags &= ~AV_LOG_SKIP_REPEATED; + else + flags |= AV_LOG_SKIP_REPEATED; + + av_log_set_flags(flags); + if (tail == arg) + arg += 6 + (arg[6]=='+'); + if(tail && !*arg) + return 0; + + for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) { + if (!strcmp(log_levels[i].name, arg)) { + av_log_set_level(log_levels[i].level); + return 0; + } + } + + level = strtol(arg, &tail, 10); + if (*tail) { + av_log(NULL, AV_LOG_FATAL, "Invalid loglevel \"%s\". " + "Possible levels are numbers or:\n", arg); + for (i = 0; i < FF_ARRAY_ELEMS(log_levels); i++) + av_log(NULL, AV_LOG_FATAL, "\"%s\"\n", log_levels[i].name); + exit_program(1); + } + av_log_set_level(level); + return 0; +} + +static void expand_filename_template(AVBPrint *bp, const char *template, + struct tm *tm) +{ + int c; + + while ((c = *(template++))) { + if (c == '%') { + if (!(c = *(template++))) + break; + switch (c) { + case 'p': + av_bprintf(bp, "%s", program_name); + break; + case 't': + av_bprintf(bp, "%04d%02d%02d-%02d%02d%02d", + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec); + break; + case '%': + av_bprint_chars(bp, c, 1); + break; + } + } else { + av_bprint_chars(bp, c, 1); + } + } +} + +static int init_report(const char *env) +{ + char *filename_template = NULL; + char *key, *val; + int ret, count = 0; + time_t now; + struct tm *tm; + AVBPrint filename; + + if (report_file) /* already opened */ + return 0; + time(&now); + tm = localtime(&now); + + while (env && *env) { + if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) { + if (count) + av_log(NULL, AV_LOG_ERROR, + "Failed to parse FFREPORT environment variable: %s\n", + av_err2str(ret)); + break; + } + if (*env) + env++; + count++; + if (!strcmp(key, "file")) { + av_free(filename_template); + filename_template = val; + val = NULL; + } else if (!strcmp(key, "level")) { + char *tail; + report_file_level = strtol(val, &tail, 10); + if (*tail) { + av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n"); + exit_program(1); + } + } else { + av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key); + } + av_free(val); + av_free(key); + } + + av_bprint_init(&filename, 0, 1); + expand_filename_template(&filename, + av_x_if_null(filename_template, "%p-%t.log"), tm); + av_free(filename_template); + if (!av_bprint_is_complete(&filename)) { + av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n"); + return AVERROR(ENOMEM); + } + + report_file = fopen(filename.str, "w"); + if (!report_file) { + int ret = AVERROR(errno); + av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n", + filename.str, strerror(errno)); + return ret; + } + av_log_set_callback(log_callback_report); + av_log(NULL, AV_LOG_INFO, + "%s started on %04d-%02d-%02d at %02d:%02d:%02d\n" + "Report written to \"%s\"\n", + program_name, + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, + tm->tm_hour, tm->tm_min, tm->tm_sec, + filename.str); + av_bprint_finalize(&filename, NULL); + return 0; +} + +int opt_report(const char *opt) +{ + return init_report(NULL); +} + +int opt_max_alloc(void *optctx, const char *opt, const char *arg) +{ + char *tail; + size_t max; + + max = strtol(arg, &tail, 10); + if (*tail) { + av_log(NULL, AV_LOG_FATAL, "Invalid max_alloc \"%s\".\n", arg); + exit_program(1); + } + av_max_alloc(max); + return 0; +} + +int opt_timelimit(void *optctx, const char *opt, const char *arg) +{ +#if HAVE_SETRLIMIT + int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX); + struct rlimit rl = { lim, lim + 1 }; + if (setrlimit(RLIMIT_CPU, &rl)) + perror("setrlimit"); +#else + av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt); +#endif + return 0; +} + +void print_error(const char *filename, int err) +{ + char errbuf[128]; + const char *errbuf_ptr = errbuf; + + if (av_strerror(err, errbuf, sizeof(errbuf)) < 0) + errbuf_ptr = strerror(AVUNERROR(err)); + av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr); +} + +static int warned_cfg = 0; + +#define INDENT 1 +#define SHOW_VERSION 2 +#define SHOW_CONFIG 4 +#define SHOW_COPYRIGHT 8 + +#define PRINT_LIB_INFO(libname, LIBNAME, flags, level) \ + if (CONFIG_##LIBNAME) { \ + const char *indent = flags & INDENT? " " : ""; \ + if (flags & SHOW_VERSION) { \ + unsigned int version = libname##_version(); \ + av_log(NULL, level, \ + "%slib%-11s %2d.%3d.%3d / %2d.%3d.%3d\n", \ + indent, #libname, \ + LIB##LIBNAME##_VERSION_MAJOR, \ + LIB##LIBNAME##_VERSION_MINOR, \ + LIB##LIBNAME##_VERSION_MICRO, \ + AV_VERSION_MAJOR(version), AV_VERSION_MINOR(version),\ + AV_VERSION_MICRO(version)); \ + } \ + if (flags & SHOW_CONFIG) { \ + const char *cfg = libname##_configuration(); \ + if (strcmp(FFMPEG_CONFIGURATION, cfg)) { \ + if (!warned_cfg) { \ + av_log(NULL, level, \ + "%sWARNING: library configuration mismatch\n", \ + indent); \ + warned_cfg = 1; \ + } \ + av_log(NULL, level, "%s%-11s configuration: %s\n", \ + indent, #libname, cfg); \ + } \ + } \ + } \ + +static void print_all_libs_info(int flags, int level) +{ + PRINT_LIB_INFO(avutil, AVUTIL, flags, level); + PRINT_LIB_INFO(avcodec, AVCODEC, flags, level); + PRINT_LIB_INFO(avformat, AVFORMAT, flags, level); + PRINT_LIB_INFO(avdevice, AVDEVICE, flags, level); + PRINT_LIB_INFO(avfilter, AVFILTER, flags, level); + PRINT_LIB_INFO(swresample, AVRESAMPLE, flags, level); + PRINT_LIB_INFO(swscale, SWSCALE, flags, level); + PRINT_LIB_INFO(swresample, SWRESAMPLE, flags, level); + PRINT_LIB_INFO(postproc, POSTPROC, flags, level); +} + +static void print_program_info(int flags, int level) +{ + const char *indent = flags & INDENT? " " : ""; + + if (flags & SHOW_COPYRIGHT) + av_log(NULL, level, "\n"); + av_log(NULL, level, FFMPEG_CONFIGURATION, indent); +} + +static void print_buildconf(int flags, int level) +{ + const char *indent = flags & INDENT ? " " : ""; + char str[] = { FFMPEG_CONFIGURATION }; + char *conflist, *remove_tilde, *splitconf; + + // Change all the ' --' strings to '~--' so that + // they can be identified as tokens. + while ((conflist = strstr(str, " --")) != NULL) { + strncpy(conflist, "~--", 3); + } + + // Compensate for the weirdness this would cause + // when passing 'pkg-config --static'. + while ((remove_tilde = strstr(str, "pkg-config~")) != NULL) { + strncpy(remove_tilde, "pkg-config ", 11); + } + + splitconf = strtok(str, "~"); + av_log(NULL, level, "\n%sconfiguration:\n", indent); + while (splitconf != NULL) { + av_log(NULL, level, "%s%s%s\n", indent, indent, splitconf); + splitconf = strtok(NULL, "~"); + } +} + +void show_banner(int argc, char **argv, const OptionDef *options) +{ + int idx = locate_option(argc, argv, options, "version"); + if (hide_banner || idx) + return; + + print_program_info (INDENT|SHOW_COPYRIGHT, AV_LOG_INFO); + print_all_libs_info(INDENT|SHOW_CONFIG, AV_LOG_INFO); + print_all_libs_info(INDENT|SHOW_VERSION, AV_LOG_INFO); +} + +int show_version(void *optctx, const char *opt, const char *arg) +{ + av_log_set_callback(log_callback_help); + print_program_info (SHOW_COPYRIGHT, AV_LOG_INFO); + print_all_libs_info(SHOW_VERSION, AV_LOG_INFO); + + return 0; +} + +int show_buildconf(void *optctx, const char *opt, const char *arg) +{ + av_log_set_callback(log_callback_help); + print_buildconf (INDENT|0, AV_LOG_INFO); + + return 0; +} + +int show_license(void *optctx, const char *opt, const char *arg) +{ +#if CONFIG_NONFREE + printf( + "This version of %s has nonfree parts compiled in.\n" + "Therefore it is not legally redistributable.\n", + program_name ); +#elif CONFIG_GPLV3 + printf( + "%s is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation; either version 3 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "%s is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with %s. If not, see .\n", + program_name, program_name, program_name ); +#elif CONFIG_GPL + printf( + "%s is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation; either version 2 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "%s is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with %s; if not, write to the Free Software\n" + "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n", + program_name, program_name, program_name ); +#elif CONFIG_LGPLV3 + printf( + "%s is free software; you can redistribute it and/or modify\n" + "it under the terms of the GNU Lesser General Public License as published by\n" + "the Free Software Foundation; either version 3 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "%s is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU Lesser General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU Lesser General Public License\n" + "along with %s. If not, see .\n", + program_name, program_name, program_name ); +#else + printf( + "%s is free software; you can redistribute it and/or\n" + "modify it under the terms of the GNU Lesser General Public\n" + "License as published by the Free Software Foundation; either\n" + "version 2.1 of the License, or (at your option) any later version.\n" + "\n" + "%s is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" + "Lesser General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU Lesser General Public\n" + "License along with %s; if not, write to the Free Software\n" + "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n", + program_name, program_name, program_name ); +#endif + + return 0; +} + +static int is_device(const AVClass *avclass) +{ + if (!avclass) + return 0; + return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category); +} + +static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only) +{ + AVInputFormat *ifmt = NULL; + AVOutputFormat *ofmt = NULL; + const char *last_name; + int is_dev; + + printf("%s\n" + " D. = Demuxing supported\n" + " .E = Muxing supported\n" + " --\n", device_only ? "Devices:" : "File formats:"); + last_name = "000"; + for (;;) { + int decode = 0; + int encode = 0; + const char *name = NULL; + const char *long_name = NULL; + + while ((ofmt = av_oformat_next(ofmt))) { + is_dev = is_device(ofmt->priv_class); + if (!is_dev && device_only) + continue; + if ((!name || strcmp(ofmt->name, name) < 0) && + strcmp(ofmt->name, last_name) > 0) { + name = ofmt->name; + long_name = ofmt->long_name; + encode = 1; + } + } + while ((ifmt = av_iformat_next(ifmt))) { + is_dev = is_device(ifmt->priv_class); + if (!is_dev && device_only) + continue; + if ((!name || strcmp(ifmt->name, name) < 0) && + strcmp(ifmt->name, last_name) > 0) { + name = ifmt->name; + long_name = ifmt->long_name; + encode = 0; + } + if (name && strcmp(ifmt->name, name) == 0) + decode = 1; + } + if (!name) + break; + last_name = name; + + printf(" %s%s %-15s %s\n", + decode ? "D" : " ", + encode ? "E" : " ", + name, + long_name ? long_name:" "); + } + return 0; +} + +int show_formats(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 0); +} + +int show_devices(void *optctx, const char *opt, const char *arg) +{ + return show_formats_devices(optctx, opt, arg, 1); +} + +#define PRINT_CODEC_SUPPORTED(codec, field, type, list_name, term, get_name) \ + if (codec->field) { \ + const type *p = codec->field; \ + \ + printf(" Supported " list_name ":"); \ + while (*p != term) { \ + get_name(*p); \ + printf(" %s", name); \ + p++; \ + } \ + printf("\n"); \ + } \ + +static void print_codec(const AVCodec *c) +{ + int encoder = av_codec_is_encoder(c); + + printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name, + c->long_name ? c->long_name : ""); + + printf(" General capabilities: "); + if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND) + printf("horizband "); + if (c->capabilities & AV_CODEC_CAP_DR1) + printf("dr1 "); + if (c->capabilities & AV_CODEC_CAP_TRUNCATED) + printf("trunc "); + if (c->capabilities & AV_CODEC_CAP_DELAY) + printf("delay "); + if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) + printf("small "); + if (c->capabilities & AV_CODEC_CAP_SUBFRAMES) + printf("subframes "); + if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL) + printf("exp "); + if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF) + printf("chconf "); + if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE) + printf("paramchange "); + if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE) + printf("variable "); + if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_AUTO_THREADS)) + printf("threads "); + if (!c->capabilities) + printf("none"); + printf("\n"); + + if (c->type == AVMEDIA_TYPE_VIDEO || + c->type == AVMEDIA_TYPE_AUDIO) { + printf(" Threading capabilities: "); + switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_AUTO_THREADS)) { + case AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break; + case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break; + case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break; + case AV_CODEC_CAP_AUTO_THREADS : printf("auto"); break; + default: printf("none"); break; + } + printf("\n"); + } + + if (c->supported_framerates) { + const AVRational *fps = c->supported_framerates; + + printf(" Supported framerates:"); + while (fps->num) { + printf(" %d/%d", fps->num, fps->den); + fps++; + } + printf("\n"); + } + PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats", + AV_PIX_FMT_NONE, GET_PIX_FMT_NAME); + PRINT_CODEC_SUPPORTED(c, supported_samplerates, int, "sample rates", 0, + GET_SAMPLE_RATE_NAME); + PRINT_CODEC_SUPPORTED(c, sample_fmts, enum AVSampleFormat, "sample formats", + AV_SAMPLE_FMT_NONE, GET_SAMPLE_FMT_NAME); + PRINT_CODEC_SUPPORTED(c, channel_layouts, uint64_t, "channel layouts", + 0, GET_CH_LAYOUT_DESC); + + if (c->priv_class) { + show_help_children(c->priv_class, + AV_OPT_FLAG_ENCODING_PARAM | + AV_OPT_FLAG_DECODING_PARAM); + } +} + +static char get_media_type_char(enum AVMediaType type) +{ + switch (type) { + case AVMEDIA_TYPE_VIDEO: return 'V'; + case AVMEDIA_TYPE_AUDIO: return 'A'; + case AVMEDIA_TYPE_DATA: return 'D'; + case AVMEDIA_TYPE_SUBTITLE: return 'S'; + case AVMEDIA_TYPE_ATTACHMENT:return 'T'; + default: return '?'; + } +} + +static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev, + int encoder) +{ + while ((prev = av_codec_next(prev))) { + if (prev->id == id && + (encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev))) + return prev; + } + return NULL; +} + +static int compare_codec_desc(const void *a, const void *b) +{ + const AVCodecDescriptor * const *da = a; + const AVCodecDescriptor * const *db = b; + + return (*da)->type != (*db)->type ? FFDIFFSIGN((*da)->type, (*db)->type) : + strcmp((*da)->name, (*db)->name); +} + +static unsigned get_codecs_sorted(const AVCodecDescriptor ***rcodecs) +{ + const AVCodecDescriptor *desc = NULL; + const AVCodecDescriptor **codecs; + unsigned nb_codecs = 0, i = 0; + + while ((desc = avcodec_descriptor_next(desc))) + nb_codecs++; + if (!(codecs = av_calloc(nb_codecs, sizeof(*codecs)))) { + av_log(NULL, AV_LOG_ERROR, "Out of memory\n"); + exit_program(1); + } + desc = NULL; + while ((desc = avcodec_descriptor_next(desc))) + codecs[i++] = desc; + av_assert0(i == nb_codecs); + qsort(codecs, nb_codecs, sizeof(*codecs), compare_codec_desc); + *rcodecs = codecs; + return nb_codecs; +} + +static void print_codecs_for_id(enum AVCodecID id, int encoder) +{ + const AVCodec *codec = NULL; + + printf(" (%s: ", encoder ? "encoders" : "decoders"); + + while ((codec = next_codec_for_id(id, codec, encoder))) + printf("%s ", codec->name); + + printf(")"); +} + +int show_codecs(void *optctx, const char *opt, const char *arg) +{ + const AVCodecDescriptor **codecs; + unsigned i, nb_codecs = get_codecs_sorted(&codecs); + + printf("Codecs:\n" + " D..... = Decoding supported\n" + " .E.... = Encoding supported\n" + " ..V... = Video codec\n" + " ..A... = Audio codec\n" + " ..S... = Subtitle codec\n" + " ...I.. = Intra frame-only codec\n" + " ....L. = Lossy compression\n" + " .....S = Lossless compression\n" + " -------\n"); + for (i = 0; i < nb_codecs; i++) { + const AVCodecDescriptor *desc = codecs[i]; + const AVCodec *codec = NULL; + + if (strstr(desc->name, "_deprecated")) + continue; + + printf(" "); + printf(avcodec_find_decoder(desc->id) ? "D" : "."); + printf(avcodec_find_encoder(desc->id) ? "E" : "."); + + printf("%c", get_media_type_char(desc->type)); + printf((desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : "."); + printf((desc->props & AV_CODEC_PROP_LOSSY) ? "L" : "."); + printf((desc->props & AV_CODEC_PROP_LOSSLESS) ? "S" : "."); + + printf(" %-20s %s", desc->name, desc->long_name ? desc->long_name : ""); + + /* print decoders/encoders when there's more than one or their + * names are different from codec name */ + while ((codec = next_codec_for_id(desc->id, codec, 0))) { + if (strcmp(codec->name, desc->name)) { + print_codecs_for_id(desc->id, 0); + break; + } + } + codec = NULL; + while ((codec = next_codec_for_id(desc->id, codec, 1))) { + if (strcmp(codec->name, desc->name)) { + print_codecs_for_id(desc->id, 1); + break; + } + } + + printf("\n"); + } + av_free(codecs); + return 0; +} + +static void print_codecs(int encoder) +{ + const AVCodecDescriptor **codecs; + unsigned i, nb_codecs = get_codecs_sorted(&codecs); + + printf("%s:\n" + " V..... = Video\n" + " A..... = Audio\n" + " S..... = Subtitle\n" + " .F.... = Frame-level multithreading\n" + " ..S... = Slice-level multithreading\n" + " ...X.. = Codec is experimental\n" + " ....B. = Supports draw_horiz_band\n" + " .....D = Supports direct rendering method 1\n" + " ------\n", + encoder ? "Encoders" : "Decoders"); + for (i = 0; i < nb_codecs; i++) { + const AVCodecDescriptor *desc = codecs[i]; + const AVCodec *codec = NULL; + + while ((codec = next_codec_for_id(desc->id, codec, encoder))) { + printf(" %c", get_media_type_char(desc->type)); + printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : "."); + printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : "."); + printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : "."); + printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : "."); + printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : "."); + + printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : ""); + if (strcmp(codec->name, desc->name)) + printf(" (codec %s)", desc->name); + + printf("\n"); + } + } + av_free(codecs); +} + +int show_decoders(void *optctx, const char *opt, const char *arg) +{ + print_codecs(0); + return 0; +} + +int show_encoders(void *optctx, const char *opt, const char *arg) +{ + print_codecs(1); + return 0; +} + +int show_bsfs(void *optctx, const char *opt, const char *arg) +{ + AVBitStreamFilter *bsf = NULL; + + printf("Bitstream filters:\n"); + while ((bsf = av_bitstream_filter_next(bsf))) + printf("%s\n", bsf->name); + printf("\n"); + return 0; +} + +int show_protocols(void *optctx, const char *opt, const char *arg) +{ + void *opaque = NULL; + const char *name; + + printf("Supported file protocols:\n" + "Input:\n"); + while ((name = avio_enum_protocols(&opaque, 0))) + printf(" %s\n", name); + printf("Output:\n"); + while ((name = avio_enum_protocols(&opaque, 1))) + printf(" %s\n", name); + return 0; +} + +int show_filters(void *optctx, const char *opt, const char *arg) +{ +#if CONFIG_AVFILTER + const AVFilter *filter = NULL; + char descr[64], *descr_cur; + int i, j; + const AVFilterPad *pad; + + printf("Filters:\n" + " T.. = Timeline support\n" + " .S. = Slice threading\n" + " ..C = Command support\n" + " A = Audio input/output\n" + " V = Video input/output\n" + " N = Dynamic number and/or type of input/output\n" + " | = Source or sink filter\n"); + while ((filter = avfilter_next(filter))) { + descr_cur = descr; + for (i = 0; i < 2; i++) { + if (i) { + *(descr_cur++) = '-'; + *(descr_cur++) = '>'; + } + pad = i ? filter->outputs : filter->inputs; + for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) { + if (descr_cur >= descr + sizeof(descr) - 4) + break; + *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j)); + } + if (!j) + *(descr_cur++) = ((!i && (filter->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)) || + ( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|'; + } + *descr_cur = 0; + printf(" %c%c%c %-17s %-10s %s\n", + filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.', + filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.', + filter->process_command ? 'C' : '.', + filter->name, descr, filter->description); + } +#else + printf("No filters available: libavfilter disabled\n"); +#endif + return 0; +} + +int show_colors(void *optctx, const char *opt, const char *arg) +{ + const char *name; + const uint8_t *rgb; + int i; + + printf("%-32s #RRGGBB\n", "name"); + + for (i = 0; name = av_get_known_color_name(i, &rgb); i++) + printf("%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]); + + return 0; +} + +int show_pix_fmts(void *optctx, const char *opt, const char *arg) +{ + const AVPixFmtDescriptor *pix_desc = NULL; + + printf("Pixel formats:\n" + "I.... = Supported Input format for conversion\n" + ".O... = Supported Output format for conversion\n" + "..H.. = Hardware accelerated format\n" + "...P. = Paletted format\n" + "....B = Bitstream format\n" + "FLAGS NAME NB_COMPONENTS BITS_PER_PIXEL\n" + "-----\n"); + +#if !CONFIG_SWSCALE +# define sws_isSupportedInput(x) 0 +# define sws_isSupportedOutput(x) 0 +#endif + + while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) { + enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(pix_desc); + printf("%c%c%c%c%c %-16s %d %2d\n", + sws_isSupportedInput (pix_fmt) ? 'I' : '.', + sws_isSupportedOutput(pix_fmt) ? 'O' : '.', + pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL ? 'H' : '.', + pix_desc->flags & AV_PIX_FMT_FLAG_PAL ? 'P' : '.', + pix_desc->flags & AV_PIX_FMT_FLAG_BITSTREAM ? 'B' : '.', + pix_desc->name, + pix_desc->nb_components, + av_get_bits_per_pixel(pix_desc)); + } + return 0; +} + +int show_layouts(void *optctx, const char *opt, const char *arg) +{ + int i = 0; + uint64_t layout, j; + const char *name, *descr; + + printf("Individual channels:\n" + "NAME DESCRIPTION\n"); + for (i = 0; i < 63; i++) { + name = av_get_channel_name((uint64_t)1 << i); + if (!name) + continue; + descr = av_get_channel_description((uint64_t)1 << i); + printf("%-14s %s\n", name, descr); + } + printf("\nStandard channel layouts:\n" + "NAME DECOMPOSITION\n"); + for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) { + if (name) { + printf("%-14s ", name); + for (j = 1; j; j <<= 1) + if ((layout & j)) + printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j)); + printf("\n"); + } + } + return 0; +} + +int show_sample_fmts(void *optctx, const char *opt, const char *arg) +{ + int i; + char fmt_str[128]; + for (i = -1; i < AV_SAMPLE_FMT_NB; i++) + printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i)); + return 0; +} + +static void show_help_codec(const char *name, int encoder) +{ + const AVCodecDescriptor *desc; + const AVCodec *codec; + + if (!name) { + av_log(NULL, AV_LOG_ERROR, "No codec name specified.\n"); + return; + } + + codec = encoder ? avcodec_find_encoder_by_name(name) : + avcodec_find_decoder_by_name(name); + + if (codec) + print_codec(codec); + else if ((desc = avcodec_descriptor_get_by_name(name))) { + int printed = 0; + + while ((codec = next_codec_for_id(desc->id, codec, encoder))) { + printed = 1; + print_codec(codec); + } + + if (!printed) { + av_log(NULL, AV_LOG_ERROR, "Codec '%s' is known to FFmpeg, " + "but no %s for it are available. FFmpeg might need to be " + "recompiled with additional external libraries.\n", + name, encoder ? "encoders" : "decoders"); + } + } else { + av_log(NULL, AV_LOG_ERROR, "Codec '%s' is not recognized by FFmpeg.\n", + name); + } +} + +static void show_help_demuxer(const char *name) +{ + const AVInputFormat *fmt = av_find_input_format(name); + + if (!fmt) { + av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); + return; + } + + printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name); + + if (fmt->extensions) + printf(" Common extensions: %s.\n", fmt->extensions); + + if (fmt->priv_class) + show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM); +} + +static void show_help_muxer(const char *name) +{ + const AVCodecDescriptor *desc; + const AVOutputFormat *fmt = av_guess_format(name, NULL, NULL); + + if (!fmt) { + av_log(NULL, AV_LOG_ERROR, "Unknown format '%s'.\n", name); + return; + } + + printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name); + + if (fmt->extensions) + printf(" Common extensions: %s.\n", fmt->extensions); + if (fmt->mime_type) + printf(" Mime type: %s.\n", fmt->mime_type); + if (fmt->video_codec != AV_CODEC_ID_NONE && + (desc = avcodec_descriptor_get(fmt->video_codec))) { + printf(" Default video codec: %s.\n", desc->name); + } + if (fmt->audio_codec != AV_CODEC_ID_NONE && + (desc = avcodec_descriptor_get(fmt->audio_codec))) { + printf(" Default audio codec: %s.\n", desc->name); + } + if (fmt->subtitle_codec != AV_CODEC_ID_NONE && + (desc = avcodec_descriptor_get(fmt->subtitle_codec))) { + printf(" Default subtitle codec: %s.\n", desc->name); + } + + if (fmt->priv_class) + show_help_children(fmt->priv_class, AV_OPT_FLAG_ENCODING_PARAM); +} + +#if CONFIG_AVFILTER +static void show_help_filter(const char *name) +{ +#if CONFIG_AVFILTER + const AVFilter *f = avfilter_get_by_name(name); + int i, count; + + if (!name) { + av_log(NULL, AV_LOG_ERROR, "No filter name specified.\n"); + return; + } else if (!f) { + av_log(NULL, AV_LOG_ERROR, "Unknown filter '%s'.\n", name); + return; + } + + printf("Filter %s\n", f->name); + if (f->description) + printf(" %s\n", f->description); + + if (f->flags & AVFILTER_FLAG_SLICE_THREADS) + printf(" slice threading supported\n"); + + printf(" Inputs:\n"); + count = avfilter_pad_count(f->inputs); + for (i = 0; i < count; i++) { + printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i), + media_type_string(avfilter_pad_get_type(f->inputs, i))); + } + if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS) + printf(" dynamic (depending on the options)\n"); + else if (!count) + printf(" none (source filter)\n"); + + printf(" Outputs:\n"); + count = avfilter_pad_count(f->outputs); + for (i = 0; i < count; i++) { + printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i), + media_type_string(avfilter_pad_get_type(f->outputs, i))); + } + if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS) + printf(" dynamic (depending on the options)\n"); + else if (!count) + printf(" none (sink filter)\n"); + + if (f->priv_class) + show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM | + AV_OPT_FLAG_AUDIO_PARAM); + if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE) + printf("This filter has support for timeline through the 'enable' option.\n"); +#else + av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; " + "can not to satisfy request\n"); +#endif +} +#endif + +int show_help(void *optctx, const char *opt, const char *arg) +{ + char *topic, *par; + av_log_set_callback(log_callback_help); + + topic = av_strdup(arg ? arg : ""); + if (!topic) + return AVERROR(ENOMEM); + par = strchr(topic, '='); + if (par) + *par++ = 0; + + if (!*topic) { + show_help_default(topic, par); + } else if (!strcmp(topic, "decoder")) { + show_help_codec(par, 0); + } else if (!strcmp(topic, "encoder")) { + show_help_codec(par, 1); + } else if (!strcmp(topic, "demuxer")) { + show_help_demuxer(par); + } else if (!strcmp(topic, "muxer")) { + show_help_muxer(par); +#if CONFIG_AVFILTER + } else if (!strcmp(topic, "filter")) { + show_help_filter(par); +#endif + } else { + show_help_default(topic, par); + } + + av_freep(&topic); + return 0; +} + +int read_yesno(void) +{ + int c = getchar(); + int yesno = (av_toupper(c) == 'Y'); + + while (c != '\n' && c != EOF) + c = getchar(); + + return yesno; +} + +FILE *get_preset_file(char *filename, size_t filename_size, + const char *preset_name, int is_path, + const char *codec_name) +{ + FILE *f = NULL; + int i; + const char *base[3] = { getenv("FFMPEG_DATADIR"), + getenv("HOME"), + FFMPEG_DATADIR, }; + + if (is_path) { + av_strlcpy(filename, preset_name, filename_size); + f = fopen(filename, "r"); + } else { +#ifdef _WIN32 + char datadir[MAX_PATH], *ls; + base[2] = NULL; + + if (GetModuleFileNameA(GetModuleHandleA(NULL), datadir, sizeof(datadir) - 1)) + { + for (ls = datadir; ls < datadir + strlen(datadir); ls++) + if (*ls == '\\') *ls = '/'; + + if (ls = strrchr(datadir, '/')) + { + *ls = 0; + strncat(datadir, "/ffpresets", sizeof(datadir) - 1 - strlen(datadir)); + base[2] = datadir; + } + } +#endif + for (i = 0; i < 3 && !f; i++) { + if (!base[i]) + continue; + snprintf(filename, filename_size, "%s%s/%s.ffpreset", base[i], + i != 1 ? "" : "/.ffmpeg", preset_name); + f = fopen(filename, "r"); + if (!f && codec_name) { + snprintf(filename, filename_size, + "%s%s/%s-%s.ffpreset", + base[i], i != 1 ? "" : "/.ffmpeg", codec_name, + preset_name); + f = fopen(filename, "r"); + } + } + } + + return f; +} + +int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec) +{ + int ret = avformat_match_stream_specifier(s, st, spec); + if (ret < 0) + av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec); + return ret; +} + +AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, + AVFormatContext *s, AVStream *st, AVCodec *codec) +{ + AVDictionary *ret = NULL; + AVDictionaryEntry *t = NULL; + int flags = s->oformat ? AV_OPT_FLAG_ENCODING_PARAM + : AV_OPT_FLAG_DECODING_PARAM; + char prefix = 0; + const AVClass *cc = avcodec_get_class(); + + if (!codec) + codec = s->oformat ? avcodec_find_encoder(codec_id) + : avcodec_find_decoder(codec_id); + + switch (st->codec->codec_type) { + case AVMEDIA_TYPE_VIDEO: + prefix = 'v'; + flags |= AV_OPT_FLAG_VIDEO_PARAM; + break; + case AVMEDIA_TYPE_AUDIO: + prefix = 'a'; + flags |= AV_OPT_FLAG_AUDIO_PARAM; + break; + case AVMEDIA_TYPE_SUBTITLE: + prefix = 's'; + flags |= AV_OPT_FLAG_SUBTITLE_PARAM; + break; + } + + while (t = av_dict_get(opts, "", t, AV_DICT_IGNORE_SUFFIX)) { + char *p = strchr(t->key, ':'); + + /* check stream specification in opt name */ + if (p) + switch (check_stream_specifier(s, st, p + 1)) { + case 1: *p = 0; break; + case 0: continue; + default: exit_program(1); + } + + if (av_opt_find(&cc, t->key, NULL, flags, AV_OPT_SEARCH_FAKE_OBJ) || + !codec || + (codec->priv_class && + av_opt_find(&codec->priv_class, t->key, NULL, flags, + AV_OPT_SEARCH_FAKE_OBJ))) + av_dict_set(&ret, t->key, t->value, 0); + else if (t->key[0] == prefix && + av_opt_find(&cc, t->key + 1, NULL, flags, + AV_OPT_SEARCH_FAKE_OBJ)) + av_dict_set(&ret, t->key + 1, t->value, 0); + + if (p) + *p = ':'; + } + return ret; +} + +AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, + AVDictionary *codec_opts) +{ + int i; + AVDictionary **opts; + + if (!s->nb_streams) + return NULL; + opts = av_mallocz_array(s->nb_streams, sizeof(*opts)); + if (!opts) { + av_log(NULL, AV_LOG_ERROR, + "Could not alloc memory for stream options.\n"); + return NULL; + } + for (i = 0; i < s->nb_streams; i++) + opts[i] = filter_codec_opts(codec_opts, s->streams[i]->codec->codec_id, + s, s->streams[i], NULL); + return opts; +} + +void *grow_array(void *array, int elem_size, int *size, int new_size) +{ + if (new_size >= INT_MAX / elem_size) { + av_log(NULL, AV_LOG_ERROR, "Array too big.\n"); + exit_program(1); + } + if (*size < new_size) { + uint8_t *tmp = av_realloc_array(array, new_size, elem_size); + if (!tmp) { + av_log(NULL, AV_LOG_ERROR, "Could not alloc buffer.\n"); + exit_program(1); + } + memset(tmp + *size*elem_size, 0, (new_size-*size) * elem_size); + *size = new_size; + return tmp; + } + return array; +} + +double get_rotation(AVStream *st) +{ + AVDictionaryEntry *rotate_tag = av_dict_get(st->metadata, "rotate", NULL, 0); + uint8_t* displaymatrix = av_stream_get_side_data(st, + AV_PKT_DATA_DISPLAYMATRIX, NULL); + double theta = 0; + + if (rotate_tag && *rotate_tag->value && strcmp(rotate_tag->value, "0")) { + char *tail; + theta = av_strtod(rotate_tag->value, &tail); + if (*tail) + theta = 0; + } + if (displaymatrix && !theta) + theta = -av_display_rotation_get((int32_t*) displaymatrix); + + theta -= 360*floor(theta/360 + 0.9/360); + + if (fabs(theta - 90*round(theta/90)) > 2) + av_log(NULL, AV_LOG_WARNING, "Odd rotation angle.\n" + "If you want to help, upload a sample " + "of this file to ftp://upload.ffmpeg.org/incoming/ " + "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)"); + + return theta; +} + +#if CONFIG_AVDEVICE +static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) +{ + int ret, i; + AVDeviceInfoList *device_list = NULL; + + if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category)) + return AVERROR(EINVAL); + + printf("Audo-detected sources for %s:\n", fmt->name); + if (!fmt->get_device_list) { + ret = AVERROR(ENOSYS); + printf("Cannot list sources. Not implemented.\n"); + goto fail; + } + + if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) { + printf("Cannot list sources.\n"); + goto fail; + } + + for (i = 0; i < device_list->nb_devices; i++) { + printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", + device_list->devices[i]->device_name, device_list->devices[i]->device_description); + } + + fail: + avdevice_free_list_devices(&device_list); + return ret; +} + +static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts) +{ + int ret, i; + AVDeviceInfoList *device_list = NULL; + + if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category)) + return AVERROR(EINVAL); + + printf("Audo-detected sinks for %s:\n", fmt->name); + if (!fmt->get_device_list) { + ret = AVERROR(ENOSYS); + printf("Cannot list sinks. Not implemented.\n"); + goto fail; + } + + if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) { + printf("Cannot list sinks.\n"); + goto fail; + } + + for (i = 0; i < device_list->nb_devices; i++) { + printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ", + device_list->devices[i]->device_name, device_list->devices[i]->device_description); + } + + fail: + avdevice_free_list_devices(&device_list); + return ret; +} + +static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionary **opts) +{ + int ret; + if (arg) { + char *opts_str = NULL; + av_assert0(dev && opts); + *dev = av_strdup(arg); + if (!*dev) + return AVERROR(ENOMEM); + if ((opts_str = strchr(*dev, ','))) { + *(opts_str++) = '\0'; + if (opts_str[0] && ((ret = av_dict_parse_string(opts, opts_str, "=", ":", 0)) < 0)) { + av_freep(dev); + return ret; + } + } + } else + printf("\nDevice name is not provided.\n" + "You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.\n\n"); + return 0; +} + +int show_sources(void *optctx, const char *opt, const char *arg) +{ + AVInputFormat *fmt = NULL; + char *dev = NULL; + AVDictionary *opts = NULL; + int ret = 0; + int error_level = av_log_get_level(); + + av_log_set_level(AV_LOG_ERROR); + + if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) + goto fail; + + do { + fmt = av_input_audio_device_next(fmt); + if (fmt) { + if (!strcmp(fmt->name, "lavfi")) + continue; //it's pointless to probe lavfi + if (dev && !av_match_name(dev, fmt->name)) + continue; + print_device_sources(fmt, opts); + } + } while (fmt); + do { + fmt = av_input_video_device_next(fmt); + if (fmt) { + if (dev && !av_match_name(dev, fmt->name)) + continue; + print_device_sources(fmt, opts); + } + } while (fmt); + fail: + av_dict_free(&opts); + av_free(dev); + av_log_set_level(error_level); + return ret; +} + +int show_sinks(void *optctx, const char *opt, const char *arg) +{ + AVOutputFormat *fmt = NULL; + char *dev = NULL; + AVDictionary *opts = NULL; + int ret = 0; + int error_level = av_log_get_level(); + + av_log_set_level(AV_LOG_ERROR); + + if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0) + goto fail; + + do { + fmt = av_output_audio_device_next(fmt); + if (fmt) { + if (dev && !av_match_name(dev, fmt->name)) + continue; + print_device_sinks(fmt, opts); + } + } while (fmt); + do { + fmt = av_output_video_device_next(fmt); + if (fmt) { + if (dev && !av_match_name(dev, fmt->name)) + continue; + print_device_sinks(fmt, opts); + } + } while (fmt); + fail: + av_dict_free(&opts); + av_free(dev); + av_log_set_level(error_level); + return ret; +} + +#endif diff --git a/app/src/main/cpp/cmdutils.h b/app/src/main/cpp/cmdutils.h new file mode 100644 index 0000000..aa64ca9 --- /dev/null +++ b/app/src/main/cpp/cmdutils.h @@ -0,0 +1,590 @@ +/* + * Various utilities for command line tools + * copyright (c) 2003 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef CMDUTILS_H +#define CMDUTILS_H + +#include + +#include "config.h" +#include "libavcodec/avcodec.h" +#include "libavfilter/avfilter.h" +#include "libavformat/avformat.h" +#include "libswscale/swscale.h" + +#ifdef _WIN32 +#undef main /* We don't want SDL to override our main() */ +#endif + +/** + * program name, defined by the program for show_version(). + */ +extern const char program_name[]; + +/** + * program birth year, defined by the program for show_banner() + */ +extern const int program_birth_year; + +extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB]; +extern AVFormatContext *avformat_opts; +extern AVDictionary *sws_dict; +extern AVDictionary *swr_opts; +extern AVDictionary *format_opts, *codec_opts, *resample_opts; +extern int hide_banner; + +/** + * Register a program-specific cleanup routine. + */ +void register_exit(void (*cb)(int ret)); + +/** + * Wraps exit with a program-specific cleanup routine. + */ +int exit_program(int ret); + +/** + * Initialize the cmdutils option system, in particular + * allocate the *_opts contexts. + */ +void init_opts(void); +/** + * Uninitialize the cmdutils option system, in particular + * free the *_opts contexts and their contents. + */ +void uninit_opts(void); + +/** + * Trivial log callback. + * Only suitable for opt_help and similar since it lacks prefix handling. + */ +void log_callback_help(void* ptr, int level, const char* fmt, va_list vl); + +/** + * Override the cpuflags. + */ +int opt_cpuflags(void *optctx, const char *opt, const char *arg); + +/** + * Fallback for options that are not explicitly handled, these will be + * parsed through AVOptions. + */ +int opt_default(void *optctx, const char *opt, const char *arg); + +/** + * Set the libav* libraries log level. + */ +int opt_loglevel(void *optctx, const char *opt, const char *arg); + +int opt_report(const char *opt); + +int opt_max_alloc(void *optctx, const char *opt, const char *arg); + +int opt_codec_debug(void *optctx, const char *opt, const char *arg); + +#if CONFIG_OPENCL +int opt_opencl(void *optctx, const char *opt, const char *arg); + +int opt_opencl_bench(void *optctx, const char *opt, const char *arg); +#endif + +/** + * Limit the execution time. + */ +int opt_timelimit(void *optctx, const char *opt, const char *arg); + +/** + * Parse a string and return its corresponding value as a double. + * Exit from the application if the string cannot be correctly + * parsed or the corresponding value is invalid. + * + * @param context the context of the value to be set (e.g. the + * corresponding command line option name) + * @param numstr the string to be parsed + * @param type the type (OPT_INT64 or OPT_FLOAT) as which the + * string should be parsed + * @param min the minimum valid accepted value + * @param max the maximum valid accepted value + */ +double parse_number_or_die(const char *context, const char *numstr, int type, + double min, double max); + +/** + * Parse a string specifying a time and return its corresponding + * value as a number of microseconds. Exit from the application if + * the string cannot be correctly parsed. + * + * @param context the context of the value to be set (e.g. the + * corresponding command line option name) + * @param timestr the string to be parsed + * @param is_duration a flag which tells how to interpret timestr, if + * not zero timestr is interpreted as a duration, otherwise as a + * date + * + * @see av_parse_time() + */ +int64_t parse_time_or_die(const char *context, const char *timestr, + int is_duration); + +typedef struct SpecifierOpt { + char *specifier; /**< stream/chapter/program/... specifier */ + union { + uint8_t *str; + int i; + int64_t i64; + float f; + double dbl; + } u; +} SpecifierOpt; + +typedef struct OptionDef { + const char *name; + int flags; +#define HAS_ARG 0x0001 +#define OPT_BOOL 0x0002 +#define OPT_EXPERT 0x0004 +#define OPT_STRING 0x0008 +#define OPT_VIDEO 0x0010 +#define OPT_AUDIO 0x0020 +#define OPT_INT 0x0080 +#define OPT_FLOAT 0x0100 +#define OPT_SUBTITLE 0x0200 +#define OPT_INT64 0x0400 +#define OPT_EXIT 0x0800 +#define OPT_DATA 0x1000 +#define OPT_PERFILE 0x2000 /* the option is per-file (currently ffmpeg-only). + implied by OPT_OFFSET or OPT_SPEC */ +#define OPT_OFFSET 0x4000 /* option is specified as an offset in a passed optctx */ +#define OPT_SPEC 0x8000 /* option is to be stored in an array of SpecifierOpt. + Implies OPT_OFFSET. Next element after the offset is + an int containing element count in the array. */ +#define OPT_TIME 0x10000 +#define OPT_DOUBLE 0x20000 +#define OPT_INPUT 0x40000 +#define OPT_OUTPUT 0x80000 + union { + void *dst_ptr; + int (*func_arg)(void *, const char *, const char *); + size_t off; + } u; + const char *help; + const char *argname; +} OptionDef; + +/** + * Print help for all options matching specified flags. + * + * @param options a list of options + * @param msg title of this group. Only printed if at least one option matches. + * @param req_flags print only options which have all those flags set. + * @param rej_flags don't print options which have any of those flags set. + * @param alt_flags print only options that have at least one of those flags set + */ +void show_help_options(const OptionDef *options, const char *msg, int req_flags, + int rej_flags, int alt_flags); + +/** + * Show help for all options with given flags in class and all its + * children. + */ +void show_help_children(const AVClass *class, int flags); + +/** + * Per-fftool specific help handler. Implemented in each + * fftool, called by show_help(). + */ +void show_help_default(const char *opt, const char *arg); + +/** + * Generic -h handler common to all fftools. + */ +int show_help(void *optctx, const char *opt, const char *arg); + +/** + * Parse the command line arguments. + * + * @param optctx an opaque options context + * @param argc number of command line arguments + * @param argv values of command line arguments + * @param options Array with the definitions required to interpret every + * option of the form: -option_name [argument] + * @param parse_arg_function Name of the function called to process every + * argument without a leading option name flag. NULL if such arguments do + * not have to be processed. + */ +void parse_options(void *optctx, int argc, char **argv, const OptionDef *options, + void (* parse_arg_function)(void *optctx, const char*)); + +/** + * Parse one given option. + * + * @return on success 1 if arg was consumed, 0 otherwise; negative number on error + */ +int parse_option(void *optctx, const char *opt, const char *arg, + const OptionDef *options); + +/** + * An option extracted from the commandline. + * Cannot use AVDictionary because of options like -map which can be + * used multiple times. + */ +typedef struct Option { + const OptionDef *opt; + const char *key; + const char *val; +} Option; + +typedef struct OptionGroupDef { + /**< group name */ + const char *name; + /** + * Option to be used as group separator. Can be NULL for groups which + * are terminated by a non-option argument (e.g. ffmpeg output files) + */ + const char *sep; + /** + * Option flags that must be set on each option that is + * applied to this group + */ + int flags; +} OptionGroupDef; + +typedef struct OptionGroup { + const OptionGroupDef *group_def; + const char *arg; + + Option *opts; + int nb_opts; + + AVDictionary *codec_opts; + AVDictionary *format_opts; + AVDictionary *resample_opts; + AVDictionary *sws_dict; + AVDictionary *swr_opts; +} OptionGroup; + +/** + * A list of option groups that all have the same group type + * (e.g. input files or output files) + */ +typedef struct OptionGroupList { + const OptionGroupDef *group_def; + + OptionGroup *groups; + int nb_groups; +} OptionGroupList; + +typedef struct OptionParseContext { + OptionGroup global_opts; + + OptionGroupList *groups; + int nb_groups; + + /* parsing state */ + OptionGroup cur_group; +} OptionParseContext; + +/** + * Parse an options group and write results into optctx. + * + * @param optctx an app-specific options context. NULL for global options group + */ +int parse_optgroup(void *optctx, OptionGroup *g); + +/** + * Split the commandline into an intermediate form convenient for further + * processing. + * + * The commandline is assumed to be composed of options which either belong to a + * group (those with OPT_SPEC, OPT_OFFSET or OPT_PERFILE) or are global + * (everything else). + * + * A group (defined by an OptionGroupDef struct) is a sequence of options + * terminated by either a group separator option (e.g. -i) or a parameter that + * is not an option (doesn't start with -). A group without a separator option + * must always be first in the supplied groups list. + * + * All options within the same group are stored in one OptionGroup struct in an + * OptionGroupList, all groups with the same group definition are stored in one + * OptionGroupList in OptionParseContext.groups. The order of group lists is the + * same as the order of group definitions. + */ +int split_commandline(OptionParseContext *octx, int argc, char *argv[], + const OptionDef *options, + const OptionGroupDef *groups, int nb_groups); + +/** + * Free all allocated memory in an OptionParseContext. + */ +void uninit_parse_context(OptionParseContext *octx); + +/** + * Find the '-loglevel' option in the command line args and apply it. + */ +void parse_loglevel(int argc, char **argv, const OptionDef *options); + +/** + * Return index of option opt in argv or 0 if not found. + */ +int locate_option(int argc, char **argv, const OptionDef *options, + const char *optname); + +/** + * Check if the given stream matches a stream specifier. + * + * @param s Corresponding format context. + * @param st Stream from s to be checked. + * @param spec A stream specifier of the [v|a|s|d]:[\] form. + * + * @return 1 if the stream matches, 0 if it doesn't, <0 on error + */ +int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec); + +/** + * Filter out options for given codec. + * + * Create a new options dictionary containing only the options from + * opts which apply to the codec with ID codec_id. + * + * @param opts dictionary to place options in + * @param codec_id ID of the codec that should be filtered for + * @param s Corresponding format context. + * @param st A stream from s for which the options should be filtered. + * @param codec The particular codec for which the options should be filtered. + * If null, the default one is looked up according to the codec id. + * @return a pointer to the created dictionary + */ +AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, + AVFormatContext *s, AVStream *st, AVCodec *codec); + +/** + * Setup AVCodecContext options for avformat_find_stream_info(). + * + * Create an array of dictionaries, one dictionary for each stream + * contained in s. + * Each dictionary will contain the options from codec_opts which can + * be applied to the corresponding stream codec context. + * + * @return pointer to the created array of dictionaries, NULL if it + * cannot be created + */ +AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, + AVDictionary *codec_opts); + +/** + * Print an error message to stderr, indicating filename and a human + * readable description of the error code err. + * + * If strerror_r() is not available the use of this function in a + * multithreaded application may be unsafe. + * + * @see av_strerror() + */ +void print_error(const char *filename, int err); + +/** + * Print the program banner to stderr. The banner contents depend on the + * current version of the repository and of the libav* libraries used by + * the program. + */ +void show_banner(int argc, char **argv, const OptionDef *options); + +/** + * Print the version of the program to stdout. The version message + * depends on the current versions of the repository and of the libav* + * libraries. + * This option processing function does not utilize the arguments. + */ +int show_version(void *optctx, const char *opt, const char *arg); + +/** + * Print the build configuration of the program to stdout. The contents + * depend on the definition of FFMPEG_CONFIGURATION. + * This option processing function does not utilize the arguments. + */ +int show_buildconf(void *optctx, const char *opt, const char *arg); + +/** + * Print the license of the program to stdout. The license depends on + * the license of the libraries compiled into the program. + * This option processing function does not utilize the arguments. + */ +int show_license(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the formats supported by the + * program (including devices). + * This option processing function does not utilize the arguments. + */ +int show_formats(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the devices supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_devices(void *optctx, const char *opt, const char *arg); + +#if CONFIG_AVDEVICE +/** + * Print a listing containing audodetected sinks of the output device. + * Device name with options may be passed as an argument to limit results. + */ +int show_sinks(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing audodetected sources of the input device. + * Device name with options may be passed as an argument to limit results. + */ +int show_sources(void *optctx, const char *opt, const char *arg); +#endif + +/** + * Print a listing containing all the codecs supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_codecs(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the decoders supported by the + * program. + */ +int show_decoders(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the encoders supported by the + * program. + */ +int show_encoders(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the filters supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_filters(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the bit stream filters supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_bsfs(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the protocols supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_protocols(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the pixel formats supported by the + * program. + * This option processing function does not utilize the arguments. + */ +int show_pix_fmts(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the standard channel layouts supported by + * the program. + * This option processing function does not utilize the arguments. + */ +int show_layouts(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the sample formats supported by the + * program. + */ +int show_sample_fmts(void *optctx, const char *opt, const char *arg); + +/** + * Print a listing containing all the color names and values recognized + * by the program. + */ +int show_colors(void *optctx, const char *opt, const char *arg); + +/** + * Return a positive value if a line read from standard input + * starts with [yY], otherwise return 0. + */ +int read_yesno(void); + +/** + * Get a file corresponding to a preset file. + * + * If is_path is non-zero, look for the file in the path preset_name. + * Otherwise search for a file named arg.ffpreset in the directories + * $FFMPEG_DATADIR (if set), $HOME/.ffmpeg, and in the datadir defined + * at configuration time or in a "ffpresets" folder along the executable + * on win32, in that order. If no such file is found and + * codec_name is defined, then search for a file named + * codec_name-preset_name.avpreset in the above-mentioned directories. + * + * @param filename buffer where the name of the found filename is written + * @param filename_size size in bytes of the filename buffer + * @param preset_name name of the preset to search + * @param is_path tell if preset_name is a filename path + * @param codec_name name of the codec for which to look for the + * preset, may be NULL + */ +FILE *get_preset_file(char *filename, size_t filename_size, + const char *preset_name, int is_path, const char *codec_name); + +/** + * Realloc array to hold new_size elements of elem_size. + * Calls exit() on failure. + * + * @param array array to reallocate + * @param elem_size size in bytes of each element + * @param size new element count will be written here + * @param new_size number of elements to place in reallocated array + * @return reallocated array + */ +void *grow_array(void *array, int elem_size, int *size, int new_size); + +#define media_type_string av_get_media_type_string + +#define GROW_ARRAY(array, nb_elems)\ + array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1) + +#define GET_PIX_FMT_NAME(pix_fmt)\ + const char *name = av_get_pix_fmt_name(pix_fmt); + +#define GET_SAMPLE_FMT_NAME(sample_fmt)\ + const char *name = av_get_sample_fmt_name(sample_fmt) + +#define GET_SAMPLE_RATE_NAME(rate)\ + char name[16];\ + snprintf(name, sizeof(name), "%d", rate); + +#define GET_CH_LAYOUT_NAME(ch_layout)\ + char name[16];\ + snprintf(name, sizeof(name), "0x%"PRIx64, ch_layout); + +#define GET_CH_LAYOUT_DESC(ch_layout)\ + char name[128];\ + av_get_channel_layout_string(name, sizeof(name), 0, ch_layout); + +double get_rotation(AVStream *st); + +#endif /* CMDUTILS_H */ diff --git a/app/src/main/cpp/cmdutils_common_opts.h b/app/src/main/cpp/cmdutils_common_opts.h new file mode 100644 index 0000000..758dac1 --- /dev/null +++ b/app/src/main/cpp/cmdutils_common_opts.h @@ -0,0 +1,35 @@ + { "L" , OPT_EXIT, {.func_arg = show_license}, "show license" }, + { "h" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" }, + { "?" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" }, + { "help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" }, + { "-help" , OPT_EXIT, {.func_arg = show_help}, "show help", "topic" }, + { "version" , OPT_EXIT, {.func_arg = show_version}, "show version" }, + { "buildconf" , OPT_EXIT, {.func_arg = show_buildconf}, "show build configuration" }, + { "formats" , OPT_EXIT, {.func_arg = show_formats }, "show available formats" }, + { "devices" , OPT_EXIT, {.func_arg = show_devices }, "show available devices" }, + { "codecs" , OPT_EXIT, {.func_arg = show_codecs }, "show available codecs" }, + { "decoders" , OPT_EXIT, {.func_arg = show_decoders }, "show available decoders" }, + { "encoders" , OPT_EXIT, {.func_arg = show_encoders }, "show available encoders" }, + { "bsfs" , OPT_EXIT, {.func_arg = show_bsfs }, "show available bit stream filters" }, + { "protocols" , OPT_EXIT, {.func_arg = show_protocols}, "show available protocols" }, + { "filters" , OPT_EXIT, {.func_arg = show_filters }, "show available filters" }, + { "pix_fmts" , OPT_EXIT, {.func_arg = show_pix_fmts }, "show available pixel formats" }, + { "layouts" , OPT_EXIT, {.func_arg = show_layouts }, "show standard channel layouts" }, + { "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" }, + { "colors" , OPT_EXIT, {.func_arg = show_colors }, "show available color names" }, + { "loglevel" , HAS_ARG, {.func_arg = opt_loglevel}, "set logging level", "loglevel" }, + { "v", HAS_ARG, {.func_arg = opt_loglevel}, "set logging level", "loglevel" }, + { "report" , 0, {(void*)opt_report}, "generate a report" }, + { "max_alloc" , HAS_ARG, {.func_arg = opt_max_alloc}, "set maximum size of a single allocated block", "bytes" }, + { "cpuflags" , HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, + { "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, +#if CONFIG_OPENCL + { "opencl_bench", OPT_EXIT, {.func_arg = opt_opencl_bench}, "run benchmark on all OpenCL devices and show results" }, + { "opencl_options", HAS_ARG, {.func_arg = opt_opencl}, "set OpenCL environment options" }, +#endif +#if CONFIG_AVDEVICE + { "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, + "list sources of the input device", "device" }, + { "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, + "list sinks of the output device", "device" }, +#endif diff --git a/app/src/main/cpp/config.h b/app/src/main/cpp/config.h new file mode 100644 index 0000000..0aec114 --- /dev/null +++ b/app/src/main/cpp/config.h @@ -0,0 +1,2230 @@ +/* Automatically generated by configure - do not modify! */ +#ifndef FFMPEG_CONFIG_H +#define FFMPEG_CONFIG_H +#define FFMPEG_CONFIGURATION "--prefix=./android/armv7-a --enable-neon --enable-hwaccel=h264_vaapi --enable-hwaccel=h264_vaapi --enable-hwaccel=h264_dxva2 --enable-hwaccel=mpeg4_vaapi --enable-hwaccels --enable-static --enable-jni --enable-mediacodec --enable-asm --disable-shared --disable-doc --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-ffserver --disable-avdevice --disable-doc --disable-symver --cross-prefix='D:/adt-bundle-windows-x86_64-20131030/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/arm-linux-androideabi-' --target-os=linux --arch=arm --enable-cross-compile --sysroot='D:/adt-bundle-windows-x86_64-20131030/sdk/ndk-bundle/platforms/android-14/arch-arm/' --extra-cflags='-Os -fpic ' --extra-ldflags= --enable-neon" +#define FFMPEG_LICENSE "LGPL version 2.1 or later" +#define CONFIG_THIS_YEAR 2017 +#define FFMPEG_DATADIR "./android/armv7-a/share/ffmpeg" +#define AVCONV_DATADIR "./android/armv7-a/share/ffmpeg" +#define CC_IDENT "gcc 4.9.x (GCC) 20150123 (prerelease)" +#define av_restrict restrict +#define EXTERN_PREFIX "" +#define EXTERN_ASM +#define BUILDSUF "" +#define SLIBSUF ".so" +#define HAVE_MMX2 HAVE_MMXEXT +#define SWS_MAX_FILTER_SIZE 256 +#define ARCH_AARCH64 0 +#define ARCH_ALPHA 0 +#define ARCH_ARM 1 +#define ARCH_AVR32 0 +#define ARCH_AVR32_AP 0 +#define ARCH_AVR32_UC 0 +#define ARCH_BFIN 0 +#define ARCH_IA64 0 +#define ARCH_M68K 0 +#define ARCH_MIPS 0 +#define ARCH_MIPS64 0 +#define ARCH_PARISC 0 +#define ARCH_PPC 0 +#define ARCH_PPC64 0 +#define ARCH_S390 0 +#define ARCH_SH4 0 +#define ARCH_SPARC 0 +#define ARCH_SPARC64 0 +#define ARCH_TILEGX 0 +#define ARCH_TILEPRO 0 +#define ARCH_TOMI 0 +#define ARCH_X86 0 +#define ARCH_X86_32 0 +#define ARCH_X86_64 0 +#define HAVE_ARMV5TE 1 +#define HAVE_ARMV6 1 +#define HAVE_ARMV6T2 1 +#define HAVE_ARMV8 0 +#define HAVE_NEON 1 +#define HAVE_VFP 1 +#define HAVE_VFPV3 1 +#define HAVE_SETEND 1 +#define HAVE_ALTIVEC 0 +#define HAVE_DCBZL 0 +#define HAVE_LDBRX 0 +#define HAVE_POWER8 0 +#define HAVE_PPC4XX 0 +#define HAVE_VSX 0 +#define HAVE_AESNI 0 +#define HAVE_AMD3DNOW 0 +#define HAVE_AMD3DNOWEXT 0 +#define HAVE_AVX 0 +#define HAVE_AVX2 0 +#define HAVE_FMA3 0 +#define HAVE_FMA4 0 +#define HAVE_MMX 0 +#define HAVE_MMXEXT 0 +#define HAVE_SSE 0 +#define HAVE_SSE2 0 +#define HAVE_SSE3 0 +#define HAVE_SSE4 0 +#define HAVE_SSE42 0 +#define HAVE_SSSE3 0 +#define HAVE_XOP 0 +#define HAVE_CPUNOP 0 +#define HAVE_I686 0 +#define HAVE_MIPSFPU 0 +#define HAVE_MIPS32R2 0 +#define HAVE_MIPS32R5 0 +#define HAVE_MIPS64R2 0 +#define HAVE_MIPS32R6 0 +#define HAVE_MIPS64R6 0 +#define HAVE_MIPSDSP 0 +#define HAVE_MIPSDSPR2 0 +#define HAVE_MSA 0 +#define HAVE_LOONGSON2 0 +#define HAVE_LOONGSON3 0 +#define HAVE_MMI 0 +#define HAVE_ARMV5TE_EXTERNAL 1 +#define HAVE_ARMV6_EXTERNAL 0 +#define HAVE_ARMV6T2_EXTERNAL 0 +#define HAVE_ARMV8_EXTERNAL 0 +#define HAVE_NEON_EXTERNAL 0 +#define HAVE_VFP_EXTERNAL 1 +#define HAVE_VFPV3_EXTERNAL 0 +#define HAVE_SETEND_EXTERNAL 0 +#define HAVE_ALTIVEC_EXTERNAL 0 +#define HAVE_DCBZL_EXTERNAL 0 +#define HAVE_LDBRX_EXTERNAL 0 +#define HAVE_POWER8_EXTERNAL 0 +#define HAVE_PPC4XX_EXTERNAL 0 +#define HAVE_VSX_EXTERNAL 0 +#define HAVE_AESNI_EXTERNAL 0 +#define HAVE_AMD3DNOW_EXTERNAL 0 +#define HAVE_AMD3DNOWEXT_EXTERNAL 0 +#define HAVE_AVX_EXTERNAL 0 +#define HAVE_AVX2_EXTERNAL 0 +#define HAVE_FMA3_EXTERNAL 0 +#define HAVE_FMA4_EXTERNAL 0 +#define HAVE_MMX_EXTERNAL 0 +#define HAVE_MMXEXT_EXTERNAL 0 +#define HAVE_SSE_EXTERNAL 0 +#define HAVE_SSE2_EXTERNAL 0 +#define HAVE_SSE3_EXTERNAL 0 +#define HAVE_SSE4_EXTERNAL 0 +#define HAVE_SSE42_EXTERNAL 0 +#define HAVE_SSSE3_EXTERNAL 0 +#define HAVE_XOP_EXTERNAL 0 +#define HAVE_CPUNOP_EXTERNAL 0 +#define HAVE_I686_EXTERNAL 0 +#define HAVE_MIPSFPU_EXTERNAL 0 +#define HAVE_MIPS32R2_EXTERNAL 0 +#define HAVE_MIPS32R5_EXTERNAL 0 +#define HAVE_MIPS64R2_EXTERNAL 0 +#define HAVE_MIPS32R6_EXTERNAL 0 +#define HAVE_MIPS64R6_EXTERNAL 0 +#define HAVE_MIPSDSP_EXTERNAL 0 +#define HAVE_MIPSDSPR2_EXTERNAL 0 +#define HAVE_MSA_EXTERNAL 0 +#define HAVE_LOONGSON2_EXTERNAL 0 +#define HAVE_LOONGSON3_EXTERNAL 0 +#define HAVE_MMI_EXTERNAL 0 +#define HAVE_ARMV5TE_INLINE 1 +#define HAVE_ARMV6_INLINE 0 +#define HAVE_ARMV6T2_INLINE 0 +#define HAVE_ARMV8_INLINE 0 +#define HAVE_NEON_INLINE 0 +#define HAVE_VFP_INLINE 0 +#define HAVE_VFPV3_INLINE 0 +#define HAVE_SETEND_INLINE 0 +#define HAVE_ALTIVEC_INLINE 0 +#define HAVE_DCBZL_INLINE 0 +#define HAVE_LDBRX_INLINE 0 +#define HAVE_POWER8_INLINE 0 +#define HAVE_PPC4XX_INLINE 0 +#define HAVE_VSX_INLINE 0 +#define HAVE_AESNI_INLINE 0 +#define HAVE_AMD3DNOW_INLINE 0 +#define HAVE_AMD3DNOWEXT_INLINE 0 +#define HAVE_AVX_INLINE 0 +#define HAVE_AVX2_INLINE 0 +#define HAVE_FMA3_INLINE 0 +#define HAVE_FMA4_INLINE 0 +#define HAVE_MMX_INLINE 0 +#define HAVE_MMXEXT_INLINE 0 +#define HAVE_SSE_INLINE 0 +#define HAVE_SSE2_INLINE 0 +#define HAVE_SSE3_INLINE 0 +#define HAVE_SSE4_INLINE 0 +#define HAVE_SSE42_INLINE 0 +#define HAVE_SSSE3_INLINE 0 +#define HAVE_XOP_INLINE 0 +#define HAVE_CPUNOP_INLINE 0 +#define HAVE_I686_INLINE 0 +#define HAVE_MIPSFPU_INLINE 0 +#define HAVE_MIPS32R2_INLINE 0 +#define HAVE_MIPS32R5_INLINE 0 +#define HAVE_MIPS64R2_INLINE 0 +#define HAVE_MIPS32R6_INLINE 0 +#define HAVE_MIPS64R6_INLINE 0 +#define HAVE_MIPSDSP_INLINE 0 +#define HAVE_MIPSDSPR2_INLINE 0 +#define HAVE_MSA_INLINE 0 +#define HAVE_LOONGSON2_INLINE 0 +#define HAVE_LOONGSON3_INLINE 0 +#define HAVE_MMI_INLINE 0 +#define HAVE_ALIGNED_STACK 0 +#define HAVE_FAST_64BIT 0 +#define HAVE_FAST_CLZ 1 +#define HAVE_FAST_CMOV 0 +#define HAVE_LOCAL_ALIGNED_8 0 +#define HAVE_LOCAL_ALIGNED_16 0 +#define HAVE_LOCAL_ALIGNED_32 0 +#define HAVE_SIMD_ALIGN_16 1 +#define HAVE_ATOMICS_GCC 1 +#define HAVE_ATOMICS_SUNCC 0 +#define HAVE_ATOMICS_WIN32 0 +#define HAVE_ATOMIC_CAS_PTR 0 +#define HAVE_ATOMIC_COMPARE_EXCHANGE 1 +#define HAVE_MACHINE_RW_BARRIER 0 +#define HAVE_MEMORYBARRIER 0 +#define HAVE_MM_EMPTY 0 +#define HAVE_RDTSC 0 +#define HAVE_SARESTART 1 +#define HAVE_SEM_TIMEDWAIT 1 +#define HAVE_SYNC_VAL_COMPARE_AND_SWAP 1 +#define HAVE_CABS 0 +#define HAVE_CEXP 0 +#define HAVE_INLINE_ASM 1 +#define HAVE_SYMVER 0 +#define HAVE_YASM 0 +#define HAVE_BIGENDIAN 0 +#define HAVE_FAST_UNALIGNED 0 +#define HAVE_ALSA_ASOUNDLIB_H 0 +#define HAVE_ALTIVEC_H 0 +#define HAVE_ARPA_INET_H 1 +#define HAVE_ASM_TYPES_H 1 +#define HAVE_CDIO_PARANOIA_H 0 +#define HAVE_CDIO_PARANOIA_PARANOIA_H 0 +#define HAVE_DISPATCH_DISPATCH_H 0 +#define HAVE_DEV_BKTR_IOCTL_BT848_H 0 +#define HAVE_DEV_BKTR_IOCTL_METEOR_H 0 +#define HAVE_DEV_IC_BT8XX_H 0 +#define HAVE_DEV_VIDEO_BKTR_IOCTL_BT848_H 0 +#define HAVE_DEV_VIDEO_METEOR_IOCTL_METEOR_H 0 +#define HAVE_DIRECT_H 0 +#define HAVE_DIRENT_H 1 +#define HAVE_DLFCN_H 1 +#define HAVE_D3D11_H 0 +#define HAVE_DXVA_H 0 +#define HAVE_ES2_GL_H 0 +#define HAVE_GSM_H 0 +#define HAVE_IO_H 0 +#define HAVE_MACH_MACH_TIME_H 0 +#define HAVE_MACHINE_IOCTL_BT848_H 0 +#define HAVE_MACHINE_IOCTL_METEOR_H 0 +#define HAVE_MALLOC_H 1 +#define HAVE_OPENCV2_CORE_CORE_C_H 0 +#define HAVE_OPENJPEG_2_1_OPENJPEG_H 0 +#define HAVE_OPENJPEG_2_0_OPENJPEG_H 0 +#define HAVE_OPENJPEG_1_5_OPENJPEG_H 0 +#define HAVE_OPENGL_GL3_H 0 +#define HAVE_POLL_H 1 +#define HAVE_SNDIO_H 0 +#define HAVE_SOUNDCARD_H 0 +#define HAVE_SYS_MMAN_H 1 +#define HAVE_SYS_PARAM_H 1 +#define HAVE_SYS_RESOURCE_H 1 +#define HAVE_SYS_SELECT_H 1 +#define HAVE_SYS_SOUNDCARD_H 0 +#define HAVE_SYS_TIME_H 1 +#define HAVE_SYS_UN_H 1 +#define HAVE_SYS_VIDEOIO_H 0 +#define HAVE_TERMIOS_H 1 +#define HAVE_UDPLITE_H 0 +#define HAVE_UNISTD_H 1 +#define HAVE_VALGRIND_VALGRIND_H 0 +#define HAVE_WINDOWS_H 0 +#define HAVE_WINSOCK2_H 0 +#define HAVE_INTRINSICS_NEON 0 +#define HAVE_ATANF 1 +#define HAVE_ATAN2F 1 +#define HAVE_CBRT 1 +#define HAVE_CBRTF 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COSF 1 +#define HAVE_ERF 1 +#define HAVE_EXP2 1 +#define HAVE_EXP2F 1 +#define HAVE_EXPF 1 +#define HAVE_HYPOT 1 +#define HAVE_ISFINITE 1 +#define HAVE_ISINF 1 +#define HAVE_ISNAN 1 +#define HAVE_LDEXPF 1 +#define HAVE_LLRINT 1 +#define HAVE_LLRINTF 1 +#define HAVE_LOG2 0 +#define HAVE_LOG2F 0 +#define HAVE_LOG10F 1 +#define HAVE_LRINT 1 +#define HAVE_LRINTF 1 +#define HAVE_POWF 1 +#define HAVE_RINT 1 +#define HAVE_ROUND 1 +#define HAVE_ROUNDF 1 +#define HAVE_SINF 1 +#define HAVE_TRUNC 1 +#define HAVE_TRUNCF 1 +#define HAVE_ACCESS 1 +#define HAVE_ALIGNED_MALLOC 0 +#define HAVE_ARC4RANDOM 1 +#define HAVE_CLOCK_GETTIME 1 +#define HAVE_CLOSESOCKET 0 +#define HAVE_COMMANDLINETOARGVW 0 +#define HAVE_COTASKMEMFREE 0 +#define HAVE_CRYPTGENRANDOM 0 +#define HAVE_DLOPEN 1 +#define HAVE_FCNTL 1 +#define HAVE_FLT_LIM 1 +#define HAVE_FORK 1 +#define HAVE_GETADDRINFO 1 +#define HAVE_GETHRTIME 0 +#define HAVE_GETOPT 1 +#define HAVE_GETPROCESSAFFINITYMASK 0 +#define HAVE_GETPROCESSMEMORYINFO 0 +#define HAVE_GETPROCESSTIMES 0 +#define HAVE_GETRUSAGE 1 +#define HAVE_GETSYSTEMTIMEASFILETIME 0 +#define HAVE_GETTIMEOFDAY 1 +#define HAVE_GLOB 0 +#define HAVE_GLXGETPROCADDRESS 0 +#define HAVE_GMTIME_R 1 +#define HAVE_INET_ATON 1 +#define HAVE_ISATTY 1 +#define HAVE_JACK_PORT_GET_LATENCY_RANGE 0 +#define HAVE_KBHIT 0 +#define HAVE_LOADLIBRARY 0 +#define HAVE_LOCALTIME_R 1 +#define HAVE_LSTAT 1 +#define HAVE_LZO1X_999_COMPRESS 0 +#define HAVE_MACH_ABSOLUTE_TIME 0 +#define HAVE_MAPVIEWOFFILE 0 +#define HAVE_MEMALIGN 1 +#define HAVE_MKSTEMP 1 +#define HAVE_MMAP 1 +#define HAVE_MPROTECT 1 +#define HAVE_NANOSLEEP 1 +#define HAVE_PEEKNAMEDPIPE 0 +#define HAVE_POSIX_MEMALIGN 0 +#define HAVE_PTHREAD_CANCEL 0 +#define HAVE_SCHED_GETAFFINITY 1 +#define HAVE_SETCONSOLETEXTATTRIBUTE 0 +#define HAVE_SETCONSOLECTRLHANDLER 0 +#define HAVE_SETMODE 0 +#define HAVE_SETRLIMIT 1 +#define HAVE_SLEEP 0 +#define HAVE_STRERROR_R 1 +#define HAVE_SYSCONF 1 +#define HAVE_SYSCTL 0 +#define HAVE_USLEEP 1 +#define HAVE_UTGETOSTYPEFROMSTRING 0 +#define HAVE_VIRTUALALLOC 0 +#define HAVE_WGLGETPROCADDRESS 0 +#define HAVE_PTHREADS 1 +#define HAVE_OS2THREADS 0 +#define HAVE_W32THREADS 0 +#define HAVE_AS_DN_DIRECTIVE 1 +#define HAVE_AS_FUNC 1 +#define HAVE_AS_OBJECT_ARCH 1 +#define HAVE_ASM_MOD_Q 1 +#define HAVE_ATTRIBUTE_MAY_ALIAS 1 +#define HAVE_ATTRIBUTE_PACKED 1 +#define HAVE_EBP_AVAILABLE 0 +#define HAVE_EBX_AVAILABLE 0 +#define HAVE_GNU_AS 1 +#define HAVE_GNU_WINDRES 0 +#define HAVE_IBM_ASM 0 +#define HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS 0 +#define HAVE_INLINE_ASM_LABELS 1 +#define HAVE_INLINE_ASM_NONLOCAL_LABELS 1 +#define HAVE_PRAGMA_DEPRECATED 1 +#define HAVE_RSYNC_CONTIMEOUT 0 +#define HAVE_SYMVER_ASM_LABEL 0 +#define HAVE_SYMVER_GNU_ASM 1 +#define HAVE_VFP_ARGS 0 +#define HAVE_XFORM_ASM 0 +#define HAVE_XMM_CLOBBERS 0 +#define HAVE_CONDITION_VARIABLE_PTR 0 +#define HAVE_SOCKLEN_T 1 +#define HAVE_STRUCT_ADDRINFO 1 +#define HAVE_STRUCT_GROUP_SOURCE_REQ 1 +#define HAVE_STRUCT_IP_MREQ_SOURCE 1 +#define HAVE_STRUCT_IPV6_MREQ 1 +#define HAVE_STRUCT_MSGHDR_MSG_FLAGS 1 +#define HAVE_STRUCT_POLLFD 1 +#define HAVE_STRUCT_RUSAGE_RU_MAXRSS 1 +#define HAVE_STRUCT_SCTP_EVENT_SUBSCRIBE 0 +#define HAVE_STRUCT_SOCKADDR_IN6 1 +#define HAVE_STRUCT_SOCKADDR_SA_LEN 0 +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 +#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 0 +#define HAVE_STRUCT_V4L2_FRMIVALENUM_DISCRETE 0 +#define HAVE_ATOMICS_NATIVE 1 +#define HAVE_DOS_PATHS 0 +#define HAVE_DXVA2_LIB 0 +#define HAVE_DXVA2API_COBJ 0 +#define HAVE_LIBC_MSVCRT 0 +#define HAVE_LIBDC1394_1 0 +#define HAVE_LIBDC1394_2 0 +#define HAVE_MAKEINFO 1 +#define HAVE_MAKEINFO_HTML 0 +#define HAVE_MMAL_PARAMETER_VIDEO_MAX_NUM_CALLBACKS 0 +#define HAVE_PERL 0 +#define HAVE_POD2MAN 0 +#define HAVE_SDL2 0 +#define HAVE_SECTION_DATA_REL_RO 1 +#define HAVE_TEXI2HTML 0 +#define HAVE_THREADS 1 +#define HAVE_VAAPI_DRM 0 +#define HAVE_VAAPI_X11 0 +#define HAVE_VDPAU_X11 0 +#define HAVE_WINRT 0 +#define HAVE_XLIB 0 +#define CONFIG_BSFS 1 +#define CONFIG_DECODERS 1 +#define CONFIG_ENCODERS 1 +#define CONFIG_HWACCELS 1 +#define CONFIG_PARSERS 1 +#define CONFIG_INDEVS 0 +#define CONFIG_OUTDEVS 0 +#define CONFIG_FILTERS 1 +#define CONFIG_DEMUXERS 1 +#define CONFIG_MUXERS 1 +#define CONFIG_PROTOCOLS 1 +#define CONFIG_DOC 0 +#define CONFIG_HTMLPAGES 0 +#define CONFIG_MANPAGES 0 +#define CONFIG_PODPAGES 0 +#define CONFIG_TXTPAGES 0 +#define CONFIG_AVIO_DIR_CMD_EXAMPLE 1 +#define CONFIG_AVIO_READING_EXAMPLE 1 +#define CONFIG_DECODING_ENCODING_EXAMPLE 1 +#define CONFIG_DEMUXING_DECODING_EXAMPLE 1 +#define CONFIG_EXTRACT_MVS_EXAMPLE 1 +#define CONFIG_FILTER_AUDIO_EXAMPLE 1 +#define CONFIG_FILTERING_AUDIO_EXAMPLE 1 +#define CONFIG_FILTERING_VIDEO_EXAMPLE 1 +#define CONFIG_HTTP_MULTICLIENT_EXAMPLE 1 +#define CONFIG_METADATA_EXAMPLE 1 +#define CONFIG_MUXING_EXAMPLE 1 +#define CONFIG_QSVDEC_EXAMPLE 0 +#define CONFIG_REMUXING_EXAMPLE 1 +#define CONFIG_RESAMPLING_AUDIO_EXAMPLE 1 +#define CONFIG_SCALING_VIDEO_EXAMPLE 1 +#define CONFIG_TRANSCODE_AAC_EXAMPLE 1 +#define CONFIG_TRANSCODING_EXAMPLE 1 +#define CONFIG_AVISYNTH 0 +#define CONFIG_BZLIB 0 +#define CONFIG_CHROMAPRINT 0 +#define CONFIG_CRYSTALHD 0 +#define CONFIG_DECKLINK 0 +#define CONFIG_FREI0R 0 +#define CONFIG_GCRYPT 0 +#define CONFIG_GMP 0 +#define CONFIG_GNUTLS 0 +#define CONFIG_ICONV 0 +#define CONFIG_JNI 1 +#define CONFIG_LADSPA 0 +#define CONFIG_LIBASS 0 +#define CONFIG_LIBBLURAY 0 +#define CONFIG_LIBBS2B 0 +#define CONFIG_LIBCACA 0 +#define CONFIG_LIBCDIO 0 +#define CONFIG_LIBCELT 0 +#define CONFIG_LIBDC1394 0 +#define CONFIG_LIBEBUR128 0 +#define CONFIG_LIBFDK_AAC 0 +#define CONFIG_LIBFLITE 0 +#define CONFIG_LIBFONTCONFIG 0 +#define CONFIG_LIBFREETYPE 0 +#define CONFIG_LIBFRIBIDI 0 +#define CONFIG_LIBGME 0 +#define CONFIG_LIBGSM 0 +#define CONFIG_LIBIEC61883 0 +#define CONFIG_LIBILBC 0 +#define CONFIG_LIBKVAZAAR 0 +#define CONFIG_LIBMODPLUG 0 +#define CONFIG_LIBMP3LAME 0 +#define CONFIG_LIBNUT 0 +#define CONFIG_LIBOPENCORE_AMRNB 0 +#define CONFIG_LIBOPENCORE_AMRWB 0 +#define CONFIG_LIBOPENCV 0 +#define CONFIG_LIBOPENH264 0 +#define CONFIG_LIBOPENJPEG 0 +#define CONFIG_LIBOPENMPT 0 +#define CONFIG_LIBOPUS 0 +#define CONFIG_LIBPULSE 0 +#define CONFIG_LIBRTMP 0 +#define CONFIG_LIBRUBBERBAND 0 +#define CONFIG_LIBSCHROEDINGER 0 +#define CONFIG_LIBSHINE 0 +#define CONFIG_LIBSMBCLIENT 0 +#define CONFIG_LIBSNAPPY 0 +#define CONFIG_LIBSOXR 0 +#define CONFIG_LIBSPEEX 0 +#define CONFIG_LIBSSH 0 +#define CONFIG_LIBTESSERACT 0 +#define CONFIG_LIBTHEORA 0 +#define CONFIG_LIBTWOLAME 0 +#define CONFIG_LIBV4L2 0 +#define CONFIG_LIBVIDSTAB 0 +#define CONFIG_LIBVO_AMRWBENC 0 +#define CONFIG_LIBVORBIS 0 +#define CONFIG_LIBVPX 0 +#define CONFIG_LIBWAVPACK 0 +#define CONFIG_LIBWEBP 0 +#define CONFIG_LIBX264 0 +#define CONFIG_LIBX265 0 +#define CONFIG_LIBXAVS 0 +#define CONFIG_LIBXCB 0 +#define CONFIG_LIBXCB_SHM 0 +#define CONFIG_LIBXCB_SHAPE 0 +#define CONFIG_LIBXCB_XFIXES 0 +#define CONFIG_LIBXVID 0 +#define CONFIG_LIBZIMG 0 +#define CONFIG_LIBZMQ 0 +#define CONFIG_LIBZVBI 0 +#define CONFIG_LZMA 0 +#define CONFIG_MEDIACODEC 1 +#define CONFIG_NETCDF 0 +#define CONFIG_OPENAL 0 +#define CONFIG_OPENCL 0 +#define CONFIG_OPENGL 0 +#define CONFIG_OPENSSL 0 +#define CONFIG_SCHANNEL 0 +#define CONFIG_SDL 0 +#define CONFIG_SDL2 0 +#define CONFIG_SECURETRANSPORT 0 +#define CONFIG_VIDEOTOOLBOX 0 +#define CONFIG_X11GRAB 0 +#define CONFIG_XLIB 0 +#define CONFIG_ZLIB 1 +#define CONFIG_AUDIOTOOLBOX 0 +#define CONFIG_CUDA 0 +#define CONFIG_CUVID 0 +#define CONFIG_D3D11VA 0 +#define CONFIG_DXVA2 0 +#define CONFIG_LIBMFX 0 +#define CONFIG_LIBNPP 0 +#define CONFIG_MMAL 0 +#define CONFIG_NVENC 0 +#define CONFIG_OMX 0 +#define CONFIG_VAAPI 0 +#define CONFIG_VDA 0 +#define CONFIG_VDPAU 0 +#define CONFIG_VIDEOTOOLBOX_HWACCEL 0 +#define CONFIG_XVMC 0 +#define CONFIG_FTRAPV 0 +#define CONFIG_GRAY 0 +#define CONFIG_HARDCODED_TABLES 0 +#define CONFIG_OMX_RPI 0 +#define CONFIG_RUNTIME_CPUDETECT 1 +#define CONFIG_SAFE_BITSTREAM_READER 1 +#define CONFIG_SHARED 0 +#define CONFIG_SMALL 0 +#define CONFIG_STATIC 1 +#define CONFIG_SWSCALE_ALPHA 1 +#define CONFIG_GPL 0 +#define CONFIG_NONFREE 0 +#define CONFIG_VERSION3 0 +#define CONFIG_AVCODEC 1 +#define CONFIG_AVDEVICE 0 +#define CONFIG_AVFILTER 1 +#define CONFIG_AVFORMAT 1 +#define CONFIG_AVRESAMPLE 0 +#define CONFIG_AVUTIL 1 +#define CONFIG_POSTPROC 0 +#define CONFIG_SWRESAMPLE 1 +#define CONFIG_SWSCALE 1 +#define CONFIG_FFPLAY 0 +#define CONFIG_FFPROBE 0 +#define CONFIG_FFSERVER 0 +#define CONFIG_FFMPEG 0 +#define CONFIG_DCT 1 +#define CONFIG_DWT 1 +#define CONFIG_ERROR_RESILIENCE 1 +#define CONFIG_FAAN 1 +#define CONFIG_FAST_UNALIGNED 0 +#define CONFIG_FFT 1 +#define CONFIG_LSP 1 +#define CONFIG_LZO 1 +#define CONFIG_MDCT 1 +#define CONFIG_PIXELUTILS 1 +#define CONFIG_NETWORK 1 +#define CONFIG_RDFT 1 +#define CONFIG_FONTCONFIG 0 +#define CONFIG_MEMALIGN_HACK 0 +#define CONFIG_MEMORY_POISONING 0 +#define CONFIG_NEON_CLOBBER_TEST 0 +#define CONFIG_PIC 1 +#define CONFIG_POD2MAN 0 +#define CONFIG_RAISE_MAJOR 0 +#define CONFIG_THUMB 0 +#define CONFIG_VALGRIND_BACKTRACE 0 +#define CONFIG_XMM_CLOBBER_TEST 0 +#define CONFIG_AANDCTTABLES 1 +#define CONFIG_AC3DSP 1 +#define CONFIG_AUDIO_FRAME_QUEUE 1 +#define CONFIG_AUDIODSP 1 +#define CONFIG_BLOCKDSP 1 +#define CONFIG_BSWAPDSP 1 +#define CONFIG_CABAC 1 +#define CONFIG_DIRAC_PARSE 1 +#define CONFIG_DVPROFILE 1 +#define CONFIG_EXIF 1 +#define CONFIG_FAANDCT 1 +#define CONFIG_FAANIDCT 1 +#define CONFIG_FDCTDSP 1 +#define CONFIG_FLACDSP 1 +#define CONFIG_FMTCONVERT 1 +#define CONFIG_FRAME_THREAD_ENCODER 1 +#define CONFIG_G722DSP 1 +#define CONFIG_GOLOMB 1 +#define CONFIG_GPLV3 0 +#define CONFIG_H263DSP 1 +#define CONFIG_H264CHROMA 1 +#define CONFIG_H264DSP 1 +#define CONFIG_H264PRED 1 +#define CONFIG_H264QPEL 1 +#define CONFIG_HPELDSP 1 +#define CONFIG_HUFFMAN 1 +#define CONFIG_HUFFYUVDSP 1 +#define CONFIG_HUFFYUVENCDSP 1 +#define CONFIG_IDCTDSP 1 +#define CONFIG_IIRFILTER 1 +#define CONFIG_IMDCT15 1 +#define CONFIG_INTRAX8 1 +#define CONFIG_ISO_MEDIA 1 +#define CONFIG_IVIDSP 1 +#define CONFIG_JPEGTABLES 1 +#define CONFIG_LGPLV3 0 +#define CONFIG_LIBX262 0 +#define CONFIG_LLAUDDSP 1 +#define CONFIG_LLVIDDSP 1 +#define CONFIG_LPC 1 +#define CONFIG_LZF 1 +#define CONFIG_ME_CMP 1 +#define CONFIG_MPEG_ER 1 +#define CONFIG_MPEGAUDIO 1 +#define CONFIG_MPEGAUDIODSP 1 +#define CONFIG_MPEGVIDEO 1 +#define CONFIG_MPEGVIDEOENC 1 +#define CONFIG_MSS34DSP 1 +#define CONFIG_PIXBLOCKDSP 1 +#define CONFIG_QPELDSP 1 +#define CONFIG_QSV 0 +#define CONFIG_QSVDEC 0 +#define CONFIG_QSVENC 0 +#define CONFIG_RANGECODER 1 +#define CONFIG_RIFFDEC 1 +#define CONFIG_RIFFENC 1 +#define CONFIG_RTPDEC 1 +#define CONFIG_RTPENC_CHAIN 1 +#define CONFIG_RV34DSP 1 +#define CONFIG_SINEWIN 1 +#define CONFIG_SNAPPY 1 +#define CONFIG_SRTP 1 +#define CONFIG_STARTCODE 1 +#define CONFIG_TEXTUREDSP 1 +#define CONFIG_TEXTUREDSPENC 0 +#define CONFIG_TPELDSP 1 +#define CONFIG_VAAPI_ENCODE 0 +#define CONFIG_VC1DSP 1 +#define CONFIG_VIDEODSP 1 +#define CONFIG_VP3DSP 1 +#define CONFIG_VP56DSP 1 +#define CONFIG_VP8DSP 1 +#define CONFIG_VT_BT2020 0 +#define CONFIG_WMA_FREQS 1 +#define CONFIG_WMV2DSP 1 +#define CONFIG_AAC_ADTSTOASC_BSF 1 +#define CONFIG_CHOMP_BSF 1 +#define CONFIG_DUMP_EXTRADATA_BSF 1 +#define CONFIG_DCA_CORE_BSF 1 +#define CONFIG_H264_MP4TOANNEXB_BSF 1 +#define CONFIG_HEVC_MP4TOANNEXB_BSF 1 +#define CONFIG_IMX_DUMP_HEADER_BSF 1 +#define CONFIG_MJPEG2JPEG_BSF 1 +#define CONFIG_MJPEGA_DUMP_HEADER_BSF 1 +#define CONFIG_MP3_HEADER_DECOMPRESS_BSF 1 +#define CONFIG_MPEG4_UNPACK_BFRAMES_BSF 1 +#define CONFIG_MOV2TEXTSUB_BSF 1 +#define CONFIG_NOISE_BSF 1 +#define CONFIG_REMOVE_EXTRADATA_BSF 1 +#define CONFIG_TEXT2MOVSUB_BSF 1 +#define CONFIG_VP9_SUPERFRAME_BSF 1 +#define CONFIG_AASC_DECODER 1 +#define CONFIG_AIC_DECODER 1 +#define CONFIG_ALIAS_PIX_DECODER 1 +#define CONFIG_AMV_DECODER 1 +#define CONFIG_ANM_DECODER 1 +#define CONFIG_ANSI_DECODER 1 +#define CONFIG_APNG_DECODER 1 +#define CONFIG_ASV1_DECODER 1 +#define CONFIG_ASV2_DECODER 1 +#define CONFIG_AURA_DECODER 1 +#define CONFIG_AURA2_DECODER 1 +#define CONFIG_AVRP_DECODER 1 +#define CONFIG_AVRN_DECODER 1 +#define CONFIG_AVS_DECODER 1 +#define CONFIG_AVUI_DECODER 1 +#define CONFIG_AYUV_DECODER 1 +#define CONFIG_BETHSOFTVID_DECODER 1 +#define CONFIG_BFI_DECODER 1 +#define CONFIG_BINK_DECODER 1 +#define CONFIG_BMP_DECODER 1 +#define CONFIG_BMV_VIDEO_DECODER 1 +#define CONFIG_BRENDER_PIX_DECODER 1 +#define CONFIG_C93_DECODER 1 +#define CONFIG_CAVS_DECODER 1 +#define CONFIG_CDGRAPHICS_DECODER 1 +#define CONFIG_CDXL_DECODER 1 +#define CONFIG_CFHD_DECODER 1 +#define CONFIG_CINEPAK_DECODER 1 +#define CONFIG_CLJR_DECODER 1 +#define CONFIG_CLLC_DECODER 1 +#define CONFIG_COMFORTNOISE_DECODER 1 +#define CONFIG_CPIA_DECODER 1 +#define CONFIG_CSCD_DECODER 1 +#define CONFIG_CYUV_DECODER 1 +#define CONFIG_DDS_DECODER 1 +#define CONFIG_DFA_DECODER 1 +#define CONFIG_DIRAC_DECODER 1 +#define CONFIG_DNXHD_DECODER 1 +#define CONFIG_DPX_DECODER 1 +#define CONFIG_DSICINVIDEO_DECODER 1 +#define CONFIG_DVAUDIO_DECODER 1 +#define CONFIG_DVVIDEO_DECODER 1 +#define CONFIG_DXA_DECODER 1 +#define CONFIG_DXTORY_DECODER 1 +#define CONFIG_DXV_DECODER 1 +#define CONFIG_EACMV_DECODER 1 +#define CONFIG_EAMAD_DECODER 1 +#define CONFIG_EATGQ_DECODER 1 +#define CONFIG_EATGV_DECODER 1 +#define CONFIG_EATQI_DECODER 1 +#define CONFIG_EIGHTBPS_DECODER 1 +#define CONFIG_EIGHTSVX_EXP_DECODER 1 +#define CONFIG_EIGHTSVX_FIB_DECODER 1 +#define CONFIG_ESCAPE124_DECODER 1 +#define CONFIG_ESCAPE130_DECODER 1 +#define CONFIG_EXR_DECODER 1 +#define CONFIG_FFV1_DECODER 1 +#define CONFIG_FFVHUFF_DECODER 1 +#define CONFIG_FIC_DECODER 1 +#define CONFIG_FLASHSV_DECODER 1 +#define CONFIG_FLASHSV2_DECODER 1 +#define CONFIG_FLIC_DECODER 1 +#define CONFIG_FLV_DECODER 1 +#define CONFIG_FOURXM_DECODER 1 +#define CONFIG_FRAPS_DECODER 1 +#define CONFIG_FRWU_DECODER 1 +#define CONFIG_G2M_DECODER 1 +#define CONFIG_GIF_DECODER 1 +#define CONFIG_H261_DECODER 1 +#define CONFIG_H263_DECODER 1 +#define CONFIG_H263I_DECODER 1 +#define CONFIG_H263P_DECODER 1 +#define CONFIG_H264_DECODER 1 +#define CONFIG_H264_CRYSTALHD_DECODER 0 +#define CONFIG_H264_MEDIACODEC_DECODER 1 +#define CONFIG_H264_MMAL_DECODER 0 +#define CONFIG_H264_QSV_DECODER 0 +#define CONFIG_H264_VDA_DECODER 0 +#define CONFIG_H264_VDPAU_DECODER 0 +#define CONFIG_HAP_DECODER 1 +#define CONFIG_HEVC_DECODER 1 +#define CONFIG_HEVC_QSV_DECODER 0 +#define CONFIG_HNM4_VIDEO_DECODER 1 +#define CONFIG_HQ_HQA_DECODER 1 +#define CONFIG_HQX_DECODER 1 +#define CONFIG_HUFFYUV_DECODER 1 +#define CONFIG_IDCIN_DECODER 1 +#define CONFIG_IFF_ILBM_DECODER 1 +#define CONFIG_INDEO2_DECODER 1 +#define CONFIG_INDEO3_DECODER 1 +#define CONFIG_INDEO4_DECODER 1 +#define CONFIG_INDEO5_DECODER 1 +#define CONFIG_INTERPLAY_VIDEO_DECODER 1 +#define CONFIG_JPEG2000_DECODER 1 +#define CONFIG_JPEGLS_DECODER 1 +#define CONFIG_JV_DECODER 1 +#define CONFIG_KGV1_DECODER 1 +#define CONFIG_KMVC_DECODER 1 +#define CONFIG_LAGARITH_DECODER 1 +#define CONFIG_LOCO_DECODER 1 +#define CONFIG_M101_DECODER 1 +#define CONFIG_MAGICYUV_DECODER 1 +#define CONFIG_MDEC_DECODER 1 +#define CONFIG_MIMIC_DECODER 1 +#define CONFIG_MJPEG_DECODER 1 +#define CONFIG_MJPEGB_DECODER 1 +#define CONFIG_MMVIDEO_DECODER 1 +#define CONFIG_MOTIONPIXELS_DECODER 1 +#define CONFIG_MPEG_XVMC_DECODER 0 +#define CONFIG_MPEG1VIDEO_DECODER 1 +#define CONFIG_MPEG2VIDEO_DECODER 1 +#define CONFIG_MPEG4_DECODER 1 +#define CONFIG_MPEG4_CRYSTALHD_DECODER 0 +#define CONFIG_MPEG4_MMAL_DECODER 0 +#define CONFIG_MPEG4_VDPAU_DECODER 0 +#define CONFIG_MPEGVIDEO_DECODER 1 +#define CONFIG_MPEG_VDPAU_DECODER 0 +#define CONFIG_MPEG1_VDPAU_DECODER 0 +#define CONFIG_MPEG2_MMAL_DECODER 0 +#define CONFIG_MPEG2_CRYSTALHD_DECODER 0 +#define CONFIG_MPEG2_QSV_DECODER 0 +#define CONFIG_MSA1_DECODER 1 +#define CONFIG_MSMPEG4_CRYSTALHD_DECODER 0 +#define CONFIG_MSMPEG4V1_DECODER 1 +#define CONFIG_MSMPEG4V2_DECODER 1 +#define CONFIG_MSMPEG4V3_DECODER 1 +#define CONFIG_MSRLE_DECODER 1 +#define CONFIG_MSS1_DECODER 1 +#define CONFIG_MSS2_DECODER 1 +#define CONFIG_MSVIDEO1_DECODER 1 +#define CONFIG_MSZH_DECODER 1 +#define CONFIG_MTS2_DECODER 1 +#define CONFIG_MVC1_DECODER 1 +#define CONFIG_MVC2_DECODER 1 +#define CONFIG_MXPEG_DECODER 1 +#define CONFIG_NUV_DECODER 1 +#define CONFIG_PAF_VIDEO_DECODER 1 +#define CONFIG_PAM_DECODER 1 +#define CONFIG_PBM_DECODER 1 +#define CONFIG_PCX_DECODER 1 +#define CONFIG_PGM_DECODER 1 +#define CONFIG_PGMYUV_DECODER 1 +#define CONFIG_PICTOR_DECODER 1 +#define CONFIG_PNG_DECODER 1 +#define CONFIG_PPM_DECODER 1 +#define CONFIG_PRORES_DECODER 1 +#define CONFIG_PRORES_LGPL_DECODER 1 +#define CONFIG_PTX_DECODER 1 +#define CONFIG_QDRAW_DECODER 1 +#define CONFIG_QPEG_DECODER 1 +#define CONFIG_QTRLE_DECODER 1 +#define CONFIG_R10K_DECODER 1 +#define CONFIG_R210_DECODER 1 +#define CONFIG_RAWVIDEO_DECODER 1 +#define CONFIG_RL2_DECODER 1 +#define CONFIG_ROQ_DECODER 1 +#define CONFIG_RPZA_DECODER 1 +#define CONFIG_RSCC_DECODER 1 +#define CONFIG_RV10_DECODER 1 +#define CONFIG_RV20_DECODER 1 +#define CONFIG_RV30_DECODER 1 +#define CONFIG_RV40_DECODER 1 +#define CONFIG_S302M_DECODER 1 +#define CONFIG_SANM_DECODER 1 +#define CONFIG_SCREENPRESSO_DECODER 1 +#define CONFIG_SDX2_DPCM_DECODER 1 +#define CONFIG_SGI_DECODER 1 +#define CONFIG_SGIRLE_DECODER 1 +#define CONFIG_SHEERVIDEO_DECODER 1 +#define CONFIG_SMACKER_DECODER 1 +#define CONFIG_SMC_DECODER 1 +#define CONFIG_SMVJPEG_DECODER 1 +#define CONFIG_SNOW_DECODER 1 +#define CONFIG_SP5X_DECODER 1 +#define CONFIG_SUNRAST_DECODER 1 +#define CONFIG_SVQ1_DECODER 1 +#define CONFIG_SVQ3_DECODER 1 +#define CONFIG_TARGA_DECODER 1 +#define CONFIG_TARGA_Y216_DECODER 1 +#define CONFIG_TDSC_DECODER 1 +#define CONFIG_THEORA_DECODER 1 +#define CONFIG_THP_DECODER 1 +#define CONFIG_TIERTEXSEQVIDEO_DECODER 1 +#define CONFIG_TIFF_DECODER 1 +#define CONFIG_TMV_DECODER 1 +#define CONFIG_TRUEMOTION1_DECODER 1 +#define CONFIG_TRUEMOTION2_DECODER 1 +#define CONFIG_TRUEMOTION2RT_DECODER 1 +#define CONFIG_TSCC_DECODER 1 +#define CONFIG_TSCC2_DECODER 1 +#define CONFIG_TXD_DECODER 1 +#define CONFIG_ULTI_DECODER 1 +#define CONFIG_UTVIDEO_DECODER 1 +#define CONFIG_V210_DECODER 1 +#define CONFIG_V210X_DECODER 1 +#define CONFIG_V308_DECODER 1 +#define CONFIG_V408_DECODER 1 +#define CONFIG_V410_DECODER 1 +#define CONFIG_VB_DECODER 1 +#define CONFIG_VBLE_DECODER 1 +#define CONFIG_VC1_DECODER 1 +#define CONFIG_VC1_CRYSTALHD_DECODER 0 +#define CONFIG_VC1_VDPAU_DECODER 0 +#define CONFIG_VC1IMAGE_DECODER 1 +#define CONFIG_VC1_MMAL_DECODER 0 +#define CONFIG_VC1_QSV_DECODER 0 +#define CONFIG_VCR1_DECODER 1 +#define CONFIG_VMDVIDEO_DECODER 1 +#define CONFIG_VMNC_DECODER 1 +#define CONFIG_VP3_DECODER 1 +#define CONFIG_VP5_DECODER 1 +#define CONFIG_VP6_DECODER 1 +#define CONFIG_VP6A_DECODER 1 +#define CONFIG_VP6F_DECODER 1 +#define CONFIG_VP7_DECODER 1 +#define CONFIG_VP8_DECODER 1 +#define CONFIG_VP9_DECODER 1 +#define CONFIG_VQA_DECODER 1 +#define CONFIG_WEBP_DECODER 1 +#define CONFIG_WMV1_DECODER 1 +#define CONFIG_WMV2_DECODER 1 +#define CONFIG_WMV3_DECODER 1 +#define CONFIG_WMV3_CRYSTALHD_DECODER 0 +#define CONFIG_WMV3_VDPAU_DECODER 0 +#define CONFIG_WMV3IMAGE_DECODER 1 +#define CONFIG_WNV1_DECODER 1 +#define CONFIG_XAN_WC3_DECODER 1 +#define CONFIG_XAN_WC4_DECODER 1 +#define CONFIG_XBM_DECODER 1 +#define CONFIG_XFACE_DECODER 1 +#define CONFIG_XL_DECODER 1 +#define CONFIG_XWD_DECODER 1 +#define CONFIG_Y41P_DECODER 1 +#define CONFIG_YLC_DECODER 1 +#define CONFIG_YOP_DECODER 1 +#define CONFIG_YUV4_DECODER 1 +#define CONFIG_ZERO12V_DECODER 1 +#define CONFIG_ZEROCODEC_DECODER 1 +#define CONFIG_ZLIB_DECODER 1 +#define CONFIG_ZMBV_DECODER 1 +#define CONFIG_AAC_DECODER 1 +#define CONFIG_AAC_FIXED_DECODER 1 +#define CONFIG_AAC_LATM_DECODER 1 +#define CONFIG_AC3_DECODER 1 +#define CONFIG_AC3_FIXED_DECODER 1 +#define CONFIG_ALAC_DECODER 1 +#define CONFIG_ALS_DECODER 1 +#define CONFIG_AMRNB_DECODER 1 +#define CONFIG_AMRWB_DECODER 1 +#define CONFIG_APE_DECODER 1 +#define CONFIG_ATRAC1_DECODER 1 +#define CONFIG_ATRAC3_DECODER 1 +#define CONFIG_ATRAC3P_DECODER 1 +#define CONFIG_BINKAUDIO_DCT_DECODER 1 +#define CONFIG_BINKAUDIO_RDFT_DECODER 1 +#define CONFIG_BMV_AUDIO_DECODER 1 +#define CONFIG_COOK_DECODER 1 +#define CONFIG_DCA_DECODER 1 +#define CONFIG_DSD_LSBF_DECODER 1 +#define CONFIG_DSD_MSBF_DECODER 1 +#define CONFIG_DSD_LSBF_PLANAR_DECODER 1 +#define CONFIG_DSD_MSBF_PLANAR_DECODER 1 +#define CONFIG_DSICINAUDIO_DECODER 1 +#define CONFIG_DSS_SP_DECODER 1 +#define CONFIG_DST_DECODER 1 +#define CONFIG_EAC3_DECODER 1 +#define CONFIG_EVRC_DECODER 1 +#define CONFIG_FFWAVESYNTH_DECODER 1 +#define CONFIG_FLAC_DECODER 1 +#define CONFIG_G723_1_DECODER 1 +#define CONFIG_G729_DECODER 1 +#define CONFIG_GSM_DECODER 1 +#define CONFIG_GSM_MS_DECODER 1 +#define CONFIG_IAC_DECODER 1 +#define CONFIG_IMC_DECODER 1 +#define CONFIG_INTERPLAY_ACM_DECODER 1 +#define CONFIG_MACE3_DECODER 1 +#define CONFIG_MACE6_DECODER 1 +#define CONFIG_METASOUND_DECODER 1 +#define CONFIG_MLP_DECODER 1 +#define CONFIG_MP1_DECODER 1 +#define CONFIG_MP1FLOAT_DECODER 1 +#define CONFIG_MP2_DECODER 1 +#define CONFIG_MP2FLOAT_DECODER 1 +#define CONFIG_MP3_DECODER 1 +#define CONFIG_MP3FLOAT_DECODER 1 +#define CONFIG_MP3ADU_DECODER 1 +#define CONFIG_MP3ADUFLOAT_DECODER 1 +#define CONFIG_MP3ON4_DECODER 1 +#define CONFIG_MP3ON4FLOAT_DECODER 1 +#define CONFIG_MPC7_DECODER 1 +#define CONFIG_MPC8_DECODER 1 +#define CONFIG_NELLYMOSER_DECODER 1 +#define CONFIG_ON2AVC_DECODER 1 +#define CONFIG_OPUS_DECODER 1 +#define CONFIG_PAF_AUDIO_DECODER 1 +#define CONFIG_QCELP_DECODER 1 +#define CONFIG_QDM2_DECODER 1 +#define CONFIG_RA_144_DECODER 1 +#define CONFIG_RA_288_DECODER 1 +#define CONFIG_RALF_DECODER 1 +#define CONFIG_SHORTEN_DECODER 1 +#define CONFIG_SIPR_DECODER 1 +#define CONFIG_SMACKAUD_DECODER 1 +#define CONFIG_SONIC_DECODER 1 +#define CONFIG_TAK_DECODER 1 +#define CONFIG_TRUEHD_DECODER 1 +#define CONFIG_TRUESPEECH_DECODER 1 +#define CONFIG_TTA_DECODER 1 +#define CONFIG_TWINVQ_DECODER 1 +#define CONFIG_VMDAUDIO_DECODER 1 +#define CONFIG_VORBIS_DECODER 1 +#define CONFIG_WAVPACK_DECODER 1 +#define CONFIG_WMALOSSLESS_DECODER 1 +#define CONFIG_WMAPRO_DECODER 1 +#define CONFIG_WMAV1_DECODER 1 +#define CONFIG_WMAV2_DECODER 1 +#define CONFIG_WMAVOICE_DECODER 1 +#define CONFIG_WS_SND1_DECODER 1 +#define CONFIG_XMA1_DECODER 1 +#define CONFIG_XMA2_DECODER 1 +#define CONFIG_PCM_ALAW_DECODER 1 +#define CONFIG_PCM_BLURAY_DECODER 1 +#define CONFIG_PCM_DVD_DECODER 1 +#define CONFIG_PCM_F32BE_DECODER 1 +#define CONFIG_PCM_F32LE_DECODER 1 +#define CONFIG_PCM_F64BE_DECODER 1 +#define CONFIG_PCM_F64LE_DECODER 1 +#define CONFIG_PCM_LXF_DECODER 1 +#define CONFIG_PCM_MULAW_DECODER 1 +#define CONFIG_PCM_S8_DECODER 1 +#define CONFIG_PCM_S8_PLANAR_DECODER 1 +#define CONFIG_PCM_S16BE_DECODER 1 +#define CONFIG_PCM_S16BE_PLANAR_DECODER 1 +#define CONFIG_PCM_S16LE_DECODER 1 +#define CONFIG_PCM_S16LE_PLANAR_DECODER 1 +#define CONFIG_PCM_S24BE_DECODER 1 +#define CONFIG_PCM_S24DAUD_DECODER 1 +#define CONFIG_PCM_S24LE_DECODER 1 +#define CONFIG_PCM_S24LE_PLANAR_DECODER 1 +#define CONFIG_PCM_S32BE_DECODER 1 +#define CONFIG_PCM_S32LE_DECODER 1 +#define CONFIG_PCM_S32LE_PLANAR_DECODER 1 +#define CONFIG_PCM_S64BE_DECODER 1 +#define CONFIG_PCM_S64LE_DECODER 1 +#define CONFIG_PCM_U8_DECODER 1 +#define CONFIG_PCM_U16BE_DECODER 1 +#define CONFIG_PCM_U16LE_DECODER 1 +#define CONFIG_PCM_U24BE_DECODER 1 +#define CONFIG_PCM_U24LE_DECODER 1 +#define CONFIG_PCM_U32BE_DECODER 1 +#define CONFIG_PCM_U32LE_DECODER 1 +#define CONFIG_PCM_ZORK_DECODER 1 +#define CONFIG_INTERPLAY_DPCM_DECODER 1 +#define CONFIG_ROQ_DPCM_DECODER 1 +#define CONFIG_SOL_DPCM_DECODER 1 +#define CONFIG_XAN_DPCM_DECODER 1 +#define CONFIG_ADPCM_4XM_DECODER 1 +#define CONFIG_ADPCM_ADX_DECODER 1 +#define CONFIG_ADPCM_AFC_DECODER 1 +#define CONFIG_ADPCM_AICA_DECODER 1 +#define CONFIG_ADPCM_CT_DECODER 1 +#define CONFIG_ADPCM_DTK_DECODER 1 +#define CONFIG_ADPCM_EA_DECODER 1 +#define CONFIG_ADPCM_EA_MAXIS_XA_DECODER 1 +#define CONFIG_ADPCM_EA_R1_DECODER 1 +#define CONFIG_ADPCM_EA_R2_DECODER 1 +#define CONFIG_ADPCM_EA_R3_DECODER 1 +#define CONFIG_ADPCM_EA_XAS_DECODER 1 +#define CONFIG_ADPCM_G722_DECODER 1 +#define CONFIG_ADPCM_G726_DECODER 1 +#define CONFIG_ADPCM_G726LE_DECODER 1 +#define CONFIG_ADPCM_IMA_AMV_DECODER 1 +#define CONFIG_ADPCM_IMA_APC_DECODER 1 +#define CONFIG_ADPCM_IMA_DAT4_DECODER 1 +#define CONFIG_ADPCM_IMA_DK3_DECODER 1 +#define CONFIG_ADPCM_IMA_DK4_DECODER 1 +#define CONFIG_ADPCM_IMA_EA_EACS_DECODER 1 +#define CONFIG_ADPCM_IMA_EA_SEAD_DECODER 1 +#define CONFIG_ADPCM_IMA_ISS_DECODER 1 +#define CONFIG_ADPCM_IMA_OKI_DECODER 1 +#define CONFIG_ADPCM_IMA_QT_DECODER 1 +#define CONFIG_ADPCM_IMA_RAD_DECODER 1 +#define CONFIG_ADPCM_IMA_SMJPEG_DECODER 1 +#define CONFIG_ADPCM_IMA_WAV_DECODER 1 +#define CONFIG_ADPCM_IMA_WS_DECODER 1 +#define CONFIG_ADPCM_MS_DECODER 1 +#define CONFIG_ADPCM_MTAF_DECODER 1 +#define CONFIG_ADPCM_PSX_DECODER 1 +#define CONFIG_ADPCM_SBPRO_2_DECODER 1 +#define CONFIG_ADPCM_SBPRO_3_DECODER 1 +#define CONFIG_ADPCM_SBPRO_4_DECODER 1 +#define CONFIG_ADPCM_SWF_DECODER 1 +#define CONFIG_ADPCM_THP_DECODER 1 +#define CONFIG_ADPCM_THP_LE_DECODER 1 +#define CONFIG_ADPCM_VIMA_DECODER 1 +#define CONFIG_ADPCM_XA_DECODER 1 +#define CONFIG_ADPCM_YAMAHA_DECODER 1 +#define CONFIG_SSA_DECODER 1 +#define CONFIG_ASS_DECODER 1 +#define CONFIG_CCAPTION_DECODER 1 +#define CONFIG_DVBSUB_DECODER 1 +#define CONFIG_DVDSUB_DECODER 1 +#define CONFIG_JACOSUB_DECODER 1 +#define CONFIG_MICRODVD_DECODER 1 +#define CONFIG_MOVTEXT_DECODER 1 +#define CONFIG_MPL2_DECODER 1 +#define CONFIG_PGSSUB_DECODER 1 +#define CONFIG_PJS_DECODER 1 +#define CONFIG_REALTEXT_DECODER 1 +#define CONFIG_SAMI_DECODER 1 +#define CONFIG_SRT_DECODER 1 +#define CONFIG_STL_DECODER 1 +#define CONFIG_SUBRIP_DECODER 1 +#define CONFIG_SUBVIEWER_DECODER 1 +#define CONFIG_SUBVIEWER1_DECODER 1 +#define CONFIG_TEXT_DECODER 1 +#define CONFIG_VPLAYER_DECODER 1 +#define CONFIG_WEBVTT_DECODER 1 +#define CONFIG_XSUB_DECODER 1 +#define CONFIG_AAC_AT_DECODER 0 +#define CONFIG_AC3_AT_DECODER 0 +#define CONFIG_ADPCM_IMA_QT_AT_DECODER 0 +#define CONFIG_ALAC_AT_DECODER 0 +#define CONFIG_AMR_NB_AT_DECODER 0 +#define CONFIG_EAC3_AT_DECODER 0 +#define CONFIG_GSM_MS_AT_DECODER 0 +#define CONFIG_ILBC_AT_DECODER 0 +#define CONFIG_MP1_AT_DECODER 0 +#define CONFIG_MP2_AT_DECODER 0 +#define CONFIG_MP3_AT_DECODER 0 +#define CONFIG_PCM_ALAW_AT_DECODER 0 +#define CONFIG_PCM_MULAW_AT_DECODER 0 +#define CONFIG_QDMC_AT_DECODER 0 +#define CONFIG_QDM2_AT_DECODER 0 +#define CONFIG_LIBCELT_DECODER 0 +#define CONFIG_LIBFDK_AAC_DECODER 0 +#define CONFIG_LIBGSM_DECODER 0 +#define CONFIG_LIBGSM_MS_DECODER 0 +#define CONFIG_LIBILBC_DECODER 0 +#define CONFIG_LIBOPENCORE_AMRNB_DECODER 0 +#define CONFIG_LIBOPENCORE_AMRWB_DECODER 0 +#define CONFIG_LIBOPENJPEG_DECODER 0 +#define CONFIG_LIBOPUS_DECODER 0 +#define CONFIG_LIBSCHROEDINGER_DECODER 0 +#define CONFIG_LIBSPEEX_DECODER 0 +#define CONFIG_LIBVORBIS_DECODER 0 +#define CONFIG_LIBVPX_VP8_DECODER 0 +#define CONFIG_LIBVPX_VP9_DECODER 0 +#define CONFIG_LIBZVBI_TELETEXT_DECODER 0 +#define CONFIG_BINTEXT_DECODER 1 +#define CONFIG_XBIN_DECODER 1 +#define CONFIG_IDF_DECODER 1 +#define CONFIG_LIBOPENH264_DECODER 0 +#define CONFIG_H263_CUVID_DECODER 0 +#define CONFIG_H264_CUVID_DECODER 0 +#define CONFIG_HEVC_CUVID_DECODER 0 +#define CONFIG_HEVC_MEDIACODEC_DECODER 1 +#define CONFIG_MJPEG_CUVID_DECODER 0 +#define CONFIG_MPEG1_CUVID_DECODER 0 +#define CONFIG_MPEG2_CUVID_DECODER 0 +#define CONFIG_MPEG4_CUVID_DECODER 0 +#define CONFIG_MPEG4_MEDIACODEC_DECODER 1 +#define CONFIG_VC1_CUVID_DECODER 0 +#define CONFIG_VP8_CUVID_DECODER 0 +#define CONFIG_VP8_MEDIACODEC_DECODER 1 +#define CONFIG_VP9_CUVID_DECODER 0 +#define CONFIG_VP9_MEDIACODEC_DECODER 1 +#define CONFIG_AA_DEMUXER 1 +#define CONFIG_AAC_DEMUXER 1 +#define CONFIG_AC3_DEMUXER 1 +#define CONFIG_ACM_DEMUXER 1 +#define CONFIG_ACT_DEMUXER 1 +#define CONFIG_ADF_DEMUXER 1 +#define CONFIG_ADP_DEMUXER 1 +#define CONFIG_ADS_DEMUXER 1 +#define CONFIG_ADX_DEMUXER 1 +#define CONFIG_AEA_DEMUXER 1 +#define CONFIG_AFC_DEMUXER 1 +#define CONFIG_AIFF_DEMUXER 1 +#define CONFIG_AIX_DEMUXER 1 +#define CONFIG_AMR_DEMUXER 1 +#define CONFIG_ANM_DEMUXER 1 +#define CONFIG_APC_DEMUXER 1 +#define CONFIG_APE_DEMUXER 1 +#define CONFIG_APNG_DEMUXER 1 +#define CONFIG_AQTITLE_DEMUXER 1 +#define CONFIG_ASF_DEMUXER 1 +#define CONFIG_ASF_O_DEMUXER 1 +#define CONFIG_ASS_DEMUXER 1 +#define CONFIG_AST_DEMUXER 1 +#define CONFIG_AU_DEMUXER 1 +#define CONFIG_AVI_DEMUXER 1 +#define CONFIG_AVISYNTH_DEMUXER 0 +#define CONFIG_AVR_DEMUXER 1 +#define CONFIG_AVS_DEMUXER 1 +#define CONFIG_BETHSOFTVID_DEMUXER 1 +#define CONFIG_BFI_DEMUXER 1 +#define CONFIG_BINTEXT_DEMUXER 1 +#define CONFIG_BINK_DEMUXER 1 +#define CONFIG_BIT_DEMUXER 1 +#define CONFIG_BMV_DEMUXER 1 +#define CONFIG_BFSTM_DEMUXER 1 +#define CONFIG_BRSTM_DEMUXER 1 +#define CONFIG_BOA_DEMUXER 1 +#define CONFIG_C93_DEMUXER 1 +#define CONFIG_CAF_DEMUXER 1 +#define CONFIG_CAVSVIDEO_DEMUXER 1 +#define CONFIG_CDG_DEMUXER 1 +#define CONFIG_CDXL_DEMUXER 1 +#define CONFIG_CINE_DEMUXER 1 +#define CONFIG_CONCAT_DEMUXER 1 +#define CONFIG_DATA_DEMUXER 1 +#define CONFIG_DAUD_DEMUXER 1 +#define CONFIG_DCSTR_DEMUXER 1 +#define CONFIG_DFA_DEMUXER 1 +#define CONFIG_DIRAC_DEMUXER 1 +#define CONFIG_DNXHD_DEMUXER 1 +#define CONFIG_DSF_DEMUXER 1 +#define CONFIG_DSICIN_DEMUXER 1 +#define CONFIG_DSS_DEMUXER 1 +#define CONFIG_DTS_DEMUXER 1 +#define CONFIG_DTSHD_DEMUXER 1 +#define CONFIG_DV_DEMUXER 1 +#define CONFIG_DVBSUB_DEMUXER 1 +#define CONFIG_DVBTXT_DEMUXER 1 +#define CONFIG_DXA_DEMUXER 1 +#define CONFIG_EA_DEMUXER 1 +#define CONFIG_EA_CDATA_DEMUXER 1 +#define CONFIG_EAC3_DEMUXER 1 +#define CONFIG_EPAF_DEMUXER 1 +#define CONFIG_FFM_DEMUXER 1 +#define CONFIG_FFMETADATA_DEMUXER 1 +#define CONFIG_FILMSTRIP_DEMUXER 1 +#define CONFIG_FLAC_DEMUXER 1 +#define CONFIG_FLIC_DEMUXER 1 +#define CONFIG_FLV_DEMUXER 1 +#define CONFIG_LIVE_FLV_DEMUXER 1 +#define CONFIG_FOURXM_DEMUXER 1 +#define CONFIG_FRM_DEMUXER 1 +#define CONFIG_FSB_DEMUXER 1 +#define CONFIG_G722_DEMUXER 1 +#define CONFIG_G723_1_DEMUXER 1 +#define CONFIG_G729_DEMUXER 1 +#define CONFIG_GENH_DEMUXER 1 +#define CONFIG_GIF_DEMUXER 1 +#define CONFIG_GSM_DEMUXER 1 +#define CONFIG_GXF_DEMUXER 1 +#define CONFIG_H261_DEMUXER 1 +#define CONFIG_H263_DEMUXER 1 +#define CONFIG_H264_DEMUXER 1 +#define CONFIG_HEVC_DEMUXER 1 +#define CONFIG_HLS_DEMUXER 1 +#define CONFIG_HNM_DEMUXER 1 +#define CONFIG_ICO_DEMUXER 1 +#define CONFIG_IDCIN_DEMUXER 1 +#define CONFIG_IDF_DEMUXER 1 +#define CONFIG_IFF_DEMUXER 1 +#define CONFIG_ILBC_DEMUXER 1 +#define CONFIG_IMAGE2_DEMUXER 1 +#define CONFIG_IMAGE2PIPE_DEMUXER 1 +#define CONFIG_IMAGE2_ALIAS_PIX_DEMUXER 1 +#define CONFIG_IMAGE2_BRENDER_PIX_DEMUXER 1 +#define CONFIG_INGENIENT_DEMUXER 1 +#define CONFIG_IPMOVIE_DEMUXER 1 +#define CONFIG_IRCAM_DEMUXER 1 +#define CONFIG_ISS_DEMUXER 1 +#define CONFIG_IV8_DEMUXER 1 +#define CONFIG_IVF_DEMUXER 1 +#define CONFIG_IVR_DEMUXER 1 +#define CONFIG_JACOSUB_DEMUXER 1 +#define CONFIG_JV_DEMUXER 1 +#define CONFIG_LMLM4_DEMUXER 1 +#define CONFIG_LOAS_DEMUXER 1 +#define CONFIG_LRC_DEMUXER 1 +#define CONFIG_LVF_DEMUXER 1 +#define CONFIG_LXF_DEMUXER 1 +#define CONFIG_M4V_DEMUXER 1 +#define CONFIG_MATROSKA_DEMUXER 1 +#define CONFIG_MGSTS_DEMUXER 1 +#define CONFIG_MICRODVD_DEMUXER 1 +#define CONFIG_MJPEG_DEMUXER 1 +#define CONFIG_MLP_DEMUXER 1 +#define CONFIG_MLV_DEMUXER 1 +#define CONFIG_MM_DEMUXER 1 +#define CONFIG_MMF_DEMUXER 1 +#define CONFIG_MOV_DEMUXER 1 +#define CONFIG_MP3_DEMUXER 1 +#define CONFIG_MPC_DEMUXER 1 +#define CONFIG_MPC8_DEMUXER 1 +#define CONFIG_MPEGPS_DEMUXER 1 +#define CONFIG_MPEGTS_DEMUXER 1 +#define CONFIG_MPEGTSRAW_DEMUXER 1 +#define CONFIG_MPEGVIDEO_DEMUXER 1 +#define CONFIG_MPJPEG_DEMUXER 1 +#define CONFIG_MPL2_DEMUXER 1 +#define CONFIG_MPSUB_DEMUXER 1 +#define CONFIG_MSF_DEMUXER 1 +#define CONFIG_MSNWC_TCP_DEMUXER 1 +#define CONFIG_MTAF_DEMUXER 1 +#define CONFIG_MTV_DEMUXER 1 +#define CONFIG_MUSX_DEMUXER 1 +#define CONFIG_MV_DEMUXER 1 +#define CONFIG_MVI_DEMUXER 1 +#define CONFIG_MXF_DEMUXER 1 +#define CONFIG_MXG_DEMUXER 1 +#define CONFIG_NC_DEMUXER 1 +#define CONFIG_NISTSPHERE_DEMUXER 1 +#define CONFIG_NSV_DEMUXER 1 +#define CONFIG_NUT_DEMUXER 1 +#define CONFIG_NUV_DEMUXER 1 +#define CONFIG_OGG_DEMUXER 1 +#define CONFIG_OMA_DEMUXER 1 +#define CONFIG_PAF_DEMUXER 1 +#define CONFIG_PCM_ALAW_DEMUXER 1 +#define CONFIG_PCM_MULAW_DEMUXER 1 +#define CONFIG_PCM_F64BE_DEMUXER 1 +#define CONFIG_PCM_F64LE_DEMUXER 1 +#define CONFIG_PCM_F32BE_DEMUXER 1 +#define CONFIG_PCM_F32LE_DEMUXER 1 +#define CONFIG_PCM_S32BE_DEMUXER 1 +#define CONFIG_PCM_S32LE_DEMUXER 1 +#define CONFIG_PCM_S24BE_DEMUXER 1 +#define CONFIG_PCM_S24LE_DEMUXER 1 +#define CONFIG_PCM_S16BE_DEMUXER 1 +#define CONFIG_PCM_S16LE_DEMUXER 1 +#define CONFIG_PCM_S8_DEMUXER 1 +#define CONFIG_PCM_U32BE_DEMUXER 1 +#define CONFIG_PCM_U32LE_DEMUXER 1 +#define CONFIG_PCM_U24BE_DEMUXER 1 +#define CONFIG_PCM_U24LE_DEMUXER 1 +#define CONFIG_PCM_U16BE_DEMUXER 1 +#define CONFIG_PCM_U16LE_DEMUXER 1 +#define CONFIG_PCM_U8_DEMUXER 1 +#define CONFIG_PJS_DEMUXER 1 +#define CONFIG_PMP_DEMUXER 1 +#define CONFIG_PVA_DEMUXER 1 +#define CONFIG_PVF_DEMUXER 1 +#define CONFIG_QCP_DEMUXER 1 +#define CONFIG_R3D_DEMUXER 1 +#define CONFIG_RAWVIDEO_DEMUXER 1 +#define CONFIG_REALTEXT_DEMUXER 1 +#define CONFIG_REDSPARK_DEMUXER 1 +#define CONFIG_RL2_DEMUXER 1 +#define CONFIG_RM_DEMUXER 1 +#define CONFIG_ROQ_DEMUXER 1 +#define CONFIG_RPL_DEMUXER 1 +#define CONFIG_RSD_DEMUXER 1 +#define CONFIG_RSO_DEMUXER 1 +#define CONFIG_RTP_DEMUXER 1 +#define CONFIG_RTSP_DEMUXER 1 +#define CONFIG_SAMI_DEMUXER 1 +#define CONFIG_SAP_DEMUXER 1 +#define CONFIG_SBG_DEMUXER 1 +#define CONFIG_SDP_DEMUXER 1 +#define CONFIG_SDR2_DEMUXER 1 +#define CONFIG_SEGAFILM_DEMUXER 1 +#define CONFIG_SHORTEN_DEMUXER 1 +#define CONFIG_SIFF_DEMUXER 1 +#define CONFIG_SLN_DEMUXER 1 +#define CONFIG_SMACKER_DEMUXER 1 +#define CONFIG_SMJPEG_DEMUXER 1 +#define CONFIG_SMUSH_DEMUXER 1 +#define CONFIG_SOL_DEMUXER 1 +#define CONFIG_SOX_DEMUXER 1 +#define CONFIG_SPDIF_DEMUXER 1 +#define CONFIG_SRT_DEMUXER 1 +#define CONFIG_STR_DEMUXER 1 +#define CONFIG_STL_DEMUXER 1 +#define CONFIG_SUBVIEWER1_DEMUXER 1 +#define CONFIG_SUBVIEWER_DEMUXER 1 +#define CONFIG_SUP_DEMUXER 1 +#define CONFIG_SVAG_DEMUXER 1 +#define CONFIG_SWF_DEMUXER 1 +#define CONFIG_TAK_DEMUXER 1 +#define CONFIG_TEDCAPTIONS_DEMUXER 1 +#define CONFIG_THP_DEMUXER 1 +#define CONFIG_THREEDOSTR_DEMUXER 1 +#define CONFIG_TIERTEXSEQ_DEMUXER 1 +#define CONFIG_TMV_DEMUXER 1 +#define CONFIG_TRUEHD_DEMUXER 1 +#define CONFIG_TTA_DEMUXER 1 +#define CONFIG_TXD_DEMUXER 1 +#define CONFIG_TTY_DEMUXER 1 +#define CONFIG_V210_DEMUXER 1 +#define CONFIG_V210X_DEMUXER 1 +#define CONFIG_VAG_DEMUXER 1 +#define CONFIG_VC1_DEMUXER 1 +#define CONFIG_VC1T_DEMUXER 1 +#define CONFIG_VIVO_DEMUXER 1 +#define CONFIG_VMD_DEMUXER 1 +#define CONFIG_VOBSUB_DEMUXER 1 +#define CONFIG_VOC_DEMUXER 1 +#define CONFIG_VPK_DEMUXER 1 +#define CONFIG_VPLAYER_DEMUXER 1 +#define CONFIG_VQF_DEMUXER 1 +#define CONFIG_W64_DEMUXER 1 +#define CONFIG_WAV_DEMUXER 1 +#define CONFIG_WC3_DEMUXER 1 +#define CONFIG_WEBM_DASH_MANIFEST_DEMUXER 1 +#define CONFIG_WEBVTT_DEMUXER 1 +#define CONFIG_WSAUD_DEMUXER 1 +#define CONFIG_WSD_DEMUXER 1 +#define CONFIG_WSVQA_DEMUXER 1 +#define CONFIG_WTV_DEMUXER 1 +#define CONFIG_WVE_DEMUXER 1 +#define CONFIG_WV_DEMUXER 1 +#define CONFIG_XA_DEMUXER 1 +#define CONFIG_XBIN_DEMUXER 1 +#define CONFIG_XMV_DEMUXER 1 +#define CONFIG_XVAG_DEMUXER 1 +#define CONFIG_XWMA_DEMUXER 1 +#define CONFIG_YOP_DEMUXER 1 +#define CONFIG_YUV4MPEGPIPE_DEMUXER 1 +#define CONFIG_IMAGE_BMP_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_DDS_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_DPX_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_EXR_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_J2K_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_JPEG_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_JPEGLS_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PAM_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PBM_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PCX_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PGMYUV_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PGM_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PICTOR_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PNG_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_PPM_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_QDRAW_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_SGI_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_SUNRAST_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_TIFF_PIPE_DEMUXER 1 +#define CONFIG_IMAGE_WEBP_PIPE_DEMUXER 1 +#define CONFIG_LIBGME_DEMUXER 0 +#define CONFIG_LIBMODPLUG_DEMUXER 0 +#define CONFIG_LIBNUT_DEMUXER 0 +#define CONFIG_LIBOPENMPT_DEMUXER 0 +#define CONFIG_A64MULTI_ENCODER 1 +#define CONFIG_A64MULTI5_ENCODER 1 +#define CONFIG_ALIAS_PIX_ENCODER 1 +#define CONFIG_AMV_ENCODER 1 +#define CONFIG_APNG_ENCODER 1 +#define CONFIG_ASV1_ENCODER 1 +#define CONFIG_ASV2_ENCODER 1 +#define CONFIG_AVRP_ENCODER 1 +#define CONFIG_AVUI_ENCODER 1 +#define CONFIG_AYUV_ENCODER 1 +#define CONFIG_BMP_ENCODER 1 +#define CONFIG_CINEPAK_ENCODER 1 +#define CONFIG_CLJR_ENCODER 1 +#define CONFIG_COMFORTNOISE_ENCODER 1 +#define CONFIG_DNXHD_ENCODER 1 +#define CONFIG_DPX_ENCODER 1 +#define CONFIG_DVVIDEO_ENCODER 1 +#define CONFIG_FFV1_ENCODER 1 +#define CONFIG_FFVHUFF_ENCODER 1 +#define CONFIG_FLASHSV_ENCODER 1 +#define CONFIG_FLASHSV2_ENCODER 1 +#define CONFIG_FLV_ENCODER 1 +#define CONFIG_GIF_ENCODER 1 +#define CONFIG_H261_ENCODER 1 +#define CONFIG_H263_ENCODER 1 +#define CONFIG_H263P_ENCODER 1 +#define CONFIG_HAP_ENCODER 0 +#define CONFIG_HUFFYUV_ENCODER 1 +#define CONFIG_JPEG2000_ENCODER 1 +#define CONFIG_JPEGLS_ENCODER 1 +#define CONFIG_LJPEG_ENCODER 1 +#define CONFIG_MJPEG_ENCODER 1 +#define CONFIG_MPEG1VIDEO_ENCODER 1 +#define CONFIG_MPEG2VIDEO_ENCODER 1 +#define CONFIG_MPEG4_ENCODER 1 +#define CONFIG_MSMPEG4V2_ENCODER 1 +#define CONFIG_MSMPEG4V3_ENCODER 1 +#define CONFIG_MSVIDEO1_ENCODER 1 +#define CONFIG_PAM_ENCODER 1 +#define CONFIG_PBM_ENCODER 1 +#define CONFIG_PCX_ENCODER 1 +#define CONFIG_PGM_ENCODER 1 +#define CONFIG_PGMYUV_ENCODER 1 +#define CONFIG_PNG_ENCODER 1 +#define CONFIG_PPM_ENCODER 1 +#define CONFIG_PRORES_ENCODER 1 +#define CONFIG_PRORES_AW_ENCODER 1 +#define CONFIG_PRORES_KS_ENCODER 1 +#define CONFIG_QTRLE_ENCODER 1 +#define CONFIG_R10K_ENCODER 1 +#define CONFIG_R210_ENCODER 1 +#define CONFIG_RAWVIDEO_ENCODER 1 +#define CONFIG_ROQ_ENCODER 1 +#define CONFIG_RV10_ENCODER 1 +#define CONFIG_RV20_ENCODER 1 +#define CONFIG_S302M_ENCODER 1 +#define CONFIG_SGI_ENCODER 1 +#define CONFIG_SNOW_ENCODER 1 +#define CONFIG_SUNRAST_ENCODER 1 +#define CONFIG_SVQ1_ENCODER 1 +#define CONFIG_TARGA_ENCODER 1 +#define CONFIG_TIFF_ENCODER 1 +#define CONFIG_UTVIDEO_ENCODER 1 +#define CONFIG_V210_ENCODER 1 +#define CONFIG_V308_ENCODER 1 +#define CONFIG_V408_ENCODER 1 +#define CONFIG_V410_ENCODER 1 +#define CONFIG_VC2_ENCODER 1 +#define CONFIG_WRAPPED_AVFRAME_ENCODER 1 +#define CONFIG_WMV1_ENCODER 1 +#define CONFIG_WMV2_ENCODER 1 +#define CONFIG_XBM_ENCODER 1 +#define CONFIG_XFACE_ENCODER 1 +#define CONFIG_XWD_ENCODER 1 +#define CONFIG_Y41P_ENCODER 1 +#define CONFIG_YUV4_ENCODER 1 +#define CONFIG_ZLIB_ENCODER 1 +#define CONFIG_ZMBV_ENCODER 1 +#define CONFIG_AAC_ENCODER 1 +#define CONFIG_AC3_ENCODER 1 +#define CONFIG_AC3_FIXED_ENCODER 1 +#define CONFIG_ALAC_ENCODER 1 +#define CONFIG_DCA_ENCODER 1 +#define CONFIG_EAC3_ENCODER 1 +#define CONFIG_FLAC_ENCODER 1 +#define CONFIG_G723_1_ENCODER 1 +#define CONFIG_MLP_ENCODER 1 +#define CONFIG_MP2_ENCODER 1 +#define CONFIG_MP2FIXED_ENCODER 1 +#define CONFIG_NELLYMOSER_ENCODER 1 +#define CONFIG_RA_144_ENCODER 1 +#define CONFIG_SONIC_ENCODER 1 +#define CONFIG_SONIC_LS_ENCODER 1 +#define CONFIG_TRUEHD_ENCODER 1 +#define CONFIG_TTA_ENCODER 1 +#define CONFIG_VORBIS_ENCODER 1 +#define CONFIG_WAVPACK_ENCODER 1 +#define CONFIG_WMAV1_ENCODER 1 +#define CONFIG_WMAV2_ENCODER 1 +#define CONFIG_PCM_ALAW_ENCODER 1 +#define CONFIG_PCM_F32BE_ENCODER 1 +#define CONFIG_PCM_F32LE_ENCODER 1 +#define CONFIG_PCM_F64BE_ENCODER 1 +#define CONFIG_PCM_F64LE_ENCODER 1 +#define CONFIG_PCM_MULAW_ENCODER 1 +#define CONFIG_PCM_S8_ENCODER 1 +#define CONFIG_PCM_S8_PLANAR_ENCODER 1 +#define CONFIG_PCM_S16BE_ENCODER 1 +#define CONFIG_PCM_S16BE_PLANAR_ENCODER 1 +#define CONFIG_PCM_S16LE_ENCODER 1 +#define CONFIG_PCM_S16LE_PLANAR_ENCODER 1 +#define CONFIG_PCM_S24BE_ENCODER 1 +#define CONFIG_PCM_S24DAUD_ENCODER 1 +#define CONFIG_PCM_S24LE_ENCODER 1 +#define CONFIG_PCM_S24LE_PLANAR_ENCODER 1 +#define CONFIG_PCM_S32BE_ENCODER 1 +#define CONFIG_PCM_S32LE_ENCODER 1 +#define CONFIG_PCM_S32LE_PLANAR_ENCODER 1 +#define CONFIG_PCM_S64BE_ENCODER 1 +#define CONFIG_PCM_S64LE_ENCODER 1 +#define CONFIG_PCM_U8_ENCODER 1 +#define CONFIG_PCM_U16BE_ENCODER 1 +#define CONFIG_PCM_U16LE_ENCODER 1 +#define CONFIG_PCM_U24BE_ENCODER 1 +#define CONFIG_PCM_U24LE_ENCODER 1 +#define CONFIG_PCM_U32BE_ENCODER 1 +#define CONFIG_PCM_U32LE_ENCODER 1 +#define CONFIG_ROQ_DPCM_ENCODER 1 +#define CONFIG_ADPCM_ADX_ENCODER 1 +#define CONFIG_ADPCM_G722_ENCODER 1 +#define CONFIG_ADPCM_G726_ENCODER 1 +#define CONFIG_ADPCM_IMA_QT_ENCODER 1 +#define CONFIG_ADPCM_IMA_WAV_ENCODER 1 +#define CONFIG_ADPCM_MS_ENCODER 1 +#define CONFIG_ADPCM_SWF_ENCODER 1 +#define CONFIG_ADPCM_YAMAHA_ENCODER 1 +#define CONFIG_SSA_ENCODER 1 +#define CONFIG_ASS_ENCODER 1 +#define CONFIG_DVBSUB_ENCODER 1 +#define CONFIG_DVDSUB_ENCODER 1 +#define CONFIG_MOVTEXT_ENCODER 1 +#define CONFIG_SRT_ENCODER 1 +#define CONFIG_SUBRIP_ENCODER 1 +#define CONFIG_TEXT_ENCODER 1 +#define CONFIG_WEBVTT_ENCODER 1 +#define CONFIG_XSUB_ENCODER 1 +#define CONFIG_AAC_AT_ENCODER 0 +#define CONFIG_ALAC_AT_ENCODER 0 +#define CONFIG_ILBC_AT_ENCODER 0 +#define CONFIG_PCM_ALAW_AT_ENCODER 0 +#define CONFIG_PCM_MULAW_AT_ENCODER 0 +#define CONFIG_LIBFDK_AAC_ENCODER 0 +#define CONFIG_LIBGSM_ENCODER 0 +#define CONFIG_LIBGSM_MS_ENCODER 0 +#define CONFIG_LIBILBC_ENCODER 0 +#define CONFIG_LIBMP3LAME_ENCODER 0 +#define CONFIG_LIBOPENCORE_AMRNB_ENCODER 0 +#define CONFIG_LIBOPENJPEG_ENCODER 0 +#define CONFIG_LIBOPUS_ENCODER 0 +#define CONFIG_LIBSCHROEDINGER_ENCODER 0 +#define CONFIG_LIBSHINE_ENCODER 0 +#define CONFIG_LIBSPEEX_ENCODER 0 +#define CONFIG_LIBTHEORA_ENCODER 0 +#define CONFIG_LIBTWOLAME_ENCODER 0 +#define CONFIG_LIBVO_AMRWBENC_ENCODER 0 +#define CONFIG_LIBVORBIS_ENCODER 0 +#define CONFIG_LIBVPX_VP8_ENCODER 0 +#define CONFIG_LIBVPX_VP9_ENCODER 0 +#define CONFIG_LIBWAVPACK_ENCODER 0 +#define CONFIG_LIBWEBP_ANIM_ENCODER 0 +#define CONFIG_LIBWEBP_ENCODER 0 +#define CONFIG_LIBX262_ENCODER 0 +#define CONFIG_LIBX264_ENCODER 0 +#define CONFIG_LIBX264RGB_ENCODER 0 +#define CONFIG_LIBX265_ENCODER 0 +#define CONFIG_LIBXAVS_ENCODER 0 +#define CONFIG_LIBXVID_ENCODER 0 +#define CONFIG_LIBOPENH264_ENCODER 0 +#define CONFIG_H264_NVENC_ENCODER 0 +#define CONFIG_H264_OMX_ENCODER 0 +#define CONFIG_H264_QSV_ENCODER 0 +#define CONFIG_H264_VAAPI_ENCODER 0 +#define CONFIG_H264_VIDEOTOOLBOX_ENCODER 0 +#define CONFIG_NVENC_ENCODER 0 +#define CONFIG_NVENC_H264_ENCODER 0 +#define CONFIG_NVENC_HEVC_ENCODER 0 +#define CONFIG_HEVC_NVENC_ENCODER 0 +#define CONFIG_HEVC_QSV_ENCODER 0 +#define CONFIG_HEVC_VAAPI_ENCODER 0 +#define CONFIG_LIBKVAZAAR_ENCODER 0 +#define CONFIG_MJPEG_VAAPI_ENCODER 0 +#define CONFIG_MPEG2_QSV_ENCODER 0 +#define CONFIG_ABENCH_FILTER 1 +#define CONFIG_ACOMPRESSOR_FILTER 1 +#define CONFIG_ACROSSFADE_FILTER 1 +#define CONFIG_ACRUSHER_FILTER 1 +#define CONFIG_ADELAY_FILTER 1 +#define CONFIG_AECHO_FILTER 1 +#define CONFIG_AEMPHASIS_FILTER 1 +#define CONFIG_AEVAL_FILTER 1 +#define CONFIG_AFADE_FILTER 1 +#define CONFIG_AFFTFILT_FILTER 1 +#define CONFIG_AFORMAT_FILTER 1 +#define CONFIG_AGATE_FILTER 1 +#define CONFIG_AINTERLEAVE_FILTER 1 +#define CONFIG_ALIMITER_FILTER 1 +#define CONFIG_ALLPASS_FILTER 1 +#define CONFIG_ALOOP_FILTER 1 +#define CONFIG_AMERGE_FILTER 1 +#define CONFIG_AMETADATA_FILTER 1 +#define CONFIG_AMIX_FILTER 1 +#define CONFIG_ANEQUALIZER_FILTER 1 +#define CONFIG_ANULL_FILTER 1 +#define CONFIG_APAD_FILTER 1 +#define CONFIG_APERMS_FILTER 1 +#define CONFIG_APHASER_FILTER 1 +#define CONFIG_APULSATOR_FILTER 1 +#define CONFIG_AREALTIME_FILTER 1 +#define CONFIG_ARESAMPLE_FILTER 1 +#define CONFIG_AREVERSE_FILTER 1 +#define CONFIG_ASELECT_FILTER 1 +#define CONFIG_ASENDCMD_FILTER 1 +#define CONFIG_ASETNSAMPLES_FILTER 1 +#define CONFIG_ASETPTS_FILTER 1 +#define CONFIG_ASETRATE_FILTER 1 +#define CONFIG_ASETTB_FILTER 1 +#define CONFIG_ASHOWINFO_FILTER 1 +#define CONFIG_ASIDEDATA_FILTER 1 +#define CONFIG_ASPLIT_FILTER 1 +#define CONFIG_ASTATS_FILTER 1 +#define CONFIG_ASTREAMSELECT_FILTER 1 +#define CONFIG_ASYNCTS_FILTER 0 +#define CONFIG_ATEMPO_FILTER 1 +#define CONFIG_ATRIM_FILTER 1 +#define CONFIG_AZMQ_FILTER 0 +#define CONFIG_BANDPASS_FILTER 1 +#define CONFIG_BANDREJECT_FILTER 1 +#define CONFIG_BASS_FILTER 1 +#define CONFIG_BIQUAD_FILTER 1 +#define CONFIG_BS2B_FILTER 0 +#define CONFIG_CHANNELMAP_FILTER 1 +#define CONFIG_CHANNELSPLIT_FILTER 1 +#define CONFIG_CHORUS_FILTER 1 +#define CONFIG_COMPAND_FILTER 1 +#define CONFIG_COMPENSATIONDELAY_FILTER 1 +#define CONFIG_CRYSTALIZER_FILTER 1 +#define CONFIG_DCSHIFT_FILTER 1 +#define CONFIG_DYNAUDNORM_FILTER 1 +#define CONFIG_EARWAX_FILTER 1 +#define CONFIG_EBUR128_FILTER 0 +#define CONFIG_EQUALIZER_FILTER 1 +#define CONFIG_EXTRASTEREO_FILTER 1 +#define CONFIG_FIREQUALIZER_FILTER 1 +#define CONFIG_FLANGER_FILTER 1 +#define CONFIG_HDCD_FILTER 1 +#define CONFIG_HIGHPASS_FILTER 1 +#define CONFIG_JOIN_FILTER 1 +#define CONFIG_LADSPA_FILTER 0 +#define CONFIG_LOUDNORM_FILTER 0 +#define CONFIG_LOWPASS_FILTER 1 +#define CONFIG_PAN_FILTER 1 +#define CONFIG_REPLAYGAIN_FILTER 1 +#define CONFIG_RESAMPLE_FILTER 0 +#define CONFIG_RUBBERBAND_FILTER 0 +#define CONFIG_SIDECHAINCOMPRESS_FILTER 1 +#define CONFIG_SIDECHAINGATE_FILTER 1 +#define CONFIG_SILENCEDETECT_FILTER 1 +#define CONFIG_SILENCEREMOVE_FILTER 1 +#define CONFIG_SOFALIZER_FILTER 0 +#define CONFIG_STEREOTOOLS_FILTER 1 +#define CONFIG_STEREOWIDEN_FILTER 1 +#define CONFIG_TREBLE_FILTER 1 +#define CONFIG_TREMOLO_FILTER 1 +#define CONFIG_VIBRATO_FILTER 1 +#define CONFIG_VOLUME_FILTER 1 +#define CONFIG_VOLUMEDETECT_FILTER 1 +#define CONFIG_AEVALSRC_FILTER 1 +#define CONFIG_ANOISESRC_FILTER 1 +#define CONFIG_ANULLSRC_FILTER 1 +#define CONFIG_FLITE_FILTER 0 +#define CONFIG_SINE_FILTER 1 +#define CONFIG_ANULLSINK_FILTER 1 +#define CONFIG_ALPHAEXTRACT_FILTER 1 +#define CONFIG_ALPHAMERGE_FILTER 1 +#define CONFIG_ASS_FILTER 0 +#define CONFIG_ATADENOISE_FILTER 1 +#define CONFIG_AVGBLUR_FILTER 1 +#define CONFIG_BBOX_FILTER 1 +#define CONFIG_BENCH_FILTER 1 +#define CONFIG_BITPLANENOISE_FILTER 1 +#define CONFIG_BLACKDETECT_FILTER 1 +#define CONFIG_BLACKFRAME_FILTER 0 +#define CONFIG_BLEND_FILTER 1 +#define CONFIG_BOXBLUR_FILTER 0 +#define CONFIG_BWDIF_FILTER 1 +#define CONFIG_CHROMAKEY_FILTER 1 +#define CONFIG_CIESCOPE_FILTER 1 +#define CONFIG_CODECVIEW_FILTER 1 +#define CONFIG_COLORBALANCE_FILTER 1 +#define CONFIG_COLORCHANNELMIXER_FILTER 1 +#define CONFIG_COLORKEY_FILTER 1 +#define CONFIG_COLORLEVELS_FILTER 1 +#define CONFIG_COLORMATRIX_FILTER 0 +#define CONFIG_COLORSPACE_FILTER 1 +#define CONFIG_CONVOLUTION_FILTER 1 +#define CONFIG_COPY_FILTER 1 +#define CONFIG_COREIMAGE_FILTER 0 +#define CONFIG_COVER_RECT_FILTER 0 +#define CONFIG_CROP_FILTER 1 +#define CONFIG_CROPDETECT_FILTER 0 +#define CONFIG_CURVES_FILTER 1 +#define CONFIG_DATASCOPE_FILTER 1 +#define CONFIG_DCTDNOIZ_FILTER 1 +#define CONFIG_DEBAND_FILTER 1 +#define CONFIG_DECIMATE_FILTER 1 +#define CONFIG_DEFLATE_FILTER 1 +#define CONFIG_DEJUDDER_FILTER 1 +#define CONFIG_DELOGO_FILTER 0 +#define CONFIG_DESHAKE_FILTER 1 +#define CONFIG_DETELECINE_FILTER 1 +#define CONFIG_DILATION_FILTER 1 +#define CONFIG_DISPLACE_FILTER 1 +#define CONFIG_DRAWBOX_FILTER 1 +#define CONFIG_DRAWGRAPH_FILTER 1 +#define CONFIG_DRAWGRID_FILTER 1 +#define CONFIG_DRAWTEXT_FILTER 0 +#define CONFIG_EDGEDETECT_FILTER 1 +#define CONFIG_ELBG_FILTER 1 +#define CONFIG_EQ_FILTER 0 +#define CONFIG_EROSION_FILTER 1 +#define CONFIG_EXTRACTPLANES_FILTER 1 +#define CONFIG_FADE_FILTER 1 +#define CONFIG_FFTFILT_FILTER 1 +#define CONFIG_FIELD_FILTER 1 +#define CONFIG_FIELDHINT_FILTER 1 +#define CONFIG_FIELDMATCH_FILTER 1 +#define CONFIG_FIELDORDER_FILTER 1 +#define CONFIG_FIND_RECT_FILTER 0 +#define CONFIG_FORMAT_FILTER 1 +#define CONFIG_FPS_FILTER 1 +#define CONFIG_FRAMEPACK_FILTER 1 +#define CONFIG_FRAMERATE_FILTER 1 +#define CONFIG_FRAMESTEP_FILTER 1 +#define CONFIG_FREI0R_FILTER 0 +#define CONFIG_FSPP_FILTER 0 +#define CONFIG_GBLUR_FILTER 1 +#define CONFIG_GEQ_FILTER 0 +#define CONFIG_GRADFUN_FILTER 1 +#define CONFIG_HALDCLUT_FILTER 1 +#define CONFIG_HFLIP_FILTER 1 +#define CONFIG_HISTEQ_FILTER 0 +#define CONFIG_HISTOGRAM_FILTER 1 +#define CONFIG_HQDN3D_FILTER 0 +#define CONFIG_HQX_FILTER 1 +#define CONFIG_HSTACK_FILTER 1 +#define CONFIG_HUE_FILTER 1 +#define CONFIG_HWDOWNLOAD_FILTER 1 +#define CONFIG_HWUPLOAD_FILTER 1 +#define CONFIG_HWUPLOAD_CUDA_FILTER 0 +#define CONFIG_HYSTERESIS_FILTER 1 +#define CONFIG_IDET_FILTER 1 +#define CONFIG_IL_FILTER 1 +#define CONFIG_INFLATE_FILTER 1 +#define CONFIG_INTERLACE_FILTER 0 +#define CONFIG_INTERLEAVE_FILTER 1 +#define CONFIG_KERNDEINT_FILTER 0 +#define CONFIG_LENSCORRECTION_FILTER 1 +#define CONFIG_LOOP_FILTER 1 +#define CONFIG_LUT_FILTER 1 +#define CONFIG_LUT2_FILTER 1 +#define CONFIG_LUT3D_FILTER 1 +#define CONFIG_LUTRGB_FILTER 1 +#define CONFIG_LUTYUV_FILTER 1 +#define CONFIG_MASKEDCLAMP_FILTER 1 +#define CONFIG_MASKEDMERGE_FILTER 1 +#define CONFIG_MCDEINT_FILTER 0 +#define CONFIG_MERGEPLANES_FILTER 1 +#define CONFIG_MESTIMATE_FILTER 1 +#define CONFIG_METADATA_FILTER 1 +#define CONFIG_MINTERPOLATE_FILTER 1 +#define CONFIG_MPDECIMATE_FILTER 0 +#define CONFIG_NEGATE_FILTER 1 +#define CONFIG_NLMEANS_FILTER 1 +#define CONFIG_NNEDI_FILTER 0 +#define CONFIG_NOFORMAT_FILTER 1 +#define CONFIG_NOISE_FILTER 1 +#define CONFIG_NULL_FILTER 1 +#define CONFIG_OCR_FILTER 0 +#define CONFIG_OCV_FILTER 0 +#define CONFIG_OVERLAY_FILTER 1 +#define CONFIG_OWDENOISE_FILTER 0 +#define CONFIG_PAD_FILTER 1 +#define CONFIG_PALETTEGEN_FILTER 1 +#define CONFIG_PALETTEUSE_FILTER 1 +#define CONFIG_PERMS_FILTER 1 +#define CONFIG_PERSPECTIVE_FILTER 0 +#define CONFIG_PHASE_FILTER 0 +#define CONFIG_PIXDESCTEST_FILTER 1 +#define CONFIG_PP_FILTER 0 +#define CONFIG_PP7_FILTER 0 +#define CONFIG_PREWITT_FILTER 1 +#define CONFIG_PSNR_FILTER 1 +#define CONFIG_PULLUP_FILTER 0 +#define CONFIG_QP_FILTER 1 +#define CONFIG_RANDOM_FILTER 1 +#define CONFIG_READVITC_FILTER 1 +#define CONFIG_REALTIME_FILTER 1 +#define CONFIG_REMAP_FILTER 1 +#define CONFIG_REMOVEGRAIN_FILTER 1 +#define CONFIG_REMOVELOGO_FILTER 1 +#define CONFIG_REPEATFIELDS_FILTER 0 +#define CONFIG_REVERSE_FILTER 1 +#define CONFIG_ROTATE_FILTER 1 +#define CONFIG_SAB_FILTER 0 +#define CONFIG_SCALE_FILTER 1 +#define CONFIG_SCALE_NPP_FILTER 0 +#define CONFIG_SCALE_VAAPI_FILTER 0 +#define CONFIG_SCALE2REF_FILTER 1 +#define CONFIG_SELECT_FILTER 1 +#define CONFIG_SELECTIVECOLOR_FILTER 1 +#define CONFIG_SENDCMD_FILTER 1 +#define CONFIG_SEPARATEFIELDS_FILTER 1 +#define CONFIG_SETDAR_FILTER 1 +#define CONFIG_SETFIELD_FILTER 1 +#define CONFIG_SETPTS_FILTER 1 +#define CONFIG_SETSAR_FILTER 1 +#define CONFIG_SETTB_FILTER 1 +#define CONFIG_SHOWINFO_FILTER 1 +#define CONFIG_SHOWPALETTE_FILTER 1 +#define CONFIG_SHUFFLEFRAMES_FILTER 1 +#define CONFIG_SHUFFLEPLANES_FILTER 1 +#define CONFIG_SIDEDATA_FILTER 1 +#define CONFIG_SIGNALSTATS_FILTER 1 +#define CONFIG_SMARTBLUR_FILTER 0 +#define CONFIG_SOBEL_FILTER 1 +#define CONFIG_SPLIT_FILTER 1 +#define CONFIG_SPP_FILTER 0 +#define CONFIG_SSIM_FILTER 1 +#define CONFIG_STEREO3D_FILTER 0 +#define CONFIG_STREAMSELECT_FILTER 1 +#define CONFIG_SUBTITLES_FILTER 0 +#define CONFIG_SUPER2XSAI_FILTER 0 +#define CONFIG_SWAPRECT_FILTER 1 +#define CONFIG_SWAPUV_FILTER 1 +#define CONFIG_TBLEND_FILTER 1 +#define CONFIG_TELECINE_FILTER 1 +#define CONFIG_THUMBNAIL_FILTER 1 +#define CONFIG_TILE_FILTER 1 +#define CONFIG_TINTERLACE_FILTER 0 +#define CONFIG_TRANSPOSE_FILTER 1 +#define CONFIG_TRIM_FILTER 1 +#define CONFIG_UNSHARP_FILTER 1 +#define CONFIG_USPP_FILTER 0 +#define CONFIG_VAGUEDENOISER_FILTER 0 +#define CONFIG_VECTORSCOPE_FILTER 1 +#define CONFIG_VFLIP_FILTER 1 +#define CONFIG_VIDSTABDETECT_FILTER 0 +#define CONFIG_VIDSTABTRANSFORM_FILTER 0 +#define CONFIG_VIGNETTE_FILTER 1 +#define CONFIG_VSTACK_FILTER 1 +#define CONFIG_W3FDIF_FILTER 1 +#define CONFIG_WAVEFORM_FILTER 1 +#define CONFIG_WEAVE_FILTER 1 +#define CONFIG_XBR_FILTER 1 +#define CONFIG_YADIF_FILTER 1 +#define CONFIG_ZMQ_FILTER 0 +#define CONFIG_ZOOMPAN_FILTER 1 +#define CONFIG_ZSCALE_FILTER 0 +#define CONFIG_ALLRGB_FILTER 1 +#define CONFIG_ALLYUV_FILTER 1 +#define CONFIG_CELLAUTO_FILTER 1 +#define CONFIG_COLOR_FILTER 1 +#define CONFIG_COREIMAGESRC_FILTER 0 +#define CONFIG_FREI0R_SRC_FILTER 0 +#define CONFIG_HALDCLUTSRC_FILTER 1 +#define CONFIG_LIFE_FILTER 1 +#define CONFIG_MANDELBROT_FILTER 1 +#define CONFIG_MPTESTSRC_FILTER 0 +#define CONFIG_NULLSRC_FILTER 1 +#define CONFIG_RGBTESTSRC_FILTER 1 +#define CONFIG_SMPTEBARS_FILTER 1 +#define CONFIG_SMPTEHDBARS_FILTER 1 +#define CONFIG_TESTSRC_FILTER 1 +#define CONFIG_TESTSRC2_FILTER 1 +#define CONFIG_YUVTESTSRC_FILTER 1 +#define CONFIG_NULLSINK_FILTER 1 +#define CONFIG_ADRAWGRAPH_FILTER 1 +#define CONFIG_AHISTOGRAM_FILTER 1 +#define CONFIG_APHASEMETER_FILTER 1 +#define CONFIG_AVECTORSCOPE_FILTER 1 +#define CONFIG_CONCAT_FILTER 1 +#define CONFIG_SHOWCQT_FILTER 1 +#define CONFIG_SHOWFREQS_FILTER 1 +#define CONFIG_SHOWSPECTRUM_FILTER 1 +#define CONFIG_SHOWSPECTRUMPIC_FILTER 1 +#define CONFIG_SHOWVOLUME_FILTER 1 +#define CONFIG_SHOWWAVES_FILTER 1 +#define CONFIG_SHOWWAVESPIC_FILTER 1 +#define CONFIG_SPECTRUMSYNTH_FILTER 1 +#define CONFIG_AMOVIE_FILTER 1 +#define CONFIG_MOVIE_FILTER 1 +#define CONFIG_H263_CUVID_HWACCEL 0 +#define CONFIG_H263_VAAPI_HWACCEL 0 +#define CONFIG_H263_VIDEOTOOLBOX_HWACCEL 0 +#define CONFIG_H264_CUVID_HWACCEL 0 +#define CONFIG_H264_D3D11VA_HWACCEL 0 +#define CONFIG_H264_DXVA2_HWACCEL 0 +#define CONFIG_H264_MEDIACODEC_HWACCEL 1 +#define CONFIG_H264_MMAL_HWACCEL 0 +#define CONFIG_H264_QSV_HWACCEL 0 +#define CONFIG_H264_VAAPI_HWACCEL 0 +#define CONFIG_H264_VDA_HWACCEL 0 +#define CONFIG_H264_VDA_OLD_HWACCEL 0 +#define CONFIG_H264_VDPAU_HWACCEL 0 +#define CONFIG_H264_VIDEOTOOLBOX_HWACCEL 0 +#define CONFIG_HEVC_CUVID_HWACCEL 0 +#define CONFIG_HEVC_D3D11VA_HWACCEL 0 +#define CONFIG_HEVC_DXVA2_HWACCEL 0 +#define CONFIG_HEVC_MEDIACODEC_HWACCEL 1 +#define CONFIG_HEVC_QSV_HWACCEL 0 +#define CONFIG_HEVC_VAAPI_HWACCEL 0 +#define CONFIG_HEVC_VDPAU_HWACCEL 0 +#define CONFIG_MJPEG_CUVID_HWACCEL 0 +#define CONFIG_MPEG1_CUVID_HWACCEL 0 +#define CONFIG_MPEG1_XVMC_HWACCEL 0 +#define CONFIG_MPEG1_VDPAU_HWACCEL 0 +#define CONFIG_MPEG1_VIDEOTOOLBOX_HWACCEL 0 +#define CONFIG_MPEG2_CUVID_HWACCEL 0 +#define CONFIG_MPEG2_XVMC_HWACCEL 0 +#define CONFIG_MPEG2_D3D11VA_HWACCEL 0 +#define CONFIG_MPEG2_DXVA2_HWACCEL 0 +#define CONFIG_MPEG2_MMAL_HWACCEL 0 +#define CONFIG_MPEG2_QSV_HWACCEL 0 +#define CONFIG_MPEG2_VAAPI_HWACCEL 0 +#define CONFIG_MPEG2_VDPAU_HWACCEL 0 +#define CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL 0 +#define CONFIG_MPEG4_CUVID_HWACCEL 0 +#define CONFIG_MPEG4_MEDIACODEC_HWACCEL 1 +#define CONFIG_MPEG4_MMAL_HWACCEL 0 +#define CONFIG_MPEG4_VAAPI_HWACCEL 0 +#define CONFIG_MPEG4_VDPAU_HWACCEL 0 +#define CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL 0 +#define CONFIG_VC1_CUVID_HWACCEL 0 +#define CONFIG_VC1_D3D11VA_HWACCEL 0 +#define CONFIG_VC1_DXVA2_HWACCEL 0 +#define CONFIG_VC1_VAAPI_HWACCEL 0 +#define CONFIG_VC1_VDPAU_HWACCEL 0 +#define CONFIG_VC1_MMAL_HWACCEL 0 +#define CONFIG_VC1_QSV_HWACCEL 0 +#define CONFIG_VP8_CUVID_HWACCEL 0 +#define CONFIG_VP8_MEDIACODEC_HWACCEL 1 +#define CONFIG_VP9_CUVID_HWACCEL 0 +#define CONFIG_VP9_D3D11VA_HWACCEL 0 +#define CONFIG_VP9_DXVA2_HWACCEL 0 +#define CONFIG_VP9_MEDIACODEC_HWACCEL 1 +#define CONFIG_VP9_VAAPI_HWACCEL 0 +#define CONFIG_WMV3_D3D11VA_HWACCEL 0 +#define CONFIG_WMV3_DXVA2_HWACCEL 0 +#define CONFIG_WMV3_VAAPI_HWACCEL 0 +#define CONFIG_WMV3_VDPAU_HWACCEL 0 +#define CONFIG_ALSA_INDEV 0 +#define CONFIG_AVFOUNDATION_INDEV 0 +#define CONFIG_BKTR_INDEV 0 +#define CONFIG_DECKLINK_INDEV 0 +#define CONFIG_DSHOW_INDEV 0 +#define CONFIG_DV1394_INDEV 0 +#define CONFIG_FBDEV_INDEV 0 +#define CONFIG_GDIGRAB_INDEV 0 +#define CONFIG_IEC61883_INDEV 0 +#define CONFIG_JACK_INDEV 0 +#define CONFIG_LAVFI_INDEV 0 +#define CONFIG_OPENAL_INDEV 0 +#define CONFIG_OSS_INDEV 0 +#define CONFIG_PULSE_INDEV 0 +#define CONFIG_QTKIT_INDEV 0 +#define CONFIG_SNDIO_INDEV 0 +#define CONFIG_V4L2_INDEV 0 +#define CONFIG_VFWCAP_INDEV 0 +#define CONFIG_X11GRAB_INDEV 0 +#define CONFIG_X11GRAB_XCB_INDEV 0 +#define CONFIG_LIBCDIO_INDEV 0 +#define CONFIG_LIBDC1394_INDEV 0 +#define CONFIG_A64_MUXER 1 +#define CONFIG_AC3_MUXER 1 +#define CONFIG_ADTS_MUXER 1 +#define CONFIG_ADX_MUXER 1 +#define CONFIG_AIFF_MUXER 1 +#define CONFIG_AMR_MUXER 1 +#define CONFIG_APNG_MUXER 1 +#define CONFIG_ASF_MUXER 1 +#define CONFIG_ASS_MUXER 1 +#define CONFIG_AST_MUXER 1 +#define CONFIG_ASF_STREAM_MUXER 1 +#define CONFIG_AU_MUXER 1 +#define CONFIG_AVI_MUXER 1 +#define CONFIG_AVM2_MUXER 1 +#define CONFIG_BIT_MUXER 1 +#define CONFIG_CAF_MUXER 1 +#define CONFIG_CAVSVIDEO_MUXER 1 +#define CONFIG_CRC_MUXER 1 +#define CONFIG_DASH_MUXER 1 +#define CONFIG_DATA_MUXER 1 +#define CONFIG_DAUD_MUXER 1 +#define CONFIG_DIRAC_MUXER 1 +#define CONFIG_DNXHD_MUXER 1 +#define CONFIG_DTS_MUXER 1 +#define CONFIG_DV_MUXER 1 +#define CONFIG_EAC3_MUXER 1 +#define CONFIG_F4V_MUXER 1 +#define CONFIG_FFM_MUXER 1 +#define CONFIG_FFMETADATA_MUXER 1 +#define CONFIG_FIFO_MUXER 1 +#define CONFIG_FILMSTRIP_MUXER 1 +#define CONFIG_FLAC_MUXER 1 +#define CONFIG_FLV_MUXER 1 +#define CONFIG_FRAMECRC_MUXER 1 +#define CONFIG_FRAMEHASH_MUXER 1 +#define CONFIG_FRAMEMD5_MUXER 1 +#define CONFIG_G722_MUXER 1 +#define CONFIG_G723_1_MUXER 1 +#define CONFIG_GIF_MUXER 1 +#define CONFIG_GSM_MUXER 1 +#define CONFIG_GXF_MUXER 1 +#define CONFIG_H261_MUXER 1 +#define CONFIG_H263_MUXER 1 +#define CONFIG_H264_MUXER 1 +#define CONFIG_HASH_MUXER 1 +#define CONFIG_HDS_MUXER 1 +#define CONFIG_HEVC_MUXER 1 +#define CONFIG_HLS_MUXER 1 +#define CONFIG_ICO_MUXER 1 +#define CONFIG_ILBC_MUXER 1 +#define CONFIG_IMAGE2_MUXER 1 +#define CONFIG_IMAGE2PIPE_MUXER 1 +#define CONFIG_IPOD_MUXER 1 +#define CONFIG_IRCAM_MUXER 1 +#define CONFIG_ISMV_MUXER 1 +#define CONFIG_IVF_MUXER 1 +#define CONFIG_JACOSUB_MUXER 1 +#define CONFIG_LATM_MUXER 1 +#define CONFIG_LRC_MUXER 1 +#define CONFIG_M4V_MUXER 1 +#define CONFIG_MD5_MUXER 1 +#define CONFIG_MATROSKA_MUXER 1 +#define CONFIG_MATROSKA_AUDIO_MUXER 1 +#define CONFIG_MICRODVD_MUXER 1 +#define CONFIG_MJPEG_MUXER 1 +#define CONFIG_MLP_MUXER 1 +#define CONFIG_MMF_MUXER 1 +#define CONFIG_MOV_MUXER 1 +#define CONFIG_MP2_MUXER 1 +#define CONFIG_MP3_MUXER 1 +#define CONFIG_MP4_MUXER 1 +#define CONFIG_MPEG1SYSTEM_MUXER 1 +#define CONFIG_MPEG1VCD_MUXER 1 +#define CONFIG_MPEG1VIDEO_MUXER 1 +#define CONFIG_MPEG2DVD_MUXER 1 +#define CONFIG_MPEG2SVCD_MUXER 1 +#define CONFIG_MPEG2VIDEO_MUXER 1 +#define CONFIG_MPEG2VOB_MUXER 1 +#define CONFIG_MPEGTS_MUXER 1 +#define CONFIG_MPJPEG_MUXER 1 +#define CONFIG_MXF_MUXER 1 +#define CONFIG_MXF_D10_MUXER 1 +#define CONFIG_MXF_OPATOM_MUXER 1 +#define CONFIG_NULL_MUXER 1 +#define CONFIG_NUT_MUXER 1 +#define CONFIG_OGA_MUXER 1 +#define CONFIG_OGG_MUXER 1 +#define CONFIG_OGV_MUXER 1 +#define CONFIG_OMA_MUXER 1 +#define CONFIG_OPUS_MUXER 1 +#define CONFIG_PCM_ALAW_MUXER 1 +#define CONFIG_PCM_MULAW_MUXER 1 +#define CONFIG_PCM_F64BE_MUXER 1 +#define CONFIG_PCM_F64LE_MUXER 1 +#define CONFIG_PCM_F32BE_MUXER 1 +#define CONFIG_PCM_F32LE_MUXER 1 +#define CONFIG_PCM_S32BE_MUXER 1 +#define CONFIG_PCM_S32LE_MUXER 1 +#define CONFIG_PCM_S24BE_MUXER 1 +#define CONFIG_PCM_S24LE_MUXER 1 +#define CONFIG_PCM_S16BE_MUXER 1 +#define CONFIG_PCM_S16LE_MUXER 1 +#define CONFIG_PCM_S8_MUXER 1 +#define CONFIG_PCM_U32BE_MUXER 1 +#define CONFIG_PCM_U32LE_MUXER 1 +#define CONFIG_PCM_U24BE_MUXER 1 +#define CONFIG_PCM_U24LE_MUXER 1 +#define CONFIG_PCM_U16BE_MUXER 1 +#define CONFIG_PCM_U16LE_MUXER 1 +#define CONFIG_PCM_U8_MUXER 1 +#define CONFIG_PSP_MUXER 1 +#define CONFIG_RAWVIDEO_MUXER 1 +#define CONFIG_RM_MUXER 1 +#define CONFIG_ROQ_MUXER 1 +#define CONFIG_RSO_MUXER 1 +#define CONFIG_RTP_MUXER 1 +#define CONFIG_RTP_MPEGTS_MUXER 1 +#define CONFIG_RTSP_MUXER 1 +#define CONFIG_SAP_MUXER 1 +#define CONFIG_SEGMENT_MUXER 1 +#define CONFIG_STREAM_SEGMENT_MUXER 1 +#define CONFIG_SINGLEJPEG_MUXER 1 +#define CONFIG_SMJPEG_MUXER 1 +#define CONFIG_SMOOTHSTREAMING_MUXER 1 +#define CONFIG_SOX_MUXER 1 +#define CONFIG_SPX_MUXER 1 +#define CONFIG_SPDIF_MUXER 1 +#define CONFIG_SRT_MUXER 1 +#define CONFIG_SWF_MUXER 1 +#define CONFIG_TEE_MUXER 1 +#define CONFIG_TG2_MUXER 1 +#define CONFIG_TGP_MUXER 1 +#define CONFIG_MKVTIMESTAMP_V2_MUXER 1 +#define CONFIG_TRUEHD_MUXER 1 +#define CONFIG_TTA_MUXER 1 +#define CONFIG_UNCODEDFRAMECRC_MUXER 1 +#define CONFIG_VC1_MUXER 1 +#define CONFIG_VC1T_MUXER 1 +#define CONFIG_VOC_MUXER 1 +#define CONFIG_W64_MUXER 1 +#define CONFIG_WAV_MUXER 1 +#define CONFIG_WEBM_MUXER 1 +#define CONFIG_WEBM_DASH_MANIFEST_MUXER 1 +#define CONFIG_WEBM_CHUNK_MUXER 1 +#define CONFIG_WEBP_MUXER 1 +#define CONFIG_WEBVTT_MUXER 1 +#define CONFIG_WTV_MUXER 1 +#define CONFIG_WV_MUXER 1 +#define CONFIG_YUV4MPEGPIPE_MUXER 1 +#define CONFIG_CHROMAPRINT_MUXER 0 +#define CONFIG_LIBNUT_MUXER 0 +#define CONFIG_ALSA_OUTDEV 0 +#define CONFIG_CACA_OUTDEV 0 +#define CONFIG_DECKLINK_OUTDEV 0 +#define CONFIG_FBDEV_OUTDEV 0 +#define CONFIG_OPENGL_OUTDEV 0 +#define CONFIG_OSS_OUTDEV 0 +#define CONFIG_PULSE_OUTDEV 0 +#define CONFIG_SDL2_OUTDEV 0 +#define CONFIG_SNDIO_OUTDEV 0 +#define CONFIG_V4L2_OUTDEV 0 +#define CONFIG_XV_OUTDEV 0 +#define CONFIG_AAC_PARSER 1 +#define CONFIG_AAC_LATM_PARSER 1 +#define CONFIG_AC3_PARSER 1 +#define CONFIG_ADX_PARSER 1 +#define CONFIG_BMP_PARSER 1 +#define CONFIG_CAVSVIDEO_PARSER 1 +#define CONFIG_COOK_PARSER 1 +#define CONFIG_DCA_PARSER 1 +#define CONFIG_DIRAC_PARSER 1 +#define CONFIG_DNXHD_PARSER 1 +#define CONFIG_DPX_PARSER 1 +#define CONFIG_DVAUDIO_PARSER 1 +#define CONFIG_DVBSUB_PARSER 1 +#define CONFIG_DVDSUB_PARSER 1 +#define CONFIG_DVD_NAV_PARSER 1 +#define CONFIG_FLAC_PARSER 1 +#define CONFIG_G729_PARSER 1 +#define CONFIG_GSM_PARSER 1 +#define CONFIG_H261_PARSER 1 +#define CONFIG_H263_PARSER 1 +#define CONFIG_H264_PARSER 1 +#define CONFIG_HEVC_PARSER 1 +#define CONFIG_MJPEG_PARSER 1 +#define CONFIG_MLP_PARSER 1 +#define CONFIG_MPEG4VIDEO_PARSER 1 +#define CONFIG_MPEGAUDIO_PARSER 1 +#define CONFIG_MPEGVIDEO_PARSER 1 +#define CONFIG_OPUS_PARSER 1 +#define CONFIG_PNG_PARSER 1 +#define CONFIG_PNM_PARSER 1 +#define CONFIG_RV30_PARSER 1 +#define CONFIG_RV40_PARSER 1 +#define CONFIG_TAK_PARSER 1 +#define CONFIG_VC1_PARSER 1 +#define CONFIG_VORBIS_PARSER 1 +#define CONFIG_VP3_PARSER 1 +#define CONFIG_VP8_PARSER 1 +#define CONFIG_VP9_PARSER 1 +#define CONFIG_ASYNC_PROTOCOL 1 +#define CONFIG_BLURAY_PROTOCOL 0 +#define CONFIG_CACHE_PROTOCOL 1 +#define CONFIG_CONCAT_PROTOCOL 1 +#define CONFIG_CRYPTO_PROTOCOL 1 +#define CONFIG_DATA_PROTOCOL 1 +#define CONFIG_FFRTMPCRYPT_PROTOCOL 0 +#define CONFIG_FFRTMPHTTP_PROTOCOL 1 +#define CONFIG_FILE_PROTOCOL 1 +#define CONFIG_FTP_PROTOCOL 1 +#define CONFIG_GOPHER_PROTOCOL 1 +#define CONFIG_HLS_PROTOCOL 1 +#define CONFIG_HTTP_PROTOCOL 1 +#define CONFIG_HTTPPROXY_PROTOCOL 1 +#define CONFIG_HTTPS_PROTOCOL 0 +#define CONFIG_ICECAST_PROTOCOL 1 +#define CONFIG_MMSH_PROTOCOL 1 +#define CONFIG_MMST_PROTOCOL 1 +#define CONFIG_MD5_PROTOCOL 1 +#define CONFIG_PIPE_PROTOCOL 1 +#define CONFIG_RTMP_PROTOCOL 1 +#define CONFIG_RTMPE_PROTOCOL 0 +#define CONFIG_RTMPS_PROTOCOL 0 +#define CONFIG_RTMPT_PROTOCOL 1 +#define CONFIG_RTMPTE_PROTOCOL 0 +#define CONFIG_RTMPTS_PROTOCOL 0 +#define CONFIG_RTP_PROTOCOL 1 +#define CONFIG_SCTP_PROTOCOL 0 +#define CONFIG_SRTP_PROTOCOL 1 +#define CONFIG_SUBFILE_PROTOCOL 1 +#define CONFIG_TEE_PROTOCOL 1 +#define CONFIG_TCP_PROTOCOL 1 +#define CONFIG_TLS_GNUTLS_PROTOCOL 0 +#define CONFIG_TLS_SCHANNEL_PROTOCOL 0 +#define CONFIG_TLS_SECURETRANSPORT_PROTOCOL 0 +#define CONFIG_TLS_OPENSSL_PROTOCOL 0 +#define CONFIG_UDP_PROTOCOL 1 +#define CONFIG_UDPLITE_PROTOCOL 1 +#define CONFIG_UNIX_PROTOCOL 1 +#define CONFIG_LIBRTMP_PROTOCOL 0 +#define CONFIG_LIBRTMPE_PROTOCOL 0 +#define CONFIG_LIBRTMPS_PROTOCOL 0 +#define CONFIG_LIBRTMPT_PROTOCOL 0 +#define CONFIG_LIBRTMPTE_PROTOCOL 0 +#define CONFIG_LIBSSH_PROTOCOL 0 +#define CONFIG_LIBSMBCLIENT_PROTOCOL 0 +#endif /* FFMPEG_CONFIG_H */ diff --git a/app/src/main/cpp/ffmpeg.c b/app/src/main/cpp/ffmpeg.c new file mode 100644 index 0000000..e303ab2 --- /dev/null +++ b/app/src/main/cpp/ffmpeg.c @@ -0,0 +1,4340 @@ +/* + * Copyright (c) 2000-2003 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * multimedia converter based on the FFmpeg libraries + */ + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include "logjam.h" + +#if HAVE_IO_H +#include +#endif +#if HAVE_UNISTD_H +#include +#endif + +#include "libavformat/avformat.h" +#include "libavdevice/avdevice.h" +#include "libswresample/swresample.h" +#include "libavutil/opt.h" +#include "libavutil/channel_layout.h" +#include "libavutil/parseutils.h" +#include "libavutil/samplefmt.h" +#include "libavutil/fifo.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/dict.h" +#include "libavutil/mathematics.h" +#include "libavutil/pixdesc.h" +#include "libavutil/avstring.h" +#include "libavutil/libm.h" +#include "libavutil/imgutils.h" +#include "libavutil/timestamp.h" +#include "libavutil/bprint.h" +#include "libavutil/time.h" +#include "libavutil/threadmessage.h" +#include "libavcodec/mathops.h" +#include "libavformat/os_support.h" + +# include "libavfilter/avfilter.h" +# include "libavfilter/buffersrc.h" +# include "libavfilter/buffersink.h" + +#if HAVE_SYS_RESOURCE_H +#include +#include +#include +#elif HAVE_GETPROCESSTIMES +#include +#endif +#if HAVE_GETPROCESSMEMORYINFO +#include +#include +#endif +#if HAVE_SETCONSOLECTRLHANDLER +#include +#endif + + +#if HAVE_SYS_SELECT_H +#include +#endif + +#if HAVE_TERMIOS_H +#include +#include +#include +#include +#elif HAVE_KBHIT +#include +#endif + +#if HAVE_PTHREADS +#include +#endif + +#include + +#include "ffmpeg.h" +#include "cmdutils.h" + +#include "libavutil/avassert.h" + +const char program_name[] = "ffmpeg"; +const int program_birth_year = 2000; + +static FILE *vstats_file; + +const char *const forced_keyframes_const_names[] = { + "n", + "n_forced", + "prev_forced_n", + "prev_forced_t", + "t", + NULL +}; + +static void do_video_stats(OutputStream *ost, int frame_size); +static int64_t getutime(void); +static int64_t getmaxrss(void); + +static int run_as_daemon = 0; +static int nb_frames_dup = 0; +static int nb_frames_drop = 0; +static int64_t decode_error_stat[2]; + +static int current_time; +AVIOContext *progress_avio = NULL; + +static uint8_t *subtitle_out; + +InputStream **input_streams = NULL; +int nb_input_streams = 0; +InputFile **input_files = NULL; +int nb_input_files = 0; + +OutputStream **output_streams = NULL; +int nb_output_streams = 0; +OutputFile **output_files = NULL; +int nb_output_files = 0; + +FilterGraph **filtergraphs; +int nb_filtergraphs; + +#if HAVE_TERMIOS_H + +/* init terminal so that we can grab keys */ +static struct termios oldtty; +static int restore_tty; +#endif + +#if HAVE_PTHREADS +static void free_input_threads(void); +#endif + +/* sub2video hack: + Convert subtitles to video with alpha to insert them in filter graphs. + This is a temporary solution until libavfilter gets real subtitles support. + */ + +static int sub2video_get_blank_frame(InputStream *ist) +{ + int ret; + AVFrame *frame = ist->sub2video.frame; + + av_frame_unref(frame); + ist->sub2video.frame->width = ist->dec_ctx->width ? ist->dec_ctx->width : ist->sub2video.w; + ist->sub2video.frame->height = ist->dec_ctx->height ? ist->dec_ctx->height : ist->sub2video.h; + ist->sub2video.frame->format = AV_PIX_FMT_RGB32; + if ((ret = av_frame_get_buffer(frame, 32)) < 0) + return ret; + memset(frame->data[0], 0, frame->height * frame->linesize[0]); + return 0; +} + +static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, + AVSubtitleRect *r) +{ + uint32_t *pal, *dst2; + uint8_t *src, *src2; + int x, y; + + if (r->type != SUBTITLE_BITMAP) { + av_log(NULL, AV_LOG_WARNING, "sub2video: non-bitmap subtitle\n"); + return; + } + if (r->x < 0 || r->x + r->w > w || r->y < 0 || r->y + r->h > h) { + av_log(NULL, AV_LOG_WARNING, "sub2video: rectangle (%d %d %d %d) overflowing %d %d\n", + r->x, r->y, r->w, r->h, w, h + ); + return; + } + + dst += r->y * dst_linesize + r->x * 4; + src = r->pict.data[0]; + pal = (uint32_t *)r->pict.data[1]; + for (y = 0; y < r->h; y++) { + dst2 = (uint32_t *)dst; + src2 = src; + for (x = 0; x < r->w; x++) + *(dst2++) = pal[*(src2++)]; + dst += dst_linesize; + src += r->pict.linesize[0]; + } +} + +static void sub2video_push_ref(InputStream *ist, int64_t pts) +{ + AVFrame *frame = ist->sub2video.frame; + int i; + + av_assert1(frame->data[0]); + ist->sub2video.last_pts = frame->pts = pts; + for (i = 0; i < ist->nb_filters; i++) + av_buffersrc_add_frame_flags(ist->filters[i]->filter, frame, + AV_BUFFERSRC_FLAG_KEEP_REF | + AV_BUFFERSRC_FLAG_PUSH); +} + +static void sub2video_update(InputStream *ist, AVSubtitle *sub) +{ + AVFrame *frame = ist->sub2video.frame; + int8_t *dst; + int dst_linesize; + int num_rects, i; + int64_t pts, end_pts; + + if (!frame) + return; + if (sub) { + pts = av_rescale_q(sub->pts + sub->start_display_time * 1000LL, + AV_TIME_BASE_Q, ist->st->time_base); + end_pts = av_rescale_q(sub->pts + sub->end_display_time * 1000LL, + AV_TIME_BASE_Q, ist->st->time_base); + num_rects = sub->num_rects; + } else { + pts = ist->sub2video.end_pts; + end_pts = INT64_MAX; + num_rects = 0; + } + if (sub2video_get_blank_frame(ist) < 0) { + av_log(ist->dec_ctx, AV_LOG_ERROR, + "Impossible to get a blank canvas.\n"); + return; + } + dst = frame->data [0]; + dst_linesize = frame->linesize[0]; + for (i = 0; i < num_rects; i++) + sub2video_copy_rect(dst, dst_linesize, frame->width, frame->height, sub->rects[i]); + sub2video_push_ref(ist, pts); + ist->sub2video.end_pts = end_pts; +} + +static void sub2video_heartbeat(InputStream *ist, int64_t pts) +{ + InputFile *infile = input_files[ist->file_index]; + int i, j, nb_reqs; + int64_t pts2; + + /* When a frame is read from a file, examine all sub2video streams in + the same file and send the sub2video frame again. Otherwise, decoded + video frames could be accumulating in the filter graph while a filter + (possibly overlay) is desperately waiting for a subtitle frame. */ + for (i = 0; i < infile->nb_streams; i++) { + InputStream *ist2 = input_streams[infile->ist_index + i]; + if (!ist2->sub2video.frame) + continue; + /* subtitles seem to be usually muxed ahead of other streams; + if not, subtracting a larger time here is necessary */ + pts2 = av_rescale_q(pts, ist->st->time_base, ist2->st->time_base) - 1; + /* do not send the heartbeat frame if the subtitle is already ahead */ + if (pts2 <= ist2->sub2video.last_pts) + continue; + if (pts2 >= ist2->sub2video.end_pts || !ist2->sub2video.frame->data[0]) + sub2video_update(ist2, NULL); + for (j = 0, nb_reqs = 0; j < ist2->nb_filters; j++) + nb_reqs += av_buffersrc_get_nb_failed_requests(ist2->filters[j]->filter); + if (nb_reqs) + sub2video_push_ref(ist2, pts2); + } +} + +static void sub2video_flush(InputStream *ist) +{ + int i; + + if (ist->sub2video.end_pts < INT64_MAX) + sub2video_update(ist, NULL); + for (i = 0; i < ist->nb_filters; i++) + av_buffersrc_add_frame(ist->filters[i]->filter, NULL); +} + +/* end of sub2video hack */ + +static void term_exit_sigsafe(void) +{ +#if HAVE_TERMIOS_H + if(restore_tty) + tcsetattr (0, TCSANOW, &oldtty); +#endif +} + +void term_exit(void) +{ + av_log(NULL, AV_LOG_QUIET, "%s", ""); + term_exit_sigsafe(); +} + +static volatile int received_sigterm = 0; +static volatile int received_nb_signals = 0; +static volatile int transcode_init_done = 0; +static volatile int ffmpeg_exited = 0; +static int main_return_code = 0; + +static void +sigterm_handler(int sig) +{ + received_sigterm = sig; + received_nb_signals++; + term_exit_sigsafe(); + if(received_nb_signals > 3) { + write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard exiting\n", + strlen("Received > 3 system signals, hard exiting\n")); + + exit(123); + } +} + +#if HAVE_SETCONSOLECTRLHANDLER +static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) +{ + av_log(NULL, AV_LOG_DEBUG, "\nReceived windows signal %ld\n", fdwCtrlType); + + switch (fdwCtrlType) + { + case CTRL_C_EVENT: + case CTRL_BREAK_EVENT: + sigterm_handler(SIGINT); + return TRUE; + + case CTRL_CLOSE_EVENT: + case CTRL_LOGOFF_EVENT: + case CTRL_SHUTDOWN_EVENT: + sigterm_handler(SIGTERM); + /* Basically, with these 3 events, when we return from this method the + process is hard terminated, so stall as long as we need to + to try and let the main thread(s) clean up and gracefully terminate + (we have at most 5 seconds, but should be done far before that). */ + while (!ffmpeg_exited) { + Sleep(0); + } + return TRUE; + + default: + av_log(NULL, AV_LOG_ERROR, "Received unknown windows signal %ld\n", fdwCtrlType); + return FALSE; + } +} +#endif + +void term_init(void) +{ +#if HAVE_TERMIOS_H + if(!run_as_daemon){ + struct termios tty; + if (tcgetattr (0, &tty) == 0) { + oldtty = tty; + restore_tty = 1; + + tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP + |INLCR|IGNCR|ICRNL|IXON); + tty.c_oflag |= OPOST; + tty.c_lflag &= ~(ECHO|ECHONL|ICANON|IEXTEN); + tty.c_cflag &= ~(CSIZE|PARENB); + tty.c_cflag |= CS8; + tty.c_cc[VMIN] = 1; + tty.c_cc[VTIME] = 0; + + tcsetattr (0, TCSANOW, &tty); + } + signal(SIGQUIT, sigterm_handler); /* Quit (POSIX). */ + } +#endif + + signal(SIGINT , sigterm_handler); /* Interrupt (ANSI). */ + signal(SIGTERM, sigterm_handler); /* Termination (ANSI). */ +#ifdef SIGXCPU + signal(SIGXCPU, sigterm_handler); +#endif +#if HAVE_SETCONSOLECTRLHANDLER + SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE); +#endif +} + +/* read a key without blocking */ +static int read_key(void) +{ + unsigned char ch; +#if HAVE_TERMIOS_H + int n = 1; + struct timeval tv; + fd_set rfds; + + FD_ZERO(&rfds); + FD_SET(0, &rfds); + tv.tv_sec = 0; + tv.tv_usec = 0; + n = select(1, &rfds, NULL, NULL, &tv); + if (n > 0) { + n = read(0, &ch, 1); + if (n == 1) + return ch; + + return n; + } +#elif HAVE_KBHIT +# if HAVE_PEEKNAMEDPIPE + static int is_pipe; + static HANDLE input_handle; + DWORD dw, nchars; + if(!input_handle){ + input_handle = GetStdHandle(STD_INPUT_HANDLE); + is_pipe = !GetConsoleMode(input_handle, &dw); + } + + if (is_pipe) { + /* When running under a GUI, you will end here. */ + if (!PeekNamedPipe(input_handle, NULL, 0, NULL, &nchars, NULL)) { + // input pipe may have been closed by the program that ran ffmpeg + return -1; + } + //Read it + if(nchars != 0) { + read(0, &ch, 1); + return ch; + }else{ + return -1; + } + } +# endif + if(kbhit()) + return(getch()); +#endif + return -1; +} + +static int decode_interrupt_cb(void *ctx) +{ + return received_nb_signals > transcode_init_done; +} + +const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }; + +static void ffmpeg_cleanup(int ret) +{ + int i, j; + + if (do_benchmark) { + int maxrss = getmaxrss() / 1024; + av_log(NULL, AV_LOG_INFO, "bench: maxrss=%ikB\n", maxrss); + } + + for (i = 0; i < nb_filtergraphs; i++) { + FilterGraph *fg = filtergraphs[i]; + avfilter_graph_free(&fg->graph); + for (j = 0; j < fg->nb_inputs; j++) { + av_freep(&fg->inputs[j]->name); + av_freep(&fg->inputs[j]); + } + av_freep(&fg->inputs); + for (j = 0; j < fg->nb_outputs; j++) { + av_freep(&fg->outputs[j]->name); + av_freep(&fg->outputs[j]); + } + av_freep(&fg->outputs); + av_freep(&fg->graph_desc); + + av_freep(&filtergraphs[i]); + } + av_freep(&filtergraphs); + + av_freep(&subtitle_out); + + /* close files */ + for (i = 0; i < nb_output_files; i++) { + OutputFile *of = output_files[i]; + AVFormatContext *s; + if (!of) + continue; + s = of->ctx; + if (s && s->oformat && !(s->oformat->flags & AVFMT_NOFILE)) + avio_closep(&s->pb); + avformat_free_context(s); + av_dict_free(&of->opts); + + av_freep(&output_files[i]); + } + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + AVBitStreamFilterContext *bsfc; + + if (!ost) + continue; + + bsfc = ost->bitstream_filters; + while (bsfc) { + AVBitStreamFilterContext *next = bsfc->next; + av_bitstream_filter_close(bsfc); + bsfc = next; + } + ost->bitstream_filters = NULL; + av_frame_free(&ost->filtered_frame); + av_frame_free(&ost->last_frame); + + av_parser_close(ost->parser); + + av_freep(&ost->forced_keyframes); + av_expr_free(ost->forced_keyframes_pexpr); + av_freep(&ost->avfilter); + av_freep(&ost->logfile_prefix); + + av_freep(&ost->audio_channels_map); + ost->audio_channels_mapped = 0; + + av_dict_free(&ost->sws_dict); + + avcodec_free_context(&ost->enc_ctx); + + av_freep(&output_streams[i]); + } +#if HAVE_PTHREADS + free_input_threads(); +#endif + for (i = 0; i < nb_input_files; i++) { + avformat_close_input(&input_files[i]->ctx); + av_freep(&input_files[i]); + } + for (i = 0; i < nb_input_streams; i++) { + InputStream *ist = input_streams[i]; + + av_frame_free(&ist->decoded_frame); + av_frame_free(&ist->filter_frame); + av_dict_free(&ist->decoder_opts); + avsubtitle_free(&ist->prev_sub.subtitle); + av_frame_free(&ist->sub2video.frame); + av_freep(&ist->filters); + av_freep(&ist->hwaccel_device); + + avcodec_free_context(&ist->dec_ctx); + + av_freep(&input_streams[i]); + } + + if (vstats_file) { + if (fclose(vstats_file)) + av_log(NULL, AV_LOG_ERROR, + "Error closing vstats file, loss of information possible: %s\n", + av_err2str(AVERROR(errno))); + } + av_freep(&vstats_filename); + + av_freep(&input_streams); + av_freep(&input_files); + av_freep(&output_streams); + av_freep(&output_files); + + uninit_opts(); + + avformat_network_deinit(); + + if (received_sigterm) { + av_log(NULL, AV_LOG_INFO, "Exiting normally, received signal %d.\n", + (int) received_sigterm); + } else if (ret && transcode_init_done) { + av_log(NULL, AV_LOG_INFO, "Conversion failed!\n"); + } + term_exit(); + ffmpeg_exited = 1; + + filtergraphs = NULL; + nb_filtergraphs = 0; + output_files = NULL; + nb_output_files = 0; + output_streams = NULL; + nb_output_streams = 0; + input_files = NULL; + nb_input_files = 0; + input_streams = NULL; + nb_input_streams = 0; +} + +void remove_avoptions(AVDictionary **a, AVDictionary *b) +{ + AVDictionaryEntry *t = NULL; + + while ((t = av_dict_get(b, "", t, AV_DICT_IGNORE_SUFFIX))) { + av_dict_set(a, t->key, NULL, AV_DICT_MATCH_CASE); + } +} + +void assert_avoptions(AVDictionary *m) +{ + AVDictionaryEntry *t; + if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) { + av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key); + exit_program(1); + } +} + +static void abort_codec_experimental(AVCodec *c, int encoder) +{ + exit_program(1); +} + +static void update_benchmark(const char *fmt, ...) +{ + if (do_benchmark_all) { + int64_t t = getutime(); + va_list va; + char buf[1024]; + + if (fmt) { + va_start(va, fmt); + vsnprintf(buf, sizeof(buf), fmt, va); + va_end(va); + av_log(NULL, AV_LOG_INFO, "bench: %8"PRIu64" %s \n", t - current_time, buf); + } + current_time = t; + } +} + +static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others) +{ + int i; + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost2 = output_streams[i]; + ost2->finished |= ost == ost2 ? this_stream : others; + } +} + +static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) +{ + AVBitStreamFilterContext *bsfc = ost->bitstream_filters; + AVCodecContext *avctx = ost->encoding_needed ? ost->enc_ctx : ost->st->codec; + int ret; + + if (!ost->st->codec->extradata_size && ost->enc_ctx->extradata_size) { + ost->st->codec->extradata = av_mallocz(ost->enc_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE); + if (ost->st->codec->extradata) { + memcpy(ost->st->codec->extradata, ost->enc_ctx->extradata, ost->enc_ctx->extradata_size); + ost->st->codec->extradata_size = ost->enc_ctx->extradata_size; + } + } + + if ((avctx->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) || + (avctx->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0)) + pkt->pts = pkt->dts = AV_NOPTS_VALUE; + + /* + * Audio encoders may split the packets -- #frames in != #packets out. + * But there is no reordering, so we can limit the number of output packets + * by simply dropping them here. + * Counting encoded video frames needs to be done separately because of + * reordering, see do_video_out() + */ + if (!(avctx->codec_type == AVMEDIA_TYPE_VIDEO && avctx->codec)) { + if (ost->frame_number >= ost->max_frames) { + av_packet_unref(pkt); + return; + } + ost->frame_number++; + } + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { + int i; + uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, + NULL); + ost->quality = sd ? AV_RL32(sd) : -1; + ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE; + + for (i = 0; ierror); i++) { + if (sd && i < sd[5]) + ost->error[i] = AV_RL64(sd + 8 + 8*i); + else + ost->error[i] = -1; + } + + if (ost->frame_rate.num && ost->is_cfr) { + if (pkt->duration > 0) + av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n"); + pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), + ost->st->time_base); + } + } + + if (bsfc) + av_packet_split_side_data(pkt); + + if ((ret = av_apply_bitstream_filters(avctx, pkt, bsfc)) < 0) { + print_error("", ret); + if (exit_on_error) + exit_program(1); + } + + if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { + if (pkt->dts != AV_NOPTS_VALUE && + pkt->pts != AV_NOPTS_VALUE && + pkt->dts > pkt->pts) { + av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n", + pkt->dts, pkt->pts, + ost->file_index, ost->st->index); + pkt->pts = + pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1 + - FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) + - FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); + } + if( + (avctx->codec_type == AVMEDIA_TYPE_AUDIO || avctx->codec_type == AVMEDIA_TYPE_VIDEO) && + pkt->dts != AV_NOPTS_VALUE && + ost->last_mux_dts != AV_NOPTS_VALUE) { + int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); + if (pkt->dts < max) { + int loglevel = max - pkt->dts > 2 || avctx->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG; + av_log(s, loglevel, "Non-monotonous DTS in output stream " + "%d:%d; previous: %"PRId64", current: %"PRId64"; ", + ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts); + if (exit_on_error) { + av_log(NULL, AV_LOG_FATAL, "aborting.\n"); + exit_program(1); + } + av_log(s, loglevel, "changing to %"PRId64". This may result " + "in incorrect timestamps in the output file.\n", + max); + if(pkt->pts >= pkt->dts) + pkt->pts = FFMAX(pkt->pts, max); + pkt->dts = max; + } + } + } + ost->last_mux_dts = pkt->dts; + + ost->data_size += pkt->size; + ost->packets_written++; + + pkt->stream_index = ost->index; + + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "muxer <- type:%s " + "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n", + av_get_media_type_string(ost->enc_ctx->codec_type), + av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base), + av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base), + pkt->size + ); + } + + ret = av_interleaved_write_frame(s, pkt); + if (ret < 0) { + print_error("av_interleaved_write_frame()", ret); + main_return_code = 1; + close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); + } + av_packet_unref(pkt); +} + +static void close_output_stream(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + + ost->finished |= ENCODER_FINISHED; + if (of->shortest) { + int64_t end = av_rescale_q(ost->sync_opts - ost->first_pts, ost->enc_ctx->time_base, AV_TIME_BASE_Q); + of->recording_time = FFMIN(of->recording_time, end); + } +} + +static int check_recording_time(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + + if (of->recording_time != INT64_MAX && + av_compare_ts(ost->sync_opts - ost->first_pts, ost->enc_ctx->time_base, of->recording_time, + AV_TIME_BASE_Q) >= 0) { + close_output_stream(ost); + return 0; + } + return 1; +} + +static void do_audio_out(AVFormatContext *s, OutputStream *ost, + AVFrame *frame) +{ + AVCodecContext *enc = ost->enc_ctx; + AVPacket pkt; + int got_packet = 0; + + av_init_packet(&pkt); + pkt.data = NULL; + pkt.size = 0; + + if (!check_recording_time(ost)) + return; + + if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0) + frame->pts = ost->sync_opts; + ost->sync_opts = frame->pts + frame->nb_samples; + ost->samples_encoded += frame->nb_samples; + ost->frames_encoded++; + + av_assert0(pkt.size || !pkt.data); + update_benchmark(NULL); + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "encoder <- type:audio " + "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n", + av_ts2str(frame->pts), av_ts2timestr(frame->pts, &enc->time_base), + enc->time_base.num, enc->time_base.den); + } + + if (avcodec_encode_audio2(enc, &pkt, frame, &got_packet) < 0) { + av_log(NULL, AV_LOG_FATAL, "Audio encoding failed (avcodec_encode_audio2)\n"); + exit_program(1); + } + update_benchmark("encode_audio %d.%d", ost->file_index, ost->index); + + if (got_packet) { + av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); + + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "encoder -> type:audio " + "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", + av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), + av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); + } + + write_frame(s, &pkt, ost); + } +} + +static void do_subtitle_out(AVFormatContext *s, + OutputStream *ost, + InputStream *ist, + AVSubtitle *sub) +{ + int subtitle_out_max_size = 1024 * 1024; + int subtitle_out_size, nb, i; + AVCodecContext *enc; + AVPacket pkt; + int64_t pts; + + if (sub->pts == AV_NOPTS_VALUE) { + av_log(NULL, AV_LOG_ERROR, "Subtitle packets must have a pts\n"); + if (exit_on_error) + exit_program(1); + return; + } + + enc = ost->enc_ctx; + + if (!subtitle_out) { + subtitle_out = av_malloc(subtitle_out_max_size); + if (!subtitle_out) { + av_log(NULL, AV_LOG_FATAL, "Failed to allocate subtitle_out\n"); + exit_program(1); + } + } + + /* Note: DVB subtitle need one packet to draw them and one other + packet to clear them */ + /* XXX: signal it in the codec context ? */ + if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) + nb = 2; + else + nb = 1; + + /* shift timestamp to honor -ss and make check_recording_time() work with -t */ + pts = sub->pts; + if (output_files[ost->file_index]->start_time != AV_NOPTS_VALUE) + pts -= output_files[ost->file_index]->start_time; + for (i = 0; i < nb; i++) { + unsigned save_num_rects = sub->num_rects; + + ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base); + if (!check_recording_time(ost)) + return; + + sub->pts = pts; + // start_display_time is required to be 0 + sub->pts += av_rescale_q(sub->start_display_time, (AVRational){ 1, 1000 }, AV_TIME_BASE_Q); + sub->end_display_time -= sub->start_display_time; + sub->start_display_time = 0; + if (i == 1) + sub->num_rects = 0; + + ost->frames_encoded++; + + subtitle_out_size = avcodec_encode_subtitle(enc, subtitle_out, + subtitle_out_max_size, sub); + if (i == 1) + sub->num_rects = save_num_rects; + if (subtitle_out_size < 0) { + av_log(NULL, AV_LOG_FATAL, "Subtitle encoding failed\n"); + exit_program(1); + } + + av_init_packet(&pkt); + pkt.data = subtitle_out; + pkt.size = subtitle_out_size; + pkt.pts = av_rescale_q(sub->pts, AV_TIME_BASE_Q, ost->st->time_base); + pkt.duration = av_rescale_q(sub->end_display_time, (AVRational){ 1, 1000 }, ost->st->time_base); + if (enc->codec_id == AV_CODEC_ID_DVB_SUBTITLE) { + /* XXX: the pts correction is handled here. Maybe handling + it in the codec would be better */ + if (i == 0) + pkt.pts += 90 * sub->start_display_time; + else + pkt.pts += 90 * sub->end_display_time; + } + pkt.dts = pkt.pts; + write_frame(s, &pkt, ost); + } +} + +static void do_video_out(AVFormatContext *s, + OutputStream *ost, + AVFrame *next_picture, + double sync_ipts) +{ + int ret, format_video_sync; + AVPacket pkt; + AVCodecContext *enc = ost->enc_ctx; + AVCodecContext *mux_enc = ost->st->codec; + int nb_frames, nb0_frames, i; + double delta, delta0; + double duration = 0; + int frame_size = 0; + InputStream *ist = NULL; + AVFilterContext *filter = ost->filter->filter; + + if (ost->source_index >= 0) + ist = input_streams[ost->source_index]; + + if (filter->inputs[0]->frame_rate.num > 0 && + filter->inputs[0]->frame_rate.den > 0) + duration = 1/(av_q2d(filter->inputs[0]->frame_rate) * av_q2d(enc->time_base)); + + if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num) + duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base))); + + if (!ost->filters_script && + !ost->filters && + next_picture && + ist && + lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) { + duration = lrintf(av_frame_get_pkt_duration(next_picture) * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)); + } + + if (!next_picture) { + //end, flushing + nb0_frames = nb_frames = mid_pred(ost->last_nb0_frames[0], + ost->last_nb0_frames[1], + ost->last_nb0_frames[2]); + } else { + delta0 = sync_ipts - ost->sync_opts; // delta0 is the "drift" between the input frame (next_picture) and where it would fall in the output. + delta = delta0 + duration; + + /* by default, we output a single frame */ + nb0_frames = 0; // tracks the number of times the PREVIOUS frame should be duplicated, mostly for variable framerate (VFR) + nb_frames = 1; + + format_video_sync = video_sync_method; + if (format_video_sync == VSYNC_AUTO) { + if(!strcmp(s->oformat->name, "avi")) { + format_video_sync = VSYNC_VFR; + } else + format_video_sync = (s->oformat->flags & AVFMT_VARIABLE_FPS) ? ((s->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR; + if ( ist + && format_video_sync == VSYNC_CFR + && input_files[ist->file_index]->ctx->nb_streams == 1 + && input_files[ist->file_index]->input_ts_offset == 0) { + format_video_sync = VSYNC_VSCFR; + } + if (format_video_sync == VSYNC_CFR && copy_ts) { + format_video_sync = VSYNC_VSCFR; + } + } + ost->is_cfr = (format_video_sync == VSYNC_CFR || format_video_sync == VSYNC_VSCFR); + + if (delta0 < 0 && + delta > 0 && + format_video_sync != VSYNC_PASSTHROUGH && + format_video_sync != VSYNC_DROP) { + if (delta0 < -0.6) { + av_log(NULL, AV_LOG_WARNING, "Past duration %f too large\n", -delta0); + } else + av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0); + sync_ipts = ost->sync_opts; + duration += delta0; + delta0 = 0; + } + + switch (format_video_sync) { + case VSYNC_VSCFR: + if (ost->frame_number == 0 && delta0 >= 0.5) { + av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0)); + delta = duration; + delta0 = 0; + ost->sync_opts = lrint(sync_ipts); + } + case VSYNC_CFR: + // FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c + if (frame_drop_threshold && delta < frame_drop_threshold && ost->frame_number) { + nb_frames = 0; + } else if (delta < -1.1) + nb_frames = 0; + else if (delta > 1.1) { + nb_frames = lrintf(delta); + if (delta0 > 1.1) + nb0_frames = lrintf(delta0 - 0.6); + } + break; + case VSYNC_VFR: + if (delta <= -0.6) + nb_frames = 0; + else if (delta > 0.6) + ost->sync_opts = lrint(sync_ipts); + break; + case VSYNC_DROP: + case VSYNC_PASSTHROUGH: + ost->sync_opts = lrint(sync_ipts); + break; + default: + av_assert0(0); + } + } + + nb_frames = FFMIN(nb_frames, ost->max_frames - ost->frame_number); + nb0_frames = FFMIN(nb0_frames, nb_frames); + + memmove(ost->last_nb0_frames + 1, + ost->last_nb0_frames, + sizeof(ost->last_nb0_frames[0]) * (FF_ARRAY_ELEMS(ost->last_nb0_frames) - 1)); + ost->last_nb0_frames[0] = nb0_frames; + + if (nb0_frames == 0 && ost->last_dropped) { + nb_frames_drop++; + av_log(NULL, AV_LOG_VERBOSE, + "*** dropping frame %d from stream %d at ts %"PRId64"\n", + ost->frame_number, ost->st->index, ost->last_frame->pts); + } + if (nb_frames > (nb0_frames && ost->last_dropped) + (nb_frames > nb0_frames)) { + if (nb_frames > dts_error_threshold * 30) { + av_log(NULL, AV_LOG_ERROR, "%d frame duplication too large, skipping\n", nb_frames - 1); + nb_frames_drop++; + return; + } + nb_frames_dup += nb_frames - (nb0_frames && ost->last_dropped) - (nb_frames > nb0_frames); + av_log(NULL, AV_LOG_VERBOSE, "*** %d dup!\n", nb_frames - 1); + } + ost->last_dropped = nb_frames == nb0_frames && next_picture; + + /* duplicates frame if needed */ + for (i = 0; i < nb_frames; i++) { + AVFrame *in_picture; + av_init_packet(&pkt); + pkt.data = NULL; + pkt.size = 0; + + if (i < nb0_frames && ost->last_frame) { + in_picture = ost->last_frame; + } else + in_picture = next_picture; + + if (!in_picture) + return; + + in_picture->pts = ost->sync_opts; + +#if 1 + if (!check_recording_time(ost)) +#else + if (ost->frame_number >= ost->max_frames) +#endif + return; + +#if FF_API_LAVF_FMT_RAWPICTURE + if (s->oformat->flags & AVFMT_RAWPICTURE && + enc->codec->id == AV_CODEC_ID_RAWVIDEO) { + /* raw pictures are written as AVPicture structure to + avoid any copies. We support temporarily the older + method. */ + if (in_picture->interlaced_frame) + mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT; + else + mux_enc->field_order = AV_FIELD_PROGRESSIVE; + pkt.data = (uint8_t *)in_picture; + pkt.size = sizeof(AVPicture); + pkt.pts = av_rescale_q(in_picture->pts, enc->time_base, ost->st->time_base); + pkt.flags |= AV_PKT_FLAG_KEY; + + write_frame(s, &pkt, ost); + } else +#endif + { + int got_packet, forced_keyframe = 0; + double pts_time; + + if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) && + ost->top_field_first >= 0) + in_picture->top_field_first = !!ost->top_field_first; + + if (in_picture->interlaced_frame) { + if (enc->codec->id == AV_CODEC_ID_MJPEG) + mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TT:AV_FIELD_BB; + else + mux_enc->field_order = in_picture->top_field_first ? AV_FIELD_TB:AV_FIELD_BT; + } else + mux_enc->field_order = AV_FIELD_PROGRESSIVE; + + in_picture->quality = enc->global_quality; + in_picture->pict_type = 0; + + pts_time = in_picture->pts != AV_NOPTS_VALUE ? + in_picture->pts * av_q2d(enc->time_base) : NAN; + if (ost->forced_kf_index < ost->forced_kf_count && + in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { + ost->forced_kf_index++; + forced_keyframe = 1; + } else if (ost->forced_keyframes_pexpr) { + double res; + ost->forced_keyframes_expr_const_values[FKF_T] = pts_time; + res = av_expr_eval(ost->forced_keyframes_pexpr, + ost->forced_keyframes_expr_const_values, NULL); + ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n", + ost->forced_keyframes_expr_const_values[FKF_N], + ost->forced_keyframes_expr_const_values[FKF_N_FORCED], + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N], + ost->forced_keyframes_expr_const_values[FKF_T], + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T], + res); + if (res) { + forced_keyframe = 1; + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = + ost->forced_keyframes_expr_const_values[FKF_N]; + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = + ost->forced_keyframes_expr_const_values[FKF_T]; + ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1; + } + + ost->forced_keyframes_expr_const_values[FKF_N] += 1; + } else if ( ost->forced_keyframes + && !strncmp(ost->forced_keyframes, "source", 6) + && in_picture->key_frame==1) { + forced_keyframe = 1; + } + + if (forced_keyframe) { + in_picture->pict_type = AV_PICTURE_TYPE_I; + av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time); + } + + update_benchmark(NULL); + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "encoder <- type:video " + "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n", + av_ts2str(in_picture->pts), av_ts2timestr(in_picture->pts, &enc->time_base), + enc->time_base.num, enc->time_base.den); + } + + ost->frames_encoded++; + + ret = avcodec_encode_video2(enc, &pkt, in_picture, &got_packet); + update_benchmark("encode_video %d.%d", ost->file_index, ost->index); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Video encoding failed\n"); + exit_program(1); + } + + if (got_packet) { + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "encoder -> type:video " + "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", + av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &enc->time_base), + av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &enc->time_base)); + } + + if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & AV_CODEC_CAP_DELAY)) + pkt.pts = ost->sync_opts; + + av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); + + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "encoder -> type:video " + "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n", + av_ts2str(pkt.pts), av_ts2timestr(pkt.pts, &ost->st->time_base), + av_ts2str(pkt.dts), av_ts2timestr(pkt.dts, &ost->st->time_base)); + } + + frame_size = pkt.size; + write_frame(s, &pkt, ost); + + /* if two pass, output log */ + if (ost->logfile && enc->stats_out) { + fprintf(ost->logfile, "%s", enc->stats_out); + } + } + } + ost->sync_opts++; + /* + * For video, number of frames in == number of packets out. + * But there may be reordering, so we can't throw away frames on encoder + * flush, we need to limit them here, before they go into encoder. + */ + ost->frame_number++; + + if (vstats_filename && frame_size) + do_video_stats(ost, frame_size); + } + + if (!ost->last_frame) + ost->last_frame = av_frame_alloc(); + av_frame_unref(ost->last_frame); + if (next_picture && ost->last_frame) + av_frame_ref(ost->last_frame, next_picture); + else + av_frame_free(&ost->last_frame); +} + +static double psnr(double d) +{ + return -10.0 * log10(d); +} + +static void do_video_stats(OutputStream *ost, int frame_size) +{ + AVCodecContext *enc; + int frame_number; + double ti1, bitrate, avg_bitrate; + + /* this is executed just the first time do_video_stats is called */ + if (!vstats_file) { + vstats_file = fopen(vstats_filename, "w"); + if (!vstats_file) { + perror("fopen"); + exit_program(1); + } + } + + enc = ost->enc_ctx; + if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { + frame_number = ost->st->nb_frames; + fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, + ost->quality / (float)FF_QP2LAMBDA); + + if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR)) + fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0))); + + fprintf(vstats_file,"f_size= %6d ", frame_size); + /* compute pts value */ + ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base); + if (ti1 < 0.01) + ti1 = 0.01; + + bitrate = (frame_size * 8) / av_q2d(enc->time_base) / 1000.0; + avg_bitrate = (double)(ost->data_size * 8) / ti1 / 1000.0; + fprintf(vstats_file, "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ", + (double)ost->data_size / 1024, ti1, bitrate, avg_bitrate); + fprintf(vstats_file, "type= %c\n", av_get_picture_type_char(ost->pict_type)); + } +} + +static void finish_output_stream(OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + int i; + + ost->finished = ENCODER_FINISHED | MUXER_FINISHED; + + if (of->shortest) { + for (i = 0; i < of->ctx->nb_streams; i++) + output_streams[of->ost_index + i]->finished = ENCODER_FINISHED | MUXER_FINISHED; + } +} + +/** + * Get and encode new output from any of the filtergraphs, without causing + * activity. + * + * @return 0 for success, <0 for severe errors + */ +static int reap_filters(int flush) +{ + AVFrame *filtered_frame = NULL; + int i; + + /* Reap all buffers present in the buffer sinks */ + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + OutputFile *of = output_files[ost->file_index]; + AVFilterContext *filter; + AVCodecContext *enc = ost->enc_ctx; + int ret = 0; + + if (!ost->filter) + continue; + filter = ost->filter->filter; + + if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) { + return AVERROR(ENOMEM); + } + filtered_frame = ost->filtered_frame; + + while (1) { + double float_pts = AV_NOPTS_VALUE; // this is identical to filtered_frame.pts but with higher precision + ret = av_buffersink_get_frame_flags(filter, filtered_frame, + AV_BUFFERSINK_FLAG_NO_REQUEST); + if (ret < 0) { + if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { + av_log(NULL, AV_LOG_WARNING, + "Error in av_buffersink_get_frame_flags(): %s\n", av_err2str(ret)); + } else if (flush && ret == AVERROR_EOF) { + if (filter->inputs[0]->type == AVMEDIA_TYPE_VIDEO) + do_video_out(of->ctx, ost, NULL, AV_NOPTS_VALUE); + } + break; + } + if (ost->finished) { + av_frame_unref(filtered_frame); + continue; + } + if (filtered_frame->pts != AV_NOPTS_VALUE) { + int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; + AVRational tb = enc->time_base; + int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16); + + tb.den <<= extra_bits; + float_pts = + av_rescale_q(filtered_frame->pts, filter->inputs[0]->time_base, tb) - + av_rescale_q(start_time, AV_TIME_BASE_Q, tb); + float_pts /= 1 << extra_bits; + // avoid exact midoints to reduce the chance of rounding differences, this can be removed in case the fps code is changed to work with integers + float_pts += FFSIGN(float_pts) * 1.0 / (1<<17); + + filtered_frame->pts = + av_rescale_q(filtered_frame->pts, filter->inputs[0]->time_base, enc->time_base) - + av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); + } + //if (ost->source_index >= 0) + // *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold + + switch (filter->inputs[0]->type) { + case AVMEDIA_TYPE_VIDEO: + if (!ost->frame_aspect_ratio.num) + enc->sample_aspect_ratio = filtered_frame->sample_aspect_ratio; + + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "filter -> pts:%s pts_time:%s exact:%f time_base:%d/%d\n", + av_ts2str(filtered_frame->pts), av_ts2timestr(filtered_frame->pts, &enc->time_base), + float_pts, + enc->time_base.num, enc->time_base.den); + } + + do_video_out(of->ctx, ost, filtered_frame, float_pts); + break; + case AVMEDIA_TYPE_AUDIO: + if (!(enc->codec->capabilities & AV_CODEC_CAP_PARAM_CHANGE) && + enc->channels != av_frame_get_channels(filtered_frame)) { + av_log(NULL, AV_LOG_ERROR, + "Audio filter graph output is not normalized and encoder does not support parameter changes\n"); + break; + } + do_audio_out(of->ctx, ost, filtered_frame); + break; + default: + // TODO support subtitle filters + av_assert0(0); + } + + av_frame_unref(filtered_frame); + } + } + + return 0; +} + +static void print_final_stats(int64_t total_size) +{ + uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0; + uint64_t subtitle_size = 0; + uint64_t data_size = 0; + float percent = -1.0; + int i, j; + int pass1_used = 1; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + switch (ost->enc_ctx->codec_type) { + case AVMEDIA_TYPE_VIDEO: video_size += ost->data_size; break; + case AVMEDIA_TYPE_AUDIO: audio_size += ost->data_size; break; + case AVMEDIA_TYPE_SUBTITLE: subtitle_size += ost->data_size; break; + default: other_size += ost->data_size; break; + } + extra_size += ost->enc_ctx->extradata_size; + data_size += ost->data_size; + if ( (ost->enc_ctx->flags & (AV_CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2)) + != AV_CODEC_FLAG_PASS1) + pass1_used = 0; + } + + if (data_size && total_size>0 && total_size >= data_size) + percent = 100.0 * (total_size - data_size) / data_size; + + av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ", + video_size / 1024.0, + audio_size / 1024.0, + subtitle_size / 1024.0, + other_size / 1024.0, + extra_size / 1024.0); + if (percent >= 0.0) + av_log(NULL, AV_LOG_INFO, "%f%%", percent); + else + av_log(NULL, AV_LOG_INFO, "unknown"); + av_log(NULL, AV_LOG_INFO, "\n"); + + /* print verbose per-stream stats */ + for (i = 0; i < nb_input_files; i++) { + InputFile *f = input_files[i]; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", + i, f->ctx->filename); + + for (j = 0; j < f->nb_streams; j++) { + InputStream *ist = input_streams[f->ist_index + j]; + enum AVMediaType type = ist->dec_ctx->codec_type; + + total_size += ist->data_size; + total_packets += ist->nb_packets; + + av_log(NULL, AV_LOG_VERBOSE, " Input stream #%d:%d (%s): ", + i, j, media_type_string(type)); + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets read (%"PRIu64" bytes); ", + ist->nb_packets, ist->data_size); + + if (ist->decoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames decoded", + ist->frames_decoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ist->samples_decoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) demuxed\n", + total_packets, total_size); + } + + for (i = 0; i < nb_output_files; i++) { + OutputFile *of = output_files[i]; + uint64_t total_packets = 0, total_size = 0; + + av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", + i, of->ctx->filename); + + for (j = 0; j < of->ctx->nb_streams; j++) { + OutputStream *ost = output_streams[of->ost_index + j]; + enum AVMediaType type = ost->enc_ctx->codec_type; + + total_size += ost->data_size; + total_packets += ost->packets_written; + + av_log(NULL, AV_LOG_VERBOSE, " Output stream #%d:%d (%s): ", + i, j, media_type_string(type)); + if (ost->encoding_needed) { + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" frames encoded", + ost->frames_encoded); + if (type == AVMEDIA_TYPE_AUDIO) + av_log(NULL, AV_LOG_VERBOSE, " (%"PRIu64" samples)", ost->samples_encoded); + av_log(NULL, AV_LOG_VERBOSE, "; "); + } + + av_log(NULL, AV_LOG_VERBOSE, "%"PRIu64" packets muxed (%"PRIu64" bytes); ", + ost->packets_written, ost->data_size); + + av_log(NULL, AV_LOG_VERBOSE, "\n"); + } + + av_log(NULL, AV_LOG_VERBOSE, " Total: %"PRIu64" packets (%"PRIu64" bytes) muxed\n", + total_packets, total_size); + } + if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){ + av_log(NULL, AV_LOG_WARNING, "Output file is empty, nothing was encoded "); + if (pass1_used) { + av_log(NULL, AV_LOG_WARNING, "\n"); + } else { + av_log(NULL, AV_LOG_WARNING, "(check -ss / -t / -frames parameters if used)\n"); + } + } +} + +static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time) +{ + char buf[1024]; + AVBPrint buf_script; + OutputStream *ost; + AVFormatContext *oc; + int64_t total_size; + AVCodecContext *enc; + int frame_number, vid, i; + double bitrate; + double speed; + int64_t pts = INT64_MIN + 1; + static int64_t last_time = -1; + static int qp_histogram[52]; + int hours, mins, secs, us; + int ret; + float t; + + if (!print_stats && !is_last_report && !progress_avio) + return; + + if (!is_last_report) { + if (last_time == -1) { + last_time = cur_time; + return; + } + if ((cur_time - last_time) < 500000) + return; + last_time = cur_time; + } + + t = (cur_time-timer_start) / 1000000.0; + + + oc = output_files[0]->ctx; + + total_size = avio_size(oc->pb); + if (total_size <= 0) // FIXME improve avio_size() so it works with non seekable output too + total_size = avio_tell(oc->pb); + + buf[0] = '\0'; + vid = 0; + av_bprint_init(&buf_script, 0, 1); + for (i = 0; i < nb_output_streams; i++) { + float q = -1; + ost = output_streams[i]; + enc = ost->enc_ctx; + if (!ost->stream_copy) + q = ost->quality / (float) FF_QP2LAMBDA; + + if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); + av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", + ost->file_index, ost->index, q); + } + if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { + float fps; + + frame_number = ost->frame_number; + fps = t > 1 ? frame_number / t : 0; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3.*f q=%3.1f ", + frame_number, fps < 9.95, fps, q); + av_bprintf(&buf_script, "frame=%d\n", frame_number); + av_bprintf(&buf_script, "fps=%.1f\n", fps); + av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n", + ost->file_index, ost->index, q); + if (is_last_report) + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L"); + if (qp_hist) { + int j; + int qp = lrintf(q); + if (qp >= 0 && qp < FF_ARRAY_ELEMS(qp_histogram)) + qp_histogram[qp]++; + for (j = 0; j < 32; j++) + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", av_log2(qp_histogram[j] + 1)); + } + + if ((enc->flags & AV_CODEC_FLAG_PSNR) && (ost->pict_type != AV_PICTURE_TYPE_NONE || is_last_report)) { + int j; + double error, error_sum = 0; + double scale, scale_sum = 0; + double p; + char type[3] = { 'Y','U','V' }; + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR="); + for (j = 0; j < 3; j++) { + if (is_last_report) { + error = enc->error[j]; + scale = enc->width * enc->height * 255.0 * 255.0 * frame_number; + } else { + error = ost->error[j]; + scale = enc->width * enc->height * 255.0 * 255.0; + } + if (j) + scale /= 4; + error_sum += error; + scale_sum += scale; + p = psnr(error / scale); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], p); + av_bprintf(&buf_script, "stream_%d_%d_psnr_%c=%2.2f\n", + ost->file_index, ost->index, type[j] | 32, p); + } + p = psnr(error_sum / scale_sum); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum / scale_sum)); + av_bprintf(&buf_script, "stream_%d_%d_psnr_all=%2.2f\n", + ost->file_index, ost->index, p); + } + vid = 1; + } + /* compute min output value */ + if (av_stream_get_end_pts(ost->st) != AV_NOPTS_VALUE) + pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st), + ost->st->time_base, AV_TIME_BASE_Q)); + if (is_last_report) + nb_frames_drop += ost->last_dropped; + } + + secs = FFABS(pts) / AV_TIME_BASE; + us = FFABS(pts) % AV_TIME_BASE; + mins = secs / 60; + secs %= 60; + hours = mins / 60; + mins %= 60; + + bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1; + speed = t != 0.0 ? (double)pts / AV_TIME_BASE / t : -1; + + if (total_size < 0) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "size=N/A time="); + else snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "size=%8.0fkB time=", total_size / 1024.0); + if (pts < 0) + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "-"); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), + "%02d:%02d:%02d.%02d ", hours, mins, secs, + (100 * us) / AV_TIME_BASE); + + if (bitrate < 0) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=N/A"); + av_bprintf(&buf_script, "bitrate=N/A\n"); + }else{ + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=%6.1fkbits/s", bitrate); + av_bprintf(&buf_script, "bitrate=%6.1fkbits/s\n", bitrate); + } + + if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n"); + else av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size); + av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts); + av_bprintf(&buf_script, "out_time=%02d:%02d:%02d.%06d\n", + hours, mins, secs, us); + + if (nb_frames_dup || nb_frames_drop) + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d", + nb_frames_dup, nb_frames_drop); + av_bprintf(&buf_script, "dup_frames=%d\n", nb_frames_dup); + av_bprintf(&buf_script, "drop_frames=%d\n", nb_frames_drop); + + if (speed < 0) { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=N/A"); + av_bprintf(&buf_script, "speed=N/A\n"); + } else { + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf)," speed=%4.3gx", speed); + av_bprintf(&buf_script, "speed=%4.3gx\n", speed); + } + + if (print_stats || is_last_report) { + const char end = is_last_report ? '\n' : '\r'; + if (print_stats==1 && AV_LOG_INFO > av_log_get_level()) { + fprintf(stderr, "%s %c", buf, end); + } else + av_log(NULL, AV_LOG_INFO, "%s %c", buf, end); + + fflush(stderr); + } + + if (progress_avio) { + av_bprintf(&buf_script, "progress=%s\n", + is_last_report ? "end" : "continue"); + avio_write(progress_avio, buf_script.str, + FFMIN(buf_script.len, buf_script.size - 1)); + avio_flush(progress_avio); + av_bprint_finalize(&buf_script, NULL); + if (is_last_report) { + if ((ret = avio_closep(&progress_avio)) < 0) + av_log(NULL, AV_LOG_ERROR, + "Error closing progress log, loss of information possible: %s\n", av_err2str(ret)); + } + } + + if (is_last_report) + print_final_stats(total_size); +} + +static void flush_encoders(void) +{ + int i, ret; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + AVCodecContext *enc = ost->enc_ctx; + AVFormatContext *os = output_files[ost->file_index]->ctx; + int stop_encoding = 0; + + if (!ost->encoding_needed) + continue; + + if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) + continue; +#if FF_API_LAVF_FMT_RAWPICTURE + if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO) + continue; +#endif + + for (;;) { + int (*encode)(AVCodecContext*, AVPacket*, const AVFrame*, int*) = NULL; + const char *desc; + + switch (enc->codec_type) { + case AVMEDIA_TYPE_AUDIO: + encode = avcodec_encode_audio2; + desc = "audio"; + break; + case AVMEDIA_TYPE_VIDEO: + encode = avcodec_encode_video2; + desc = "video"; + break; + default: + stop_encoding = 1; + } + + if (encode) { + AVPacket pkt; + int pkt_size; + int got_packet; + av_init_packet(&pkt); + pkt.data = NULL; + pkt.size = 0; + + update_benchmark(NULL); + ret = encode(enc, &pkt, NULL, &got_packet); + update_benchmark("flush_%s %d.%d", desc, ost->file_index, ost->index); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n", + desc, + av_err2str(ret)); + exit_program(1); + } + if (ost->logfile && enc->stats_out) { + fprintf(ost->logfile, "%s", enc->stats_out); + } + if (!got_packet) { + stop_encoding = 1; + break; + } + if (ost->finished & MUXER_FINISHED) { + av_packet_unref(&pkt); + continue; + } + av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base); + pkt_size = pkt.size; + write_frame(os, &pkt, ost); + if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) { + do_video_stats(ost, pkt_size); + } + } + + if (stop_encoding) + break; + } + } +} + +/* + * Check whether a packet from ist should be written into ost at this time + */ +static int check_output_constraints(InputStream *ist, OutputStream *ost) +{ + OutputFile *of = output_files[ost->file_index]; + int ist_index = input_files[ist->file_index]->ist_index + ist->st->index; + + if (ost->source_index != ist_index) + return 0; + + if (ost->finished) + return 0; + + if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time) + return 0; + + return 1; +} + +static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt) +{ + OutputFile *of = output_files[ost->file_index]; + InputFile *f = input_files [ist->file_index]; + int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time; + int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->st->time_base); + AVPicture pict; + AVPacket opkt; + + av_init_packet(&opkt); + + if ((!ost->frame_number && !(pkt->flags & AV_PKT_FLAG_KEY)) && + !ost->copy_initial_nonkeyframes) + return; + + if (!ost->frame_number && !ost->copy_prior_start) { + int64_t comp_start = start_time; + if (copy_ts && f->start_time != AV_NOPTS_VALUE) + comp_start = FFMAX(start_time, f->start_time + f->ts_offset); + if (pkt->pts == AV_NOPTS_VALUE ? + ist->pts < comp_start : + pkt->pts < av_rescale_q(comp_start, AV_TIME_BASE_Q, ist->st->time_base)) + return; + } + + if (of->recording_time != INT64_MAX && + ist->pts >= of->recording_time + start_time) { + close_output_stream(ost); + return; + } + + if (f->recording_time != INT64_MAX) { + start_time = f->ctx->start_time; + if (f->start_time != AV_NOPTS_VALUE && copy_ts) + start_time += f->start_time; + if (ist->pts >= f->recording_time + start_time) { + close_output_stream(ost); + return; + } + } + + /* force the input stream PTS */ + if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) + ost->sync_opts++; + + if (pkt->pts != AV_NOPTS_VALUE) + opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->st->time_base) - ost_tb_start_time; + else + opkt.pts = AV_NOPTS_VALUE; + + if (pkt->dts == AV_NOPTS_VALUE) + opkt.dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->st->time_base); + else + opkt.dts = av_rescale_q(pkt->dts, ist->st->time_base, ost->st->time_base); + opkt.dts -= ost_tb_start_time; + + if (ost->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && pkt->dts != AV_NOPTS_VALUE) { + int duration = av_get_audio_frame_duration(ist->dec_ctx, pkt->size); + if(!duration) + duration = ist->dec_ctx->frame_size; + opkt.dts = opkt.pts = av_rescale_delta(ist->st->time_base, pkt->dts, + (AVRational){1, ist->dec_ctx->sample_rate}, duration, &ist->filter_in_rescale_delta_last, + ost->st->time_base) - ost_tb_start_time; + } + + opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->st->time_base); + opkt.flags = pkt->flags; + // FIXME remove the following 2 lines they shall be replaced by the bitstream filters + if ( ost->st->codec->codec_id != AV_CODEC_ID_H264 + && ost->st->codec->codec_id != AV_CODEC_ID_MPEG1VIDEO + && ost->st->codec->codec_id != AV_CODEC_ID_MPEG2VIDEO + && ost->st->codec->codec_id != AV_CODEC_ID_VC1 + ) { + int ret = av_parser_change(ost->parser, ost->st->codec, + &opkt.data, &opkt.size, + pkt->data, pkt->size, + pkt->flags & AV_PKT_FLAG_KEY); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "av_parser_change failed: %s\n", + av_err2str(ret)); + exit_program(1); + } + if (ret) { + opkt.buf = av_buffer_create(opkt.data, opkt.size, av_buffer_default_free, NULL, 0); + if (!opkt.buf) + exit_program(1); + } + } else { + opkt.data = pkt->data; + opkt.size = pkt->size; + } + av_copy_packet_side_data(&opkt, pkt); + +#if FF_API_LAVF_FMT_RAWPICTURE + if (ost->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && + ost->st->codec->codec_id == AV_CODEC_ID_RAWVIDEO && + (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) { + /* store AVPicture in AVPacket, as expected by the output format */ + int ret = avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "avpicture_fill failed: %s\n", + av_err2str(ret)); + exit_program(1); + } + opkt.data = (uint8_t *)&pict; + opkt.size = sizeof(AVPicture); + opkt.flags |= AV_PKT_FLAG_KEY; + } +#endif + + write_frame(of->ctx, &opkt, ost); +} + +int guess_input_channel_layout(InputStream *ist) +{ + AVCodecContext *dec = ist->dec_ctx; + + if (!dec->channel_layout) { + char layout_name[256]; + + if (dec->channels > ist->guess_layout_max) + return 0; + dec->channel_layout = av_get_default_channel_layout(dec->channels); + if (!dec->channel_layout) + return 0; + av_get_channel_layout_string(layout_name, sizeof(layout_name), + dec->channels, dec->channel_layout); + av_log(NULL, AV_LOG_WARNING, "Guessed Channel Layout for Input Stream " + "#%d.%d : %s\n", ist->file_index, ist->st->index, layout_name); + } + return 1; +} + +static void check_decode_result(InputStream *ist, int *got_output, int ret) +{ + if (*got_output || ret<0) + decode_error_stat[ret<0] ++; + + if (ret < 0 && exit_on_error) + exit_program(1); + + if (exit_on_error && *got_output && ist) { + if (av_frame_get_decode_error_flags(ist->decoded_frame) || (ist->decoded_frame->flags & AV_FRAME_FLAG_CORRUPT)) { + av_log(NULL, AV_LOG_FATAL, "%s: corrupt decoded frame in stream %d\n", input_files[ist->file_index]->ctx->filename, ist->st->index); + exit_program(1); + } + } +} + +static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) +{ + AVFrame *decoded_frame, *f; + AVCodecContext *avctx = ist->dec_ctx; + int i, ret, err = 0, resample_changed; + AVRational decoded_frame_tb; + + if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + decoded_frame = ist->decoded_frame; + + update_benchmark(NULL); + ret = avcodec_decode_audio4(avctx, decoded_frame, got_output, pkt); + update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index); + + if (ret >= 0 && avctx->sample_rate <= 0) { + av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate); + ret = AVERROR_INVALIDDATA; + } + + check_decode_result(ist, got_output, ret); + + if (!*got_output || ret < 0) + return ret; + + ist->samples_decoded += decoded_frame->nb_samples; + ist->frames_decoded++; + +#if 1 + /* increment next_dts to use for the case where the input stream does not + have timestamps or there are multiple frames in the packet */ + ist->next_pts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / + avctx->sample_rate; + ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / + avctx->sample_rate; +#endif + + resample_changed = ist->resample_sample_fmt != decoded_frame->format || + ist->resample_channels != avctx->channels || + ist->resample_channel_layout != decoded_frame->channel_layout || + ist->resample_sample_rate != decoded_frame->sample_rate; + if (resample_changed) { + char layout1[64], layout2[64]; + + if (!guess_input_channel_layout(ist)) { + av_log(NULL, AV_LOG_FATAL, "Unable to find default channel " + "layout for Input Stream #%d.%d\n", ist->file_index, + ist->st->index); + exit_program(1); + } + decoded_frame->channel_layout = avctx->channel_layout; + + av_get_channel_layout_string(layout1, sizeof(layout1), ist->resample_channels, + ist->resample_channel_layout); + av_get_channel_layout_string(layout2, sizeof(layout2), avctx->channels, + decoded_frame->channel_layout); + + av_log(NULL, AV_LOG_INFO, + "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:%s to rate:%d fmt:%s ch:%d chl:%s\n", + ist->file_index, ist->st->index, + ist->resample_sample_rate, av_get_sample_fmt_name(ist->resample_sample_fmt), + ist->resample_channels, layout1, + decoded_frame->sample_rate, av_get_sample_fmt_name(decoded_frame->format), + avctx->channels, layout2); + + ist->resample_sample_fmt = decoded_frame->format; + ist->resample_sample_rate = decoded_frame->sample_rate; + ist->resample_channel_layout = decoded_frame->channel_layout; + ist->resample_channels = avctx->channels; + + for (i = 0; i < nb_filtergraphs; i++) + if (ist_in_filtergraph(filtergraphs[i], ist)) { + FilterGraph *fg = filtergraphs[i]; + if (configure_filtergraph(fg) < 0) { + av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n"); + exit_program(1); + } + } + } + + /* if the decoder provides a pts, use it instead of the last packet pts. + the decoder could be delaying output by a packet or more. */ + if (decoded_frame->pts != AV_NOPTS_VALUE) { + ist->dts = ist->next_dts = ist->pts = ist->next_pts = av_rescale_q(decoded_frame->pts, avctx->time_base, AV_TIME_BASE_Q); + decoded_frame_tb = avctx->time_base; + } else if (decoded_frame->pkt_pts != AV_NOPTS_VALUE) { + decoded_frame->pts = decoded_frame->pkt_pts; + decoded_frame_tb = ist->st->time_base; + } else if (pkt->pts != AV_NOPTS_VALUE) { + decoded_frame->pts = pkt->pts; + decoded_frame_tb = ist->st->time_base; + }else { + decoded_frame->pts = ist->dts; + decoded_frame_tb = AV_TIME_BASE_Q; + } + pkt->pts = AV_NOPTS_VALUE; + if (decoded_frame->pts != AV_NOPTS_VALUE) + decoded_frame->pts = av_rescale_delta(decoded_frame_tb, decoded_frame->pts, + (AVRational){1, avctx->sample_rate}, decoded_frame->nb_samples, &ist->filter_in_rescale_delta_last, + (AVRational){1, avctx->sample_rate}); + ist->nb_samples = decoded_frame->nb_samples; + for (i = 0; i < ist->nb_filters; i++) { + if (i < ist->nb_filters - 1) { + f = ist->filter_frame; + err = av_frame_ref(f, decoded_frame); + if (err < 0) + break; + } else + f = decoded_frame; + err = av_buffersrc_add_frame_flags(ist->filters[i]->filter, f, + AV_BUFFERSRC_FLAG_PUSH); + if (err == AVERROR_EOF) + err = 0; /* ignore */ + if (err < 0) + break; + } + decoded_frame->pts = AV_NOPTS_VALUE; + + av_frame_unref(ist->filter_frame); + av_frame_unref(decoded_frame); + return err < 0 ? err : ret; +} + +static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output) +{ + AVFrame *decoded_frame, *f; + int i, ret = 0, err = 0, resample_changed; + int64_t best_effort_timestamp; + AVRational *frame_sample_aspect; + + if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) + return AVERROR(ENOMEM); + decoded_frame = ist->decoded_frame; + pkt->dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ist->st->time_base); + + update_benchmark(NULL); + ret = avcodec_decode_video2(ist->dec_ctx, + decoded_frame, got_output, pkt); + update_benchmark("decode_video %d.%d", ist->file_index, ist->st->index); + + // The following line may be required in some cases where there is no parser + // or the parser does not has_b_frames correctly + if (ist->st->codec->has_b_frames < ist->dec_ctx->has_b_frames) { + if (ist->dec_ctx->codec_id == AV_CODEC_ID_H264) { + ist->st->codec->has_b_frames = ist->dec_ctx->has_b_frames; + } else + av_log(ist->dec_ctx, AV_LOG_WARNING, + "has_b_frames is larger in decoder than demuxer %d > %d.\n" + "If you want to help, upload a sample " + "of this file to ftp://upload.ffmpeg.org/incoming/ " + "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)", + ist->dec_ctx->has_b_frames, + ist->st->codec->has_b_frames); + } + + check_decode_result(ist, got_output, ret); + + if (*got_output && ret >= 0) { + if (ist->dec_ctx->width != decoded_frame->width || + ist->dec_ctx->height != decoded_frame->height || + ist->dec_ctx->pix_fmt != decoded_frame->format) { + av_log(NULL, AV_LOG_DEBUG, "Frame parameters mismatch context %d,%d,%d != %d,%d,%d\n", + decoded_frame->width, + decoded_frame->height, + decoded_frame->format, + ist->dec_ctx->width, + ist->dec_ctx->height, + ist->dec_ctx->pix_fmt); + } + } + + if (!*got_output || ret < 0) + return ret; + + if(ist->top_field_first>=0) + decoded_frame->top_field_first = ist->top_field_first; + + ist->frames_decoded++; + + if (ist->hwaccel_retrieve_data && decoded_frame->format == ist->hwaccel_pix_fmt) { + err = ist->hwaccel_retrieve_data(ist->dec_ctx, decoded_frame); + if (err < 0) + goto fail; + } + ist->hwaccel_retrieved_pix_fmt = decoded_frame->format; + + best_effort_timestamp= av_frame_get_best_effort_timestamp(decoded_frame); + if(best_effort_timestamp != AV_NOPTS_VALUE) + ist->next_pts = ist->pts = av_rescale_q(decoded_frame->pts = best_effort_timestamp, ist->st->time_base, AV_TIME_BASE_Q); + + if (debug_ts) { + av_log(NULL, AV_LOG_INFO, "decoder -> ist_index:%d type:video " + "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64" best_effort_ts_time:%s keyframe:%d frame_type:%d time_base:%d/%d\n", + ist->st->index, av_ts2str(decoded_frame->pts), + av_ts2timestr(decoded_frame->pts, &ist->st->time_base), + best_effort_timestamp, + av_ts2timestr(best_effort_timestamp, &ist->st->time_base), + decoded_frame->key_frame, decoded_frame->pict_type, + ist->st->time_base.num, ist->st->time_base.den); + } + + pkt->size = 0; + + if (ist->st->sample_aspect_ratio.num) + decoded_frame->sample_aspect_ratio = ist->st->sample_aspect_ratio; + + resample_changed = ist->resample_width != decoded_frame->width || + ist->resample_height != decoded_frame->height || + ist->resample_pix_fmt != decoded_frame->format; + if (resample_changed) { + av_log(NULL, AV_LOG_INFO, + "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n", + ist->file_index, ist->st->index, + ist->resample_width, ist->resample_height, av_get_pix_fmt_name(ist->resample_pix_fmt), + decoded_frame->width, decoded_frame->height, av_get_pix_fmt_name(decoded_frame->format)); + + ist->resample_width = decoded_frame->width; + ist->resample_height = decoded_frame->height; + ist->resample_pix_fmt = decoded_frame->format; + + for (i = 0; i < nb_filtergraphs; i++) { + if (ist_in_filtergraph(filtergraphs[i], ist) && ist->reinit_filters && + configure_filtergraph(filtergraphs[i]) < 0) { + av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n"); + exit_program(1); + } + } + } + + frame_sample_aspect= av_opt_ptr(avcodec_get_frame_class(), decoded_frame, "sample_aspect_ratio"); + for (i = 0; i < ist->nb_filters; i++) { + if (!frame_sample_aspect->num) + *frame_sample_aspect = ist->st->sample_aspect_ratio; + + if (i < ist->nb_filters - 1) { + f = ist->filter_frame; + err = av_frame_ref(f, decoded_frame); + if (err < 0) + break; + } else + f = decoded_frame; + ret = av_buffersrc_add_frame_flags(ist->filters[i]->filter, f, AV_BUFFERSRC_FLAG_PUSH); + if (ret == AVERROR_EOF) { + ret = 0; /* ignore */ + } else if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Failed to inject frame into filter network: %s\n", av_err2str(ret)); + exit_program(1); + } + } + +fail: + av_frame_unref(ist->filter_frame); + av_frame_unref(decoded_frame); + return err < 0 ? err : ret; +} + +static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output) +{ + AVSubtitle subtitle; + int i, ret = avcodec_decode_subtitle2(ist->dec_ctx, + &subtitle, got_output, pkt); + + check_decode_result(NULL, got_output, ret); + + if (ret < 0 || !*got_output) { + if (!pkt->size) + sub2video_flush(ist); + return ret; + } + + if (ist->fix_sub_duration) { + int end = 1; + if (ist->prev_sub.got_output) { + end = av_rescale(subtitle.pts - ist->prev_sub.subtitle.pts, + 1000, AV_TIME_BASE); + if (end < ist->prev_sub.subtitle.end_display_time) { + av_log(ist->dec_ctx, AV_LOG_DEBUG, + "Subtitle duration reduced from %d to %d%s\n", + ist->prev_sub.subtitle.end_display_time, end, + end <= 0 ? ", dropping it" : ""); + ist->prev_sub.subtitle.end_display_time = end; + } + } + FFSWAP(int, *got_output, ist->prev_sub.got_output); + FFSWAP(int, ret, ist->prev_sub.ret); + FFSWAP(AVSubtitle, subtitle, ist->prev_sub.subtitle); + if (end <= 0) + goto out; + } + + if (!*got_output) + return ret; + + sub2video_update(ist, &subtitle); + + if (!subtitle.num_rects) + goto out; + + ist->frames_decoded++; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + + if (!check_output_constraints(ist, ost) || !ost->encoding_needed + || ost->enc->type != AVMEDIA_TYPE_SUBTITLE) + continue; + + do_subtitle_out(output_files[ost->file_index]->ctx, ost, ist, &subtitle); + } + +out: + avsubtitle_free(&subtitle); + return ret; +} + +static int send_filter_eof(InputStream *ist) +{ + int i, ret; + for (i = 0; i < ist->nb_filters; i++) { + ret = av_buffersrc_add_frame(ist->filters[i]->filter, NULL); + if (ret < 0) + return ret; + } + return 0; +} + +/* pkt = NULL means EOF (needed to flush decoder buffers) */ +static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof) +{ + int ret = 0, i; + int got_output = 0; + + AVPacket avpkt; + if (!ist->saw_first_ts) { + ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0; + ist->pts = 0; + if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) { + ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q); + ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong + } + ist->saw_first_ts = 1; + } + + if (ist->next_dts == AV_NOPTS_VALUE) + ist->next_dts = ist->dts; + if (ist->next_pts == AV_NOPTS_VALUE) + ist->next_pts = ist->pts; + + if (!pkt) { + /* EOF handling */ + av_init_packet(&avpkt); + avpkt.data = NULL; + avpkt.size = 0; + goto handle_eof; + } else { + avpkt = *pkt; + } + + if (pkt->dts != AV_NOPTS_VALUE) { + ist->next_dts = ist->dts = av_rescale_q(pkt->dts, ist->st->time_base, AV_TIME_BASE_Q); + if (ist->dec_ctx->codec_type != AVMEDIA_TYPE_VIDEO || !ist->decoding_needed) + ist->next_pts = ist->pts = ist->dts; + } + + // while we have more to decode or while the decoder did output something on EOF + while (ist->decoding_needed && (avpkt.size > 0 || (!pkt && got_output))) { + int duration; + handle_eof: + + ist->pts = ist->next_pts; + ist->dts = ist->next_dts; + + if (avpkt.size && avpkt.size != pkt->size && + !(ist->dec->capabilities & AV_CODEC_CAP_SUBFRAMES)) { + av_log(NULL, ist->showed_multi_packet_warning ? AV_LOG_VERBOSE : AV_LOG_WARNING, + "Multiple frames in a packet from stream %d\n", pkt->stream_index); + ist->showed_multi_packet_warning = 1; + } + + switch (ist->dec_ctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + ret = decode_audio (ist, &avpkt, &got_output); + break; + case AVMEDIA_TYPE_VIDEO: + ret = decode_video (ist, &avpkt, &got_output); + if (avpkt.duration) { + duration = av_rescale_q(avpkt.duration, ist->st->time_base, AV_TIME_BASE_Q); + } else if(ist->dec_ctx->framerate.num != 0 && ist->dec_ctx->framerate.den != 0) { + int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict+1 : ist->dec_ctx->ticks_per_frame; + duration = ((int64_t)AV_TIME_BASE * + ist->dec_ctx->framerate.den * ticks) / + ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame; + } else + duration = 0; + + if(ist->dts != AV_NOPTS_VALUE && duration) { + ist->next_dts += duration; + }else + ist->next_dts = AV_NOPTS_VALUE; + + if (got_output) + ist->next_pts += duration; //FIXME the duration is not correct in some cases + break; + case AVMEDIA_TYPE_SUBTITLE: + ret = transcode_subtitles(ist, &avpkt, &got_output); + break; + default: + return -1; + } + + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, "Error while decoding stream #%d:%d: %s\n", + ist->file_index, ist->st->index, av_err2str(ret)); + if (exit_on_error) + exit_program(1); + break; + } + + avpkt.dts= + avpkt.pts= AV_NOPTS_VALUE; + + // touch data and size only if not EOF + if (pkt) { + if(ist->dec_ctx->codec_type != AVMEDIA_TYPE_AUDIO) + ret = avpkt.size; + avpkt.data += ret; + avpkt.size -= ret; + } + if (!got_output) { + continue; + } + if (got_output && !pkt) + break; + } + + /* after flushing, send an EOF on all the filter inputs attached to the stream */ + /* except when looping we need to flush but not to send an EOF */ + if (!pkt && ist->decoding_needed && !got_output && !no_eof) { + int ret = send_filter_eof(ist); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, "Error marking filters as finished\n"); + exit_program(1); + } + } + + /* handle stream copy */ + if (!ist->decoding_needed) { + ist->dts = ist->next_dts; + switch (ist->dec_ctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) / + ist->dec_ctx->sample_rate; + break; + case AVMEDIA_TYPE_VIDEO: + if (ist->framerate.num) { + // TODO: Remove work-around for c99-to-c89 issue 7 + AVRational time_base_q = AV_TIME_BASE_Q; + int64_t next_dts = av_rescale_q(ist->next_dts, time_base_q, av_inv_q(ist->framerate)); + ist->next_dts = av_rescale_q(next_dts + 1, av_inv_q(ist->framerate), time_base_q); + } else if (pkt->duration) { + ist->next_dts += av_rescale_q(pkt->duration, ist->st->time_base, AV_TIME_BASE_Q); + } else if(ist->dec_ctx->framerate.num != 0) { + int ticks= av_stream_get_parser(ist->st) ? av_stream_get_parser(ist->st)->repeat_pict + 1 : ist->dec_ctx->ticks_per_frame; + ist->next_dts += ((int64_t)AV_TIME_BASE * + ist->dec_ctx->framerate.den * ticks) / + ist->dec_ctx->framerate.num / ist->dec_ctx->ticks_per_frame; + } + break; + } + ist->pts = ist->dts; + ist->next_pts = ist->next_dts; + } + for (i = 0; pkt && i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + + if (!check_output_constraints(ist, ost) || ost->encoding_needed) + continue; + + do_streamcopy(ist, ost, pkt); + } + + return got_output; +} + +static void print_sdp(void) +{ + char sdp[16384]; + int i; + int j; + AVIOContext *sdp_pb; + AVFormatContext **avc = av_malloc_array(nb_output_files, sizeof(*avc)); + + if (!avc) + exit_program(1); + for (i = 0, j = 0; i < nb_output_files; i++) { + if (!strcmp(output_files[i]->ctx->oformat->name, "rtp")) { + avc[j] = output_files[i]->ctx; + j++; + } + } + + if (!j) + goto fail; + + av_sdp_create(avc, j, sdp, sizeof(sdp)); + + if (!sdp_filename) { + printf("SDP:\n%s\n", sdp); + fflush(stdout); + } else { + if (avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL) < 0) { + av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename); + } else { + avio_printf(sdp_pb, "SDP:\n%s", sdp); + avio_closep(&sdp_pb); + av_freep(&sdp_filename); + } + } + +fail: + av_freep(&avc); +} + +static const HWAccel *get_hwaccel(enum AVPixelFormat pix_fmt) +{ + int i; + for (i = 0; hwaccels[i].name; i++) + if (hwaccels[i].pix_fmt == pix_fmt) + return &hwaccels[i]; + return NULL; +} + +static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts) +{ + InputStream *ist = s->opaque; + const enum AVPixelFormat *p; + int ret; + + for (p = pix_fmts; *p != -1; p++) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p); + const HWAccel *hwaccel; + + if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) + break; + + hwaccel = get_hwaccel(*p); + if (!hwaccel || + (ist->active_hwaccel_id && ist->active_hwaccel_id != hwaccel->id) || + (ist->hwaccel_id != HWACCEL_AUTO && ist->hwaccel_id != hwaccel->id)) + continue; + + ret = hwaccel->init(s); + if (ret < 0) { + if (ist->hwaccel_id == hwaccel->id) { + av_log(NULL, AV_LOG_FATAL, + "%s hwaccel requested for input stream #%d:%d, " + "but cannot be initialized.\n", hwaccel->name, + ist->file_index, ist->st->index); + return AV_PIX_FMT_NONE; + } + continue; + } + ist->active_hwaccel_id = hwaccel->id; + ist->hwaccel_pix_fmt = *p; + break; + } + + return *p; +} + +static int get_buffer(AVCodecContext *s, AVFrame *frame, int flags) +{ + InputStream *ist = s->opaque; + + if (ist->hwaccel_get_buffer && frame->format == ist->hwaccel_pix_fmt) + return ist->hwaccel_get_buffer(s, frame, flags); + + return avcodec_default_get_buffer2(s, frame, flags); +} + +static int init_input_stream(int ist_index, char *error, int error_len) +{ + int ret; + InputStream *ist = input_streams[ist_index]; + + if (ist->decoding_needed) { + AVCodec *codec = ist->dec; + if (!codec) { + snprintf(error, error_len, "Decoder (codec %s) not found for input stream #%d:%d", + avcodec_get_name(ist->dec_ctx->codec_id), ist->file_index, ist->st->index); + return AVERROR(EINVAL); + } + + ist->dec_ctx->opaque = ist; + ist->dec_ctx->get_format = get_format; + ist->dec_ctx->get_buffer2 = get_buffer; + ist->dec_ctx->thread_safe_callbacks = 1; + + av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0); + if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE && + (ist->decoding_needed & DECODING_FOR_OST)) { + av_dict_set(&ist->decoder_opts, "compute_edt", "1", AV_DICT_DONT_OVERWRITE); + if (ist->decoding_needed & DECODING_FOR_FILTER) + av_log(NULL, AV_LOG_WARNING, "Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n"); + } + + if (!av_dict_get(ist->decoder_opts, "threads", NULL, 0)) + av_dict_set(&ist->decoder_opts, "threads", "auto", 0); + if ((ret = avcodec_open2(ist->dec_ctx, codec, &ist->decoder_opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 0); + + snprintf(error, error_len, + "Error while opening decoder for input stream " + "#%d:%d : %s", + ist->file_index, ist->st->index, av_err2str(ret)); + return ret; + } + assert_avoptions(ist->decoder_opts); + } + + ist->next_pts = AV_NOPTS_VALUE; + ist->next_dts = AV_NOPTS_VALUE; + + return 0; +} + +static InputStream *get_input_stream(OutputStream *ost) +{ + if (ost->source_index >= 0) + return input_streams[ost->source_index]; + return NULL; +} + +static int compare_int64(const void *a, const void *b) +{ + return FFDIFFSIGN(*(const int64_t *)a, *(const int64_t *)b); +} + +static int init_output_stream(OutputStream *ost, char *error, int error_len) +{ + int ret = 0; + + if (ost->encoding_needed) { + AVCodec *codec = ost->enc; + AVCodecContext *dec = NULL; + InputStream *ist; + + if ((ist = get_input_stream(ost))) + dec = ist->dec_ctx; + if (dec && dec->subtitle_header) { + /* ASS code assumes this buffer is null terminated so add extra byte. */ + ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1); + if (!ost->enc_ctx->subtitle_header) + return AVERROR(ENOMEM); + memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size); + ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size; + } + if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0)) + av_dict_set(&ost->encoder_opts, "threads", "auto", 0); + if (ost->enc->type == AVMEDIA_TYPE_AUDIO && + !codec->defaults && + !av_dict_get(ost->encoder_opts, "b", NULL, 0) && + !av_dict_get(ost->encoder_opts, "ab", NULL, 0)) + av_dict_set(&ost->encoder_opts, "b", "128000", 0); + + if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) { + if (ret == AVERROR_EXPERIMENTAL) + abort_codec_experimental(codec, 1); + snprintf(error, error_len, + "Error while opening encoder for output stream #%d:%d - " + "maybe incorrect parameters such as bit_rate, rate, width or height", + ost->file_index, ost->index); + return ret; + } + if (ost->enc->type == AVMEDIA_TYPE_AUDIO && + !(ost->enc->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)) + av_buffersink_set_frame_size(ost->filter->filter, + ost->enc_ctx->frame_size); + assert_avoptions(ost->encoder_opts); + if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000) + av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." + " It takes bits/s as argument, not kbits/s\n"); + + ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error initializing the output stream codec context.\n"); + exit_program(1); + } + + if (ost->enc_ctx->nb_coded_side_data) { + int i; + + ost->st->side_data = av_realloc_array(NULL, ost->enc_ctx->nb_coded_side_data, + sizeof(*ost->st->side_data)); + if (!ost->st->side_data) + return AVERROR(ENOMEM); + + for (i = 0; i < ost->enc_ctx->nb_coded_side_data; i++) { + const AVPacketSideData *sd_src = &ost->enc_ctx->coded_side_data[i]; + AVPacketSideData *sd_dst = &ost->st->side_data[i]; + + sd_dst->data = av_malloc(sd_src->size); + if (!sd_dst->data) + return AVERROR(ENOMEM); + memcpy(sd_dst->data, sd_src->data, sd_src->size); + sd_dst->size = sd_src->size; + sd_dst->type = sd_src->type; + ost->st->nb_side_data++; + } + } + + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->enc_ctx->time_base, (AVRational){0, 1}); + ost->st->codec->codec= ost->enc_ctx->codec; + } else { + ret = av_opt_set_dict(ost->enc_ctx, &ost->encoder_opts); + if (ret < 0) { + av_log(NULL, AV_LOG_FATAL, + "Error setting up codec context options.\n"); + return ret; + } + // copy timebase while removing common factors + ost->st->time_base = av_add_q(ost->st->codec->time_base, (AVRational){0, 1}); + } + + return ret; +} + +static void parse_forced_key_frames(char *kf, OutputStream *ost, + AVCodecContext *avctx) +{ + char *p; + int n = 1, i, size, index = 0; + int64_t t, *pts; + + for (p = kf; *p; p++) + if (*p == ',') + n++; + size = n; + pts = av_malloc_array(size, sizeof(*pts)); + if (!pts) { + av_log(NULL, AV_LOG_FATAL, "Could not allocate forced key frames array.\n"); + exit_program(1); + } + + p = kf; + for (i = 0; i < n; i++) { + char *next = strchr(p, ','); + + if (next) + *next++ = 0; + + if (!memcmp(p, "chapters", 8)) { + + AVFormatContext *avf = output_files[ost->file_index]->ctx; + int j; + + if (avf->nb_chapters > INT_MAX - size || + !(pts = av_realloc_f(pts, size += avf->nb_chapters - 1, + sizeof(*pts)))) { + av_log(NULL, AV_LOG_FATAL, + "Could not allocate forced key frames array.\n"); + exit_program(1); + } + t = p[8] ? parse_time_or_die("force_key_frames", p + 8, 1) : 0; + t = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base); + + for (j = 0; j < avf->nb_chapters; j++) { + AVChapter *c = avf->chapters[j]; + av_assert1(index < size); + pts[index++] = av_rescale_q(c->start, c->time_base, + avctx->time_base) + t; + } + + } else { + + t = parse_time_or_die("force_key_frames", p, 1); + av_assert1(index < size); + pts[index++] = av_rescale_q(t, AV_TIME_BASE_Q, avctx->time_base); + + } + + p = next; + } + + av_assert0(index == size); + qsort(pts, size, sizeof(*pts), compare_int64); + ost->forced_kf_count = size; + ost->forced_kf_pts = pts; +} + +static void report_new_stream(int input_index, AVPacket *pkt) +{ + InputFile *file = input_files[input_index]; + AVStream *st = file->ctx->streams[pkt->stream_index]; + + if (pkt->stream_index < file->nb_streams_warn) + return; + av_log(file->ctx, AV_LOG_WARNING, + "New %s stream %d:%d at pos:%"PRId64" and DTS:%ss\n", + av_get_media_type_string(st->codec->codec_type), + input_index, pkt->stream_index, + pkt->pos, av_ts2timestr(pkt->dts, &st->time_base)); + file->nb_streams_warn = pkt->stream_index + 1; +} + +static void set_encoder_id(OutputFile *of, OutputStream *ost) +{ + AVDictionaryEntry *e; + + uint8_t *encoder_string; + int encoder_string_len; + int format_flags = 0; + int codec_flags = 0; + + if (av_dict_get(ost->st->metadata, "encoder", NULL, 0)) + return; + + e = av_dict_get(of->opts, "fflags", NULL, 0); + if (e) { + const AVOption *o = av_opt_find(of->ctx, "fflags", NULL, 0, 0); + if (!o) + return; + av_opt_eval_flags(of->ctx, o, e->value, &format_flags); + } + e = av_dict_get(ost->encoder_opts, "flags", NULL, 0); + if (e) { + const AVOption *o = av_opt_find(ost->enc_ctx, "flags", NULL, 0, 0); + if (!o) + return; + av_opt_eval_flags(ost->enc_ctx, o, e->value, &codec_flags); + } + + encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(ost->enc->name) + 2; + encoder_string = av_mallocz(encoder_string_len); + if (!encoder_string) + exit_program(1); + + if (!(format_flags & AVFMT_FLAG_BITEXACT) && !(codec_flags & AV_CODEC_FLAG_BITEXACT)) + av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len); + else + av_strlcpy(encoder_string, "Lavc ", encoder_string_len); + av_strlcat(encoder_string, ost->enc->name, encoder_string_len); + av_dict_set(&ost->st->metadata, "encoder", encoder_string, + AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE); +} + +static int transcode_init(void) +{ + int ret = 0, i, j, k; + AVFormatContext *oc; + OutputStream *ost; + InputStream *ist; + char error[1024] = {0}; + int want_sdp = 1; + + for (i = 0; i < nb_filtergraphs; i++) { + FilterGraph *fg = filtergraphs[i]; + for (j = 0; j < fg->nb_outputs; j++) { + OutputFilter *ofilter = fg->outputs[j]; + if (!ofilter->ost || ofilter->ost->source_index >= 0) + continue; + if (fg->nb_inputs != 1) + continue; + for (k = nb_input_streams-1; k >= 0 ; k--) + if (fg->inputs[0]->ist == input_streams[k]) + break; + ofilter->ost->source_index = k; + } + } + + /* init framerate emulation */ + for (i = 0; i < nb_input_files; i++) { + InputFile *ifile = input_files[i]; + if (ifile->rate_emu) + for (j = 0; j < ifile->nb_streams; j++) + input_streams[j + ifile->ist_index]->start = av_gettime_relative(); + } + + /* for each output stream, we compute the right encoding parameters */ + for (i = 0; i < nb_output_streams; i++) { + AVCodecContext *enc_ctx; + AVCodecContext *dec_ctx = NULL; + ost = output_streams[i]; + oc = output_files[ost->file_index]->ctx; + ist = get_input_stream(ost); + + if (ost->attachment_filename) + continue; + + enc_ctx = ost->stream_copy ? ost->st->codec : ost->enc_ctx; + + if (ist) { + dec_ctx = ist->dec_ctx; + + ost->st->disposition = ist->st->disposition; + enc_ctx->bits_per_raw_sample = dec_ctx->bits_per_raw_sample; + enc_ctx->chroma_sample_location = dec_ctx->chroma_sample_location; + } else { + for (j=0; jnb_streams; j++) { + AVStream *st = oc->streams[j]; + if (st != ost->st && st->codec->codec_type == enc_ctx->codec_type) + break; + } + if (j == oc->nb_streams) + if (enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO || enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) + ost->st->disposition = AV_DISPOSITION_DEFAULT; + } + + if (ost->stream_copy) { + AVRational sar; + uint64_t extra_size; + + av_assert0(ist && !ost->filter); + + extra_size = (uint64_t)dec_ctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE; + + if (extra_size > INT_MAX) { + return AVERROR(EINVAL); + } + + /* if stream_copy is selected, no need to decode or encode */ + enc_ctx->codec_id = dec_ctx->codec_id; + enc_ctx->codec_type = dec_ctx->codec_type; + + if (!enc_ctx->codec_tag) { + unsigned int codec_tag; + if (!oc->oformat->codec_tag || + av_codec_get_id (oc->oformat->codec_tag, dec_ctx->codec_tag) == enc_ctx->codec_id || + !av_codec_get_tag2(oc->oformat->codec_tag, dec_ctx->codec_id, &codec_tag)) + enc_ctx->codec_tag = dec_ctx->codec_tag; + } + + enc_ctx->bit_rate = dec_ctx->bit_rate; + enc_ctx->rc_max_rate = dec_ctx->rc_max_rate; + enc_ctx->rc_buffer_size = dec_ctx->rc_buffer_size; + enc_ctx->field_order = dec_ctx->field_order; + if (dec_ctx->extradata_size) { + enc_ctx->extradata = av_mallocz(extra_size); + if (!enc_ctx->extradata) { + return AVERROR(ENOMEM); + } + memcpy(enc_ctx->extradata, dec_ctx->extradata, dec_ctx->extradata_size); + } + enc_ctx->extradata_size= dec_ctx->extradata_size; + enc_ctx->bits_per_coded_sample = dec_ctx->bits_per_coded_sample; + + enc_ctx->time_base = ist->st->time_base; + /* + * Avi is a special case here because it supports variable fps but + * having the fps and timebase differe significantly adds quite some + * overhead + */ + if(!strcmp(oc->oformat->name, "avi")) { + if ( copy_tb<0 && av_q2d(ist->st->r_frame_rate) >= av_q2d(ist->st->avg_frame_rate) + && 0.5/av_q2d(ist->st->r_frame_rate) > av_q2d(ist->st->time_base) + && 0.5/av_q2d(ist->st->r_frame_rate) > av_q2d(dec_ctx->time_base) + && av_q2d(ist->st->time_base) < 1.0/500 && av_q2d(dec_ctx->time_base) < 1.0/500 + || copy_tb==2){ + enc_ctx->time_base.num = ist->st->r_frame_rate.den; + enc_ctx->time_base.den = 2*ist->st->r_frame_rate.num; + enc_ctx->ticks_per_frame = 2; + } else if ( copy_tb<0 && av_q2d(dec_ctx->time_base)*dec_ctx->ticks_per_frame > 2*av_q2d(ist->st->time_base) + && av_q2d(ist->st->time_base) < 1.0/500 + || copy_tb==0){ + enc_ctx->time_base = dec_ctx->time_base; + enc_ctx->time_base.num *= dec_ctx->ticks_per_frame; + enc_ctx->time_base.den *= 2; + enc_ctx->ticks_per_frame = 2; + } + } else if(!(oc->oformat->flags & AVFMT_VARIABLE_FPS) + && strcmp(oc->oformat->name, "mov") && strcmp(oc->oformat->name, "mp4") && strcmp(oc->oformat->name, "3gp") + && strcmp(oc->oformat->name, "3g2") && strcmp(oc->oformat->name, "psp") && strcmp(oc->oformat->name, "ipod") + && strcmp(oc->oformat->name, "f4v") + ) { + if( copy_tb<0 && dec_ctx->time_base.den + && av_q2d(dec_ctx->time_base)*dec_ctx->ticks_per_frame > av_q2d(ist->st->time_base) + && av_q2d(ist->st->time_base) < 1.0/500 + || copy_tb==0){ + enc_ctx->time_base = dec_ctx->time_base; + enc_ctx->time_base.num *= dec_ctx->ticks_per_frame; + } + } + if ( enc_ctx->codec_tag == AV_RL32("tmcd") + && dec_ctx->time_base.num < dec_ctx->time_base.den + && dec_ctx->time_base.num > 0 + && 121LL*dec_ctx->time_base.num > dec_ctx->time_base.den) { + enc_ctx->time_base = dec_ctx->time_base; + } + + if (!ost->frame_rate.num) + ost->frame_rate = ist->framerate; + if(ost->frame_rate.num) + enc_ctx->time_base = av_inv_q(ost->frame_rate); + + av_reduce(&enc_ctx->time_base.num, &enc_ctx->time_base.den, + enc_ctx->time_base.num, enc_ctx->time_base.den, INT_MAX); + + if (ist->st->nb_side_data) { + ost->st->side_data = av_realloc_array(NULL, ist->st->nb_side_data, + sizeof(*ist->st->side_data)); + if (!ost->st->side_data) + return AVERROR(ENOMEM); + + ost->st->nb_side_data = 0; + for (j = 0; j < ist->st->nb_side_data; j++) { + const AVPacketSideData *sd_src = &ist->st->side_data[j]; + AVPacketSideData *sd_dst = &ost->st->side_data[ost->st->nb_side_data]; + + if (ost->rotate_overridden && sd_src->type == AV_PKT_DATA_DISPLAYMATRIX) + continue; + + sd_dst->data = av_malloc(sd_src->size); + if (!sd_dst->data) + return AVERROR(ENOMEM); + memcpy(sd_dst->data, sd_src->data, sd_src->size); + sd_dst->size = sd_src->size; + sd_dst->type = sd_src->type; + ost->st->nb_side_data++; + } + } + + ost->parser = av_parser_init(enc_ctx->codec_id); + + switch (enc_ctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + if (audio_volume != 256) { + av_log(NULL, AV_LOG_FATAL, "-acodec copy and -vol are incompatible (frames are not decoded)\n"); + exit_program(1); + } + enc_ctx->channel_layout = dec_ctx->channel_layout; + enc_ctx->sample_rate = dec_ctx->sample_rate; + enc_ctx->channels = dec_ctx->channels; + enc_ctx->frame_size = dec_ctx->frame_size; + enc_ctx->audio_service_type = dec_ctx->audio_service_type; + enc_ctx->block_align = dec_ctx->block_align; + enc_ctx->initial_padding = dec_ctx->delay; + enc_ctx->profile = dec_ctx->profile; +#if FF_API_AUDIOENC_DELAY + enc_ctx->delay = dec_ctx->delay; +#endif + if((enc_ctx->block_align == 1 || enc_ctx->block_align == 1152 || enc_ctx->block_align == 576) && enc_ctx->codec_id == AV_CODEC_ID_MP3) + enc_ctx->block_align= 0; + if(enc_ctx->codec_id == AV_CODEC_ID_AC3) + enc_ctx->block_align= 0; + break; + case AVMEDIA_TYPE_VIDEO: + enc_ctx->pix_fmt = dec_ctx->pix_fmt; + enc_ctx->width = dec_ctx->width; + enc_ctx->height = dec_ctx->height; + enc_ctx->has_b_frames = dec_ctx->has_b_frames; + if (ost->frame_aspect_ratio.num) { // overridden by the -aspect cli option + sar = + av_mul_q(ost->frame_aspect_ratio, + (AVRational){ enc_ctx->height, enc_ctx->width }); + av_log(NULL, AV_LOG_WARNING, "Overriding aspect ratio " + "with stream copy may produce invalid files\n"); + } + else if (ist->st->sample_aspect_ratio.num) + sar = ist->st->sample_aspect_ratio; + else + sar = dec_ctx->sample_aspect_ratio; + ost->st->sample_aspect_ratio = enc_ctx->sample_aspect_ratio = sar; + ost->st->avg_frame_rate = ist->st->avg_frame_rate; + ost->st->r_frame_rate = ist->st->r_frame_rate; + break; + case AVMEDIA_TYPE_SUBTITLE: + enc_ctx->width = dec_ctx->width; + enc_ctx->height = dec_ctx->height; + break; + case AVMEDIA_TYPE_UNKNOWN: + case AVMEDIA_TYPE_DATA: + case AVMEDIA_TYPE_ATTACHMENT: + break; + default: + abort(); + } + } else { + if (!ost->enc) + ost->enc = avcodec_find_encoder(enc_ctx->codec_id); + if (!ost->enc) { + /* should only happen when a default codec is not present. */ + snprintf(error, sizeof(error), "Encoder (codec %s) not found for output stream #%d:%d", + avcodec_get_name(ost->st->codec->codec_id), ost->file_index, ost->index); + ret = AVERROR(EINVAL); + goto dump_format; + } + + set_encoder_id(output_files[ost->file_index], ost); + +#if CONFIG_LIBMFX + if (qsv_transcode_init(ost)) + exit_program(1); +#endif + + if (!ost->filter && + (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO || + enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO)) { + FilterGraph *fg; + fg = init_simple_filtergraph(ist, ost); + if (configure_filtergraph(fg)) { + av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n"); + exit_program(1); + } + } + + if (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO) { + if (!ost->frame_rate.num) + ost->frame_rate = av_buffersink_get_frame_rate(ost->filter->filter); + if (ist && !ost->frame_rate.num) + ost->frame_rate = ist->framerate; + if (ist && !ost->frame_rate.num) + ost->frame_rate = ist->st->r_frame_rate; + if (ist && !ost->frame_rate.num) { + ost->frame_rate = (AVRational){25, 1}; + av_log(NULL, AV_LOG_WARNING, + "No information " + "about the input framerate is available. Falling " + "back to a default value of 25fps for output stream #%d:%d. Use the -r option " + "if you want a different framerate.\n", + ost->file_index, ost->index); + } +// ost->frame_rate = ist->st->avg_frame_rate.num ? ist->st->avg_frame_rate : (AVRational){25, 1}; + if (ost->enc && ost->enc->supported_framerates && !ost->force_fps) { + int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates); + ost->frame_rate = ost->enc->supported_framerates[idx]; + } + // reduce frame rate for mpeg4 to be within the spec limits + if (enc_ctx->codec_id == AV_CODEC_ID_MPEG4) { + av_reduce(&ost->frame_rate.num, &ost->frame_rate.den, + ost->frame_rate.num, ost->frame_rate.den, 65535); + } + } + + switch (enc_ctx->codec_type) { + case AVMEDIA_TYPE_AUDIO: + enc_ctx->sample_fmt = ost->filter->filter->inputs[0]->format; + enc_ctx->sample_rate = ost->filter->filter->inputs[0]->sample_rate; + enc_ctx->channel_layout = ost->filter->filter->inputs[0]->channel_layout; + enc_ctx->channels = avfilter_link_get_channels(ost->filter->filter->inputs[0]); + enc_ctx->time_base = (AVRational){ 1, enc_ctx->sample_rate }; + break; + case AVMEDIA_TYPE_VIDEO: + enc_ctx->time_base = av_inv_q(ost->frame_rate); + if (!(enc_ctx->time_base.num && enc_ctx->time_base.den)) + enc_ctx->time_base = ost->filter->filter->inputs[0]->time_base; + if ( av_q2d(enc_ctx->time_base) < 0.001 && video_sync_method != VSYNC_PASSTHROUGH + && (video_sync_method == VSYNC_CFR || video_sync_method == VSYNC_VSCFR || (video_sync_method == VSYNC_AUTO && !(oc->oformat->flags & AVFMT_VARIABLE_FPS)))){ + av_log(oc, AV_LOG_WARNING, "Frame rate very high for a muxer not efficiently supporting it.\n" + "Please consider specifying a lower framerate, a different muxer or -vsync 2\n"); + } + for (j = 0; j < ost->forced_kf_count; j++) + ost->forced_kf_pts[j] = av_rescale_q(ost->forced_kf_pts[j], + AV_TIME_BASE_Q, + enc_ctx->time_base); + + enc_ctx->width = ost->filter->filter->inputs[0]->w; + enc_ctx->height = ost->filter->filter->inputs[0]->h; + enc_ctx->sample_aspect_ratio = ost->st->sample_aspect_ratio = + ost->frame_aspect_ratio.num ? // overridden by the -aspect cli option + av_mul_q(ost->frame_aspect_ratio, (AVRational){ enc_ctx->height, enc_ctx->width }) : + ost->filter->filter->inputs[0]->sample_aspect_ratio; + if (!strncmp(ost->enc->name, "libx264", 7) && + enc_ctx->pix_fmt == AV_PIX_FMT_NONE && + ost->filter->filter->inputs[0]->format != AV_PIX_FMT_YUV420P) + av_log(NULL, AV_LOG_WARNING, + "No pixel format specified, %s for H.264 encoding chosen.\n" + "Use -pix_fmt yuv420p for compatibility with outdated media players.\n", + av_get_pix_fmt_name(ost->filter->filter->inputs[0]->format)); + if (!strncmp(ost->enc->name, "mpeg2video", 10) && + enc_ctx->pix_fmt == AV_PIX_FMT_NONE && + ost->filter->filter->inputs[0]->format != AV_PIX_FMT_YUV420P) + av_log(NULL, AV_LOG_WARNING, + "No pixel format specified, %s for MPEG-2 encoding chosen.\n" + "Use -pix_fmt yuv420p for compatibility with outdated media players.\n", + av_get_pix_fmt_name(ost->filter->filter->inputs[0]->format)); + enc_ctx->pix_fmt = ost->filter->filter->inputs[0]->format; + + ost->st->avg_frame_rate = ost->frame_rate; + + if (!dec_ctx || + enc_ctx->width != dec_ctx->width || + enc_ctx->height != dec_ctx->height || + enc_ctx->pix_fmt != dec_ctx->pix_fmt) { + enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample; + } + + if (ost->forced_keyframes) { + if (!strncmp(ost->forced_keyframes, "expr:", 5)) { + ret = av_expr_parse(&ost->forced_keyframes_pexpr, ost->forced_keyframes+5, + forced_keyframes_const_names, NULL, NULL, NULL, NULL, 0, NULL); + if (ret < 0) { + av_log(NULL, AV_LOG_ERROR, + "Invalid force_key_frames expression '%s'\n", ost->forced_keyframes+5); + return ret; + } + ost->forced_keyframes_expr_const_values[FKF_N] = 0; + ost->forced_keyframes_expr_const_values[FKF_N_FORCED] = 0; + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] = NAN; + ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] = NAN; + + // Don't parse the 'forced_keyframes' in case of 'keep-source-keyframes', + // parse it only for static kf timings + } else if(strncmp(ost->forced_keyframes, "source", 6)) { + parse_forced_key_frames(ost->forced_keyframes, ost, ost->enc_ctx); + } + } + break; + case AVMEDIA_TYPE_SUBTITLE: + enc_ctx->time_base = (AVRational){1, 1000}; + if (!enc_ctx->width) { + enc_ctx->width = input_streams[ost->source_index]->st->codec->width; + enc_ctx->height = input_streams[ost->source_index]->st->codec->height; + } + break; + case AVMEDIA_TYPE_DATA: + break; + default: + abort(); + break; + } + } + + if (ost->disposition) { + static const AVOption opts[] = { + { "disposition" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" }, + { "default" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DEFAULT }, .unit = "flags" }, + { "dub" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DUB }, .unit = "flags" }, + { "original" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_ORIGINAL }, .unit = "flags" }, + { "comment" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_COMMENT }, .unit = "flags" }, + { "lyrics" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_LYRICS }, .unit = "flags" }, + { "karaoke" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_KARAOKE }, .unit = "flags" }, + { "forced" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_FORCED }, .unit = "flags" }, + { "hearing_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_HEARING_IMPAIRED }, .unit = "flags" }, + { "visual_impaired" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_VISUAL_IMPAIRED }, .unit = "flags" }, + { "clean_effects" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CLEAN_EFFECTS }, .unit = "flags" }, + { "captions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_CAPTIONS }, .unit = "flags" }, + { "descriptions" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_DESCRIPTIONS }, .unit = "flags" }, + { "metadata" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_DISPOSITION_METADATA }, .unit = "flags" }, + { NULL }, + }; + static const AVClass class = { + .class_name = "", + .item_name = av_default_item_name, + .option = opts, + .version = LIBAVUTIL_VERSION_INT, + }; + const AVClass *pclass = &class; + + ret = av_opt_eval_flags(&pclass, &opts[0], ost->disposition, &ost->st->disposition); + if (ret < 0) + goto dump_format; + } + } + + /* open each encoder */ + for (i = 0; i < nb_output_streams; i++) { + ret = init_output_stream(output_streams[i], error, sizeof(error)); + if (ret < 0) + goto dump_format; + } + + /* init input streams */ + for (i = 0; i < nb_input_streams; i++) + if ((ret = init_input_stream(i, error, sizeof(error))) < 0) { + for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; + avcodec_close(ost->enc_ctx); + } + goto dump_format; + } + + /* discard unused programs */ + for (i = 0; i < nb_input_files; i++) { + InputFile *ifile = input_files[i]; + for (j = 0; j < ifile->ctx->nb_programs; j++) { + AVProgram *p = ifile->ctx->programs[j]; + int discard = AVDISCARD_ALL; + + for (k = 0; k < p->nb_stream_indexes; k++) + if (!input_streams[ifile->ist_index + p->stream_index[k]]->discard) { + discard = AVDISCARD_DEFAULT; + break; + } + p->discard = discard; + } + } + + /* open files and write file headers */ + for (i = 0; i < nb_output_files; i++) { + oc = output_files[i]->ctx; + oc->interrupt_callback = int_cb; + if ((ret = avformat_write_header(oc, &output_files[i]->opts)) < 0) { + snprintf(error, sizeof(error), + "Could not write header for output file #%d " + "(incorrect codec parameters ?): %s", + i, av_err2str(ret)); + ret = AVERROR(EINVAL); + goto dump_format; + } +// assert_avoptions(output_files[i]->opts); + if (strcmp(oc->oformat->name, "rtp")) { + want_sdp = 0; + } + } + + dump_format: + /* dump the file output parameters - cannot be done before in case + of stream copy */ + for (i = 0; i < nb_output_files; i++) { + av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1); + } + + /* dump the stream mapping */ + av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); + for (i = 0; i < nb_input_streams; i++) { + ist = input_streams[i]; + + for (j = 0; j < ist->nb_filters; j++) { + if (ist->filters[j]->graph->graph_desc) { + av_log(NULL, AV_LOG_INFO, " Stream #%d:%d (%s) -> %s", + ist->file_index, ist->st->index, ist->dec ? ist->dec->name : "?", + ist->filters[j]->name); + if (nb_filtergraphs > 1) + av_log(NULL, AV_LOG_INFO, " (graph %d)", ist->filters[j]->graph->index); + av_log(NULL, AV_LOG_INFO, "\n"); + } + } + } + + for (i = 0; i < nb_output_streams; i++) { + ost = output_streams[i]; + + if (ost->attachment_filename) { + /* an attached file */ + av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n", + ost->attachment_filename, ost->file_index, ost->index); + continue; + } + + if (ost->filter && ost->filter->graph->graph_desc) { + /* output from a complex graph */ + av_log(NULL, AV_LOG_INFO, " %s", ost->filter->name); + if (nb_filtergraphs > 1) + av_log(NULL, AV_LOG_INFO, " (graph %d)", ost->filter->graph->index); + + av_log(NULL, AV_LOG_INFO, " -> Stream #%d:%d (%s)\n", ost->file_index, + ost->index, ost->enc ? ost->enc->name : "?"); + continue; + } + + av_log(NULL, AV_LOG_INFO, " Stream #%d:%d -> #%d:%d", + input_streams[ost->source_index]->file_index, + input_streams[ost->source_index]->st->index, + ost->file_index, + ost->index); + if (ost->sync_ist != input_streams[ost->source_index]) + av_log(NULL, AV_LOG_INFO, " [sync #%d:%d]", + ost->sync_ist->file_index, + ost->sync_ist->st->index); + if (ost->stream_copy) + av_log(NULL, AV_LOG_INFO, " (copy)"); + else { + const AVCodec *in_codec = input_streams[ost->source_index]->dec; + const AVCodec *out_codec = ost->enc; + const char *decoder_name = "?"; + const char *in_codec_name = "?"; + const char *encoder_name = "?"; + const char *out_codec_name = "?"; + const AVCodecDescriptor *desc; + + if (in_codec) { + decoder_name = in_codec->name; + desc = avcodec_descriptor_get(in_codec->id); + if (desc) + in_codec_name = desc->name; + if (!strcmp(decoder_name, in_codec_name)) + decoder_name = "native"; + } + + if (out_codec) { + encoder_name = out_codec->name; + desc = avcodec_descriptor_get(out_codec->id); + if (desc) + out_codec_name = desc->name; + if (!strcmp(encoder_name, out_codec_name)) + encoder_name = "native"; + } + + av_log(NULL, AV_LOG_INFO, " (%s (%s) -> %s (%s))", + in_codec_name, decoder_name, + out_codec_name, encoder_name); + } + av_log(NULL, AV_LOG_INFO, "\n"); + } + + if (ret) { + av_log(NULL, AV_LOG_ERROR, "%s\n", error); + return ret; + } + + if (sdp_filename || want_sdp) { + print_sdp(); + } + + transcode_init_done = 1; + + return 0; +} + +/* Return 1 if there remain streams where more output is wanted, 0 otherwise. */ +static int need_output(void) +{ + int i; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + OutputFile *of = output_files[ost->file_index]; + AVFormatContext *os = output_files[ost->file_index]->ctx; + + if (ost->finished || + (os->pb && avio_tell(os->pb) >= of->limit_filesize)) + continue; + if (ost->frame_number >= ost->max_frames) { + int j; + for (j = 0; j < of->ctx->nb_streams; j++) + close_output_stream(output_streams[of->ost_index + j]); + continue; + } + + return 1; + } + + return 0; +} + +/** + * Select the output stream to process. + * + * @return selected output stream, or NULL if none available + */ +static OutputStream *choose_output(void) +{ + int i; + int64_t opts_min = INT64_MAX; + OutputStream *ost_min = NULL; + + for (i = 0; i < nb_output_streams; i++) { + OutputStream *ost = output_streams[i]; + int64_t opts = ost->st->cur_dts == AV_NOPTS_VALUE ? INT64_MIN : + av_rescale_q(ost->st->cur_dts, ost->st->time_base, + AV_TIME_BASE_Q); + if (ost->st->cur_dts == AV_NOPTS_VALUE) + av_log(NULL, AV_LOG_DEBUG, "cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n"); + + if (!ost->finished && opts < opts_min) { + opts_min = opts; + ost_min = ost->unavailable ? NULL : ost; + } + } + return ost_min; +} + +static void set_tty_echo(int on) +{ +#if HAVE_TERMIOS_H + struct termios tty; + if (tcgetattr(0, &tty) == 0) { + if (on) tty.c_lflag |= ECHO; + else tty.c_lflag &= ~ECHO; + tcsetattr(0, TCSANOW, &tty); + } +#endif +} + +static int check_keyboard_interaction(int64_t cur_time) +{ + int i, ret, key; + static int64_t last_time; + if (received_nb_signals) + return AVERROR_EXIT; + /* read_key() returns 0 on EOF */ + if(cur_time - last_time >= 100000 && !run_as_daemon){ + key = read_key(); + last_time = cur_time; + }else + key = -1; + if (key == 'q') + return AVERROR_EXIT; + if (key == '+') av_log_set_level(av_log_get_level()+10); + if (key == '-') av_log_set_level(av_log_get_level()-10); + if (key == 's') qp_hist ^= 1; + if (key == 'h'){ + if (do_hex_dump){ + do_hex_dump = do_pkt_dump = 0; + } else if(do_pkt_dump){ + do_hex_dump = 1; + } else + do_pkt_dump = 1; + av_log_set_level(AV_LOG_DEBUG); + } + if (key == 'c' || key == 'C'){ + char buf[4096], target[64], command[256], arg[256] = {0}; + double time; + int k, n = 0; + fprintf(stderr, "\nEnter command: |all