use ffmpeg n5.1.1
This commit is contained in:
parent
2485467fa5
commit
bba2b62694
@ -28,7 +28,7 @@ echo -e "\nINFO: Using Android NDK v${DETECTED_NDK_VERSION} provided at ${ANDROI
|
||||
echo -e "INFO: Build options: $*\n" 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
||||
# SET DEFAULT BUILD OPTIONS
|
||||
GPL_ENABLED="no"
|
||||
export GPL_ENABLED="no"
|
||||
DISPLAY_HELP=""
|
||||
BUILD_FULL=""
|
||||
BUILD_TYPE_ID=""
|
||||
@ -105,7 +105,7 @@ while [ ! $# -eq 0 ]; do
|
||||
BUILD_FULL="1"
|
||||
;;
|
||||
--enable-gpl)
|
||||
GPL_ENABLED="yes"
|
||||
export GPL_ENABLED="yes"
|
||||
;;
|
||||
--enable-custom-library-*)
|
||||
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
|
||||
|
@ -38,7 +38,7 @@ PROJECT_NAME = "FFmpegKit Android API"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 4.5.1
|
||||
PROJECT_NUMBER = 5.1
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
@ -1,14 +1,14 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
ndkVersion "22.1.7171670"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 240451
|
||||
versionName "4.5.1"
|
||||
targetSdkVersion 31
|
||||
versionCode 240510
|
||||
versionName "5.1"
|
||||
project.archivesBaseName = "ffmpeg-kit"
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ volatile int handleSIGXCPU = 1;
|
||||
volatile int handleSIGPIPE = 1;
|
||||
|
||||
/** Holds the id of the current session */
|
||||
__thread volatile long globalSessionId = 0;
|
||||
__thread long globalSessionId = 0;
|
||||
|
||||
/** Holds the default log level */
|
||||
int configuredLogLevel = AV_LOG_INFO;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "libavutil/ffversion.h"
|
||||
|
||||
/** Library version string */
|
||||
#define FFMPEG_KIT_VERSION "4.5.1"
|
||||
#define FFMPEG_KIT_VERSION "5.1"
|
||||
|
||||
/** Defines tag used for Android logging. */
|
||||
#define LIB_NAME "ffmpeg-kit"
|
||||
|
@ -24,13 +24,14 @@
|
||||
#include "config.h"
|
||||
#include "libavcodec/jni.h"
|
||||
#include "libavutil/bprint.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "ffmpegkit.h"
|
||||
|
||||
/** Forward declaration for function defined in fftools_ffprobe.c */
|
||||
int ffprobe_execute(int argc, char **argv);
|
||||
|
||||
extern int configuredLogLevel;
|
||||
extern __thread volatile long globalSessionId;
|
||||
extern __thread long globalSessionId;
|
||||
extern void addSession(long sessionId);
|
||||
extern void removeSession(long sessionId);
|
||||
extern void resetMessagesInTransmit(long sessionId);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Various utilities for command line tools
|
||||
* copyright (c) 2003 Fabrice Bellard
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@ -20,25 +21,37 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* - AV_LOG_STDERR introduced
|
||||
* This file is the modified version of cmdutils.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - config.h include added back
|
||||
*
|
||||
* 01.2020
|
||||
* --------------------------------------------------------
|
||||
* - ffprobe support added (variables used by ffprobe marked with "__thread" specifier)
|
||||
* - AV_LOG_STDERR log level added
|
||||
*
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads)
|
||||
*
|
||||
* 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Include guards renamed
|
||||
* - Unused headers removed
|
||||
* - include guards renamed
|
||||
* - unused headers removed
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_CMDUTILS_H
|
||||
@ -46,6 +59,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavfilter/avfilter.h"
|
||||
#include "libavformat/avformat.h"
|
||||
@ -70,11 +84,9 @@ extern __thread char *program_name;
|
||||
*/
|
||||
extern __thread int program_birth_year;
|
||||
|
||||
extern __thread AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
||||
extern __thread AVFormatContext *avformat_opts;
|
||||
extern __thread AVDictionary *sws_dict;
|
||||
extern __thread AVDictionary *swr_opts;
|
||||
extern __thread AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
extern __thread AVDictionary *format_opts, *codec_opts;
|
||||
extern __thread int hide_banner;
|
||||
extern __thread int find_stream_info;
|
||||
|
||||
@ -93,11 +105,6 @@ void exit_program(int ret) av_noreturn;
|
||||
*/
|
||||
void init_dynload(void);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -110,33 +117,12 @@ void uninit_opts(void);
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Override the cpucount.
|
||||
*/
|
||||
int opt_cpucount(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(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_codec_debug(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Limit the execution time.
|
||||
*/
|
||||
@ -237,7 +223,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||
* Show help for all options with given flags in class and all its
|
||||
* children.
|
||||
*/
|
||||
void show_help_children(const AVClass *class, int flags);
|
||||
void show_help_children(const AVClass *clazz, int flags);
|
||||
|
||||
/**
|
||||
* Per-fftool specific help handler. Implemented in each
|
||||
@ -309,7 +295,6 @@ typedef struct OptionGroup {
|
||||
|
||||
AVDictionary *codec_opts;
|
||||
AVDictionary *format_opts;
|
||||
AVDictionary *resample_opts;
|
||||
AVDictionary *sws_dict;
|
||||
AVDictionary *swr_opts;
|
||||
} OptionGroup;
|
||||
@ -417,8 +402,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
|
||||
* 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
|
||||
* @return pointer to the created array of dictionaries.
|
||||
* Calls exit() on failure.
|
||||
*/
|
||||
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
|
||||
AVDictionary *codec_opts);
|
||||
@ -441,136 +426,6 @@ void print_error(const char *filename, int err);
|
||||
*/
|
||||
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 muxers supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_muxers(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Print a listing containing all the demuxer supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_demuxers(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 autodetected 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 autodetected 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.
|
||||
@ -610,11 +465,26 @@ FILE *get_preset_file(char *filename, size_t filename_size,
|
||||
*/
|
||||
void *grow_array(void *array, int elem_size, int *size, int new_size);
|
||||
|
||||
#define media_type_string av_get_media_type_string
|
||||
/**
|
||||
* Atomically add a new element to an array of pointers, i.e. allocate
|
||||
* a new entry, reallocate the array of pointers and make the new last
|
||||
* member of this array point to the newly allocated buffer.
|
||||
* Calls exit() on failure.
|
||||
*
|
||||
* @param array array of pointers to reallocate
|
||||
* @param elem_size size of the new element to allocate
|
||||
* @param nb_elems pointer to the number of elements of the array array;
|
||||
* *nb_elems will be incremented by one by this function.
|
||||
* @return pointer to the newly allocated entry
|
||||
*/
|
||||
void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
|
||||
|
||||
#define GROW_ARRAY(array, nb_elems)\
|
||||
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
||||
|
||||
#define ALLOC_ARRAY_ELEM(array, nb_elems)\
|
||||
allocate_array_elem(&array, sizeof(*array[0]), &nb_elems)
|
||||
|
||||
#define GET_PIX_FMT_NAME(pix_fmt)\
|
||||
const char *name = av_get_pix_fmt_name(pix_fmt);
|
||||
|
||||
@ -628,14 +498,6 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
|
||||
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);
|
||||
double get_rotation(int32_t *displaymatrix);
|
||||
|
||||
#endif /* FFTOOLS_CMDUTILS_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
* Copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -17,33 +18,46 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 06.2020
|
||||
* This file is the modified version of ffmpeg.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - config.h include added back
|
||||
* - volatile dropped from thread local variables
|
||||
*
|
||||
* 06.2020
|
||||
* --------------------------------------------------------
|
||||
* - cancel_operation() method signature updated with id
|
||||
*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads,
|
||||
* signatures of ffmpeg_opt.c methods called by both ffmpeg and ffprobe added)
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
* - set_report_callback() method declared
|
||||
* - cancel_operation() method declared
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Include guards renamed
|
||||
* - include guards renamed
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_FFMPEG_H
|
||||
#define FFTOOLS_FFMPEG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@ -70,12 +84,14 @@
|
||||
|
||||
#include "libswresample/swresample.h"
|
||||
|
||||
#define VSYNC_AUTO -1
|
||||
#define VSYNC_PASSTHROUGH 0
|
||||
#define VSYNC_CFR 1
|
||||
#define VSYNC_VFR 2
|
||||
#define VSYNC_VSCFR 0xfe
|
||||
#define VSYNC_DROP 0xff
|
||||
enum VideoSyncMethod {
|
||||
VSYNC_AUTO = -1,
|
||||
VSYNC_PASSTHROUGH,
|
||||
VSYNC_CFR,
|
||||
VSYNC_VFR,
|
||||
VSYNC_VSCFR,
|
||||
VSYNC_DROP,
|
||||
};
|
||||
|
||||
#define MAX_STREAMS 1024 /* arbitrary sanity check value */
|
||||
|
||||
@ -83,16 +99,8 @@ enum HWAccelID {
|
||||
HWACCEL_NONE = 0,
|
||||
HWACCEL_AUTO,
|
||||
HWACCEL_GENERIC,
|
||||
HWACCEL_VIDEOTOOLBOX,
|
||||
};
|
||||
|
||||
typedef struct HWAccel {
|
||||
const char *name;
|
||||
int (*init)(AVCodecContext *s);
|
||||
enum HWAccelID id;
|
||||
enum AVPixelFormat pix_fmt;
|
||||
} HWAccel;
|
||||
|
||||
typedef struct HWDevice {
|
||||
const char *name;
|
||||
enum AVHWDeviceType type;
|
||||
@ -125,6 +133,8 @@ typedef struct OptionsContext {
|
||||
|
||||
SpecifierOpt *codec_names;
|
||||
int nb_codec_names;
|
||||
SpecifierOpt *audio_ch_layouts;
|
||||
int nb_audio_ch_layouts;
|
||||
SpecifierOpt *audio_channels;
|
||||
int nb_audio_channels;
|
||||
SpecifierOpt *audio_sample_rate;
|
||||
@ -145,6 +155,7 @@ typedef struct OptionsContext {
|
||||
float readrate;
|
||||
int accurate_seek;
|
||||
int thread_queue_size;
|
||||
int input_sync_ref;
|
||||
|
||||
SpecifierOpt *ts_scale;
|
||||
int nb_ts_scale;
|
||||
@ -203,6 +214,8 @@ typedef struct OptionsContext {
|
||||
int nb_qscale;
|
||||
SpecifierOpt *forced_key_frames;
|
||||
int nb_forced_key_frames;
|
||||
SpecifierOpt *fps_mode;
|
||||
int nb_fps_mode;
|
||||
SpecifierOpt *force_fps;
|
||||
int nb_force_fps;
|
||||
SpecifierOpt *frame_aspect_ratios;
|
||||
@ -259,6 +272,8 @@ typedef struct OptionsContext {
|
||||
int nb_enc_time_bases;
|
||||
SpecifierOpt *autoscale;
|
||||
int nb_autoscale;
|
||||
SpecifierOpt *bits_per_raw_sample;
|
||||
int nb_bits_per_raw_sample;
|
||||
} OptionsContext;
|
||||
|
||||
typedef struct InputFilter {
|
||||
@ -268,7 +283,7 @@ typedef struct InputFilter {
|
||||
uint8_t *name;
|
||||
enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video
|
||||
|
||||
AVFifoBuffer *frame_queue;
|
||||
AVFifo *frame_queue;
|
||||
|
||||
// parameters configured for this input
|
||||
int format;
|
||||
@ -277,10 +292,10 @@ typedef struct InputFilter {
|
||||
AVRational sample_aspect_ratio;
|
||||
|
||||
int sample_rate;
|
||||
int channels;
|
||||
uint64_t channel_layout;
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
int32_t *displaymatrix;
|
||||
|
||||
int eof;
|
||||
} InputFilter;
|
||||
@ -300,12 +315,13 @@ typedef struct OutputFilter {
|
||||
AVRational frame_rate;
|
||||
int format;
|
||||
int sample_rate;
|
||||
uint64_t channel_layout;
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
// those are only set if no format is specified and the encoder gives us multiple options
|
||||
int *formats;
|
||||
uint64_t *channel_layouts;
|
||||
int *sample_rates;
|
||||
// They point directly to the relevant lists of the encoder.
|
||||
const int *formats;
|
||||
const AVChannelLayout *ch_layouts;
|
||||
const int *sample_rates;
|
||||
} OutputFilter;
|
||||
|
||||
typedef struct FilterGraph {
|
||||
@ -314,6 +330,9 @@ typedef struct FilterGraph {
|
||||
|
||||
AVFilterGraph *graph;
|
||||
int reconfiguration;
|
||||
// true when the filtergraph contains only meta filters
|
||||
// that do not modify the frame data
|
||||
int is_meta;
|
||||
|
||||
InputFilter **inputs;
|
||||
int nb_inputs;
|
||||
@ -329,13 +348,14 @@ typedef struct InputStream {
|
||||
int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
|
||||
#define DECODING_FOR_OST 1
|
||||
#define DECODING_FOR_FILTER 2
|
||||
int processing_needed; /* non zero if the packets must be processed */
|
||||
|
||||
AVCodecContext *dec_ctx;
|
||||
const AVCodec *dec;
|
||||
AVFrame *decoded_frame;
|
||||
AVFrame *filter_frame; /* a ref of decoded_frame, to be sent to filters */
|
||||
AVPacket *pkt;
|
||||
|
||||
int64_t prev_pkt_pts;
|
||||
int64_t start; /* time when read started */
|
||||
/* predicted dts of the next packet read for this stream or (when there are
|
||||
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
|
||||
@ -377,14 +397,12 @@ typedef struct InputStream {
|
||||
struct sub2video {
|
||||
int64_t last_pts;
|
||||
int64_t end_pts;
|
||||
AVFifoBuffer *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFifo *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFrame *frame;
|
||||
int w, h;
|
||||
unsigned int initialize; ///< marks if sub2video_update should force an initialization
|
||||
} sub2video;
|
||||
|
||||
int dr1;
|
||||
|
||||
/* decoded data from this stream goes into all those filters
|
||||
* currently video and audio only */
|
||||
InputFilter **filters;
|
||||
@ -401,11 +419,9 @@ typedef struct InputStream {
|
||||
/* hwaccel context */
|
||||
void *hwaccel_ctx;
|
||||
void (*hwaccel_uninit)(AVCodecContext *s);
|
||||
int (*hwaccel_get_buffer)(AVCodecContext *s, AVFrame *frame, int flags);
|
||||
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
|
||||
enum AVPixelFormat hwaccel_pix_fmt;
|
||||
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
|
||||
/* stats */
|
||||
// combined size of all the packets read
|
||||
@ -432,11 +448,11 @@ typedef struct InputFile {
|
||||
at the moment when looping happens */
|
||||
AVRational time_base; /* time base of the duration */
|
||||
int64_t input_ts_offset;
|
||||
int input_sync_ref;
|
||||
|
||||
int64_t ts_offset;
|
||||
int64_t last_ts;
|
||||
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
|
||||
int seek_timestamp;
|
||||
int64_t recording_time;
|
||||
int nb_streams; /* number of stream that ffmpeg is aware of; may be different
|
||||
from ctx.nb_streams if new streams appear during av_read_frame() */
|
||||
@ -465,7 +481,7 @@ enum forced_keyframes_const {
|
||||
FKF_NB
|
||||
};
|
||||
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
|
||||
|
||||
extern const char *const forced_keyframes_const_names[];
|
||||
@ -481,7 +497,7 @@ typedef struct OutputStream {
|
||||
int source_index; /* InputStream index */
|
||||
AVStream *st; /* stream in the output file */
|
||||
int encoding_needed; /* true if encoding needed for this stream */
|
||||
int frame_number;
|
||||
int64_t frame_number;
|
||||
/* input pts and corresponding output pts
|
||||
for A/V sync */
|
||||
struct InputStream *sync_ist; /* input stream to sync against */
|
||||
@ -504,19 +520,22 @@ typedef struct OutputStream {
|
||||
AVFrame *filtered_frame;
|
||||
AVFrame *last_frame;
|
||||
AVPacket *pkt;
|
||||
int last_dropped;
|
||||
int last_nb0_frames[3];
|
||||
int64_t last_dropped;
|
||||
int64_t last_nb0_frames[3];
|
||||
|
||||
void *hwaccel_ctx;
|
||||
|
||||
/* video only */
|
||||
AVRational frame_rate;
|
||||
AVRational max_frame_rate;
|
||||
enum VideoSyncMethod vsync_method;
|
||||
int is_cfr;
|
||||
const char *fps_mode;
|
||||
int force_fps;
|
||||
int top_field_first;
|
||||
int rotate_overridden;
|
||||
int autoscale;
|
||||
int bits_per_raw_sample;
|
||||
double rotate_override_value;
|
||||
|
||||
AVRational frame_aspect_ratio;
|
||||
@ -546,7 +565,6 @@ typedef struct OutputStream {
|
||||
AVDictionary *encoder_opts;
|
||||
AVDictionary *sws_dict;
|
||||
AVDictionary *swr_opts;
|
||||
AVDictionary *resample_opts;
|
||||
char *apad;
|
||||
OSTFinished finished; /* no more packets should be written for this stream */
|
||||
int unavailable; /* true if the steram is unavailable (possibly temporarily) */
|
||||
@ -560,6 +578,7 @@ typedef struct OutputStream {
|
||||
int inputs_done;
|
||||
|
||||
const char *attachment_filename;
|
||||
int streamcopy_started;
|
||||
int copy_initial_nonkeyframes;
|
||||
int copy_prior_start;
|
||||
char *disposition;
|
||||
@ -574,6 +593,8 @@ typedef struct OutputStream {
|
||||
// number of frames/samples sent to the encoder
|
||||
uint64_t frames_encoded;
|
||||
uint64_t samples_encoded;
|
||||
// number of packets received from the encoder
|
||||
uint64_t packets_encoded;
|
||||
|
||||
/* packet quality factor */
|
||||
int quality;
|
||||
@ -581,7 +602,7 @@ typedef struct OutputStream {
|
||||
int max_muxing_queue_size;
|
||||
|
||||
/* the packets are buffered here until the muxer is ready to be initialized */
|
||||
AVFifoBuffer *muxing_queue;
|
||||
AVFifo *muxing_queue;
|
||||
|
||||
/*
|
||||
* The size of the AVPackets' buffers in queue.
|
||||
@ -600,6 +621,10 @@ typedef struct OutputStream {
|
||||
} OutputStream;
|
||||
|
||||
typedef struct OutputFile {
|
||||
int index;
|
||||
|
||||
const AVOutputFormat *format;
|
||||
|
||||
AVFormatContext *ctx;
|
||||
AVDictionary *opts;
|
||||
int ost_index; /* index of the first stream in output_streams */
|
||||
@ -634,7 +659,7 @@ extern __thread float dts_error_threshold;
|
||||
|
||||
extern __thread int audio_volume;
|
||||
extern __thread int audio_sync_method;
|
||||
extern __thread int video_sync_method;
|
||||
extern __thread enum VideoSyncMethod video_sync_method;
|
||||
extern __thread float frame_drop_threshold;
|
||||
extern __thread int do_benchmark;
|
||||
extern __thread int do_benchmark_all;
|
||||
@ -654,41 +679,35 @@ extern __thread int stdin_interaction;
|
||||
extern __thread int frame_bits_per_raw_sample;
|
||||
extern __thread AVIOContext *progress_avio;
|
||||
extern __thread float max_error_rate;
|
||||
extern __thread char *videotoolbox_pixfmt;
|
||||
|
||||
extern __thread int filter_nbthreads;
|
||||
extern __thread char *filter_nbthreads;
|
||||
extern __thread int filter_complex_nbthreads;
|
||||
extern __thread int vstats_version;
|
||||
extern __thread int auto_conversion_filters;
|
||||
|
||||
extern __thread const AVIOInterruptCB int_cb;
|
||||
|
||||
extern const HWAccel hwaccels[];
|
||||
#if CONFIG_QSV
|
||||
extern __thread char *qsv_device;
|
||||
#endif
|
||||
extern __thread HWDevice *filter_hw_device;
|
||||
|
||||
extern __thread int want_sdp;
|
||||
extern __thread unsigned nb_output_dumped;
|
||||
extern __thread int main_ffmpeg_return_code;
|
||||
|
||||
void term_init(void);
|
||||
void term_exit(void);
|
||||
|
||||
void reset_options(OptionsContext *o, int is_input);
|
||||
void show_usage(void);
|
||||
|
||||
void opt_output_file(void *optctx, const char *filename);
|
||||
|
||||
void remove_avoptions(AVDictionary **a, AVDictionary *b);
|
||||
void assert_avoptions(AVDictionary *m);
|
||||
|
||||
int guess_input_channel_layout(InputStream *ist);
|
||||
|
||||
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, const AVCodec *codec, enum AVPixelFormat target);
|
||||
void choose_sample_fmt(AVStream *st, const AVCodec *codec);
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg);
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
|
||||
void check_filter_outputs(void);
|
||||
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
|
||||
int filtergraph_is_simple(FilterGraph *fg);
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost);
|
||||
int init_complex_filtergraph(FilterGraph *fg);
|
||||
@ -712,6 +731,14 @@ int hw_device_setup_for_filter(FilterGraph *fg);
|
||||
|
||||
int hwaccel_decode_init(AVCodecContext *avctx);
|
||||
|
||||
/* open the muxer when all the streams are initialized */
|
||||
int of_check_init(OutputFile *of);
|
||||
int of_write_trailer(OutputFile *of);
|
||||
void of_close(OutputFile **pof);
|
||||
|
||||
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
|
||||
int unqueue);
|
||||
|
||||
void set_report_callback(void (*callback)(int, float, float, int64_t, int, double, double));
|
||||
|
||||
void cancel_operation(long id);
|
||||
@ -759,7 +786,6 @@ int opt_filter_hw_device(void *optctx, const char *opt, const char *arg);
|
||||
void add_input_streams(OptionsContext *o, AVFormatContext *ic);
|
||||
void assert_file_overwrite(const char *filename);
|
||||
void dump_attachment(AVStream *st, const char *filename);
|
||||
uint8_t *get_line(AVIOContext *s);
|
||||
void uninit_options(OptionsContext *o);
|
||||
void init_options(OptionsContext *o);
|
||||
AVDictionary *strip_specifiers(AVDictionary *dict);
|
||||
@ -772,7 +798,6 @@ int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOConte
|
||||
int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost);
|
||||
OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index);
|
||||
void parse_matrix_coeffs(uint16_t *dest, const char *str);
|
||||
uint8_t *fftools_read_file(const char *filename);
|
||||
char *get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost);
|
||||
void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc, const OutputStream *ost, enum AVMediaType type);
|
||||
OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
@ -781,7 +806,6 @@ OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int source
|
||||
OutputStream *new_unknown_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata);
|
||||
void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc);
|
||||
int init_complex_filters(void);
|
||||
int open_output_file(OptionsContext *o, const char *filename);
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* ffmpeg filter configuration
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@ -19,13 +20,19 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 08.2018
|
||||
* This file is the modified version of ffmpeg_filter.c file living in ffmpeg source code under the fftools folder.
|
||||
* We manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Unused headers removed
|
||||
* - unused headers removed
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
@ -53,7 +60,7 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c
|
||||
{
|
||||
static const enum AVPixelFormat mjpeg_formats[] =
|
||||
{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
|
||||
AV_PIX_FMT_NONE};
|
||||
AV_PIX_FMT_NONE };
|
||||
|
||||
if (!strcmp(codec->name, "mjpeg")) {
|
||||
return mjpeg_formats;
|
||||
@ -93,10 +100,13 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx,
|
||||
return target;
|
||||
}
|
||||
|
||||
static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
/* May return NULL (no pixel format found), a static string or a string
|
||||
* backed by the bprint. Nothing has been written to the AVBPrint in case
|
||||
* NULL is returned. The AVBPrint provided should be clean. */
|
||||
static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
|
||||
{
|
||||
OutputStream *ost = ofilter->ost;
|
||||
AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
|
||||
const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
|
||||
if (strict_dict)
|
||||
// used by choose_pixel_fmt() and below
|
||||
av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
|
||||
@ -106,18 +116,12 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
AVFILTER_AUTO_CONVERT_NONE);
|
||||
if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
|
||||
return NULL;
|
||||
return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt));
|
||||
return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt);
|
||||
}
|
||||
if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
|
||||
return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)));
|
||||
return av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt));
|
||||
} else if (ost->enc && ost->enc->pix_fmts) {
|
||||
const enum AVPixelFormat *p;
|
||||
AVIOContext *s = NULL;
|
||||
uint8_t *ret;
|
||||
int len;
|
||||
|
||||
if (avio_open_dyn_buf(&s) < 0)
|
||||
exit_program(1);
|
||||
|
||||
p = ost->enc->pix_fmts;
|
||||
if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
|
||||
@ -126,11 +130,11 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
|
||||
for (; *p != AV_PIX_FMT_NONE; p++) {
|
||||
const char *name = av_get_pix_fmt_name(*p);
|
||||
avio_printf(s, "%s|", name);
|
||||
av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|');
|
||||
}
|
||||
len = avio_close_dyn_buf(s, &ret);
|
||||
ret[len - 1] = 0;
|
||||
return ret;
|
||||
if (!av_bprint_is_complete(bprint))
|
||||
exit_program(1);
|
||||
return bprint->str;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
@ -166,39 +170,54 @@ DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats,
|
||||
DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0,
|
||||
"%d", )
|
||||
|
||||
DEF_CHOOSE_FORMAT(channel_layouts, uint64_t, channel_layout, channel_layouts, 0,
|
||||
"0x%"PRIx64, )
|
||||
static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
|
||||
{
|
||||
if (av_channel_layout_check(&ofilter->ch_layout)) {
|
||||
av_bprintf(bprint, "channel_layouts=");
|
||||
av_channel_layout_describe_bprint(&ofilter->ch_layout, bprint);
|
||||
} else if (ofilter->ch_layouts) {
|
||||
const AVChannelLayout *p;
|
||||
|
||||
av_bprintf(bprint, "channel_layouts=");
|
||||
for (p = ofilter->ch_layouts; p->nb_channels; p++) {
|
||||
av_channel_layout_describe_bprint(p, bprint);
|
||||
av_bprintf(bprint, "|");
|
||||
}
|
||||
if (bprint->len > 0)
|
||||
bprint->str[--bprint->len] = '\0';
|
||||
} else
|
||||
return;
|
||||
av_bprint_chars(bprint, ':', 1);
|
||||
}
|
||||
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
{
|
||||
FilterGraph *fg = av_mallocz(sizeof(*fg));
|
||||
OutputFilter *ofilter;
|
||||
InputFilter *ifilter;
|
||||
|
||||
if (!fg)
|
||||
exit_program(1);
|
||||
fg->index = nb_filtergraphs;
|
||||
|
||||
GROW_ARRAY(fg->outputs, fg->nb_outputs);
|
||||
if (!(fg->outputs[0] = av_mallocz(sizeof(*fg->outputs[0]))))
|
||||
exit_program(1);
|
||||
fg->outputs[0]->ost = ost;
|
||||
fg->outputs[0]->graph = fg;
|
||||
fg->outputs[0]->format = -1;
|
||||
ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
ofilter->ost = ost;
|
||||
ofilter->graph = fg;
|
||||
ofilter->format = -1;
|
||||
|
||||
ost->filter = fg->outputs[0];
|
||||
ost->filter = ofilter;
|
||||
|
||||
GROW_ARRAY(fg->inputs, fg->nb_inputs);
|
||||
if (!(fg->inputs[0] = av_mallocz(sizeof(*fg->inputs[0]))))
|
||||
exit_program(1);
|
||||
fg->inputs[0]->ist = ist;
|
||||
fg->inputs[0]->graph = fg;
|
||||
fg->inputs[0]->format = -1;
|
||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
|
||||
fg->inputs[0]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[0]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[0];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
|
||||
GROW_ARRAY(filtergraphs, nb_filtergraphs);
|
||||
filtergraphs[nb_filtergraphs - 1] = fg;
|
||||
@ -211,17 +230,15 @@ static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
|
||||
AVFilterContext *ctx = inout->filter_ctx;
|
||||
AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads;
|
||||
int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs;
|
||||
AVIOContext *pb;
|
||||
uint8_t *res = NULL;
|
||||
char *res;
|
||||
|
||||
if (avio_open_dyn_buf(&pb) < 0)
|
||||
exit_program(1);
|
||||
|
||||
avio_printf(pb, "%s", ctx->filter->name);
|
||||
if (nb_pads > 1)
|
||||
avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));
|
||||
avio_w8(pb, 0);
|
||||
avio_close_dyn_buf(pb, &res);
|
||||
res = av_strdup(ctx->filter->name);
|
||||
else
|
||||
res = av_asprintf("%s:%s", ctx->filter->name,
|
||||
avfilter_pad_get_name(pads, inout->pad_idx));
|
||||
if (!res)
|
||||
exit_program(1);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -229,6 +246,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
{
|
||||
InputStream *ist = NULL;
|
||||
enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
|
||||
InputFilter *ifilter;
|
||||
int i;
|
||||
|
||||
// TODO: support other filter types
|
||||
@ -293,23 +311,22 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
|
||||
ist->discard = 0;
|
||||
ist->decoding_needed |= DECODING_FOR_FILTER;
|
||||
ist->processing_needed = 1;
|
||||
ist->st->discard = AVDISCARD_NONE;
|
||||
|
||||
GROW_ARRAY(fg->inputs, fg->nb_inputs);
|
||||
if (!(fg->inputs[fg->nb_inputs - 1] = av_mallocz(sizeof(*fg->inputs[0]))))
|
||||
exit_program(1);
|
||||
fg->inputs[fg->nb_inputs - 1]->ist = ist;
|
||||
fg->inputs[fg->nb_inputs - 1]->graph = fg;
|
||||
fg->inputs[fg->nb_inputs - 1]->format = -1;
|
||||
fg->inputs[fg->nb_inputs - 1]->type = ist->st->codecpar->codec_type;
|
||||
fg->inputs[fg->nb_inputs - 1]->name = describe_filter_link(fg, in, 1);
|
||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
ifilter->type = ist->st->codecpar->codec_type;
|
||||
ifilter->name = describe_filter_link(fg, in, 1);
|
||||
|
||||
fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[fg->nb_inputs - 1]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
}
|
||||
|
||||
int init_complex_filtergraph(FilterGraph *fg)
|
||||
@ -333,18 +350,15 @@ int init_complex_filtergraph(FilterGraph *fg)
|
||||
init_input_filter(fg, cur);
|
||||
|
||||
for (cur = outputs; cur;) {
|
||||
GROW_ARRAY(fg->outputs, fg->nb_outputs);
|
||||
fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0]));
|
||||
if (!fg->outputs[fg->nb_outputs - 1])
|
||||
exit_program(1);
|
||||
OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
|
||||
fg->outputs[fg->nb_outputs - 1]->graph = fg;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
|
||||
fg->outputs[fg->nb_outputs - 1]->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
ofilter->graph = fg;
|
||||
ofilter->out_tmp = cur;
|
||||
ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
cur->pad_idx);
|
||||
fg->outputs[fg->nb_outputs - 1]->name = describe_filter_link(fg, cur, 0);
|
||||
ofilter->name = describe_filter_link(fg, cur, 0);
|
||||
cur = cur->next;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL;
|
||||
ofilter->out_tmp->next = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
@ -428,12 +442,13 @@ static int insert_filter(AVFilterContext **last_filter, int *pad_idx,
|
||||
|
||||
static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
|
||||
{
|
||||
char *pix_fmts;
|
||||
OutputStream *ost = ofilter->ost;
|
||||
OutputFile *of = output_files[ost->file_index];
|
||||
AVFilterContext *last_filter = out->filter_ctx;
|
||||
AVBPrint bprint;
|
||||
int pad_idx = out->pad_idx;
|
||||
int ret;
|
||||
const char *pix_fmts;
|
||||
char name[255];
|
||||
|
||||
snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
|
||||
@ -447,7 +462,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) {
|
||||
char args[255];
|
||||
AVFilterContext *filter;
|
||||
AVDictionaryEntry *e = NULL;
|
||||
const AVDictionaryEntry *e = NULL;
|
||||
|
||||
snprintf(args, sizeof(args), "%d:%d",
|
||||
ofilter->width, ofilter->height);
|
||||
@ -469,13 +484,14 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
pad_idx = 0;
|
||||
}
|
||||
|
||||
if ((pix_fmts = choose_pix_fmts(ofilter))) {
|
||||
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||
if ((pix_fmts = choose_pix_fmts(ofilter, &bprint))) {
|
||||
AVFilterContext *filter;
|
||||
|
||||
ret = avfilter_graph_create_filter(&filter,
|
||||
avfilter_get_by_name("format"),
|
||||
"format", pix_fmts, NULL, fg->graph);
|
||||
av_freep(&pix_fmts);
|
||||
av_bprint_finalize(&bprint, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
|
||||
@ -560,9 +576,10 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
} while (0)
|
||||
av_bprint_init(&args, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||
if (ost->audio_channels_mapped) {
|
||||
AVChannelLayout mapped_layout = { 0 };
|
||||
int i;
|
||||
av_bprintf(&args, "0x%"PRIx64,
|
||||
av_get_default_channel_layout(ost->audio_channels_mapped));
|
||||
av_channel_layout_default(&mapped_layout, ost->audio_channels_mapped);
|
||||
av_channel_layout_describe_bprint(&mapped_layout, &args);
|
||||
for (i = 0; i < ost->audio_channels_mapped; i++)
|
||||
if (ost->audio_channels_map[i] != -1)
|
||||
av_bprintf(&args, "|c%d=c%d", i, ost->audio_channels_map[i]);
|
||||
@ -571,8 +588,8 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
av_bprint_clear(&args);
|
||||
}
|
||||
|
||||
if (codec->channels && !codec->channel_layout)
|
||||
codec->channel_layout = av_get_default_channel_layout(codec->channels);
|
||||
if (codec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
|
||||
av_channel_layout_default(&codec->ch_layout, codec->ch_layout.nb_channels);
|
||||
|
||||
choose_sample_fmts(ofilter, &args);
|
||||
choose_sample_rates(ofilter, &args);
|
||||
@ -624,7 +641,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
fail:
|
||||
av_bprint_finalize(&args, NULL);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
@ -709,6 +726,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
{
|
||||
AVFilterContext *last_filter;
|
||||
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
||||
const AVPixFmtDescriptor *desc;
|
||||
InputStream *ist = ifilter->ist;
|
||||
InputFile *f = input_files[ist->file_index];
|
||||
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
|
||||
@ -766,44 +784,46 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
av_freep(&par);
|
||||
last_filter = ifilter->filter;
|
||||
|
||||
if (ist->autorotate) {
|
||||
double theta = get_rotation(ist->st);
|
||||
desc = av_pix_fmt_desc_get(ifilter->format);
|
||||
av_assert0(desc);
|
||||
|
||||
// TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
|
||||
if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
|
||||
int32_t *displaymatrix = ifilter->displaymatrix;
|
||||
double theta;
|
||||
|
||||
if (!displaymatrix)
|
||||
displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
|
||||
theta = get_rotation(displaymatrix);
|
||||
|
||||
if (fabs(theta - 90) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock");
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose",
|
||||
displaymatrix[3] > 0 ? "cclock_flip" : "clock");
|
||||
} else if (fabs(theta - 180) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
if (displaymatrix[0] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (displaymatrix[4] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
}
|
||||
} else if (fabs(theta - 270) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock");
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose",
|
||||
displaymatrix[3] < 0 ? "clock_flip" : "cclock");
|
||||
} else if (fabs(theta) > 1.0) {
|
||||
char rotate_buf[64];
|
||||
snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
|
||||
ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
|
||||
} else if (fabs(theta) < 1.0) {
|
||||
if (displaymatrix && displaymatrix[4] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
}
|
||||
}
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (do_deinterlace) {
|
||||
AVFilterContext *yadif;
|
||||
|
||||
snprintf(name, sizeof(name), "deinterlace_in_%d_%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if ((ret = avfilter_graph_create_filter(&yadif,
|
||||
avfilter_get_by_name("yadif"),
|
||||
name, "", NULL,
|
||||
fg->graph)) < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
last_filter = yadif;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "trim_in_%d_%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if (copy_ts) {
|
||||
@ -848,11 +868,12 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
1, ifilter->sample_rate,
|
||||
ifilter->sample_rate,
|
||||
av_get_sample_fmt_name(ifilter->format));
|
||||
if (ifilter->channel_layout)
|
||||
av_bprintf(&args, ":channel_layout=0x%"PRIx64,
|
||||
ifilter->channel_layout);
|
||||
else
|
||||
av_bprintf(&args, ":channels=%d", ifilter->channels);
|
||||
if (av_channel_layout_check(&ifilter->ch_layout) &&
|
||||
ifilter->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
|
||||
av_bprintf(&args, ":channel_layout=");
|
||||
av_channel_layout_describe_bprint(&ifilter->ch_layout, &args);
|
||||
} else
|
||||
av_bprintf(&args, ":channels=%d", ifilter->ch_layout.nb_channels);
|
||||
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
|
||||
ist->file_index, ist->st->index);
|
||||
|
||||
@ -962,6 +983,30 @@ static void cleanup_filtergraph(FilterGraph *fg)
|
||||
avfilter_graph_free(&fg->graph);
|
||||
}
|
||||
|
||||
static int filter_is_buffersrc(const AVFilterContext *f)
|
||||
{
|
||||
return f->nb_inputs == 0 &&
|
||||
(!strcmp(f->filter->name, "buffer") ||
|
||||
!strcmp(f->filter->name, "abuffer"));
|
||||
}
|
||||
|
||||
static int graph_is_meta(AVFilterGraph *graph)
|
||||
{
|
||||
for (unsigned i = 0; i < graph->nb_filters; i++) {
|
||||
const AVFilterContext *f = graph->filters[i];
|
||||
|
||||
/* in addition to filters flagged as meta, also
|
||||
* disregard sinks and buffersources (but not other sources,
|
||||
* since they introduce data we are not aware of)
|
||||
*/
|
||||
if (!((f->filter->flags & AVFILTER_FLAG_METADATA_ONLY) ||
|
||||
f->nb_outputs == 0 ||
|
||||
filter_is_buffersrc(f)))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg)
|
||||
{
|
||||
AVFilterInOut *inputs, *outputs, *cur;
|
||||
@ -976,24 +1021,31 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if (simple) {
|
||||
OutputStream *ost = fg->outputs[0]->ost;
|
||||
char args[512];
|
||||
AVDictionaryEntry *e = NULL;
|
||||
const AVDictionaryEntry *e = NULL;
|
||||
|
||||
fg->graph->nb_threads = filter_nbthreads;
|
||||
if (filter_nbthreads) {
|
||||
ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
} else {
|
||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||
if (e)
|
||||
av_opt_set(fg->graph, "threads", e->value, 0);
|
||||
}
|
||||
|
||||
args[0] = 0;
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(ost->sws_dict, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
}
|
||||
if (strlen(args))
|
||||
if (strlen(args)) {
|
||||
args[strlen(args)-1] = 0;
|
||||
|
||||
if (!strncmp(args, "sws_flags=", 10)) {
|
||||
// keep the 'flags=' part
|
||||
fg->graph->scale_sws_opts = av_strdup(args+4);
|
||||
fg->graph->scale_sws_opts = av_strdup(args);
|
||||
}
|
||||
|
||||
args[0] = 0;
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(ost->swr_opts, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
@ -1001,18 +1053,6 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if (strlen(args))
|
||||
args[strlen(args)-1] = 0;
|
||||
av_opt_set(fg->graph, "aresample_swr_opts", args, 0);
|
||||
|
||||
args[0] = '\0';
|
||||
while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
}
|
||||
if (strlen(args))
|
||||
args[strlen(args) - 1] = '\0';
|
||||
|
||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||
if (e)
|
||||
av_opt_set(fg->graph, "threads", e->value, 0);
|
||||
} else {
|
||||
fg->graph->nb_threads = filter_complex_nbthreads;
|
||||
}
|
||||
@ -1067,6 +1107,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
|
||||
goto fail;
|
||||
|
||||
fg->is_meta = graph_is_meta(fg->graph);
|
||||
|
||||
/* limit the lists of allowed formats to the ones selected, to
|
||||
* make sure they stay the same if the filtergraph is reconfigured later */
|
||||
for (i = 0; i < fg->nb_outputs; i++) {
|
||||
@ -1079,7 +1121,10 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
ofilter->height = av_buffersink_get_h(sink);
|
||||
|
||||
ofilter->sample_rate = av_buffersink_get_sample_rate(sink);
|
||||
ofilter->channel_layout = av_buffersink_get_channel_layout(sink);
|
||||
av_channel_layout_uninit(&ofilter->ch_layout);
|
||||
ret = av_buffersink_get_ch_layout(sink, &ofilter->ch_layout);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fg->reconfiguration = 1;
|
||||
@ -1101,9 +1146,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
}
|
||||
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
while (av_fifo_size(fg->inputs[i]->frame_queue)) {
|
||||
AVFrame *tmp;
|
||||
av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL);
|
||||
AVFrame *tmp;
|
||||
while (av_fifo_read(fg->inputs[i]->frame_queue, &tmp, 1) >= 0) {
|
||||
ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp);
|
||||
av_frame_free(&tmp);
|
||||
if (ret < 0)
|
||||
@ -1124,9 +1168,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
InputStream *ist = fg->inputs[i]->ist;
|
||||
if (ist->sub2video.sub_queue && ist->sub2video.frame) {
|
||||
while (av_fifo_size(ist->sub2video.sub_queue)) {
|
||||
AVSubtitle tmp;
|
||||
av_fifo_generic_read(ist->sub2video.sub_queue, &tmp, sizeof(tmp), NULL);
|
||||
AVSubtitle tmp;
|
||||
while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) {
|
||||
sub2video_update(ist, INT64_MIN, &tmp);
|
||||
avsubtitle_free(&tmp);
|
||||
}
|
||||
@ -1142,6 +1185,9 @@ fail:
|
||||
|
||||
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *sd;
|
||||
int ret;
|
||||
|
||||
av_buffer_unref(&ifilter->hw_frames_ctx);
|
||||
|
||||
ifilter->format = frame->format;
|
||||
@ -1151,8 +1197,14 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
|
||||
ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
|
||||
|
||||
ifilter->sample_rate = frame->sample_rate;
|
||||
ifilter->channels = frame->channels;
|
||||
ifilter->channel_layout = frame->channel_layout;
|
||||
ret = av_channel_layout_copy(&ifilter->ch_layout, &frame->ch_layout);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
av_freep(&ifilter->displaymatrix);
|
||||
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
|
||||
if (sd)
|
||||
ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
|
||||
|
||||
if (frame->hw_frames_ctx) {
|
||||
ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
@ -17,10 +19,17 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
* This file is the modified version of ffmpeg_hw.c file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads)
|
||||
*
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
*/
|
||||
@ -102,6 +111,8 @@ static char *hw_device_default_name(enum AVHWDeviceType type)
|
||||
|
||||
int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
{
|
||||
// "type=name"
|
||||
// "type=name,key=value,key2=value2"
|
||||
// "type=name:device,key=value,key2=value2"
|
||||
// "type:device,key=value,key2=value2"
|
||||
// -> av_hwdevice_ctx_create()
|
||||
@ -133,7 +144,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
}
|
||||
|
||||
if (*p == '=') {
|
||||
k = strcspn(p + 1, ":@");
|
||||
k = strcspn(p + 1, ":@,");
|
||||
|
||||
name = av_strndup(p + 1, k);
|
||||
if (!name) {
|
||||
@ -167,11 +178,11 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
q = strchr(p, ',');
|
||||
if (q) {
|
||||
if (q - p > 0) {
|
||||
device = av_strndup(p, q - p);
|
||||
if (!device) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
device = av_strndup(p, q - p);
|
||||
if (!device) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
|
||||
if (err < 0) {
|
||||
@ -199,6 +210,18 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
src->device_ref, 0);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
} else if (*p == ',') {
|
||||
err = av_dict_parse_string(&options, p + 1, "=", ",", 0);
|
||||
|
||||
if (err < 0) {
|
||||
errmsg = "failed to parse options";
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
err = av_hwdevice_ctx_create(&device_ref, type,
|
||||
NULL, options, 0);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
} else {
|
||||
errmsg = "parse error";
|
||||
goto invalid;
|
||||
@ -548,15 +571,21 @@ int hw_device_setup_for_filter(FilterGraph *fg)
|
||||
HWDevice *dev;
|
||||
int i;
|
||||
|
||||
// If the user has supplied exactly one hardware device then just
|
||||
// give it straight to every filter for convenience. If more than
|
||||
// one device is available then the user needs to pick one explcitly
|
||||
// with the filter_hw_device option.
|
||||
// Pick the last hardware device if the user doesn't pick the device for
|
||||
// filters explicitly with the filter_hw_device option.
|
||||
if (filter_hw_device)
|
||||
dev = filter_hw_device;
|
||||
else if (nb_hw_devices == 1)
|
||||
dev = hw_devices[0];
|
||||
else
|
||||
else if (nb_hw_devices > 0) {
|
||||
dev = hw_devices[nb_hw_devices - 1];
|
||||
|
||||
if (nb_hw_devices > 1)
|
||||
av_log(NULL, AV_LOG_WARNING, "There are %d hardware devices. device "
|
||||
"%s of type %s is picked for filters by default. Set hardware "
|
||||
"device explicitly with the filter_hw_device option if device "
|
||||
"%s is not usable for filters.\n",
|
||||
nb_hw_devices, dev->name,
|
||||
av_hwdevice_get_type_name(dev->type), dev->name);
|
||||
} else
|
||||
dev = NULL;
|
||||
|
||||
if (dev) {
|
||||
|
331
android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffmpeg_mux.c
Normal file
331
android/ffmpeg-kit-android-lib/src/main/cpp/fftools_ffmpeg_mux.c
Normal file
@ -0,0 +1,331 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
* copyright (c) 2022 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of ffmpeg_mux.c file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to fftools headers
|
||||
* - using main_ffmpeg_return_code instead of main_return_code
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fftools_ffmpeg.h"
|
||||
|
||||
#include "libavutil/fifo.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/timestamp.h"
|
||||
|
||||
#include "libavcodec/packet.h"
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavformat/avio.h"
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
|
||||
int unqueue)
|
||||
{
|
||||
AVFormatContext *s = of->ctx;
|
||||
AVStream *st = ost->st;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* 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().
|
||||
* Do not count the packet when unqueued because it has been counted when queued.
|
||||
*/
|
||||
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) && !unqueue) {
|
||||
if (ost->frame_number >= ost->max_frames) {
|
||||
av_packet_unref(pkt);
|
||||
return;
|
||||
}
|
||||
ost->frame_number++;
|
||||
}
|
||||
|
||||
if (!of->header_written) {
|
||||
AVPacket *tmp_pkt;
|
||||
/* the muxer is not initialized yet, buffer the packet */
|
||||
if (!av_fifo_can_write(ost->muxing_queue)) {
|
||||
size_t cur_size = av_fifo_can_read(ost->muxing_queue);
|
||||
unsigned int are_we_over_size =
|
||||
(ost->muxing_queue_data_size + pkt->size) > ost->muxing_queue_data_threshold;
|
||||
size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX;
|
||||
size_t new_size = FFMIN(2 * cur_size, limit);
|
||||
|
||||
if (new_size <= cur_size) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Too many packets buffered for output stream %d:%d.\n",
|
||||
ost->file_index, ost->st->index);
|
||||
exit_program(1);
|
||||
}
|
||||
ret = av_fifo_grow2(ost->muxing_queue, new_size - cur_size);
|
||||
if (ret < 0)
|
||||
exit_program(1);
|
||||
}
|
||||
ret = av_packet_make_refcounted(pkt);
|
||||
if (ret < 0)
|
||||
exit_program(1);
|
||||
tmp_pkt = av_packet_alloc();
|
||||
if (!tmp_pkt)
|
||||
exit_program(1);
|
||||
av_packet_move_ref(tmp_pkt, pkt);
|
||||
ost->muxing_queue_data_size += tmp_pkt->size;
|
||||
av_fifo_write(ost->muxing_queue, &tmp_pkt, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) ||
|
||||
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
|
||||
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
|
||||
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
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->mux_timebase);
|
||||
}
|
||||
}
|
||||
|
||||
av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base);
|
||||
|
||||
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 ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) &&
|
||||
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 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG;
|
||||
if (exit_on_error)
|
||||
loglevel = AV_LOG_ERROR;
|
||||
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 duration:%s duration_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),
|
||||
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ost->st->time_base),
|
||||
pkt->size
|
||||
);
|
||||
}
|
||||
|
||||
ret = av_interleaved_write_frame(s, pkt);
|
||||
if (ret < 0) {
|
||||
print_error("av_interleaved_write_frame()", ret);
|
||||
main_ffmpeg_return_code = 1;
|
||||
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED);
|
||||
}
|
||||
}
|
||||
|
||||
static int print_sdp(void)
|
||||
{
|
||||
char sdp[16384];
|
||||
int i;
|
||||
int j, ret;
|
||||
AVIOContext *sdp_pb;
|
||||
AVFormatContext **avc;
|
||||
|
||||
for (i = 0; i < nb_output_files; i++) {
|
||||
if (!output_files[i]->header_written)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = av_sdp_create(avc, j, sdp, sizeof(sdp));
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
if (!sdp_filename) {
|
||||
printf("SDP:\n%s\n", sdp);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
avio_print(sdp_pb, sdp);
|
||||
avio_closep(&sdp_pb);
|
||||
av_freep(&sdp_filename);
|
||||
}
|
||||
|
||||
fail:
|
||||
av_freep(&avc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* open the muxer when all the streams are initialized */
|
||||
int of_check_init(OutputFile *of)
|
||||
{
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < of->ctx->nb_streams; i++) {
|
||||
OutputStream *ost = output_streams[of->ost_index + i];
|
||||
if (!ost->initialized)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = avformat_write_header(of->ctx, &of->opts);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Could not write header for output file #%d "
|
||||
"(incorrect codec parameters ?): %s\n",
|
||||
of->index, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
//assert_avoptions(of->opts);
|
||||
of->header_written = 1;
|
||||
|
||||
av_dump_format(of->ctx, of->index, of->ctx->url, 1);
|
||||
nb_output_dumped++;
|
||||
|
||||
if (sdp_filename || want_sdp) {
|
||||
ret = print_sdp();
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error writing the SDP.\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* flush the muxing queues */
|
||||
for (i = 0; i < of->ctx->nb_streams; i++) {
|
||||
OutputStream *ost = output_streams[of->ost_index + i];
|
||||
AVPacket *pkt;
|
||||
|
||||
/* try to improve muxing time_base (only possible if nothing has been written yet) */
|
||||
if (!av_fifo_can_read(ost->muxing_queue))
|
||||
ost->mux_timebase = ost->st->time_base;
|
||||
|
||||
while (av_fifo_read(ost->muxing_queue, &pkt, 1) >= 0) {
|
||||
ost->muxing_queue_data_size -= pkt->size;
|
||||
of_write_packet(of, pkt, ost, 1);
|
||||
av_packet_free(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int of_write_trailer(OutputFile *of)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!of->header_written) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Nothing was written into output file %d (%s), because "
|
||||
"at least one of its streams received no packets.\n",
|
||||
of->index, of->ctx->url);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = av_write_trailer(of->ctx);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void of_close(OutputFile **pof)
|
||||
{
|
||||
OutputFile *of = *pof;
|
||||
AVFormatContext *s;
|
||||
|
||||
if (!of)
|
||||
return;
|
||||
|
||||
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(pof);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of fopen_utf8.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_FOPEN_UTF8_H
|
||||
#define FFTOOLS_FOPEN_UTF8_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8,
|
||||
* except that it doesn't set O_CLOEXEC, and that it isn't exported
|
||||
* from a different library. (On Windows, each DLL might use a different
|
||||
* CRT, and FILE* handles can't be shared across them.) */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "libavutil/wchar_filename.h"
|
||||
|
||||
static inline FILE *fopen_utf8(const char *path_utf8, const char *mode)
|
||||
{
|
||||
wchar_t *path_w, *mode_w;
|
||||
FILE *f;
|
||||
|
||||
/* convert UTF-8 to wide chars */
|
||||
if (get_extended_win32_path(path_utf8, &path_w)) /* This sets errno on error. */
|
||||
return NULL;
|
||||
if (!path_w)
|
||||
goto fallback;
|
||||
|
||||
if (utf8towchar(mode, &mode_w))
|
||||
return NULL;
|
||||
if (!mode_w) {
|
||||
/* If failing to interpret the mode string as utf8, it is an invalid
|
||||
* parameter. */
|
||||
av_freep(&path_w);
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f = _wfopen(path_w, mode_w);
|
||||
av_freep(&path_w);
|
||||
av_freep(&mode_w);
|
||||
|
||||
return f;
|
||||
fallback:
|
||||
/* path may be in CP_ACP */
|
||||
return fopen(path_utf8, mode);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline FILE *fopen_utf8(const char *path, const char *mode)
|
||||
{
|
||||
return fopen(path, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FFTOOLS_FOPEN_UTF8_H */
|
1492
android/ffmpeg-kit-android-lib/src/main/cpp/fftools_opt_common.c
Normal file
1492
android/ffmpeg-kit-android-lib/src/main/cpp/fftools_opt_common.c
Normal file
File diff suppressed because it is too large
Load Diff
202
android/ffmpeg-kit-android-lib/src/main/cpp/fftools_opt_common.h
Normal file
202
android/ffmpeg-kit-android-lib/src/main/cpp/fftools_opt_common.h
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Option handlers shared between the tools.
|
||||
* copyright (c) 2022 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of opt_common.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - CMDUTILS_COMMON_OPTIONS and CMDUTILS_COMMON_OPTIONS_AVDEVICE defines dropped
|
||||
* - fftools_ prefix added to fftools headers
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_OPT_COMMON_H
|
||||
#define FFTOOLS_OPT_COMMON_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fftools_cmdutils.h"
|
||||
|
||||
#if CONFIG_AVDEVICE
|
||||
/**
|
||||
* Print a listing containing autodetected 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 autodetected 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 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);
|
||||
|
||||
/**
|
||||
* Generic -h handler common to all fftools.
|
||||
*/
|
||||
int show_help(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* 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 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 muxers supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_muxers(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Print a listing containing all the demuxer supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_demuxers(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);
|
||||
|
||||
/**
|
||||
* 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 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 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 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 supported stream dispositions.
|
||||
*/
|
||||
int show_dispositions(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);
|
||||
|
||||
/**
|
||||
* Set the libav* libraries log level.
|
||||
*/
|
||||
int opt_loglevel(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_report(void *optctx, const char *opt, const char *arg);
|
||||
int init_report(const char *env, FILE **file);
|
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Override the cpuflags.
|
||||
*/
|
||||
int opt_cpuflags(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Override the cpucount.
|
||||
*/
|
||||
int opt_cpucount(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
#endif /* FFTOOLS_OPT_COMMON_H */
|
@ -85,7 +85,7 @@ public class NativeLoader {
|
||||
}
|
||||
|
||||
static String loadVersion() {
|
||||
final String version = "4.5.1";
|
||||
final String version = "5.1";
|
||||
|
||||
if (isTestModeDisabled()) {
|
||||
return FFmpegKitConfig.getVersion();
|
||||
|
@ -69,7 +69,7 @@ include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module, cpu-features)
|
||||
|
||||
MY_SRC_FILES := ffmpegkit.c ffprobekit.c ffmpegkit_exception.c fftools_cmdutils.c fftools_ffmpeg.c fftools_ffprobe.c fftools_ffmpeg_opt.c fftools_ffmpeg_hw.c fftools_ffmpeg_filter.c
|
||||
MY_SRC_FILES := ffmpegkit.c ffprobekit.c ffmpegkit_exception.c fftools_cmdutils.c fftools_ffmpeg.c fftools_ffprobe.c fftools_ffmpeg_mux.c fftools_ffmpeg_opt.c fftools_opt_common.c fftools_ffmpeg_hw.c fftools_ffmpeg_filter.c
|
||||
|
||||
ifeq ($(TARGET_PLATFORM),android-16)
|
||||
MY_SRC_FILES += android_lts_support.c
|
||||
|
1
apple.sh
1
apple.sh
@ -141,7 +141,6 @@ echo -e "INFO: Using iOS SDK: ${DETECTED_IOS_SDK_VERSION}, tvOS SDK: ${DETECTED_
|
||||
echo -e "INFO: Build options: $*\n" 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
||||
# SET DEFAULT BUILD OPTIONS
|
||||
GPL_ENABLED="no"
|
||||
DISPLAY_HELP=""
|
||||
BUILD_TYPE_ID=""
|
||||
BUILD_FULL=""
|
||||
|
@ -38,7 +38,7 @@ PROJECT_NAME = "FFmpegKit iOS / macOS / tvOS API"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 4.5.1
|
||||
PROJECT_NUMBER = 5.1
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
@ -1,6 +1,6 @@
|
||||
# ffmpeg-kit 4.5.1 configure.ac
|
||||
# ffmpeg-kit 5.1 configure.ac
|
||||
|
||||
AC_INIT([ffmpeg-kit], [4.5.1], [https://github.com/tanersener/ffmpeg-kit/issues/new])
|
||||
AC_INIT([ffmpeg-kit], [5.1], [https://github.com/tanersener/ffmpeg-kit/issues/new])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([src/FFmpegKit.m])
|
||||
|
||||
@ -35,15 +35,6 @@ AC_CHECK_HEADERS([libavformat/avformat.h libavcodec/avcodec.h libavfilter/avfilt
|
||||
])
|
||||
AC_CHECK_HEADERS([fcntl.h limits.h stdint.h stdlib.h string.h sys/ioctl.h sys/time.h termios.h unistd.h])
|
||||
|
||||
AC_ARG_ENABLE([videotoolbox],
|
||||
[ --enable-videotoolbox enable videotoolbox support],
|
||||
[case "${enableval}" in
|
||||
yes) videotoolbox=true ;;
|
||||
no) videotoolbox=false ;;
|
||||
*) AC_MSG_ERROR([bad value ${enableval} for --enable-videotoolbox]) ;;
|
||||
esac],[videotoolbox=false])
|
||||
AM_CONDITIONAL([FFMPEGKIT_VIDEOTOOLBOX], [test x$videotoolbox = xtrue])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_INLINE
|
||||
AC_TYPE_INT32_T
|
||||
|
@ -36,7 +36,7 @@
|
||||
#import "SessionState.h"
|
||||
|
||||
/** Global library version */
|
||||
NSString* const FFmpegKitVersion = @"4.5.1";
|
||||
NSString* const FFmpegKitVersion = @"5.1";
|
||||
|
||||
/**
|
||||
* Prefix of named pipes created by ffmpeg-kit.
|
||||
@ -88,7 +88,7 @@ volatile int handleSIGXCPU = 1;
|
||||
volatile int handleSIGPIPE = 1;
|
||||
|
||||
/** Holds the id of the current execution */
|
||||
__thread volatile long globalSessionId = 0;
|
||||
__thread long globalSessionId = 0;
|
||||
|
||||
/** Holds the default log level */
|
||||
int configuredLogLevel = LevelAVLogInfo;
|
||||
|
@ -25,12 +25,10 @@ libffmpegkit_la_SOURCES = \
|
||||
fftools_ffmpeg.c \
|
||||
fftools_ffmpeg_filter.c \
|
||||
fftools_ffmpeg_hw.c \
|
||||
fftools_ffmpeg_mux.c \
|
||||
fftools_ffmpeg_opt.c \
|
||||
fftools_ffprobe.c
|
||||
|
||||
if FFMPEGKIT_VIDEOTOOLBOX
|
||||
libffmpegkit_la_SOURCES += fftools_ffmpeg_videotoolbox.c
|
||||
endif
|
||||
fftools_ffprobe.c \
|
||||
fftools_opt_common.c
|
||||
|
||||
include_HEADERS = \
|
||||
AbstractSession.h \
|
||||
@ -61,7 +59,9 @@ include_HEADERS = \
|
||||
StreamInformation.h \
|
||||
ffmpegkit_exception.h \
|
||||
fftools_cmdutils.h \
|
||||
fftools_ffmpeg.h
|
||||
fftools_ffmpeg.h \
|
||||
fftools_fopen_utf8.h \
|
||||
fftools_opt_common.h
|
||||
|
||||
libffmpegkit_la_CFLAGS = $(CFLAGS)
|
||||
libffmpegkit_la_OBJCFLAGS = $(CFLAGS)
|
||||
|
@ -89,7 +89,6 @@ PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@FFMPEGKIT_VIDEOTOOLBOX_TRUE@am__append_1 = fftools_ffmpeg_videotoolbox.c
|
||||
subdir = src
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
|
||||
@ -133,16 +132,6 @@ am__uninstall_files_from_dir = { \
|
||||
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libffmpegkit_la_DEPENDENCIES =
|
||||
am__libffmpegkit_la_SOURCES_DIST = AbstractSession.m ArchDetect.m \
|
||||
AtomicLong.m Chapter.m FFmpegKit.m FFmpegKitConfig.m \
|
||||
FFmpegSession.m FFprobeKit.m FFprobeSession.m Log.m \
|
||||
MediaInformation.m MediaInformationJsonParser.m \
|
||||
MediaInformationSession.m Packages.m ReturnCode.m Statistics.m \
|
||||
StreamInformation.m ffmpegkit_exception.m fftools_cmdutils.c \
|
||||
fftools_ffmpeg.c fftools_ffmpeg_filter.c fftools_ffmpeg_hw.c \
|
||||
fftools_ffmpeg_opt.c fftools_ffprobe.c \
|
||||
fftools_ffmpeg_videotoolbox.c
|
||||
@FFMPEGKIT_VIDEOTOOLBOX_TRUE@am__objects_1 = libffmpegkit_la-fftools_ffmpeg_videotoolbox.lo
|
||||
am_libffmpegkit_la_OBJECTS = libffmpegkit_la-AbstractSession.lo \
|
||||
libffmpegkit_la-ArchDetect.lo libffmpegkit_la-AtomicLong.lo \
|
||||
libffmpegkit_la-Chapter.lo libffmpegkit_la-FFmpegKit.lo \
|
||||
@ -160,8 +149,10 @@ am_libffmpegkit_la_OBJECTS = libffmpegkit_la-AbstractSession.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_filter.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_hw.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_mux.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_opt.lo \
|
||||
libffmpegkit_la-fftools_ffprobe.lo $(am__objects_1)
|
||||
libffmpegkit_la-fftools_ffprobe.lo \
|
||||
libffmpegkit_la-fftools_opt_common.lo
|
||||
libffmpegkit_la_OBJECTS = $(am_libffmpegkit_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
@ -208,9 +199,10 @@ am__depfiles_remade = ./$(DEPDIR)/libffmpegkit_la-AbstractSession.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_videotoolbox.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
@ -249,7 +241,7 @@ am__v_OBJCLD_ = $(am__v_OBJCLD_@AM_DEFAULT_V@)
|
||||
am__v_OBJCLD_0 = @echo " OBJCLD " $@;
|
||||
am__v_OBJCLD_1 =
|
||||
SOURCES = $(libffmpegkit_la_SOURCES)
|
||||
DIST_SOURCES = $(am__libffmpegkit_la_SOURCES_DIST)
|
||||
DIST_SOURCES = $(libffmpegkit_la_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
@ -402,14 +394,34 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
lib_LTLIBRARIES = libffmpegkit.la
|
||||
libffmpegkit_la_LIBADD = @FFMPEG_FRAMEWORKS@
|
||||
libffmpegkit_la_SOURCES = AbstractSession.m ArchDetect.m AtomicLong.m \
|
||||
Chapter.m FFmpegKit.m FFmpegKitConfig.m FFmpegSession.m \
|
||||
FFprobeKit.m FFprobeSession.m Log.m MediaInformation.m \
|
||||
MediaInformationJsonParser.m MediaInformationSession.m \
|
||||
Packages.m ReturnCode.m Statistics.m StreamInformation.m \
|
||||
ffmpegkit_exception.m fftools_cmdutils.c fftools_ffmpeg.c \
|
||||
fftools_ffmpeg_filter.c fftools_ffmpeg_hw.c \
|
||||
fftools_ffmpeg_opt.c fftools_ffprobe.c $(am__append_1)
|
||||
libffmpegkit_la_SOURCES = \
|
||||
AbstractSession.m \
|
||||
ArchDetect.m \
|
||||
AtomicLong.m \
|
||||
Chapter.m \
|
||||
FFmpegKit.m \
|
||||
FFmpegKitConfig.m \
|
||||
FFmpegSession.m \
|
||||
FFprobeKit.m \
|
||||
FFprobeSession.m \
|
||||
Log.m \
|
||||
MediaInformation.m \
|
||||
MediaInformationJsonParser.m \
|
||||
MediaInformationSession.m \
|
||||
Packages.m \
|
||||
ReturnCode.m \
|
||||
Statistics.m \
|
||||
StreamInformation.m \
|
||||
ffmpegkit_exception.m \
|
||||
fftools_cmdutils.c \
|
||||
fftools_ffmpeg.c \
|
||||
fftools_ffmpeg_filter.c \
|
||||
fftools_ffmpeg_hw.c \
|
||||
fftools_ffmpeg_mux.c \
|
||||
fftools_ffmpeg_opt.c \
|
||||
fftools_ffprobe.c \
|
||||
fftools_opt_common.c
|
||||
|
||||
include_HEADERS = \
|
||||
AbstractSession.h \
|
||||
ArchDetect.h \
|
||||
@ -439,7 +451,9 @@ include_HEADERS = \
|
||||
StreamInformation.h \
|
||||
ffmpegkit_exception.h \
|
||||
fftools_cmdutils.h \
|
||||
fftools_ffmpeg.h
|
||||
fftools_ffmpeg.h \
|
||||
fftools_fopen_utf8.h \
|
||||
fftools_opt_common.h
|
||||
|
||||
libffmpegkit_la_CFLAGS = $(CFLAGS)
|
||||
libffmpegkit_la_OBJCFLAGS = $(CFLAGS)
|
||||
@ -545,9 +559,10 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_videotoolbox.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo@am__quote@ # am--include-marker
|
||||
|
||||
$(am__depfiles_remade):
|
||||
@$(MKDIR_P) $(@D)
|
||||
@ -607,6 +622,13 @@ libffmpegkit_la-fftools_ffmpeg_hw.lo: fftools_ffmpeg_hw.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_ffmpeg_hw.lo `test -f 'fftools_ffmpeg_hw.c' || echo '$(srcdir)/'`fftools_ffmpeg_hw.c
|
||||
|
||||
libffmpegkit_la-fftools_ffmpeg_mux.lo: fftools_ffmpeg_mux.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -MT libffmpegkit_la-fftools_ffmpeg_mux.lo -MD -MP -MF $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Tpo -c -o libffmpegkit_la-fftools_ffmpeg_mux.lo `test -f 'fftools_ffmpeg_mux.c' || echo '$(srcdir)/'`fftools_ffmpeg_mux.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Tpo $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fftools_ffmpeg_mux.c' object='libffmpegkit_la-fftools_ffmpeg_mux.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_ffmpeg_mux.lo `test -f 'fftools_ffmpeg_mux.c' || echo '$(srcdir)/'`fftools_ffmpeg_mux.c
|
||||
|
||||
libffmpegkit_la-fftools_ffmpeg_opt.lo: fftools_ffmpeg_opt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -MT libffmpegkit_la-fftools_ffmpeg_opt.lo -MD -MP -MF $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Tpo -c -o libffmpegkit_la-fftools_ffmpeg_opt.lo `test -f 'fftools_ffmpeg_opt.c' || echo '$(srcdir)/'`fftools_ffmpeg_opt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Tpo $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo
|
||||
@ -621,12 +643,12 @@ libffmpegkit_la-fftools_ffprobe.lo: fftools_ffprobe.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_ffprobe.lo `test -f 'fftools_ffprobe.c' || echo '$(srcdir)/'`fftools_ffprobe.c
|
||||
|
||||
libffmpegkit_la-fftools_ffmpeg_videotoolbox.lo: fftools_ffmpeg_videotoolbox.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -MT libffmpegkit_la-fftools_ffmpeg_videotoolbox.lo -MD -MP -MF $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_videotoolbox.Tpo -c -o libffmpegkit_la-fftools_ffmpeg_videotoolbox.lo `test -f 'fftools_ffmpeg_videotoolbox.c' || echo '$(srcdir)/'`fftools_ffmpeg_videotoolbox.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_videotoolbox.Tpo $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_videotoolbox.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fftools_ffmpeg_videotoolbox.c' object='libffmpegkit_la-fftools_ffmpeg_videotoolbox.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
libffmpegkit_la-fftools_opt_common.lo: fftools_opt_common.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -MT libffmpegkit_la-fftools_opt_common.lo -MD -MP -MF $(DEPDIR)/libffmpegkit_la-fftools_opt_common.Tpo -c -o libffmpegkit_la-fftools_opt_common.lo `test -f 'fftools_opt_common.c' || echo '$(srcdir)/'`fftools_opt_common.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libffmpegkit_la-fftools_opt_common.Tpo $(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fftools_opt_common.c' object='libffmpegkit_la-fftools_opt_common.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_ffmpeg_videotoolbox.lo `test -f 'fftools_ffmpeg_videotoolbox.c' || echo '$(srcdir)/'`fftools_ffmpeg_videotoolbox.c
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_opt_common.lo `test -f 'fftools_opt_common.c' || echo '$(srcdir)/'`fftools_opt_common.c
|
||||
|
||||
.m.o:
|
||||
@am__fastdepOBJC_TRUE@ $(AM_V_OBJC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
||||
@ -954,9 +976,10 @@ distclean: distclean-am
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_videotoolbox.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
@ -1024,9 +1047,10 @@ maintainer-clean: maintainer-clean-am
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_videotoolbox.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
|
@ -73,7 +73,6 @@ static NSMutableArray *supportedExternalLibraries;
|
||||
Boolean gnutls = [enabledLibraryArray containsObject:@"gnutls"];
|
||||
Boolean xvid = [enabledLibraryArray containsObject:@"xvid"];
|
||||
|
||||
Boolean min = false;
|
||||
Boolean minGpl = false;
|
||||
Boolean https = false;
|
||||
Boolean httpsGpl = false;
|
||||
@ -101,8 +100,6 @@ static NSMutableArray *supportedExternalLibraries;
|
||||
} else {
|
||||
if (gnutls) {
|
||||
https = true;
|
||||
} else {
|
||||
min = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Various utilities for command line tools
|
||||
* copyright (c) 2003 Fabrice Bellard
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@ -20,25 +21,37 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* - AV_LOG_STDERR introduced
|
||||
* This file is the modified version of cmdutils.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - config.h include added back
|
||||
*
|
||||
* 01.2020
|
||||
* --------------------------------------------------------
|
||||
* - ffprobe support added (variables used by ffprobe marked with "__thread" specifier)
|
||||
* - AV_LOG_STDERR log level added
|
||||
*
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads)
|
||||
*
|
||||
* 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Include guards renamed
|
||||
* - Unused headers removed
|
||||
* - include guards renamed
|
||||
* - unused headers removed
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_CMDUTILS_H
|
||||
@ -46,6 +59,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavfilter/avfilter.h"
|
||||
#include "libavformat/avformat.h"
|
||||
@ -70,11 +84,9 @@ extern __thread char *program_name;
|
||||
*/
|
||||
extern __thread int program_birth_year;
|
||||
|
||||
extern __thread AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
||||
extern __thread AVFormatContext *avformat_opts;
|
||||
extern __thread AVDictionary *sws_dict;
|
||||
extern __thread AVDictionary *swr_opts;
|
||||
extern __thread AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
extern __thread AVDictionary *format_opts, *codec_opts;
|
||||
extern __thread int hide_banner;
|
||||
extern __thread int find_stream_info;
|
||||
|
||||
@ -93,11 +105,6 @@ void exit_program(int ret) av_noreturn;
|
||||
*/
|
||||
void init_dynload(void);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -110,33 +117,12 @@ void uninit_opts(void);
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Override the cpucount.
|
||||
*/
|
||||
int opt_cpucount(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(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_codec_debug(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Limit the execution time.
|
||||
*/
|
||||
@ -237,7 +223,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||
* Show help for all options with given flags in class and all its
|
||||
* children.
|
||||
*/
|
||||
void show_help_children(const AVClass *class, int flags);
|
||||
void show_help_children(const AVClass *clazz, int flags);
|
||||
|
||||
/**
|
||||
* Per-fftool specific help handler. Implemented in each
|
||||
@ -309,7 +295,6 @@ typedef struct OptionGroup {
|
||||
|
||||
AVDictionary *codec_opts;
|
||||
AVDictionary *format_opts;
|
||||
AVDictionary *resample_opts;
|
||||
AVDictionary *sws_dict;
|
||||
AVDictionary *swr_opts;
|
||||
} OptionGroup;
|
||||
@ -417,8 +402,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
|
||||
* 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
|
||||
* @return pointer to the created array of dictionaries.
|
||||
* Calls exit() on failure.
|
||||
*/
|
||||
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
|
||||
AVDictionary *codec_opts);
|
||||
@ -441,136 +426,6 @@ void print_error(const char *filename, int err);
|
||||
*/
|
||||
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 muxers supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_muxers(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Print a listing containing all the demuxer supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_demuxers(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 autodetected 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 autodetected 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.
|
||||
@ -610,11 +465,26 @@ FILE *get_preset_file(char *filename, size_t filename_size,
|
||||
*/
|
||||
void *grow_array(void *array, int elem_size, int *size, int new_size);
|
||||
|
||||
#define media_type_string av_get_media_type_string
|
||||
/**
|
||||
* Atomically add a new element to an array of pointers, i.e. allocate
|
||||
* a new entry, reallocate the array of pointers and make the new last
|
||||
* member of this array point to the newly allocated buffer.
|
||||
* Calls exit() on failure.
|
||||
*
|
||||
* @param array array of pointers to reallocate
|
||||
* @param elem_size size of the new element to allocate
|
||||
* @param nb_elems pointer to the number of elements of the array array;
|
||||
* *nb_elems will be incremented by one by this function.
|
||||
* @return pointer to the newly allocated entry
|
||||
*/
|
||||
void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
|
||||
|
||||
#define GROW_ARRAY(array, nb_elems)\
|
||||
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
||||
|
||||
#define ALLOC_ARRAY_ELEM(array, nb_elems)\
|
||||
allocate_array_elem(&array, sizeof(*array[0]), &nb_elems)
|
||||
|
||||
#define GET_PIX_FMT_NAME(pix_fmt)\
|
||||
const char *name = av_get_pix_fmt_name(pix_fmt);
|
||||
|
||||
@ -628,14 +498,6 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
|
||||
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);
|
||||
double get_rotation(int32_t *displaymatrix);
|
||||
|
||||
#endif /* FFTOOLS_CMDUTILS_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
* Copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -17,33 +18,46 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 06.2020
|
||||
* This file is the modified version of ffmpeg.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - config.h include added back
|
||||
* - volatile dropped from thread local variables
|
||||
*
|
||||
* 06.2020
|
||||
* --------------------------------------------------------
|
||||
* - cancel_operation() method signature updated with id
|
||||
*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads,
|
||||
* signatures of ffmpeg_opt.c methods called by both ffmpeg and ffprobe added)
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
* - set_report_callback() method declared
|
||||
* - cancel_operation() method declared
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Include guards renamed
|
||||
* - include guards renamed
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_FFMPEG_H
|
||||
#define FFTOOLS_FFMPEG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@ -70,12 +84,14 @@
|
||||
|
||||
#include "libswresample/swresample.h"
|
||||
|
||||
#define VSYNC_AUTO -1
|
||||
#define VSYNC_PASSTHROUGH 0
|
||||
#define VSYNC_CFR 1
|
||||
#define VSYNC_VFR 2
|
||||
#define VSYNC_VSCFR 0xfe
|
||||
#define VSYNC_DROP 0xff
|
||||
enum VideoSyncMethod {
|
||||
VSYNC_AUTO = -1,
|
||||
VSYNC_PASSTHROUGH,
|
||||
VSYNC_CFR,
|
||||
VSYNC_VFR,
|
||||
VSYNC_VSCFR,
|
||||
VSYNC_DROP,
|
||||
};
|
||||
|
||||
#define MAX_STREAMS 1024 /* arbitrary sanity check value */
|
||||
|
||||
@ -83,16 +99,8 @@ enum HWAccelID {
|
||||
HWACCEL_NONE = 0,
|
||||
HWACCEL_AUTO,
|
||||
HWACCEL_GENERIC,
|
||||
HWACCEL_VIDEOTOOLBOX,
|
||||
};
|
||||
|
||||
typedef struct HWAccel {
|
||||
const char *name;
|
||||
int (*init)(AVCodecContext *s);
|
||||
enum HWAccelID id;
|
||||
enum AVPixelFormat pix_fmt;
|
||||
} HWAccel;
|
||||
|
||||
typedef struct HWDevice {
|
||||
const char *name;
|
||||
enum AVHWDeviceType type;
|
||||
@ -125,6 +133,8 @@ typedef struct OptionsContext {
|
||||
|
||||
SpecifierOpt *codec_names;
|
||||
int nb_codec_names;
|
||||
SpecifierOpt *audio_ch_layouts;
|
||||
int nb_audio_ch_layouts;
|
||||
SpecifierOpt *audio_channels;
|
||||
int nb_audio_channels;
|
||||
SpecifierOpt *audio_sample_rate;
|
||||
@ -145,6 +155,7 @@ typedef struct OptionsContext {
|
||||
float readrate;
|
||||
int accurate_seek;
|
||||
int thread_queue_size;
|
||||
int input_sync_ref;
|
||||
|
||||
SpecifierOpt *ts_scale;
|
||||
int nb_ts_scale;
|
||||
@ -203,6 +214,8 @@ typedef struct OptionsContext {
|
||||
int nb_qscale;
|
||||
SpecifierOpt *forced_key_frames;
|
||||
int nb_forced_key_frames;
|
||||
SpecifierOpt *fps_mode;
|
||||
int nb_fps_mode;
|
||||
SpecifierOpt *force_fps;
|
||||
int nb_force_fps;
|
||||
SpecifierOpt *frame_aspect_ratios;
|
||||
@ -259,6 +272,8 @@ typedef struct OptionsContext {
|
||||
int nb_enc_time_bases;
|
||||
SpecifierOpt *autoscale;
|
||||
int nb_autoscale;
|
||||
SpecifierOpt *bits_per_raw_sample;
|
||||
int nb_bits_per_raw_sample;
|
||||
} OptionsContext;
|
||||
|
||||
typedef struct InputFilter {
|
||||
@ -268,7 +283,7 @@ typedef struct InputFilter {
|
||||
uint8_t *name;
|
||||
enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video
|
||||
|
||||
AVFifoBuffer *frame_queue;
|
||||
AVFifo *frame_queue;
|
||||
|
||||
// parameters configured for this input
|
||||
int format;
|
||||
@ -277,10 +292,10 @@ typedef struct InputFilter {
|
||||
AVRational sample_aspect_ratio;
|
||||
|
||||
int sample_rate;
|
||||
int channels;
|
||||
uint64_t channel_layout;
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
int32_t *displaymatrix;
|
||||
|
||||
int eof;
|
||||
} InputFilter;
|
||||
@ -300,12 +315,13 @@ typedef struct OutputFilter {
|
||||
AVRational frame_rate;
|
||||
int format;
|
||||
int sample_rate;
|
||||
uint64_t channel_layout;
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
// those are only set if no format is specified and the encoder gives us multiple options
|
||||
int *formats;
|
||||
uint64_t *channel_layouts;
|
||||
int *sample_rates;
|
||||
// They point directly to the relevant lists of the encoder.
|
||||
const int *formats;
|
||||
const AVChannelLayout *ch_layouts;
|
||||
const int *sample_rates;
|
||||
} OutputFilter;
|
||||
|
||||
typedef struct FilterGraph {
|
||||
@ -314,6 +330,9 @@ typedef struct FilterGraph {
|
||||
|
||||
AVFilterGraph *graph;
|
||||
int reconfiguration;
|
||||
// true when the filtergraph contains only meta filters
|
||||
// that do not modify the frame data
|
||||
int is_meta;
|
||||
|
||||
InputFilter **inputs;
|
||||
int nb_inputs;
|
||||
@ -329,13 +348,14 @@ typedef struct InputStream {
|
||||
int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
|
||||
#define DECODING_FOR_OST 1
|
||||
#define DECODING_FOR_FILTER 2
|
||||
int processing_needed; /* non zero if the packets must be processed */
|
||||
|
||||
AVCodecContext *dec_ctx;
|
||||
const AVCodec *dec;
|
||||
AVFrame *decoded_frame;
|
||||
AVFrame *filter_frame; /* a ref of decoded_frame, to be sent to filters */
|
||||
AVPacket *pkt;
|
||||
|
||||
int64_t prev_pkt_pts;
|
||||
int64_t start; /* time when read started */
|
||||
/* predicted dts of the next packet read for this stream or (when there are
|
||||
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
|
||||
@ -377,14 +397,12 @@ typedef struct InputStream {
|
||||
struct sub2video {
|
||||
int64_t last_pts;
|
||||
int64_t end_pts;
|
||||
AVFifoBuffer *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFifo *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFrame *frame;
|
||||
int w, h;
|
||||
unsigned int initialize; ///< marks if sub2video_update should force an initialization
|
||||
} sub2video;
|
||||
|
||||
int dr1;
|
||||
|
||||
/* decoded data from this stream goes into all those filters
|
||||
* currently video and audio only */
|
||||
InputFilter **filters;
|
||||
@ -401,11 +419,9 @@ typedef struct InputStream {
|
||||
/* hwaccel context */
|
||||
void *hwaccel_ctx;
|
||||
void (*hwaccel_uninit)(AVCodecContext *s);
|
||||
int (*hwaccel_get_buffer)(AVCodecContext *s, AVFrame *frame, int flags);
|
||||
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
|
||||
enum AVPixelFormat hwaccel_pix_fmt;
|
||||
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
|
||||
/* stats */
|
||||
// combined size of all the packets read
|
||||
@ -432,11 +448,11 @@ typedef struct InputFile {
|
||||
at the moment when looping happens */
|
||||
AVRational time_base; /* time base of the duration */
|
||||
int64_t input_ts_offset;
|
||||
int input_sync_ref;
|
||||
|
||||
int64_t ts_offset;
|
||||
int64_t last_ts;
|
||||
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
|
||||
int seek_timestamp;
|
||||
int64_t recording_time;
|
||||
int nb_streams; /* number of stream that ffmpeg is aware of; may be different
|
||||
from ctx.nb_streams if new streams appear during av_read_frame() */
|
||||
@ -465,7 +481,7 @@ enum forced_keyframes_const {
|
||||
FKF_NB
|
||||
};
|
||||
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
|
||||
|
||||
extern const char *const forced_keyframes_const_names[];
|
||||
@ -481,7 +497,7 @@ typedef struct OutputStream {
|
||||
int source_index; /* InputStream index */
|
||||
AVStream *st; /* stream in the output file */
|
||||
int encoding_needed; /* true if encoding needed for this stream */
|
||||
int frame_number;
|
||||
int64_t frame_number;
|
||||
/* input pts and corresponding output pts
|
||||
for A/V sync */
|
||||
struct InputStream *sync_ist; /* input stream to sync against */
|
||||
@ -504,19 +520,22 @@ typedef struct OutputStream {
|
||||
AVFrame *filtered_frame;
|
||||
AVFrame *last_frame;
|
||||
AVPacket *pkt;
|
||||
int last_dropped;
|
||||
int last_nb0_frames[3];
|
||||
int64_t last_dropped;
|
||||
int64_t last_nb0_frames[3];
|
||||
|
||||
void *hwaccel_ctx;
|
||||
|
||||
/* video only */
|
||||
AVRational frame_rate;
|
||||
AVRational max_frame_rate;
|
||||
enum VideoSyncMethod vsync_method;
|
||||
int is_cfr;
|
||||
const char *fps_mode;
|
||||
int force_fps;
|
||||
int top_field_first;
|
||||
int rotate_overridden;
|
||||
int autoscale;
|
||||
int bits_per_raw_sample;
|
||||
double rotate_override_value;
|
||||
|
||||
AVRational frame_aspect_ratio;
|
||||
@ -546,7 +565,6 @@ typedef struct OutputStream {
|
||||
AVDictionary *encoder_opts;
|
||||
AVDictionary *sws_dict;
|
||||
AVDictionary *swr_opts;
|
||||
AVDictionary *resample_opts;
|
||||
char *apad;
|
||||
OSTFinished finished; /* no more packets should be written for this stream */
|
||||
int unavailable; /* true if the steram is unavailable (possibly temporarily) */
|
||||
@ -560,6 +578,7 @@ typedef struct OutputStream {
|
||||
int inputs_done;
|
||||
|
||||
const char *attachment_filename;
|
||||
int streamcopy_started;
|
||||
int copy_initial_nonkeyframes;
|
||||
int copy_prior_start;
|
||||
char *disposition;
|
||||
@ -574,6 +593,8 @@ typedef struct OutputStream {
|
||||
// number of frames/samples sent to the encoder
|
||||
uint64_t frames_encoded;
|
||||
uint64_t samples_encoded;
|
||||
// number of packets received from the encoder
|
||||
uint64_t packets_encoded;
|
||||
|
||||
/* packet quality factor */
|
||||
int quality;
|
||||
@ -581,7 +602,7 @@ typedef struct OutputStream {
|
||||
int max_muxing_queue_size;
|
||||
|
||||
/* the packets are buffered here until the muxer is ready to be initialized */
|
||||
AVFifoBuffer *muxing_queue;
|
||||
AVFifo *muxing_queue;
|
||||
|
||||
/*
|
||||
* The size of the AVPackets' buffers in queue.
|
||||
@ -600,6 +621,10 @@ typedef struct OutputStream {
|
||||
} OutputStream;
|
||||
|
||||
typedef struct OutputFile {
|
||||
int index;
|
||||
|
||||
const AVOutputFormat *format;
|
||||
|
||||
AVFormatContext *ctx;
|
||||
AVDictionary *opts;
|
||||
int ost_index; /* index of the first stream in output_streams */
|
||||
@ -634,7 +659,7 @@ extern __thread float dts_error_threshold;
|
||||
|
||||
extern __thread int audio_volume;
|
||||
extern __thread int audio_sync_method;
|
||||
extern __thread int video_sync_method;
|
||||
extern __thread enum VideoSyncMethod video_sync_method;
|
||||
extern __thread float frame_drop_threshold;
|
||||
extern __thread int do_benchmark;
|
||||
extern __thread int do_benchmark_all;
|
||||
@ -654,41 +679,35 @@ extern __thread int stdin_interaction;
|
||||
extern __thread int frame_bits_per_raw_sample;
|
||||
extern __thread AVIOContext *progress_avio;
|
||||
extern __thread float max_error_rate;
|
||||
extern __thread char *videotoolbox_pixfmt;
|
||||
|
||||
extern __thread int filter_nbthreads;
|
||||
extern __thread char *filter_nbthreads;
|
||||
extern __thread int filter_complex_nbthreads;
|
||||
extern __thread int vstats_version;
|
||||
extern __thread int auto_conversion_filters;
|
||||
|
||||
extern __thread const AVIOInterruptCB int_cb;
|
||||
|
||||
extern const HWAccel hwaccels[];
|
||||
#if CONFIG_QSV
|
||||
extern __thread char *qsv_device;
|
||||
#endif
|
||||
extern __thread HWDevice *filter_hw_device;
|
||||
|
||||
extern __thread int want_sdp;
|
||||
extern __thread unsigned nb_output_dumped;
|
||||
extern __thread int main_ffmpeg_return_code;
|
||||
|
||||
void term_init(void);
|
||||
void term_exit(void);
|
||||
|
||||
void reset_options(OptionsContext *o, int is_input);
|
||||
void show_usage(void);
|
||||
|
||||
void opt_output_file(void *optctx, const char *filename);
|
||||
|
||||
void remove_avoptions(AVDictionary **a, AVDictionary *b);
|
||||
void assert_avoptions(AVDictionary *m);
|
||||
|
||||
int guess_input_channel_layout(InputStream *ist);
|
||||
|
||||
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, const AVCodec *codec, enum AVPixelFormat target);
|
||||
void choose_sample_fmt(AVStream *st, const AVCodec *codec);
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg);
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
|
||||
void check_filter_outputs(void);
|
||||
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
|
||||
int filtergraph_is_simple(FilterGraph *fg);
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost);
|
||||
int init_complex_filtergraph(FilterGraph *fg);
|
||||
@ -712,6 +731,14 @@ int hw_device_setup_for_filter(FilterGraph *fg);
|
||||
|
||||
int hwaccel_decode_init(AVCodecContext *avctx);
|
||||
|
||||
/* open the muxer when all the streams are initialized */
|
||||
int of_check_init(OutputFile *of);
|
||||
int of_write_trailer(OutputFile *of);
|
||||
void of_close(OutputFile **pof);
|
||||
|
||||
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
|
||||
int unqueue);
|
||||
|
||||
void set_report_callback(void (*callback)(int, float, float, int64_t, int, double, double));
|
||||
|
||||
void cancel_operation(long id);
|
||||
@ -759,7 +786,6 @@ int opt_filter_hw_device(void *optctx, const char *opt, const char *arg);
|
||||
void add_input_streams(OptionsContext *o, AVFormatContext *ic);
|
||||
void assert_file_overwrite(const char *filename);
|
||||
void dump_attachment(AVStream *st, const char *filename);
|
||||
uint8_t *get_line(AVIOContext *s);
|
||||
void uninit_options(OptionsContext *o);
|
||||
void init_options(OptionsContext *o);
|
||||
AVDictionary *strip_specifiers(AVDictionary *dict);
|
||||
@ -772,7 +798,6 @@ int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOConte
|
||||
int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost);
|
||||
OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index);
|
||||
void parse_matrix_coeffs(uint16_t *dest, const char *str);
|
||||
uint8_t *fftools_read_file(const char *filename);
|
||||
char *get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost);
|
||||
void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc, const OutputStream *ost, enum AVMediaType type);
|
||||
OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
@ -781,7 +806,6 @@ OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int source
|
||||
OutputStream *new_unknown_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata);
|
||||
void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc);
|
||||
int init_complex_filters(void);
|
||||
int open_output_file(OptionsContext *o, const char *filename);
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* ffmpeg filter configuration
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@ -19,13 +20,19 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 08.2018
|
||||
* This file is the modified version of ffmpeg_filter.c file living in ffmpeg source code under the fftools folder.
|
||||
* We manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Unused headers removed
|
||||
* - unused headers removed
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
@ -53,7 +60,7 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c
|
||||
{
|
||||
static const enum AVPixelFormat mjpeg_formats[] =
|
||||
{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
|
||||
AV_PIX_FMT_NONE};
|
||||
AV_PIX_FMT_NONE };
|
||||
|
||||
if (!strcmp(codec->name, "mjpeg")) {
|
||||
return mjpeg_formats;
|
||||
@ -62,7 +69,8 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c
|
||||
}
|
||||
}
|
||||
|
||||
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, const AVCodec *codec, enum AVPixelFormat target)
|
||||
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx,
|
||||
const AVCodec *codec, enum AVPixelFormat target)
|
||||
{
|
||||
if (codec && codec->pix_fmts) {
|
||||
const enum AVPixelFormat *p = codec->pix_fmts;
|
||||
@ -92,10 +100,13 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, const
|
||||
return target;
|
||||
}
|
||||
|
||||
static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
/* May return NULL (no pixel format found), a static string or a string
|
||||
* backed by the bprint. Nothing has been written to the AVBPrint in case
|
||||
* NULL is returned. The AVBPrint provided should be clean. */
|
||||
static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
|
||||
{
|
||||
OutputStream *ost = ofilter->ost;
|
||||
AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
|
||||
const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
|
||||
if (strict_dict)
|
||||
// used by choose_pixel_fmt() and below
|
||||
av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
|
||||
@ -105,18 +116,12 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
AVFILTER_AUTO_CONVERT_NONE);
|
||||
if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
|
||||
return NULL;
|
||||
return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt));
|
||||
return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt);
|
||||
}
|
||||
if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
|
||||
return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)));
|
||||
return av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt));
|
||||
} else if (ost->enc && ost->enc->pix_fmts) {
|
||||
const enum AVPixelFormat *p;
|
||||
AVIOContext *s = NULL;
|
||||
uint8_t *ret;
|
||||
int len;
|
||||
|
||||
if (avio_open_dyn_buf(&s) < 0)
|
||||
exit_program(1);
|
||||
|
||||
p = ost->enc->pix_fmts;
|
||||
if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
|
||||
@ -125,11 +130,11 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
|
||||
for (; *p != AV_PIX_FMT_NONE; p++) {
|
||||
const char *name = av_get_pix_fmt_name(*p);
|
||||
avio_printf(s, "%s|", name);
|
||||
av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|');
|
||||
}
|
||||
len = avio_close_dyn_buf(s, &ret);
|
||||
ret[len - 1] = 0;
|
||||
return ret;
|
||||
if (!av_bprint_is_complete(bprint))
|
||||
exit_program(1);
|
||||
return bprint->str;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
@ -165,39 +170,54 @@ DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats,
|
||||
DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0,
|
||||
"%d", )
|
||||
|
||||
DEF_CHOOSE_FORMAT(channel_layouts, uint64_t, channel_layout, channel_layouts, 0,
|
||||
"0x%"PRIx64, )
|
||||
static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
|
||||
{
|
||||
if (av_channel_layout_check(&ofilter->ch_layout)) {
|
||||
av_bprintf(bprint, "channel_layouts=");
|
||||
av_channel_layout_describe_bprint(&ofilter->ch_layout, bprint);
|
||||
} else if (ofilter->ch_layouts) {
|
||||
const AVChannelLayout *p;
|
||||
|
||||
av_bprintf(bprint, "channel_layouts=");
|
||||
for (p = ofilter->ch_layouts; p->nb_channels; p++) {
|
||||
av_channel_layout_describe_bprint(p, bprint);
|
||||
av_bprintf(bprint, "|");
|
||||
}
|
||||
if (bprint->len > 0)
|
||||
bprint->str[--bprint->len] = '\0';
|
||||
} else
|
||||
return;
|
||||
av_bprint_chars(bprint, ':', 1);
|
||||
}
|
||||
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
{
|
||||
FilterGraph *fg = av_mallocz(sizeof(*fg));
|
||||
OutputFilter *ofilter;
|
||||
InputFilter *ifilter;
|
||||
|
||||
if (!fg)
|
||||
exit_program(1);
|
||||
fg->index = nb_filtergraphs;
|
||||
|
||||
GROW_ARRAY(fg->outputs, fg->nb_outputs);
|
||||
if (!(fg->outputs[0] = av_mallocz(sizeof(*fg->outputs[0]))))
|
||||
exit_program(1);
|
||||
fg->outputs[0]->ost = ost;
|
||||
fg->outputs[0]->graph = fg;
|
||||
fg->outputs[0]->format = -1;
|
||||
ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
ofilter->ost = ost;
|
||||
ofilter->graph = fg;
|
||||
ofilter->format = -1;
|
||||
|
||||
ost->filter = fg->outputs[0];
|
||||
ost->filter = ofilter;
|
||||
|
||||
GROW_ARRAY(fg->inputs, fg->nb_inputs);
|
||||
if (!(fg->inputs[0] = av_mallocz(sizeof(*fg->inputs[0]))))
|
||||
exit_program(1);
|
||||
fg->inputs[0]->ist = ist;
|
||||
fg->inputs[0]->graph = fg;
|
||||
fg->inputs[0]->format = -1;
|
||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
|
||||
fg->inputs[0]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[0]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[0];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
|
||||
GROW_ARRAY(filtergraphs, nb_filtergraphs);
|
||||
filtergraphs[nb_filtergraphs - 1] = fg;
|
||||
@ -210,17 +230,15 @@ static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
|
||||
AVFilterContext *ctx = inout->filter_ctx;
|
||||
AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads;
|
||||
int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs;
|
||||
AVIOContext *pb;
|
||||
uint8_t *res = NULL;
|
||||
char *res;
|
||||
|
||||
if (avio_open_dyn_buf(&pb) < 0)
|
||||
exit_program(1);
|
||||
|
||||
avio_printf(pb, "%s", ctx->filter->name);
|
||||
if (nb_pads > 1)
|
||||
avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));
|
||||
avio_w8(pb, 0);
|
||||
avio_close_dyn_buf(pb, &res);
|
||||
res = av_strdup(ctx->filter->name);
|
||||
else
|
||||
res = av_asprintf("%s:%s", ctx->filter->name,
|
||||
avfilter_pad_get_name(pads, inout->pad_idx));
|
||||
if (!res)
|
||||
exit_program(1);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -228,6 +246,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
{
|
||||
InputStream *ist = NULL;
|
||||
enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
|
||||
InputFilter *ifilter;
|
||||
int i;
|
||||
|
||||
// TODO: support other filter types
|
||||
@ -292,23 +311,22 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
|
||||
ist->discard = 0;
|
||||
ist->decoding_needed |= DECODING_FOR_FILTER;
|
||||
ist->processing_needed = 1;
|
||||
ist->st->discard = AVDISCARD_NONE;
|
||||
|
||||
GROW_ARRAY(fg->inputs, fg->nb_inputs);
|
||||
if (!(fg->inputs[fg->nb_inputs - 1] = av_mallocz(sizeof(*fg->inputs[0]))))
|
||||
exit_program(1);
|
||||
fg->inputs[fg->nb_inputs - 1]->ist = ist;
|
||||
fg->inputs[fg->nb_inputs - 1]->graph = fg;
|
||||
fg->inputs[fg->nb_inputs - 1]->format = -1;
|
||||
fg->inputs[fg->nb_inputs - 1]->type = ist->st->codecpar->codec_type;
|
||||
fg->inputs[fg->nb_inputs - 1]->name = describe_filter_link(fg, in, 1);
|
||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
ifilter->type = ist->st->codecpar->codec_type;
|
||||
ifilter->name = describe_filter_link(fg, in, 1);
|
||||
|
||||
fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[fg->nb_inputs - 1]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
}
|
||||
|
||||
int init_complex_filtergraph(FilterGraph *fg)
|
||||
@ -332,18 +350,15 @@ int init_complex_filtergraph(FilterGraph *fg)
|
||||
init_input_filter(fg, cur);
|
||||
|
||||
for (cur = outputs; cur;) {
|
||||
GROW_ARRAY(fg->outputs, fg->nb_outputs);
|
||||
fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0]));
|
||||
if (!fg->outputs[fg->nb_outputs - 1])
|
||||
exit_program(1);
|
||||
OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
|
||||
fg->outputs[fg->nb_outputs - 1]->graph = fg;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
|
||||
fg->outputs[fg->nb_outputs - 1]->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
ofilter->graph = fg;
|
||||
ofilter->out_tmp = cur;
|
||||
ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
cur->pad_idx);
|
||||
fg->outputs[fg->nb_outputs - 1]->name = describe_filter_link(fg, cur, 0);
|
||||
ofilter->name = describe_filter_link(fg, cur, 0);
|
||||
cur = cur->next;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL;
|
||||
ofilter->out_tmp->next = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
@ -427,12 +442,13 @@ static int insert_filter(AVFilterContext **last_filter, int *pad_idx,
|
||||
|
||||
static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
|
||||
{
|
||||
char *pix_fmts;
|
||||
OutputStream *ost = ofilter->ost;
|
||||
OutputFile *of = output_files[ost->file_index];
|
||||
AVFilterContext *last_filter = out->filter_ctx;
|
||||
AVBPrint bprint;
|
||||
int pad_idx = out->pad_idx;
|
||||
int ret;
|
||||
const char *pix_fmts;
|
||||
char name[255];
|
||||
|
||||
snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
|
||||
@ -446,7 +462,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) {
|
||||
char args[255];
|
||||
AVFilterContext *filter;
|
||||
AVDictionaryEntry *e = NULL;
|
||||
const AVDictionaryEntry *e = NULL;
|
||||
|
||||
snprintf(args, sizeof(args), "%d:%d",
|
||||
ofilter->width, ofilter->height);
|
||||
@ -468,13 +484,14 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
pad_idx = 0;
|
||||
}
|
||||
|
||||
if ((pix_fmts = choose_pix_fmts(ofilter))) {
|
||||
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||
if ((pix_fmts = choose_pix_fmts(ofilter, &bprint))) {
|
||||
AVFilterContext *filter;
|
||||
|
||||
ret = avfilter_graph_create_filter(&filter,
|
||||
avfilter_get_by_name("format"),
|
||||
"format", pix_fmts, NULL, fg->graph);
|
||||
av_freep(&pix_fmts);
|
||||
av_bprint_finalize(&bprint, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
|
||||
@ -559,9 +576,10 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
} while (0)
|
||||
av_bprint_init(&args, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||
if (ost->audio_channels_mapped) {
|
||||
AVChannelLayout mapped_layout = { 0 };
|
||||
int i;
|
||||
av_bprintf(&args, "0x%"PRIx64,
|
||||
av_get_default_channel_layout(ost->audio_channels_mapped));
|
||||
av_channel_layout_default(&mapped_layout, ost->audio_channels_mapped);
|
||||
av_channel_layout_describe_bprint(&mapped_layout, &args);
|
||||
for (i = 0; i < ost->audio_channels_mapped; i++)
|
||||
if (ost->audio_channels_map[i] != -1)
|
||||
av_bprintf(&args, "|c%d=c%d", i, ost->audio_channels_map[i]);
|
||||
@ -570,8 +588,8 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
av_bprint_clear(&args);
|
||||
}
|
||||
|
||||
if (codec->channels && !codec->channel_layout)
|
||||
codec->channel_layout = av_get_default_channel_layout(codec->channels);
|
||||
if (codec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
|
||||
av_channel_layout_default(&codec->ch_layout, codec->ch_layout.nb_channels);
|
||||
|
||||
choose_sample_fmts(ofilter, &args);
|
||||
choose_sample_rates(ofilter, &args);
|
||||
@ -623,10 +641,11 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
fail:
|
||||
av_bprint_finalize(&args, NULL);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
AVFilterInOut *out)
|
||||
{
|
||||
if (!ofilter->ost) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
|
||||
@ -707,6 +726,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
{
|
||||
AVFilterContext *last_filter;
|
||||
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
||||
const AVPixFmtDescriptor *desc;
|
||||
InputStream *ist = ifilter->ist;
|
||||
InputFile *f = input_files[ist->file_index];
|
||||
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
|
||||
@ -764,44 +784,46 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
av_freep(&par);
|
||||
last_filter = ifilter->filter;
|
||||
|
||||
if (ist->autorotate) {
|
||||
double theta = get_rotation(ist->st);
|
||||
desc = av_pix_fmt_desc_get(ifilter->format);
|
||||
av_assert0(desc);
|
||||
|
||||
// TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
|
||||
if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
|
||||
int32_t *displaymatrix = ifilter->displaymatrix;
|
||||
double theta;
|
||||
|
||||
if (!displaymatrix)
|
||||
displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
|
||||
theta = get_rotation(displaymatrix);
|
||||
|
||||
if (fabs(theta - 90) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock");
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose",
|
||||
displaymatrix[3] > 0 ? "cclock_flip" : "clock");
|
||||
} else if (fabs(theta - 180) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
if (displaymatrix[0] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (displaymatrix[4] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
}
|
||||
} else if (fabs(theta - 270) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock");
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose",
|
||||
displaymatrix[3] < 0 ? "clock_flip" : "cclock");
|
||||
} else if (fabs(theta) > 1.0) {
|
||||
char rotate_buf[64];
|
||||
snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
|
||||
ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
|
||||
} else if (fabs(theta) < 1.0) {
|
||||
if (displaymatrix && displaymatrix[4] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
}
|
||||
}
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (do_deinterlace) {
|
||||
AVFilterContext *yadif;
|
||||
|
||||
snprintf(name, sizeof(name), "deinterlace_in_%d_%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if ((ret = avfilter_graph_create_filter(&yadif,
|
||||
avfilter_get_by_name("yadif"),
|
||||
name, "", NULL,
|
||||
fg->graph)) < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
last_filter = yadif;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "trim_in_%d_%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if (copy_ts) {
|
||||
@ -846,11 +868,12 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
1, ifilter->sample_rate,
|
||||
ifilter->sample_rate,
|
||||
av_get_sample_fmt_name(ifilter->format));
|
||||
if (ifilter->channel_layout)
|
||||
av_bprintf(&args, ":channel_layout=0x%"PRIx64,
|
||||
ifilter->channel_layout);
|
||||
else
|
||||
av_bprintf(&args, ":channels=%d", ifilter->channels);
|
||||
if (av_channel_layout_check(&ifilter->ch_layout) &&
|
||||
ifilter->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
|
||||
av_bprintf(&args, ":channel_layout=");
|
||||
av_channel_layout_describe_bprint(&ifilter->ch_layout, &args);
|
||||
} else
|
||||
av_bprintf(&args, ":channels=%d", ifilter->ch_layout.nb_channels);
|
||||
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
|
||||
ist->file_index, ist->st->index);
|
||||
|
||||
@ -960,6 +983,30 @@ static void cleanup_filtergraph(FilterGraph *fg)
|
||||
avfilter_graph_free(&fg->graph);
|
||||
}
|
||||
|
||||
static int filter_is_buffersrc(const AVFilterContext *f)
|
||||
{
|
||||
return f->nb_inputs == 0 &&
|
||||
(!strcmp(f->filter->name, "buffer") ||
|
||||
!strcmp(f->filter->name, "abuffer"));
|
||||
}
|
||||
|
||||
static int graph_is_meta(AVFilterGraph *graph)
|
||||
{
|
||||
for (unsigned i = 0; i < graph->nb_filters; i++) {
|
||||
const AVFilterContext *f = graph->filters[i];
|
||||
|
||||
/* in addition to filters flagged as meta, also
|
||||
* disregard sinks and buffersources (but not other sources,
|
||||
* since they introduce data we are not aware of)
|
||||
*/
|
||||
if (!((f->filter->flags & AVFILTER_FLAG_METADATA_ONLY) ||
|
||||
f->nb_outputs == 0 ||
|
||||
filter_is_buffersrc(f)))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg)
|
||||
{
|
||||
AVFilterInOut *inputs, *outputs, *cur;
|
||||
@ -974,24 +1021,31 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if (simple) {
|
||||
OutputStream *ost = fg->outputs[0]->ost;
|
||||
char args[512];
|
||||
AVDictionaryEntry *e = NULL;
|
||||
const AVDictionaryEntry *e = NULL;
|
||||
|
||||
fg->graph->nb_threads = filter_nbthreads;
|
||||
if (filter_nbthreads) {
|
||||
ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
} else {
|
||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||
if (e)
|
||||
av_opt_set(fg->graph, "threads", e->value, 0);
|
||||
}
|
||||
|
||||
args[0] = 0;
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(ost->sws_dict, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
}
|
||||
if (strlen(args))
|
||||
if (strlen(args)) {
|
||||
args[strlen(args)-1] = 0;
|
||||
|
||||
if (!strncmp(args, "sws_flags=", 10)) {
|
||||
// keep the 'flags=' part
|
||||
fg->graph->scale_sws_opts = av_strdup(args+4);
|
||||
fg->graph->scale_sws_opts = av_strdup(args);
|
||||
}
|
||||
|
||||
args[0] = 0;
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(ost->swr_opts, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
@ -999,18 +1053,6 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if (strlen(args))
|
||||
args[strlen(args)-1] = 0;
|
||||
av_opt_set(fg->graph, "aresample_swr_opts", args, 0);
|
||||
|
||||
args[0] = '\0';
|
||||
while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
}
|
||||
if (strlen(args))
|
||||
args[strlen(args) - 1] = '\0';
|
||||
|
||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||
if (e)
|
||||
av_opt_set(fg->graph, "threads", e->value, 0);
|
||||
} else {
|
||||
fg->graph->nb_threads = filter_complex_nbthreads;
|
||||
}
|
||||
@ -1065,6 +1107,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
|
||||
goto fail;
|
||||
|
||||
fg->is_meta = graph_is_meta(fg->graph);
|
||||
|
||||
/* limit the lists of allowed formats to the ones selected, to
|
||||
* make sure they stay the same if the filtergraph is reconfigured later */
|
||||
for (i = 0; i < fg->nb_outputs; i++) {
|
||||
@ -1077,7 +1121,10 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
ofilter->height = av_buffersink_get_h(sink);
|
||||
|
||||
ofilter->sample_rate = av_buffersink_get_sample_rate(sink);
|
||||
ofilter->channel_layout = av_buffersink_get_channel_layout(sink);
|
||||
av_channel_layout_uninit(&ofilter->ch_layout);
|
||||
ret = av_buffersink_get_ch_layout(sink, &ofilter->ch_layout);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fg->reconfiguration = 1;
|
||||
@ -1099,9 +1146,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
}
|
||||
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
while (av_fifo_size(fg->inputs[i]->frame_queue)) {
|
||||
AVFrame *tmp;
|
||||
av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL);
|
||||
AVFrame *tmp;
|
||||
while (av_fifo_read(fg->inputs[i]->frame_queue, &tmp, 1) >= 0) {
|
||||
ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp);
|
||||
av_frame_free(&tmp);
|
||||
if (ret < 0)
|
||||
@ -1122,9 +1168,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
InputStream *ist = fg->inputs[i]->ist;
|
||||
if (ist->sub2video.sub_queue && ist->sub2video.frame) {
|
||||
while (av_fifo_size(ist->sub2video.sub_queue)) {
|
||||
AVSubtitle tmp;
|
||||
av_fifo_generic_read(ist->sub2video.sub_queue, &tmp, sizeof(tmp), NULL);
|
||||
AVSubtitle tmp;
|
||||
while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) {
|
||||
sub2video_update(ist, INT64_MIN, &tmp);
|
||||
avsubtitle_free(&tmp);
|
||||
}
|
||||
@ -1140,6 +1185,9 @@ fail:
|
||||
|
||||
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *sd;
|
||||
int ret;
|
||||
|
||||
av_buffer_unref(&ifilter->hw_frames_ctx);
|
||||
|
||||
ifilter->format = frame->format;
|
||||
@ -1149,8 +1197,14 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
|
||||
ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
|
||||
|
||||
ifilter->sample_rate = frame->sample_rate;
|
||||
ifilter->channels = frame->channels;
|
||||
ifilter->channel_layout = frame->channel_layout;
|
||||
ret = av_channel_layout_copy(&ifilter->ch_layout, &frame->ch_layout);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
av_freep(&ifilter->displaymatrix);
|
||||
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
|
||||
if (sd)
|
||||
ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
|
||||
|
||||
if (frame->hw_frames_ctx) {
|
||||
ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
@ -17,10 +19,17 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
* This file is the modified version of ffmpeg_hw.c file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads)
|
||||
*
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
*/
|
||||
@ -102,6 +111,8 @@ static char *hw_device_default_name(enum AVHWDeviceType type)
|
||||
|
||||
int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
{
|
||||
// "type=name"
|
||||
// "type=name,key=value,key2=value2"
|
||||
// "type=name:device,key=value,key2=value2"
|
||||
// "type:device,key=value,key2=value2"
|
||||
// -> av_hwdevice_ctx_create()
|
||||
@ -133,7 +144,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
}
|
||||
|
||||
if (*p == '=') {
|
||||
k = strcspn(p + 1, ":@");
|
||||
k = strcspn(p + 1, ":@,");
|
||||
|
||||
name = av_strndup(p + 1, k);
|
||||
if (!name) {
|
||||
@ -167,11 +178,11 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
q = strchr(p, ',');
|
||||
if (q) {
|
||||
if (q - p > 0) {
|
||||
device = av_strndup(p, q - p);
|
||||
if (!device) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
device = av_strndup(p, q - p);
|
||||
if (!device) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
|
||||
if (err < 0) {
|
||||
@ -199,6 +210,18 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
src->device_ref, 0);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
} else if (*p == ',') {
|
||||
err = av_dict_parse_string(&options, p + 1, "=", ",", 0);
|
||||
|
||||
if (err < 0) {
|
||||
errmsg = "failed to parse options";
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
err = av_hwdevice_ctx_create(&device_ref, type,
|
||||
NULL, options, 0);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
} else {
|
||||
errmsg = "parse error";
|
||||
goto invalid;
|
||||
@ -548,15 +571,21 @@ int hw_device_setup_for_filter(FilterGraph *fg)
|
||||
HWDevice *dev;
|
||||
int i;
|
||||
|
||||
// If the user has supplied exactly one hardware device then just
|
||||
// give it straight to every filter for convenience. If more than
|
||||
// one device is available then the user needs to pick one explcitly
|
||||
// with the filter_hw_device option.
|
||||
// Pick the last hardware device if the user doesn't pick the device for
|
||||
// filters explicitly with the filter_hw_device option.
|
||||
if (filter_hw_device)
|
||||
dev = filter_hw_device;
|
||||
else if (nb_hw_devices == 1)
|
||||
dev = hw_devices[0];
|
||||
else
|
||||
else if (nb_hw_devices > 0) {
|
||||
dev = hw_devices[nb_hw_devices - 1];
|
||||
|
||||
if (nb_hw_devices > 1)
|
||||
av_log(NULL, AV_LOG_WARNING, "There are %d hardware devices. device "
|
||||
"%s of type %s is picked for filters by default. Set hardware "
|
||||
"device explicitly with the filter_hw_device option if device "
|
||||
"%s is not usable for filters.\n",
|
||||
nb_hw_devices, dev->name,
|
||||
av_hwdevice_get_type_name(dev->type), dev->name);
|
||||
} else
|
||||
dev = NULL;
|
||||
|
||||
if (dev) {
|
||||
|
332
apple/src/fftools_ffmpeg_mux.c
Normal file
332
apple/src/fftools_ffmpeg_mux.c
Normal file
@ -0,0 +1,332 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
* copyright (c) 2022 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of ffmpeg_mux.c file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to fftools headers
|
||||
* - using main_ffmpeg_return_code instead of main_return_code
|
||||
* - printf replaced with av_log statements
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fftools_ffmpeg.h"
|
||||
|
||||
#include "libavutil/fifo.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/timestamp.h"
|
||||
|
||||
#include "libavcodec/packet.h"
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavformat/avio.h"
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
|
||||
int unqueue)
|
||||
{
|
||||
AVFormatContext *s = of->ctx;
|
||||
AVStream *st = ost->st;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* 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().
|
||||
* Do not count the packet when unqueued because it has been counted when queued.
|
||||
*/
|
||||
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) && !unqueue) {
|
||||
if (ost->frame_number >= ost->max_frames) {
|
||||
av_packet_unref(pkt);
|
||||
return;
|
||||
}
|
||||
ost->frame_number++;
|
||||
}
|
||||
|
||||
if (!of->header_written) {
|
||||
AVPacket *tmp_pkt;
|
||||
/* the muxer is not initialized yet, buffer the packet */
|
||||
if (!av_fifo_can_write(ost->muxing_queue)) {
|
||||
size_t cur_size = av_fifo_can_read(ost->muxing_queue);
|
||||
unsigned int are_we_over_size =
|
||||
(ost->muxing_queue_data_size + pkt->size) > ost->muxing_queue_data_threshold;
|
||||
size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX;
|
||||
size_t new_size = FFMIN(2 * cur_size, limit);
|
||||
|
||||
if (new_size <= cur_size) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Too many packets buffered for output stream %d:%d.\n",
|
||||
ost->file_index, ost->st->index);
|
||||
exit_program(1);
|
||||
}
|
||||
ret = av_fifo_grow2(ost->muxing_queue, new_size - cur_size);
|
||||
if (ret < 0)
|
||||
exit_program(1);
|
||||
}
|
||||
ret = av_packet_make_refcounted(pkt);
|
||||
if (ret < 0)
|
||||
exit_program(1);
|
||||
tmp_pkt = av_packet_alloc();
|
||||
if (!tmp_pkt)
|
||||
exit_program(1);
|
||||
av_packet_move_ref(tmp_pkt, pkt);
|
||||
ost->muxing_queue_data_size += tmp_pkt->size;
|
||||
av_fifo_write(ost->muxing_queue, &tmp_pkt, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) ||
|
||||
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
|
||||
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
|
||||
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
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->mux_timebase);
|
||||
}
|
||||
}
|
||||
|
||||
av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base);
|
||||
|
||||
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 ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) &&
|
||||
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 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG;
|
||||
if (exit_on_error)
|
||||
loglevel = AV_LOG_ERROR;
|
||||
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 duration:%s duration_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),
|
||||
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ost->st->time_base),
|
||||
pkt->size
|
||||
);
|
||||
}
|
||||
|
||||
ret = av_interleaved_write_frame(s, pkt);
|
||||
if (ret < 0) {
|
||||
print_error("av_interleaved_write_frame()", ret);
|
||||
main_ffmpeg_return_code = 1;
|
||||
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED);
|
||||
}
|
||||
}
|
||||
|
||||
static int print_sdp(void)
|
||||
{
|
||||
char sdp[16384];
|
||||
int i;
|
||||
int j, ret;
|
||||
AVIOContext *sdp_pb;
|
||||
AVFormatContext **avc;
|
||||
|
||||
for (i = 0; i < nb_output_files; i++) {
|
||||
if (!output_files[i]->header_written)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = av_sdp_create(avc, j, sdp, sizeof(sdp));
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
if (!sdp_filename) {
|
||||
av_log(NULL, AV_LOG_ERROR, "SDP:\n%s\n", sdp);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
avio_print(sdp_pb, sdp);
|
||||
avio_closep(&sdp_pb);
|
||||
av_freep(&sdp_filename);
|
||||
}
|
||||
|
||||
fail:
|
||||
av_freep(&avc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* open the muxer when all the streams are initialized */
|
||||
int of_check_init(OutputFile *of)
|
||||
{
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < of->ctx->nb_streams; i++) {
|
||||
OutputStream *ost = output_streams[of->ost_index + i];
|
||||
if (!ost->initialized)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = avformat_write_header(of->ctx, &of->opts);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Could not write header for output file #%d "
|
||||
"(incorrect codec parameters ?): %s\n",
|
||||
of->index, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
//assert_avoptions(of->opts);
|
||||
of->header_written = 1;
|
||||
|
||||
av_dump_format(of->ctx, of->index, of->ctx->url, 1);
|
||||
nb_output_dumped++;
|
||||
|
||||
if (sdp_filename || want_sdp) {
|
||||
ret = print_sdp();
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error writing the SDP.\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* flush the muxing queues */
|
||||
for (i = 0; i < of->ctx->nb_streams; i++) {
|
||||
OutputStream *ost = output_streams[of->ost_index + i];
|
||||
AVPacket *pkt;
|
||||
|
||||
/* try to improve muxing time_base (only possible if nothing has been written yet) */
|
||||
if (!av_fifo_can_read(ost->muxing_queue))
|
||||
ost->mux_timebase = ost->st->time_base;
|
||||
|
||||
while (av_fifo_read(ost->muxing_queue, &pkt, 1) >= 0) {
|
||||
ost->muxing_queue_data_size -= pkt->size;
|
||||
of_write_packet(of, pkt, ost, 1);
|
||||
av_packet_free(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int of_write_trailer(OutputFile *of)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!of->header_written) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Nothing was written into output file %d (%s), because "
|
||||
"at least one of its streams received no packets.\n",
|
||||
of->index, of->ctx->url);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = av_write_trailer(of->ctx);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void of_close(OutputFile **pof)
|
||||
{
|
||||
OutputFile *of = *pof;
|
||||
AVFormatContext *s;
|
||||
|
||||
if (!of)
|
||||
return;
|
||||
|
||||
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(pof);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,177 +0,0 @@
|
||||
/*
|
||||
* 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 "config.h"
|
||||
|
||||
#if HAVE_UTGETOSTYPEFROMSTRING
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#endif
|
||||
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavcodec/videotoolbox.h"
|
||||
#include "libavutil/imgutils.h"
|
||||
#include "fftools_ffmpeg.h"
|
||||
|
||||
typedef struct VTContext {
|
||||
AVFrame *tmp_frame;
|
||||
int log_once;
|
||||
} VTContext;
|
||||
|
||||
__thread char *videotoolbox_pixfmt;
|
||||
|
||||
static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
VTContext *vt = ist->hwaccel_ctx;
|
||||
CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->data[3];
|
||||
OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
|
||||
CVReturn err;
|
||||
uint8_t *data[4] = { 0 };
|
||||
int linesize[4] = { 0 };
|
||||
int planes, ret, i;
|
||||
|
||||
if (frame->format == ist->hwaccel_output_format) {
|
||||
av_log_once(s, AV_LOG_INFO, AV_LOG_TRACE, &vt->log_once,
|
||||
"There is no video filter for videotoolbox pix_fmt now, remove the "
|
||||
"-hwaccel_output_format option if video filter doesn't work\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
av_frame_unref(vt->tmp_frame);
|
||||
|
||||
switch (pixel_format) {
|
||||
case kCVPixelFormatType_420YpCbCr8Planar: vt->tmp_frame->format = AV_PIX_FMT_YUV420P; break;
|
||||
case kCVPixelFormatType_422YpCbCr8: vt->tmp_frame->format = AV_PIX_FMT_UYVY422; break;
|
||||
case kCVPixelFormatType_32BGRA: vt->tmp_frame->format = AV_PIX_FMT_BGRA; break;
|
||||
#ifdef kCFCoreFoundationVersionNumber10_7
|
||||
case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
|
||||
case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_NV12; break;
|
||||
#endif
|
||||
#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
|
||||
case kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange:
|
||||
case kCVPixelFormatType_420YpCbCr10BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_P010; break;
|
||||
#endif
|
||||
default:
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"%s: Unsupported pixel format: %s\n",
|
||||
av_fourcc2str(s->codec_tag), videotoolbox_pixfmt);
|
||||
return AVERROR(ENOSYS);
|
||||
}
|
||||
|
||||
vt->tmp_frame->width = frame->width;
|
||||
vt->tmp_frame->height = frame->height;
|
||||
ret = av_frame_get_buffer(vt->tmp_frame, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
|
||||
if (err != kCVReturnSuccess) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error locking the pixel buffer.\n");
|
||||
return AVERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
if (CVPixelBufferIsPlanar(pixbuf)) {
|
||||
|
||||
planes = CVPixelBufferGetPlaneCount(pixbuf);
|
||||
for (i = 0; i < planes; i++) {
|
||||
data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i);
|
||||
linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i);
|
||||
}
|
||||
} else {
|
||||
data[0] = CVPixelBufferGetBaseAddress(pixbuf);
|
||||
linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf);
|
||||
}
|
||||
|
||||
av_image_copy(vt->tmp_frame->data, vt->tmp_frame->linesize,
|
||||
(const uint8_t **)data, linesize, vt->tmp_frame->format,
|
||||
frame->width, frame->height);
|
||||
|
||||
ret = av_frame_copy_props(vt->tmp_frame, frame);
|
||||
CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
av_frame_unref(frame);
|
||||
av_frame_move_ref(frame, vt->tmp_frame);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void videotoolbox_uninit(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
VTContext *vt = ist->hwaccel_ctx;
|
||||
|
||||
ist->hwaccel_uninit = NULL;
|
||||
ist->hwaccel_retrieve_data = NULL;
|
||||
|
||||
av_frame_free(&vt->tmp_frame);
|
||||
|
||||
av_videotoolbox_default_free(s);
|
||||
av_freep(&ist->hwaccel_ctx);
|
||||
}
|
||||
|
||||
int videotoolbox_init(AVCodecContext *s)
|
||||
{
|
||||
InputStream *ist = s->opaque;
|
||||
int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
|
||||
int ret = 0;
|
||||
VTContext *vt;
|
||||
|
||||
vt = av_mallocz(sizeof(*vt));
|
||||
if (!vt)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
ist->hwaccel_ctx = vt;
|
||||
ist->hwaccel_uninit = videotoolbox_uninit;
|
||||
ist->hwaccel_retrieve_data = videotoolbox_retrieve_data;
|
||||
|
||||
vt->tmp_frame = av_frame_alloc();
|
||||
if (!vt->tmp_frame) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// TODO: reindent
|
||||
if (!videotoolbox_pixfmt) {
|
||||
ret = av_videotoolbox_default_init(s);
|
||||
} else {
|
||||
AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context();
|
||||
CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault,
|
||||
videotoolbox_pixfmt,
|
||||
kCFStringEncodingUTF8);
|
||||
#if HAVE_UTGETOSTYPEFROMSTRING
|
||||
vtctx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str);
|
||||
#else
|
||||
av_log(s, loglevel, "UTGetOSTypeFromString() is not available "
|
||||
"on this platform, %s pixel format can not be honored from "
|
||||
"the command line\n", videotoolbox_pixfmt);
|
||||
#endif
|
||||
ret = av_videotoolbox_default_init2(s, vtctx);
|
||||
CFRelease(pixfmt_str);
|
||||
}
|
||||
if (ret < 0) {
|
||||
av_log(NULL, loglevel, "Error creating Videotoolbox decoder.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
return 0;
|
||||
fail:
|
||||
videotoolbox_uninit(s);
|
||||
return ret;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
79
apple/src/fftools_fopen_utf8.h
Normal file
79
apple/src/fftools_fopen_utf8.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of fopen_utf8.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_FOPEN_UTF8_H
|
||||
#define FFTOOLS_FOPEN_UTF8_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8,
|
||||
* except that it doesn't set O_CLOEXEC, and that it isn't exported
|
||||
* from a different library. (On Windows, each DLL might use a different
|
||||
* CRT, and FILE* handles can't be shared across them.) */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "libavutil/wchar_filename.h"
|
||||
|
||||
static inline FILE *fopen_utf8(const char *path_utf8, const char *mode)
|
||||
{
|
||||
wchar_t *path_w, *mode_w;
|
||||
FILE *f;
|
||||
|
||||
/* convert UTF-8 to wide chars */
|
||||
if (get_extended_win32_path(path_utf8, &path_w)) /* This sets errno on error. */
|
||||
return NULL;
|
||||
if (!path_w)
|
||||
goto fallback;
|
||||
|
||||
if (utf8towchar(mode, &mode_w))
|
||||
return NULL;
|
||||
if (!mode_w) {
|
||||
/* If failing to interpret the mode string as utf8, it is an invalid
|
||||
* parameter. */
|
||||
av_freep(&path_w);
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f = _wfopen(path_w, mode_w);
|
||||
av_freep(&path_w);
|
||||
av_freep(&mode_w);
|
||||
|
||||
return f;
|
||||
fallback:
|
||||
/* path may be in CP_ACP */
|
||||
return fopen(path_utf8, mode);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline FILE *fopen_utf8(const char *path, const char *mode)
|
||||
{
|
||||
return fopen(path, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FFTOOLS_FOPEN_UTF8_H */
|
1492
apple/src/fftools_opt_common.c
Normal file
1492
apple/src/fftools_opt_common.c
Normal file
File diff suppressed because it is too large
Load Diff
202
apple/src/fftools_opt_common.h
Normal file
202
apple/src/fftools_opt_common.h
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Option handlers shared between the tools.
|
||||
* copyright (c) 2022 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of opt_common.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - CMDUTILS_COMMON_OPTIONS and CMDUTILS_COMMON_OPTIONS_AVDEVICE defines dropped
|
||||
* - fftools_ prefix added to fftools headers
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_OPT_COMMON_H
|
||||
#define FFTOOLS_OPT_COMMON_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fftools_cmdutils.h"
|
||||
|
||||
#if CONFIG_AVDEVICE
|
||||
/**
|
||||
* Print a listing containing autodetected 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 autodetected 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 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);
|
||||
|
||||
/**
|
||||
* Generic -h handler common to all fftools.
|
||||
*/
|
||||
int show_help(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* 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 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 muxers supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_muxers(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Print a listing containing all the demuxer supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_demuxers(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);
|
||||
|
||||
/**
|
||||
* 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 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 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 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 supported stream dispositions.
|
||||
*/
|
||||
int show_dispositions(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);
|
||||
|
||||
/**
|
||||
* Set the libav* libraries log level.
|
||||
*/
|
||||
int opt_loglevel(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_report(void *optctx, const char *opt, const char *arg);
|
||||
int init_report(const char *env, FILE **file);
|
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Override the cpuflags.
|
||||
*/
|
||||
int opt_cpuflags(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Override the cpucount.
|
||||
*/
|
||||
int opt_cpucount(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
#endif /* FFTOOLS_OPT_COMMON_H */
|
4
ios.sh
4
ios.sh
@ -33,7 +33,7 @@ echo -e "\nINFO: Using SDK ${DETECTED_IOS_SDK_VERSION} by Xcode provided at $(xc
|
||||
echo -e "INFO: Build options: $*\n" 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
||||
# SET DEFAULT BUILD OPTIONS
|
||||
GPL_ENABLED="no"
|
||||
export GPL_ENABLED="no"
|
||||
DISPLAY_HELP=""
|
||||
BUILD_TYPE_ID=""
|
||||
BUILD_FULL=""
|
||||
@ -114,7 +114,7 @@ while [ ! $# -eq 0 ]; do
|
||||
BUILD_FULL="1"
|
||||
;;
|
||||
--enable-gpl)
|
||||
GPL_ENABLED="yes"
|
||||
export GPL_ENABLED="yes"
|
||||
;;
|
||||
--enable-custom-library-*)
|
||||
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
|
||||
|
4
linux.sh
4
linux.sh
@ -13,7 +13,7 @@ enable_default_linux_architectures
|
||||
echo -e "INFO: Build options: $*\n" 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
||||
# SET DEFAULT BUILD OPTIONS
|
||||
GPL_ENABLED="no"
|
||||
export GPL_ENABLED="no"
|
||||
DISPLAY_HELP=""
|
||||
BUILD_FULL=""
|
||||
BUILD_TYPE_ID=""
|
||||
@ -78,7 +78,7 @@ while [ ! $# -eq 0 ]; do
|
||||
BUILD_FULL="1"
|
||||
;;
|
||||
--enable-gpl)
|
||||
GPL_ENABLED="yes"
|
||||
export GPL_ENABLED="yes"
|
||||
;;
|
||||
--enable-custom-library-*)
|
||||
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
|
||||
|
@ -38,7 +38,7 @@ PROJECT_NAME = "FFmpegKit Linux API"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = 4.5.1
|
||||
PROJECT_NUMBER = 5.1
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
@ -1,6 +1,6 @@
|
||||
# ffmpeg-kit 4.5.1 configure.ac
|
||||
# ffmpeg-kit 5.1 configure.ac
|
||||
|
||||
AC_INIT([ffmpeg-kit], [4.5.1], [https://github.com/tanersener/ffmpeg-kit/issues/new])
|
||||
AC_INIT([ffmpeg-kit], [5.1], [https://github.com/tanersener/ffmpeg-kit/issues/new])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([src/FFmpegKit.cpp])
|
||||
|
||||
|
@ -89,7 +89,7 @@ volatile int handleSIGXCPU = 1;
|
||||
volatile int handleSIGPIPE = 1;
|
||||
|
||||
/** Holds the id of the current execution */
|
||||
__thread volatile long globalSessionId = 0;
|
||||
__thread long globalSessionId = 0;
|
||||
|
||||
/** Holds the default log level */
|
||||
int configuredLogLevel = ffmpegkit::LevelAVLogInfo;
|
||||
|
@ -42,7 +42,7 @@ namespace ffmpegkit {
|
||||
public:
|
||||
|
||||
/** Global library version */
|
||||
static constexpr const char* FFmpegKitVersion = "4.5.1";
|
||||
static constexpr const char* FFmpegKitVersion = "5.1";
|
||||
|
||||
/**
|
||||
* Prefix of named pipes created by ffmpeg-kit.
|
||||
|
@ -24,8 +24,10 @@ libffmpegkit_la_SOURCES = \
|
||||
fftools_ffmpeg.c \
|
||||
fftools_ffmpeg_filter.c \
|
||||
fftools_ffmpeg_hw.c \
|
||||
fftools_ffmpeg_mux.c \
|
||||
fftools_ffmpeg_opt.c \
|
||||
fftools_ffprobe.c
|
||||
fftools_ffprobe.c \
|
||||
fftools_opt_common.c
|
||||
|
||||
include_HEADERS = \
|
||||
AbstractSession.h \
|
||||
@ -56,7 +58,9 @@ include_HEADERS = \
|
||||
StreamInformation.h \
|
||||
ffmpegkit_exception.h \
|
||||
fftools_cmdutils.h \
|
||||
fftools_ffmpeg.h
|
||||
fftools_ffmpeg.h \
|
||||
fftools_fopen_utf8.h \
|
||||
fftools_opt_common.h
|
||||
|
||||
libffmpegkit_la_CFLAGS = $(CFLAGS)
|
||||
libffmpegkit_la_OBJCFLAGS = $(CFLAGS)
|
||||
|
@ -149,8 +149,10 @@ am_libffmpegkit_la_OBJECTS = libffmpegkit_la-AbstractSession.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_filter.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_hw.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_mux.lo \
|
||||
libffmpegkit_la-fftools_ffmpeg_opt.lo \
|
||||
libffmpegkit_la-fftools_ffprobe.lo
|
||||
libffmpegkit_la-fftools_ffprobe.lo \
|
||||
libffmpegkit_la-fftools_opt_common.lo
|
||||
libffmpegkit_la_OBJECTS = $(am_libffmpegkit_la_OBJECTS)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
@ -196,8 +198,10 @@ am__depfiles_remade = ./$(DEPDIR)/libffmpegkit_la-AbstractSession.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo \
|
||||
./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
@ -413,8 +417,10 @@ libffmpegkit_la_SOURCES = \
|
||||
fftools_ffmpeg.c \
|
||||
fftools_ffmpeg_filter.c \
|
||||
fftools_ffmpeg_hw.c \
|
||||
fftools_ffmpeg_mux.c \
|
||||
fftools_ffmpeg_opt.c \
|
||||
fftools_ffprobe.c
|
||||
fftools_ffprobe.c \
|
||||
fftools_opt_common.c
|
||||
|
||||
include_HEADERS = \
|
||||
AbstractSession.h \
|
||||
@ -445,7 +451,9 @@ include_HEADERS = \
|
||||
StreamInformation.h \
|
||||
ffmpegkit_exception.h \
|
||||
fftools_cmdutils.h \
|
||||
fftools_ffmpeg.h
|
||||
fftools_ffmpeg.h \
|
||||
fftools_fopen_utf8.h \
|
||||
fftools_opt_common.h
|
||||
|
||||
libffmpegkit_la_CFLAGS = $(CFLAGS)
|
||||
libffmpegkit_la_OBJCFLAGS = $(CFLAGS)
|
||||
@ -550,8 +558,10 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo@am__quote@ # am--include-marker
|
||||
|
||||
$(am__depfiles_remade):
|
||||
@$(MKDIR_P) $(@D)
|
||||
@ -611,6 +621,13 @@ libffmpegkit_la-fftools_ffmpeg_hw.lo: fftools_ffmpeg_hw.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_ffmpeg_hw.lo `test -f 'fftools_ffmpeg_hw.c' || echo '$(srcdir)/'`fftools_ffmpeg_hw.c
|
||||
|
||||
libffmpegkit_la-fftools_ffmpeg_mux.lo: fftools_ffmpeg_mux.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -MT libffmpegkit_la-fftools_ffmpeg_mux.lo -MD -MP -MF $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Tpo -c -o libffmpegkit_la-fftools_ffmpeg_mux.lo `test -f 'fftools_ffmpeg_mux.c' || echo '$(srcdir)/'`fftools_ffmpeg_mux.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Tpo $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fftools_ffmpeg_mux.c' object='libffmpegkit_la-fftools_ffmpeg_mux.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_ffmpeg_mux.lo `test -f 'fftools_ffmpeg_mux.c' || echo '$(srcdir)/'`fftools_ffmpeg_mux.c
|
||||
|
||||
libffmpegkit_la-fftools_ffmpeg_opt.lo: fftools_ffmpeg_opt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -MT libffmpegkit_la-fftools_ffmpeg_opt.lo -MD -MP -MF $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Tpo -c -o libffmpegkit_la-fftools_ffmpeg_opt.lo `test -f 'fftools_ffmpeg_opt.c' || echo '$(srcdir)/'`fftools_ffmpeg_opt.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Tpo $(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo
|
||||
@ -625,6 +642,13 @@ libffmpegkit_la-fftools_ffprobe.lo: fftools_ffprobe.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_ffprobe.lo `test -f 'fftools_ffprobe.c' || echo '$(srcdir)/'`fftools_ffprobe.c
|
||||
|
||||
libffmpegkit_la-fftools_opt_common.lo: fftools_opt_common.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -MT libffmpegkit_la-fftools_opt_common.lo -MD -MP -MF $(DEPDIR)/libffmpegkit_la-fftools_opt_common.Tpo -c -o libffmpegkit_la-fftools_opt_common.lo `test -f 'fftools_opt_common.c' || echo '$(srcdir)/'`fftools_opt_common.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libffmpegkit_la-fftools_opt_common.Tpo $(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fftools_opt_common.c' object='libffmpegkit_la-fftools_opt_common.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libffmpegkit_la_CFLAGS) $(CFLAGS) -c -o libffmpegkit_la-fftools_opt_common.lo `test -f 'fftools_opt_common.c' || echo '$(srcdir)/'`fftools_opt_common.c
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
|
||||
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
|
||||
@ -944,8 +968,10 @@ distclean: distclean-am
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-tags
|
||||
@ -1012,8 +1038,10 @@ maintainer-clean: maintainer-clean-am
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_filter.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_hw.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_mux.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffmpeg_opt.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_ffprobe.Plo
|
||||
-rm -f ./$(DEPDIR)/libffmpegkit_la-fftools_opt_common.Plo
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
/*
|
||||
* Various utilities for command line tools
|
||||
* copyright (c) 2003 Fabrice Bellard
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@ -20,25 +21,37 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* - AV_LOG_STDERR introduced
|
||||
* This file is the modified version of cmdutils.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - config.h include added back
|
||||
*
|
||||
* 01.2020
|
||||
* --------------------------------------------------------
|
||||
* - ffprobe support added (variables used by ffprobe marked with "__thread" specifier)
|
||||
* - AV_LOG_STDERR log level added
|
||||
*
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads)
|
||||
*
|
||||
* 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Include guards renamed
|
||||
* - Unused headers removed
|
||||
* - include guards renamed
|
||||
* - unused headers removed
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_CMDUTILS_H
|
||||
@ -46,6 +59,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavfilter/avfilter.h"
|
||||
#include "libavformat/avformat.h"
|
||||
@ -70,11 +84,9 @@ extern __thread char *program_name;
|
||||
*/
|
||||
extern __thread int program_birth_year;
|
||||
|
||||
extern __thread AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
||||
extern __thread AVFormatContext *avformat_opts;
|
||||
extern __thread AVDictionary *sws_dict;
|
||||
extern __thread AVDictionary *swr_opts;
|
||||
extern __thread AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
extern __thread AVDictionary *format_opts, *codec_opts;
|
||||
extern __thread int hide_banner;
|
||||
extern __thread int find_stream_info;
|
||||
|
||||
@ -93,11 +105,6 @@ void exit_program(int ret) av_noreturn;
|
||||
*/
|
||||
void init_dynload(void);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@ -110,33 +117,12 @@ void uninit_opts(void);
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* Override the cpucount.
|
||||
*/
|
||||
int opt_cpucount(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(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_codec_debug(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Limit the execution time.
|
||||
*/
|
||||
@ -237,7 +223,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||
* Show help for all options with given flags in class and all its
|
||||
* children.
|
||||
*/
|
||||
void show_help_children(const AVClass *avClass, int flags);
|
||||
void show_help_children(const AVClass *clazz, int flags);
|
||||
|
||||
/**
|
||||
* Per-fftool specific help handler. Implemented in each
|
||||
@ -309,7 +295,6 @@ typedef struct OptionGroup {
|
||||
|
||||
AVDictionary *codec_opts;
|
||||
AVDictionary *format_opts;
|
||||
AVDictionary *resample_opts;
|
||||
AVDictionary *sws_dict;
|
||||
AVDictionary *swr_opts;
|
||||
} OptionGroup;
|
||||
@ -417,8 +402,8 @@ AVDictionary *filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id,
|
||||
* 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
|
||||
* @return pointer to the created array of dictionaries.
|
||||
* Calls exit() on failure.
|
||||
*/
|
||||
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,
|
||||
AVDictionary *codec_opts);
|
||||
@ -441,136 +426,6 @@ void print_error(const char *filename, int err);
|
||||
*/
|
||||
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 muxers supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_muxers(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Print a listing containing all the demuxer supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_demuxers(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 autodetected 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 autodetected 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.
|
||||
@ -610,11 +465,26 @@ FILE *get_preset_file(char *filename, size_t filename_size,
|
||||
*/
|
||||
void *grow_array(void *array, int elem_size, int *size, int new_size);
|
||||
|
||||
#define media_type_string av_get_media_type_string
|
||||
/**
|
||||
* Atomically add a new element to an array of pointers, i.e. allocate
|
||||
* a new entry, reallocate the array of pointers and make the new last
|
||||
* member of this array point to the newly allocated buffer.
|
||||
* Calls exit() on failure.
|
||||
*
|
||||
* @param array array of pointers to reallocate
|
||||
* @param elem_size size of the new element to allocate
|
||||
* @param nb_elems pointer to the number of elements of the array array;
|
||||
* *nb_elems will be incremented by one by this function.
|
||||
* @return pointer to the newly allocated entry
|
||||
*/
|
||||
void *allocate_array_elem(void *array, size_t elem_size, int *nb_elems);
|
||||
|
||||
#define GROW_ARRAY(array, nb_elems)\
|
||||
array = grow_array(array, sizeof(*array), &nb_elems, nb_elems + 1)
|
||||
|
||||
#define ALLOC_ARRAY_ELEM(array, nb_elems)\
|
||||
allocate_array_elem(&array, sizeof(*array[0]), &nb_elems)
|
||||
|
||||
#define GET_PIX_FMT_NAME(pix_fmt)\
|
||||
const char *name = av_get_pix_fmt_name(pix_fmt);
|
||||
|
||||
@ -628,14 +498,6 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
|
||||
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);
|
||||
double get_rotation(int32_t *displaymatrix);
|
||||
|
||||
#endif /* FFTOOLS_CMDUTILS_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
* Copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -17,33 +18,46 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 06.2020
|
||||
* This file is the modified version of ffmpeg.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - config.h include added back
|
||||
* - volatile dropped from thread local variables
|
||||
*
|
||||
* 06.2020
|
||||
* --------------------------------------------------------
|
||||
* - cancel_operation() method signature updated with id
|
||||
*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads,
|
||||
* signatures of ffmpeg_opt.c methods called by both ffmpeg and ffprobe added)
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
* - set_report_callback() method declared
|
||||
* - cancel_operation() method declared
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Include guards renamed
|
||||
* - include guards renamed
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_FFMPEG_H
|
||||
#define FFTOOLS_FFMPEG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@ -70,12 +84,14 @@
|
||||
|
||||
#include "libswresample/swresample.h"
|
||||
|
||||
#define VSYNC_AUTO -1
|
||||
#define VSYNC_PASSTHROUGH 0
|
||||
#define VSYNC_CFR 1
|
||||
#define VSYNC_VFR 2
|
||||
#define VSYNC_VSCFR 0xfe
|
||||
#define VSYNC_DROP 0xff
|
||||
enum VideoSyncMethod {
|
||||
VSYNC_AUTO = -1,
|
||||
VSYNC_PASSTHROUGH,
|
||||
VSYNC_CFR,
|
||||
VSYNC_VFR,
|
||||
VSYNC_VSCFR,
|
||||
VSYNC_DROP,
|
||||
};
|
||||
|
||||
#define MAX_STREAMS 1024 /* arbitrary sanity check value */
|
||||
|
||||
@ -83,16 +99,8 @@ enum HWAccelID {
|
||||
HWACCEL_NONE = 0,
|
||||
HWACCEL_AUTO,
|
||||
HWACCEL_GENERIC,
|
||||
HWACCEL_VIDEOTOOLBOX,
|
||||
};
|
||||
|
||||
typedef struct HWAccel {
|
||||
const char *name;
|
||||
int (*init)(AVCodecContext *s);
|
||||
enum HWAccelID id;
|
||||
enum AVPixelFormat pix_fmt;
|
||||
} HWAccel;
|
||||
|
||||
typedef struct HWDevice {
|
||||
const char *name;
|
||||
enum AVHWDeviceType type;
|
||||
@ -125,6 +133,8 @@ typedef struct OptionsContext {
|
||||
|
||||
SpecifierOpt *codec_names;
|
||||
int nb_codec_names;
|
||||
SpecifierOpt *audio_ch_layouts;
|
||||
int nb_audio_ch_layouts;
|
||||
SpecifierOpt *audio_channels;
|
||||
int nb_audio_channels;
|
||||
SpecifierOpt *audio_sample_rate;
|
||||
@ -145,6 +155,7 @@ typedef struct OptionsContext {
|
||||
float readrate;
|
||||
int accurate_seek;
|
||||
int thread_queue_size;
|
||||
int input_sync_ref;
|
||||
|
||||
SpecifierOpt *ts_scale;
|
||||
int nb_ts_scale;
|
||||
@ -203,6 +214,8 @@ typedef struct OptionsContext {
|
||||
int nb_qscale;
|
||||
SpecifierOpt *forced_key_frames;
|
||||
int nb_forced_key_frames;
|
||||
SpecifierOpt *fps_mode;
|
||||
int nb_fps_mode;
|
||||
SpecifierOpt *force_fps;
|
||||
int nb_force_fps;
|
||||
SpecifierOpt *frame_aspect_ratios;
|
||||
@ -259,6 +272,8 @@ typedef struct OptionsContext {
|
||||
int nb_enc_time_bases;
|
||||
SpecifierOpt *autoscale;
|
||||
int nb_autoscale;
|
||||
SpecifierOpt *bits_per_raw_sample;
|
||||
int nb_bits_per_raw_sample;
|
||||
} OptionsContext;
|
||||
|
||||
typedef struct InputFilter {
|
||||
@ -268,7 +283,7 @@ typedef struct InputFilter {
|
||||
uint8_t *name;
|
||||
enum AVMediaType type; // AVMEDIA_TYPE_SUBTITLE for sub2video
|
||||
|
||||
AVFifoBuffer *frame_queue;
|
||||
AVFifo *frame_queue;
|
||||
|
||||
// parameters configured for this input
|
||||
int format;
|
||||
@ -277,10 +292,10 @@ typedef struct InputFilter {
|
||||
AVRational sample_aspect_ratio;
|
||||
|
||||
int sample_rate;
|
||||
int channels;
|
||||
uint64_t channel_layout;
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
int32_t *displaymatrix;
|
||||
|
||||
int eof;
|
||||
} InputFilter;
|
||||
@ -300,12 +315,13 @@ typedef struct OutputFilter {
|
||||
AVRational frame_rate;
|
||||
int format;
|
||||
int sample_rate;
|
||||
uint64_t channel_layout;
|
||||
AVChannelLayout ch_layout;
|
||||
|
||||
// those are only set if no format is specified and the encoder gives us multiple options
|
||||
int *formats;
|
||||
uint64_t *channel_layouts;
|
||||
int *sample_rates;
|
||||
// They point directly to the relevant lists of the encoder.
|
||||
const int *formats;
|
||||
const AVChannelLayout *ch_layouts;
|
||||
const int *sample_rates;
|
||||
} OutputFilter;
|
||||
|
||||
typedef struct FilterGraph {
|
||||
@ -314,6 +330,9 @@ typedef struct FilterGraph {
|
||||
|
||||
AVFilterGraph *graph;
|
||||
int reconfiguration;
|
||||
// true when the filtergraph contains only meta filters
|
||||
// that do not modify the frame data
|
||||
int is_meta;
|
||||
|
||||
InputFilter **inputs;
|
||||
int nb_inputs;
|
||||
@ -329,13 +348,14 @@ typedef struct InputStream {
|
||||
int decoding_needed; /* non zero if the packets must be decoded in 'raw_fifo', see DECODING_FOR_* */
|
||||
#define DECODING_FOR_OST 1
|
||||
#define DECODING_FOR_FILTER 2
|
||||
int processing_needed; /* non zero if the packets must be processed */
|
||||
|
||||
AVCodecContext *dec_ctx;
|
||||
const AVCodec *dec;
|
||||
AVFrame *decoded_frame;
|
||||
AVFrame *filter_frame; /* a ref of decoded_frame, to be sent to filters */
|
||||
AVPacket *pkt;
|
||||
|
||||
int64_t prev_pkt_pts;
|
||||
int64_t start; /* time when read started */
|
||||
/* predicted dts of the next packet read for this stream or (when there are
|
||||
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
|
||||
@ -377,14 +397,12 @@ typedef struct InputStream {
|
||||
struct sub2video {
|
||||
int64_t last_pts;
|
||||
int64_t end_pts;
|
||||
AVFifoBuffer *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFifo *sub_queue; ///< queue of AVSubtitle* before filter init
|
||||
AVFrame *frame;
|
||||
int w, h;
|
||||
unsigned int initialize; ///< marks if sub2video_update should force an initialization
|
||||
} sub2video;
|
||||
|
||||
int dr1;
|
||||
|
||||
/* decoded data from this stream goes into all those filters
|
||||
* currently video and audio only */
|
||||
InputFilter **filters;
|
||||
@ -401,11 +419,9 @@ typedef struct InputStream {
|
||||
/* hwaccel context */
|
||||
void *hwaccel_ctx;
|
||||
void (*hwaccel_uninit)(AVCodecContext *s);
|
||||
int (*hwaccel_get_buffer)(AVCodecContext *s, AVFrame *frame, int flags);
|
||||
int (*hwaccel_retrieve_data)(AVCodecContext *s, AVFrame *frame);
|
||||
enum AVPixelFormat hwaccel_pix_fmt;
|
||||
enum AVPixelFormat hwaccel_retrieved_pix_fmt;
|
||||
AVBufferRef *hw_frames_ctx;
|
||||
|
||||
/* stats */
|
||||
// combined size of all the packets read
|
||||
@ -432,11 +448,11 @@ typedef struct InputFile {
|
||||
at the moment when looping happens */
|
||||
AVRational time_base; /* time base of the duration */
|
||||
int64_t input_ts_offset;
|
||||
int input_sync_ref;
|
||||
|
||||
int64_t ts_offset;
|
||||
int64_t last_ts;
|
||||
int64_t start_time; /* user-specified start time in AV_TIME_BASE or AV_NOPTS_VALUE */
|
||||
int seek_timestamp;
|
||||
int64_t recording_time;
|
||||
int nb_streams; /* number of stream that ffmpeg is aware of; may be different
|
||||
from ctx.nb_streams if new streams appear during av_read_frame() */
|
||||
@ -465,7 +481,7 @@ enum forced_keyframes_const {
|
||||
FKF_NB
|
||||
};
|
||||
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0)
|
||||
#define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1)
|
||||
|
||||
extern const char *const forced_keyframes_const_names[];
|
||||
@ -481,7 +497,7 @@ typedef struct OutputStream {
|
||||
int source_index; /* InputStream index */
|
||||
AVStream *st; /* stream in the output file */
|
||||
int encoding_needed; /* true if encoding needed for this stream */
|
||||
int frame_number;
|
||||
int64_t frame_number;
|
||||
/* input pts and corresponding output pts
|
||||
for A/V sync */
|
||||
struct InputStream *sync_ist; /* input stream to sync against */
|
||||
@ -504,19 +520,22 @@ typedef struct OutputStream {
|
||||
AVFrame *filtered_frame;
|
||||
AVFrame *last_frame;
|
||||
AVPacket *pkt;
|
||||
int last_dropped;
|
||||
int last_nb0_frames[3];
|
||||
int64_t last_dropped;
|
||||
int64_t last_nb0_frames[3];
|
||||
|
||||
void *hwaccel_ctx;
|
||||
|
||||
/* video only */
|
||||
AVRational frame_rate;
|
||||
AVRational max_frame_rate;
|
||||
enum VideoSyncMethod vsync_method;
|
||||
int is_cfr;
|
||||
const char *fps_mode;
|
||||
int force_fps;
|
||||
int top_field_first;
|
||||
int rotate_overridden;
|
||||
int autoscale;
|
||||
int bits_per_raw_sample;
|
||||
double rotate_override_value;
|
||||
|
||||
AVRational frame_aspect_ratio;
|
||||
@ -546,7 +565,6 @@ typedef struct OutputStream {
|
||||
AVDictionary *encoder_opts;
|
||||
AVDictionary *sws_dict;
|
||||
AVDictionary *swr_opts;
|
||||
AVDictionary *resample_opts;
|
||||
char *apad;
|
||||
OSTFinished finished; /* no more packets should be written for this stream */
|
||||
int unavailable; /* true if the steram is unavailable (possibly temporarily) */
|
||||
@ -560,6 +578,7 @@ typedef struct OutputStream {
|
||||
int inputs_done;
|
||||
|
||||
const char *attachment_filename;
|
||||
int streamcopy_started;
|
||||
int copy_initial_nonkeyframes;
|
||||
int copy_prior_start;
|
||||
char *disposition;
|
||||
@ -574,6 +593,8 @@ typedef struct OutputStream {
|
||||
// number of frames/samples sent to the encoder
|
||||
uint64_t frames_encoded;
|
||||
uint64_t samples_encoded;
|
||||
// number of packets received from the encoder
|
||||
uint64_t packets_encoded;
|
||||
|
||||
/* packet quality factor */
|
||||
int quality;
|
||||
@ -581,7 +602,7 @@ typedef struct OutputStream {
|
||||
int max_muxing_queue_size;
|
||||
|
||||
/* the packets are buffered here until the muxer is ready to be initialized */
|
||||
AVFifoBuffer *muxing_queue;
|
||||
AVFifo *muxing_queue;
|
||||
|
||||
/*
|
||||
* The size of the AVPackets' buffers in queue.
|
||||
@ -600,6 +621,10 @@ typedef struct OutputStream {
|
||||
} OutputStream;
|
||||
|
||||
typedef struct OutputFile {
|
||||
int index;
|
||||
|
||||
const AVOutputFormat *format;
|
||||
|
||||
AVFormatContext *ctx;
|
||||
AVDictionary *opts;
|
||||
int ost_index; /* index of the first stream in output_streams */
|
||||
@ -634,7 +659,7 @@ extern __thread float dts_error_threshold;
|
||||
|
||||
extern __thread int audio_volume;
|
||||
extern __thread int audio_sync_method;
|
||||
extern __thread int video_sync_method;
|
||||
extern __thread enum VideoSyncMethod video_sync_method;
|
||||
extern __thread float frame_drop_threshold;
|
||||
extern __thread int do_benchmark;
|
||||
extern __thread int do_benchmark_all;
|
||||
@ -654,41 +679,35 @@ extern __thread int stdin_interaction;
|
||||
extern __thread int frame_bits_per_raw_sample;
|
||||
extern __thread AVIOContext *progress_avio;
|
||||
extern __thread float max_error_rate;
|
||||
extern __thread char *videotoolbox_pixfmt;
|
||||
|
||||
extern __thread int filter_nbthreads;
|
||||
extern __thread char *filter_nbthreads;
|
||||
extern __thread int filter_complex_nbthreads;
|
||||
extern __thread int vstats_version;
|
||||
extern __thread int auto_conversion_filters;
|
||||
|
||||
extern __thread const AVIOInterruptCB int_cb;
|
||||
|
||||
extern const HWAccel hwaccels[];
|
||||
#if CONFIG_QSV
|
||||
extern __thread char *qsv_device;
|
||||
#endif
|
||||
extern __thread HWDevice *filter_hw_device;
|
||||
|
||||
extern __thread int want_sdp;
|
||||
extern __thread unsigned nb_output_dumped;
|
||||
extern __thread int main_ffmpeg_return_code;
|
||||
|
||||
void term_init(void);
|
||||
void term_exit(void);
|
||||
|
||||
void reset_options(OptionsContext *o, int is_input);
|
||||
void show_usage(void);
|
||||
|
||||
void opt_output_file(void *optctx, const char *filename);
|
||||
|
||||
void remove_avoptions(AVDictionary **a, AVDictionary *b);
|
||||
void assert_avoptions(AVDictionary *m);
|
||||
|
||||
int guess_input_channel_layout(InputStream *ist);
|
||||
|
||||
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *avctx, const AVCodec *codec, enum AVPixelFormat target);
|
||||
void choose_sample_fmt(AVStream *st, const AVCodec *codec);
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg);
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
|
||||
void check_filter_outputs(void);
|
||||
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
|
||||
int filtergraph_is_simple(FilterGraph *fg);
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost);
|
||||
int init_complex_filtergraph(FilterGraph *fg);
|
||||
@ -712,6 +731,14 @@ int hw_device_setup_for_filter(FilterGraph *fg);
|
||||
|
||||
int hwaccel_decode_init(AVCodecContext *avctx);
|
||||
|
||||
/* open the muxer when all the streams are initialized */
|
||||
int of_check_init(OutputFile *of);
|
||||
int of_write_trailer(OutputFile *of);
|
||||
void of_close(OutputFile **pof);
|
||||
|
||||
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
|
||||
int unqueue);
|
||||
|
||||
void set_report_callback(void (*callback)(int, float, float, int64_t, int, double, double));
|
||||
|
||||
void cancel_operation(long id);
|
||||
@ -759,7 +786,6 @@ int opt_filter_hw_device(void *optctx, const char *opt, const char *arg);
|
||||
void add_input_streams(OptionsContext *o, AVFormatContext *ic);
|
||||
void assert_file_overwrite(const char *filename);
|
||||
void dump_attachment(AVStream *st, const char *filename);
|
||||
uint8_t *get_line(AVIOContext *s);
|
||||
void uninit_options(OptionsContext *o);
|
||||
void init_options(OptionsContext *o);
|
||||
AVDictionary *strip_specifiers(AVDictionary *dict);
|
||||
@ -772,7 +798,6 @@ int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOConte
|
||||
int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost);
|
||||
OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index);
|
||||
void parse_matrix_coeffs(uint16_t *dest, const char *str);
|
||||
uint8_t *fftools_read_file(const char *filename);
|
||||
char *get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost);
|
||||
void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc, const OutputStream *ost, enum AVMediaType type);
|
||||
OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
@ -781,7 +806,6 @@ OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int source
|
||||
OutputStream *new_unknown_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata);
|
||||
void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc);
|
||||
int init_complex_filters(void);
|
||||
int open_output_file(OptionsContext *o, const char *filename);
|
||||
|
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* ffmpeg filter configuration
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
@ -19,13 +20,19 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 08.2018
|
||||
* This file is the modified version of ffmpeg_filter.c file living in ffmpeg source code under the fftools folder.
|
||||
* We manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - Unused headers removed
|
||||
* - unused headers removed
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
@ -53,7 +60,7 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c
|
||||
{
|
||||
static const enum AVPixelFormat mjpeg_formats[] =
|
||||
{ AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P,
|
||||
AV_PIX_FMT_NONE};
|
||||
AV_PIX_FMT_NONE };
|
||||
|
||||
if (!strcmp(codec->name, "mjpeg")) {
|
||||
return mjpeg_formats;
|
||||
@ -62,7 +69,8 @@ static const enum AVPixelFormat *get_compliance_normal_pix_fmts(const AVCodec *c
|
||||
}
|
||||
}
|
||||
|
||||
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, const AVCodec *codec, enum AVPixelFormat target)
|
||||
enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx,
|
||||
const AVCodec *codec, enum AVPixelFormat target)
|
||||
{
|
||||
if (codec && codec->pix_fmts) {
|
||||
const enum AVPixelFormat *p = codec->pix_fmts;
|
||||
@ -92,10 +100,13 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, const
|
||||
return target;
|
||||
}
|
||||
|
||||
static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
/* May return NULL (no pixel format found), a static string or a string
|
||||
* backed by the bprint. Nothing has been written to the AVBPrint in case
|
||||
* NULL is returned. The AVBPrint provided should be clean. */
|
||||
static const char *choose_pix_fmts(OutputFilter *ofilter, AVBPrint *bprint)
|
||||
{
|
||||
OutputStream *ost = ofilter->ost;
|
||||
AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
|
||||
const AVDictionaryEntry *strict_dict = av_dict_get(ost->encoder_opts, "strict", NULL, 0);
|
||||
if (strict_dict)
|
||||
// used by choose_pixel_fmt() and below
|
||||
av_opt_set(ost->enc_ctx, "strict", strict_dict->value, 0);
|
||||
@ -105,18 +116,12 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
AVFILTER_AUTO_CONVERT_NONE);
|
||||
if (ost->enc_ctx->pix_fmt == AV_PIX_FMT_NONE)
|
||||
return NULL;
|
||||
return av_strdup(av_get_pix_fmt_name(ost->enc_ctx->pix_fmt));
|
||||
return av_get_pix_fmt_name(ost->enc_ctx->pix_fmt);
|
||||
}
|
||||
if (ost->enc_ctx->pix_fmt != AV_PIX_FMT_NONE) {
|
||||
return av_strdup(av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt)));
|
||||
return av_get_pix_fmt_name(choose_pixel_fmt(ost->st, ost->enc_ctx, ost->enc, ost->enc_ctx->pix_fmt));
|
||||
} else if (ost->enc && ost->enc->pix_fmts) {
|
||||
const enum AVPixelFormat *p;
|
||||
AVIOContext *s = NULL;
|
||||
uint8_t *ret;
|
||||
int len;
|
||||
|
||||
if (avio_open_dyn_buf(&s) < 0)
|
||||
exit_program(1);
|
||||
|
||||
p = ost->enc->pix_fmts;
|
||||
if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) {
|
||||
@ -125,11 +130,11 @@ static char *choose_pix_fmts(OutputFilter *ofilter)
|
||||
|
||||
for (; *p != AV_PIX_FMT_NONE; p++) {
|
||||
const char *name = av_get_pix_fmt_name(*p);
|
||||
avio_printf(s, "%s|", name);
|
||||
av_bprintf(bprint, "%s%c", name, p[1] == AV_PIX_FMT_NONE ? '\0' : '|');
|
||||
}
|
||||
len = avio_close_dyn_buf(s, &ret);
|
||||
ret[len - 1] = 0;
|
||||
return ret;
|
||||
if (!av_bprint_is_complete(bprint))
|
||||
exit_program(1);
|
||||
return bprint->str;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
@ -165,39 +170,54 @@ DEF_CHOOSE_FORMAT(sample_fmts, enum AVSampleFormat, format, formats,
|
||||
DEF_CHOOSE_FORMAT(sample_rates, int, sample_rate, sample_rates, 0,
|
||||
"%d", )
|
||||
|
||||
DEF_CHOOSE_FORMAT(channel_layouts, uint64_t, channel_layout, channel_layouts, 0,
|
||||
"0x%"PRIx64, )
|
||||
static void choose_channel_layouts(OutputFilter *ofilter, AVBPrint *bprint)
|
||||
{
|
||||
if (av_channel_layout_check(&ofilter->ch_layout)) {
|
||||
av_bprintf(bprint, "channel_layouts=");
|
||||
av_channel_layout_describe_bprint(&ofilter->ch_layout, bprint);
|
||||
} else if (ofilter->ch_layouts) {
|
||||
const AVChannelLayout *p;
|
||||
|
||||
av_bprintf(bprint, "channel_layouts=");
|
||||
for (p = ofilter->ch_layouts; p->nb_channels; p++) {
|
||||
av_channel_layout_describe_bprint(p, bprint);
|
||||
av_bprintf(bprint, "|");
|
||||
}
|
||||
if (bprint->len > 0)
|
||||
bprint->str[--bprint->len] = '\0';
|
||||
} else
|
||||
return;
|
||||
av_bprint_chars(bprint, ':', 1);
|
||||
}
|
||||
|
||||
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
|
||||
{
|
||||
FilterGraph *fg = av_mallocz(sizeof(*fg));
|
||||
OutputFilter *ofilter;
|
||||
InputFilter *ifilter;
|
||||
|
||||
if (!fg)
|
||||
exit_program(1);
|
||||
fg->index = nb_filtergraphs;
|
||||
|
||||
GROW_ARRAY(fg->outputs, fg->nb_outputs);
|
||||
if (!(fg->outputs[0] = av_mallocz(sizeof(*fg->outputs[0]))))
|
||||
exit_program(1);
|
||||
fg->outputs[0]->ost = ost;
|
||||
fg->outputs[0]->graph = fg;
|
||||
fg->outputs[0]->format = -1;
|
||||
ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
ofilter->ost = ost;
|
||||
ofilter->graph = fg;
|
||||
ofilter->format = -1;
|
||||
|
||||
ost->filter = fg->outputs[0];
|
||||
ost->filter = ofilter;
|
||||
|
||||
GROW_ARRAY(fg->inputs, fg->nb_inputs);
|
||||
if (!(fg->inputs[0] = av_mallocz(sizeof(*fg->inputs[0]))))
|
||||
exit_program(1);
|
||||
fg->inputs[0]->ist = ist;
|
||||
fg->inputs[0]->graph = fg;
|
||||
fg->inputs[0]->format = -1;
|
||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
|
||||
fg->inputs[0]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[0]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[0];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
|
||||
GROW_ARRAY(filtergraphs, nb_filtergraphs);
|
||||
filtergraphs[nb_filtergraphs - 1] = fg;
|
||||
@ -210,17 +230,15 @@ static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
|
||||
AVFilterContext *ctx = inout->filter_ctx;
|
||||
AVFilterPad *pads = in ? ctx->input_pads : ctx->output_pads;
|
||||
int nb_pads = in ? ctx->nb_inputs : ctx->nb_outputs;
|
||||
AVIOContext *pb;
|
||||
uint8_t *res = NULL;
|
||||
char *res;
|
||||
|
||||
if (avio_open_dyn_buf(&pb) < 0)
|
||||
exit_program(1);
|
||||
|
||||
avio_printf(pb, "%s", ctx->filter->name);
|
||||
if (nb_pads > 1)
|
||||
avio_printf(pb, ":%s", avfilter_pad_get_name(pads, inout->pad_idx));
|
||||
avio_w8(pb, 0);
|
||||
avio_close_dyn_buf(pb, &res);
|
||||
res = av_strdup(ctx->filter->name);
|
||||
else
|
||||
res = av_asprintf("%s:%s", ctx->filter->name,
|
||||
avfilter_pad_get_name(pads, inout->pad_idx));
|
||||
if (!res)
|
||||
exit_program(1);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -228,6 +246,7 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
{
|
||||
InputStream *ist = NULL;
|
||||
enum AVMediaType type = avfilter_pad_get_type(in->filter_ctx->input_pads, in->pad_idx);
|
||||
InputFilter *ifilter;
|
||||
int i;
|
||||
|
||||
// TODO: support other filter types
|
||||
@ -292,23 +311,22 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
|
||||
|
||||
ist->discard = 0;
|
||||
ist->decoding_needed |= DECODING_FOR_FILTER;
|
||||
ist->processing_needed = 1;
|
||||
ist->st->discard = AVDISCARD_NONE;
|
||||
|
||||
GROW_ARRAY(fg->inputs, fg->nb_inputs);
|
||||
if (!(fg->inputs[fg->nb_inputs - 1] = av_mallocz(sizeof(*fg->inputs[0]))))
|
||||
exit_program(1);
|
||||
fg->inputs[fg->nb_inputs - 1]->ist = ist;
|
||||
fg->inputs[fg->nb_inputs - 1]->graph = fg;
|
||||
fg->inputs[fg->nb_inputs - 1]->format = -1;
|
||||
fg->inputs[fg->nb_inputs - 1]->type = ist->st->codecpar->codec_type;
|
||||
fg->inputs[fg->nb_inputs - 1]->name = describe_filter_link(fg, in, 1);
|
||||
ifilter = ALLOC_ARRAY_ELEM(fg->inputs, fg->nb_inputs);
|
||||
ifilter->ist = ist;
|
||||
ifilter->graph = fg;
|
||||
ifilter->format = -1;
|
||||
ifilter->type = ist->st->codecpar->codec_type;
|
||||
ifilter->name = describe_filter_link(fg, in, 1);
|
||||
|
||||
fg->inputs[fg->nb_inputs - 1]->frame_queue = av_fifo_alloc(8 * sizeof(AVFrame*));
|
||||
if (!fg->inputs[fg->nb_inputs - 1]->frame_queue)
|
||||
ifilter->frame_queue = av_fifo_alloc2(8, sizeof(AVFrame*), AV_FIFO_FLAG_AUTO_GROW);
|
||||
if (!ifilter->frame_queue)
|
||||
exit_program(1);
|
||||
|
||||
GROW_ARRAY(ist->filters, ist->nb_filters);
|
||||
ist->filters[ist->nb_filters - 1] = fg->inputs[fg->nb_inputs - 1];
|
||||
ist->filters[ist->nb_filters - 1] = ifilter;
|
||||
}
|
||||
|
||||
int init_complex_filtergraph(FilterGraph *fg)
|
||||
@ -332,18 +350,15 @@ int init_complex_filtergraph(FilterGraph *fg)
|
||||
init_input_filter(fg, cur);
|
||||
|
||||
for (cur = outputs; cur;) {
|
||||
GROW_ARRAY(fg->outputs, fg->nb_outputs);
|
||||
fg->outputs[fg->nb_outputs - 1] = av_mallocz(sizeof(*fg->outputs[0]));
|
||||
if (!fg->outputs[fg->nb_outputs - 1])
|
||||
exit_program(1);
|
||||
OutputFilter *const ofilter = ALLOC_ARRAY_ELEM(fg->outputs, fg->nb_outputs);
|
||||
|
||||
fg->outputs[fg->nb_outputs - 1]->graph = fg;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp = cur;
|
||||
fg->outputs[fg->nb_outputs - 1]->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
ofilter->graph = fg;
|
||||
ofilter->out_tmp = cur;
|
||||
ofilter->type = avfilter_pad_get_type(cur->filter_ctx->output_pads,
|
||||
cur->pad_idx);
|
||||
fg->outputs[fg->nb_outputs - 1]->name = describe_filter_link(fg, cur, 0);
|
||||
ofilter->name = describe_filter_link(fg, cur, 0);
|
||||
cur = cur->next;
|
||||
fg->outputs[fg->nb_outputs - 1]->out_tmp->next = NULL;
|
||||
ofilter->out_tmp->next = NULL;
|
||||
}
|
||||
|
||||
fail:
|
||||
@ -427,12 +442,13 @@ static int insert_filter(AVFilterContext **last_filter, int *pad_idx,
|
||||
|
||||
static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
|
||||
{
|
||||
char *pix_fmts;
|
||||
OutputStream *ost = ofilter->ost;
|
||||
OutputFile *of = output_files[ost->file_index];
|
||||
AVFilterContext *last_filter = out->filter_ctx;
|
||||
AVBPrint bprint;
|
||||
int pad_idx = out->pad_idx;
|
||||
int ret;
|
||||
const char *pix_fmts;
|
||||
char name[255];
|
||||
|
||||
snprintf(name, sizeof(name), "out_%d_%d", ost->file_index, ost->index);
|
||||
@ -446,7 +462,7 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
if ((ofilter->width || ofilter->height) && ofilter->ost->autoscale) {
|
||||
char args[255];
|
||||
AVFilterContext *filter;
|
||||
AVDictionaryEntry *e = NULL;
|
||||
const AVDictionaryEntry *e = NULL;
|
||||
|
||||
snprintf(args, sizeof(args), "%d:%d",
|
||||
ofilter->width, ofilter->height);
|
||||
@ -468,13 +484,14 @@ static int configure_output_video_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
pad_idx = 0;
|
||||
}
|
||||
|
||||
if ((pix_fmts = choose_pix_fmts(ofilter))) {
|
||||
av_bprint_init(&bprint, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||
if ((pix_fmts = choose_pix_fmts(ofilter, &bprint))) {
|
||||
AVFilterContext *filter;
|
||||
|
||||
ret = avfilter_graph_create_filter(&filter,
|
||||
avfilter_get_by_name("format"),
|
||||
"format", pix_fmts, NULL, fg->graph);
|
||||
av_freep(&pix_fmts);
|
||||
av_bprint_finalize(&bprint, NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if ((ret = avfilter_link(last_filter, pad_idx, filter, 0)) < 0)
|
||||
@ -559,9 +576,10 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
} while (0)
|
||||
av_bprint_init(&args, 0, AV_BPRINT_SIZE_UNLIMITED);
|
||||
if (ost->audio_channels_mapped) {
|
||||
AVChannelLayout mapped_layout = { 0 };
|
||||
int i;
|
||||
av_bprintf(&args, "0x%"PRIx64,
|
||||
av_get_default_channel_layout(ost->audio_channels_mapped));
|
||||
av_channel_layout_default(&mapped_layout, ost->audio_channels_mapped);
|
||||
av_channel_layout_describe_bprint(&mapped_layout, &args);
|
||||
for (i = 0; i < ost->audio_channels_mapped; i++)
|
||||
if (ost->audio_channels_map[i] != -1)
|
||||
av_bprintf(&args, "|c%d=c%d", i, ost->audio_channels_map[i]);
|
||||
@ -570,8 +588,8 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
av_bprint_clear(&args);
|
||||
}
|
||||
|
||||
if (codec->channels && !codec->channel_layout)
|
||||
codec->channel_layout = av_get_default_channel_layout(codec->channels);
|
||||
if (codec->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
|
||||
av_channel_layout_default(&codec->ch_layout, codec->ch_layout.nb_channels);
|
||||
|
||||
choose_sample_fmts(ofilter, &args);
|
||||
choose_sample_rates(ofilter, &args);
|
||||
@ -623,10 +641,11 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
fail:
|
||||
av_bprint_finalize(&args, NULL);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
|
||||
int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter,
|
||||
AVFilterInOut *out)
|
||||
{
|
||||
if (!ofilter->ost) {
|
||||
av_log(NULL, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
|
||||
@ -707,6 +726,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
{
|
||||
AVFilterContext *last_filter;
|
||||
const AVFilter *buffer_filt = avfilter_get_by_name("buffer");
|
||||
const AVPixFmtDescriptor *desc;
|
||||
InputStream *ist = ifilter->ist;
|
||||
InputFile *f = input_files[ist->file_index];
|
||||
AVRational tb = ist->framerate.num ? av_inv_q(ist->framerate) :
|
||||
@ -764,44 +784,46 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
av_freep(&par);
|
||||
last_filter = ifilter->filter;
|
||||
|
||||
if (ist->autorotate) {
|
||||
double theta = get_rotation(ist->st);
|
||||
desc = av_pix_fmt_desc_get(ifilter->format);
|
||||
av_assert0(desc);
|
||||
|
||||
// TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
|
||||
if (ist->autorotate && !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
|
||||
int32_t *displaymatrix = ifilter->displaymatrix;
|
||||
double theta;
|
||||
|
||||
if (!displaymatrix)
|
||||
displaymatrix = (int32_t *)av_stream_get_side_data(ist->st, AV_PKT_DATA_DISPLAYMATRIX, NULL);
|
||||
theta = get_rotation(displaymatrix);
|
||||
|
||||
if (fabs(theta - 90) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock");
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose",
|
||||
displaymatrix[3] > 0 ? "cclock_flip" : "clock");
|
||||
} else if (fabs(theta - 180) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
if (displaymatrix[0] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
if (displaymatrix[4] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
}
|
||||
} else if (fabs(theta - 270) < 1.0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock");
|
||||
ret = insert_filter(&last_filter, &pad_idx, "transpose",
|
||||
displaymatrix[3] < 0 ? "clock_flip" : "cclock");
|
||||
} else if (fabs(theta) > 1.0) {
|
||||
char rotate_buf[64];
|
||||
snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta);
|
||||
ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf);
|
||||
} else if (fabs(theta) < 1.0) {
|
||||
if (displaymatrix && displaymatrix[4] < 0) {
|
||||
ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL);
|
||||
}
|
||||
}
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (do_deinterlace) {
|
||||
AVFilterContext *yadif;
|
||||
|
||||
snprintf(name, sizeof(name), "deinterlace_in_%d_%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if ((ret = avfilter_graph_create_filter(&yadif,
|
||||
avfilter_get_by_name("yadif"),
|
||||
name, "", NULL,
|
||||
fg->graph)) < 0)
|
||||
return ret;
|
||||
|
||||
if ((ret = avfilter_link(last_filter, 0, yadif, 0)) < 0)
|
||||
return ret;
|
||||
|
||||
last_filter = yadif;
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), "trim_in_%d_%d",
|
||||
ist->file_index, ist->st->index);
|
||||
if (copy_ts) {
|
||||
@ -846,11 +868,12 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
|
||||
1, ifilter->sample_rate,
|
||||
ifilter->sample_rate,
|
||||
av_get_sample_fmt_name(ifilter->format));
|
||||
if (ifilter->channel_layout)
|
||||
av_bprintf(&args, ":channel_layout=0x%"PRIx64,
|
||||
ifilter->channel_layout);
|
||||
else
|
||||
av_bprintf(&args, ":channels=%d", ifilter->channels);
|
||||
if (av_channel_layout_check(&ifilter->ch_layout) &&
|
||||
ifilter->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
|
||||
av_bprintf(&args, ":channel_layout=");
|
||||
av_channel_layout_describe_bprint(&ifilter->ch_layout, &args);
|
||||
} else
|
||||
av_bprintf(&args, ":channels=%d", ifilter->ch_layout.nb_channels);
|
||||
snprintf(name, sizeof(name), "graph_%d_in_%d_%d", fg->index,
|
||||
ist->file_index, ist->st->index);
|
||||
|
||||
@ -960,6 +983,30 @@ static void cleanup_filtergraph(FilterGraph *fg)
|
||||
avfilter_graph_free(&fg->graph);
|
||||
}
|
||||
|
||||
static int filter_is_buffersrc(const AVFilterContext *f)
|
||||
{
|
||||
return f->nb_inputs == 0 &&
|
||||
(!strcmp(f->filter->name, "buffer") ||
|
||||
!strcmp(f->filter->name, "abuffer"));
|
||||
}
|
||||
|
||||
static int graph_is_meta(AVFilterGraph *graph)
|
||||
{
|
||||
for (unsigned i = 0; i < graph->nb_filters; i++) {
|
||||
const AVFilterContext *f = graph->filters[i];
|
||||
|
||||
/* in addition to filters flagged as meta, also
|
||||
* disregard sinks and buffersources (but not other sources,
|
||||
* since they introduce data we are not aware of)
|
||||
*/
|
||||
if (!((f->filter->flags & AVFILTER_FLAG_METADATA_ONLY) ||
|
||||
f->nb_outputs == 0 ||
|
||||
filter_is_buffersrc(f)))
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int configure_filtergraph(FilterGraph *fg)
|
||||
{
|
||||
AVFilterInOut *inputs, *outputs, *cur;
|
||||
@ -974,24 +1021,31 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if (simple) {
|
||||
OutputStream *ost = fg->outputs[0]->ost;
|
||||
char args[512];
|
||||
AVDictionaryEntry *e = NULL;
|
||||
const AVDictionaryEntry *e = NULL;
|
||||
|
||||
fg->graph->nb_threads = filter_nbthreads;
|
||||
if (filter_nbthreads) {
|
||||
ret = av_opt_set(fg->graph, "threads", filter_nbthreads, 0);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
} else {
|
||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||
if (e)
|
||||
av_opt_set(fg->graph, "threads", e->value, 0);
|
||||
}
|
||||
|
||||
args[0] = 0;
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(ost->sws_dict, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
}
|
||||
if (strlen(args))
|
||||
if (strlen(args)) {
|
||||
args[strlen(args)-1] = 0;
|
||||
|
||||
if (!strncmp(args, "sws_flags=", 10)) {
|
||||
// keep the 'flags=' part
|
||||
fg->graph->scale_sws_opts = av_strdup(args+4);
|
||||
fg->graph->scale_sws_opts = av_strdup(args);
|
||||
}
|
||||
|
||||
args[0] = 0;
|
||||
e = NULL;
|
||||
while ((e = av_dict_get(ost->swr_opts, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
@ -999,18 +1053,6 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if (strlen(args))
|
||||
args[strlen(args)-1] = 0;
|
||||
av_opt_set(fg->graph, "aresample_swr_opts", args, 0);
|
||||
|
||||
args[0] = '\0';
|
||||
while ((e = av_dict_get(fg->outputs[0]->ost->resample_opts, "", e,
|
||||
AV_DICT_IGNORE_SUFFIX))) {
|
||||
av_strlcatf(args, sizeof(args), "%s=%s:", e->key, e->value);
|
||||
}
|
||||
if (strlen(args))
|
||||
args[strlen(args) - 1] = '\0';
|
||||
|
||||
e = av_dict_get(ost->encoder_opts, "threads", NULL, 0);
|
||||
if (e)
|
||||
av_opt_set(fg->graph, "threads", e->value, 0);
|
||||
} else {
|
||||
fg->graph->nb_threads = filter_complex_nbthreads;
|
||||
}
|
||||
@ -1065,6 +1107,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
if ((ret = avfilter_graph_config(fg->graph, NULL)) < 0)
|
||||
goto fail;
|
||||
|
||||
fg->is_meta = graph_is_meta(fg->graph);
|
||||
|
||||
/* limit the lists of allowed formats to the ones selected, to
|
||||
* make sure they stay the same if the filtergraph is reconfigured later */
|
||||
for (i = 0; i < fg->nb_outputs; i++) {
|
||||
@ -1077,7 +1121,10 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
ofilter->height = av_buffersink_get_h(sink);
|
||||
|
||||
ofilter->sample_rate = av_buffersink_get_sample_rate(sink);
|
||||
ofilter->channel_layout = av_buffersink_get_channel_layout(sink);
|
||||
av_channel_layout_uninit(&ofilter->ch_layout);
|
||||
ret = av_buffersink_get_ch_layout(sink, &ofilter->ch_layout);
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fg->reconfiguration = 1;
|
||||
@ -1099,9 +1146,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
}
|
||||
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
while (av_fifo_size(fg->inputs[i]->frame_queue)) {
|
||||
AVFrame *tmp;
|
||||
av_fifo_generic_read(fg->inputs[i]->frame_queue, &tmp, sizeof(tmp), NULL);
|
||||
AVFrame *tmp;
|
||||
while (av_fifo_read(fg->inputs[i]->frame_queue, &tmp, 1) >= 0) {
|
||||
ret = av_buffersrc_add_frame(fg->inputs[i]->filter, tmp);
|
||||
av_frame_free(&tmp);
|
||||
if (ret < 0)
|
||||
@ -1122,9 +1168,8 @@ int configure_filtergraph(FilterGraph *fg)
|
||||
for (i = 0; i < fg->nb_inputs; i++) {
|
||||
InputStream *ist = fg->inputs[i]->ist;
|
||||
if (ist->sub2video.sub_queue && ist->sub2video.frame) {
|
||||
while (av_fifo_size(ist->sub2video.sub_queue)) {
|
||||
AVSubtitle tmp;
|
||||
av_fifo_generic_read(ist->sub2video.sub_queue, &tmp, sizeof(tmp), NULL);
|
||||
AVSubtitle tmp;
|
||||
while (av_fifo_read(ist->sub2video.sub_queue, &tmp, 1) >= 0) {
|
||||
sub2video_update(ist, INT64_MIN, &tmp);
|
||||
avsubtitle_free(&tmp);
|
||||
}
|
||||
@ -1140,6 +1185,9 @@ fail:
|
||||
|
||||
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
|
||||
{
|
||||
AVFrameSideData *sd;
|
||||
int ret;
|
||||
|
||||
av_buffer_unref(&ifilter->hw_frames_ctx);
|
||||
|
||||
ifilter->format = frame->format;
|
||||
@ -1149,8 +1197,14 @@ int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
|
||||
ifilter->sample_aspect_ratio = frame->sample_aspect_ratio;
|
||||
|
||||
ifilter->sample_rate = frame->sample_rate;
|
||||
ifilter->channels = frame->channels;
|
||||
ifilter->channel_layout = frame->channel_layout;
|
||||
ret = av_channel_layout_copy(&ifilter->ch_layout, &frame->ch_layout);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
av_freep(&ifilter->displaymatrix);
|
||||
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
|
||||
if (sd)
|
||||
ifilter->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9);
|
||||
|
||||
if (frame->hw_frames_ctx) {
|
||||
ifilter->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx);
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*
|
||||
* copyright (c) 2018 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* This file is part of FFmpeg.
|
||||
*
|
||||
* FFmpeg is free software; you can redistribute it and/or
|
||||
@ -17,10 +19,17 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
* This file is the modified version of ffmpeg_hw.c file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop mobile-ffmpeg and later ffmpeg-kit libraries.
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* mobile-ffmpeg / ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 12.2019
|
||||
* --------------------------------------------------------
|
||||
* - concurrent execution support ("__thread" specifier added to variables used by multiple threads)
|
||||
*
|
||||
* 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
*/
|
||||
@ -102,6 +111,8 @@ static char *hw_device_default_name(enum AVHWDeviceType type)
|
||||
|
||||
int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
{
|
||||
// "type=name"
|
||||
// "type=name,key=value,key2=value2"
|
||||
// "type=name:device,key=value,key2=value2"
|
||||
// "type:device,key=value,key2=value2"
|
||||
// -> av_hwdevice_ctx_create()
|
||||
@ -133,7 +144,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
}
|
||||
|
||||
if (*p == '=') {
|
||||
k = strcspn(p + 1, ":@");
|
||||
k = strcspn(p + 1, ":@,");
|
||||
|
||||
name = av_strndup(p + 1, k);
|
||||
if (!name) {
|
||||
@ -167,11 +178,11 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
q = strchr(p, ',');
|
||||
if (q) {
|
||||
if (q - p > 0) {
|
||||
device = av_strndup(p, q - p);
|
||||
if (!device) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
device = av_strndup(p, q - p);
|
||||
if (!device) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
|
||||
if (err < 0) {
|
||||
@ -199,6 +210,18 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
src->device_ref, 0);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
} else if (*p == ',') {
|
||||
err = av_dict_parse_string(&options, p + 1, "=", ",", 0);
|
||||
|
||||
if (err < 0) {
|
||||
errmsg = "failed to parse options";
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
err = av_hwdevice_ctx_create(&device_ref, type,
|
||||
NULL, options, 0);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
} else {
|
||||
errmsg = "parse error";
|
||||
goto invalid;
|
||||
@ -548,15 +571,21 @@ int hw_device_setup_for_filter(FilterGraph *fg)
|
||||
HWDevice *dev;
|
||||
int i;
|
||||
|
||||
// If the user has supplied exactly one hardware device then just
|
||||
// give it straight to every filter for convenience. If more than
|
||||
// one device is available then the user needs to pick one explcitly
|
||||
// with the filter_hw_device option.
|
||||
// Pick the last hardware device if the user doesn't pick the device for
|
||||
// filters explicitly with the filter_hw_device option.
|
||||
if (filter_hw_device)
|
||||
dev = filter_hw_device;
|
||||
else if (nb_hw_devices == 1)
|
||||
dev = hw_devices[0];
|
||||
else
|
||||
else if (nb_hw_devices > 0) {
|
||||
dev = hw_devices[nb_hw_devices - 1];
|
||||
|
||||
if (nb_hw_devices > 1)
|
||||
av_log(NULL, AV_LOG_WARNING, "There are %d hardware devices. device "
|
||||
"%s of type %s is picked for filters by default. Set hardware "
|
||||
"device explicitly with the filter_hw_device option if device "
|
||||
"%s is not usable for filters.\n",
|
||||
nb_hw_devices, dev->name,
|
||||
av_hwdevice_get_type_name(dev->type), dev->name);
|
||||
} else
|
||||
dev = NULL;
|
||||
|
||||
if (dev) {
|
||||
|
331
linux/src/fftools_ffmpeg_mux.c
Normal file
331
linux/src/fftools_ffmpeg_mux.c
Normal file
@ -0,0 +1,331 @@
|
||||
/*
|
||||
* This file is part of FFmpeg.
|
||||
* copyright (c) 2022 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of ffmpeg_mux.c file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to fftools headers
|
||||
* - using main_ffmpeg_return_code instead of main_return_code
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fftools_ffmpeg.h"
|
||||
|
||||
#include "libavutil/fifo.h"
|
||||
#include "libavutil/intreadwrite.h"
|
||||
#include "libavutil/log.h"
|
||||
#include "libavutil/mem.h"
|
||||
#include "libavutil/timestamp.h"
|
||||
|
||||
#include "libavcodec/packet.h"
|
||||
|
||||
#include "libavformat/avformat.h"
|
||||
#include "libavformat/avio.h"
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void of_write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost,
|
||||
int unqueue)
|
||||
{
|
||||
AVFormatContext *s = of->ctx;
|
||||
AVStream *st = ost->st;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* 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().
|
||||
* Do not count the packet when unqueued because it has been counted when queued.
|
||||
*/
|
||||
if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed) && !unqueue) {
|
||||
if (ost->frame_number >= ost->max_frames) {
|
||||
av_packet_unref(pkt);
|
||||
return;
|
||||
}
|
||||
ost->frame_number++;
|
||||
}
|
||||
|
||||
if (!of->header_written) {
|
||||
AVPacket *tmp_pkt;
|
||||
/* the muxer is not initialized yet, buffer the packet */
|
||||
if (!av_fifo_can_write(ost->muxing_queue)) {
|
||||
size_t cur_size = av_fifo_can_read(ost->muxing_queue);
|
||||
unsigned int are_we_over_size =
|
||||
(ost->muxing_queue_data_size + pkt->size) > ost->muxing_queue_data_threshold;
|
||||
size_t limit = are_we_over_size ? ost->max_muxing_queue_size : SIZE_MAX;
|
||||
size_t new_size = FFMIN(2 * cur_size, limit);
|
||||
|
||||
if (new_size <= cur_size) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Too many packets buffered for output stream %d:%d.\n",
|
||||
ost->file_index, ost->st->index);
|
||||
exit_program(1);
|
||||
}
|
||||
ret = av_fifo_grow2(ost->muxing_queue, new_size - cur_size);
|
||||
if (ret < 0)
|
||||
exit_program(1);
|
||||
}
|
||||
ret = av_packet_make_refcounted(pkt);
|
||||
if (ret < 0)
|
||||
exit_program(1);
|
||||
tmp_pkt = av_packet_alloc();
|
||||
if (!tmp_pkt)
|
||||
exit_program(1);
|
||||
av_packet_move_ref(tmp_pkt, pkt);
|
||||
ost->muxing_queue_data_size += tmp_pkt->size;
|
||||
av_fifo_write(ost->muxing_queue, &tmp_pkt, 1);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) ||
|
||||
(st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
|
||||
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
|
||||
|
||||
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||
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->mux_timebase);
|
||||
}
|
||||
}
|
||||
|
||||
av_packet_rescale_ts(pkt, ost->mux_timebase, ost->st->time_base);
|
||||
|
||||
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 ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) &&
|
||||
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 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG;
|
||||
if (exit_on_error)
|
||||
loglevel = AV_LOG_ERROR;
|
||||
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 duration:%s duration_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),
|
||||
av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, &ost->st->time_base),
|
||||
pkt->size
|
||||
);
|
||||
}
|
||||
|
||||
ret = av_interleaved_write_frame(s, pkt);
|
||||
if (ret < 0) {
|
||||
print_error("av_interleaved_write_frame()", ret);
|
||||
main_ffmpeg_return_code = 1;
|
||||
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED);
|
||||
}
|
||||
}
|
||||
|
||||
static int print_sdp(void)
|
||||
{
|
||||
char sdp[16384];
|
||||
int i;
|
||||
int j, ret;
|
||||
AVIOContext *sdp_pb;
|
||||
AVFormatContext **avc;
|
||||
|
||||
for (i = 0; i < nb_output_files; i++) {
|
||||
if (!output_files[i]->header_written)
|
||||
return 0;
|
||||
}
|
||||
|
||||
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) {
|
||||
av_log(NULL, AV_LOG_ERROR, "No output streams in the SDP.\n");
|
||||
ret = AVERROR(EINVAL);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = av_sdp_create(avc, j, sdp, sizeof(sdp));
|
||||
if (ret < 0)
|
||||
goto fail;
|
||||
|
||||
if (!sdp_filename) {
|
||||
printf("SDP:\n%s\n", sdp);
|
||||
fflush(stdout);
|
||||
} else {
|
||||
ret = avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Failed to open sdp file '%s'\n", sdp_filename);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
avio_print(sdp_pb, sdp);
|
||||
avio_closep(&sdp_pb);
|
||||
av_freep(&sdp_filename);
|
||||
}
|
||||
|
||||
fail:
|
||||
av_freep(&avc);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* open the muxer when all the streams are initialized */
|
||||
int of_check_init(OutputFile *of)
|
||||
{
|
||||
int ret, i;
|
||||
|
||||
for (i = 0; i < of->ctx->nb_streams; i++) {
|
||||
OutputStream *ost = output_streams[of->ost_index + i];
|
||||
if (!ost->initialized)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = avformat_write_header(of->ctx, &of->opts);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Could not write header for output file #%d "
|
||||
"(incorrect codec parameters ?): %s\n",
|
||||
of->index, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
//assert_avoptions(of->opts);
|
||||
of->header_written = 1;
|
||||
|
||||
av_dump_format(of->ctx, of->index, of->ctx->url, 1);
|
||||
nb_output_dumped++;
|
||||
|
||||
if (sdp_filename || want_sdp) {
|
||||
ret = print_sdp();
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error writing the SDP.\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/* flush the muxing queues */
|
||||
for (i = 0; i < of->ctx->nb_streams; i++) {
|
||||
OutputStream *ost = output_streams[of->ost_index + i];
|
||||
AVPacket *pkt;
|
||||
|
||||
/* try to improve muxing time_base (only possible if nothing has been written yet) */
|
||||
if (!av_fifo_can_read(ost->muxing_queue))
|
||||
ost->mux_timebase = ost->st->time_base;
|
||||
|
||||
while (av_fifo_read(ost->muxing_queue, &pkt, 1) >= 0) {
|
||||
ost->muxing_queue_data_size -= pkt->size;
|
||||
of_write_packet(of, pkt, ost, 1);
|
||||
av_packet_free(&pkt);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int of_write_trailer(OutputFile *of)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!of->header_written) {
|
||||
av_log(NULL, AV_LOG_ERROR,
|
||||
"Nothing was written into output file %d (%s), because "
|
||||
"at least one of its streams received no packets.\n",
|
||||
of->index, of->ctx->url);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
ret = av_write_trailer(of->ctx);
|
||||
if (ret < 0) {
|
||||
av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", of->ctx->url, av_err2str(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void of_close(OutputFile **pof)
|
||||
{
|
||||
OutputFile *of = *pof;
|
||||
AVFormatContext *s;
|
||||
|
||||
if (!of)
|
||||
return;
|
||||
|
||||
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(pof);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
79
linux/src/fftools_fopen_utf8.h
Normal file
79
linux/src/fftools_fopen_utf8.h
Normal file
@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of fopen_utf8.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_FOPEN_UTF8_H
|
||||
#define FFTOOLS_FOPEN_UTF8_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8,
|
||||
* except that it doesn't set O_CLOEXEC, and that it isn't exported
|
||||
* from a different library. (On Windows, each DLL might use a different
|
||||
* CRT, and FILE* handles can't be shared across them.) */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "libavutil/wchar_filename.h"
|
||||
|
||||
static inline FILE *fopen_utf8(const char *path_utf8, const char *mode)
|
||||
{
|
||||
wchar_t *path_w, *mode_w;
|
||||
FILE *f;
|
||||
|
||||
/* convert UTF-8 to wide chars */
|
||||
if (get_extended_win32_path(path_utf8, &path_w)) /* This sets errno on error. */
|
||||
return NULL;
|
||||
if (!path_w)
|
||||
goto fallback;
|
||||
|
||||
if (utf8towchar(mode, &mode_w))
|
||||
return NULL;
|
||||
if (!mode_w) {
|
||||
/* If failing to interpret the mode string as utf8, it is an invalid
|
||||
* parameter. */
|
||||
av_freep(&path_w);
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f = _wfopen(path_w, mode_w);
|
||||
av_freep(&path_w);
|
||||
av_freep(&mode_w);
|
||||
|
||||
return f;
|
||||
fallback:
|
||||
/* path may be in CP_ACP */
|
||||
return fopen(path_utf8, mode);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline FILE *fopen_utf8(const char *path, const char *mode)
|
||||
{
|
||||
return fopen(path, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FFTOOLS_FOPEN_UTF8_H */
|
1492
linux/src/fftools_opt_common.c
Normal file
1492
linux/src/fftools_opt_common.c
Normal file
File diff suppressed because it is too large
Load Diff
202
linux/src/fftools_opt_common.h
Normal file
202
linux/src/fftools_opt_common.h
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Option handlers shared between the tools.
|
||||
* copyright (c) 2022 Taner Sener ( tanersener gmail com )
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is the modified version of opt_common.h file living in ffmpeg source code under the fftools folder. We
|
||||
* manually update it each time we depend on a new ffmpeg version. Below you can see the list of changes applied
|
||||
* by us to develop the ffmpeg-kit library.
|
||||
*
|
||||
* ffmpeg-kit changes by Taner Sener
|
||||
*
|
||||
* 09.2022
|
||||
* --------------------------------------------------------
|
||||
* - CMDUTILS_COMMON_OPTIONS and CMDUTILS_COMMON_OPTIONS_AVDEVICE defines dropped
|
||||
* - fftools_ prefix added to fftools headers
|
||||
*/
|
||||
|
||||
#ifndef FFTOOLS_OPT_COMMON_H
|
||||
#define FFTOOLS_OPT_COMMON_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "fftools_cmdutils.h"
|
||||
|
||||
#if CONFIG_AVDEVICE
|
||||
/**
|
||||
* Print a listing containing autodetected 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 autodetected 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 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);
|
||||
|
||||
/**
|
||||
* Generic -h handler common to all fftools.
|
||||
*/
|
||||
int show_help(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* 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 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 muxers supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_muxers(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Print a listing containing all the demuxer supported by the
|
||||
* program (including devices).
|
||||
* This option processing function does not utilize the arguments.
|
||||
*/
|
||||
int show_demuxers(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);
|
||||
|
||||
/**
|
||||
* 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 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 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 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 supported stream dispositions.
|
||||
*/
|
||||
int show_dispositions(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);
|
||||
|
||||
/**
|
||||
* Set the libav* libraries log level.
|
||||
*/
|
||||
int opt_loglevel(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_report(void *optctx, const char *opt, const char *arg);
|
||||
int init_report(const char *env, FILE **file);
|
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Override the cpuflags.
|
||||
*/
|
||||
int opt_cpuflags(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Override the cpucount.
|
||||
*/
|
||||
int opt_cpucount(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
#endif /* FFTOOLS_OPT_COMMON_H */
|
4
macos.sh
4
macos.sh
@ -33,7 +33,7 @@ echo -e "\nINFO: Using SDK ${DETECTED_MACOS_SDK_VERSION} by Xcode provided at $(
|
||||
echo -e "\nINFO: Build options: $*\n" 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
||||
# SET DEFAULT BUILD OPTIONS
|
||||
GPL_ENABLED="no"
|
||||
export GPL_ENABLED="no"
|
||||
DISPLAY_HELP=""
|
||||
BUILD_TYPE_ID=""
|
||||
BUILD_FULL=""
|
||||
@ -114,7 +114,7 @@ while [ ! $# -eq 0 ]; do
|
||||
BUILD_FULL="1"
|
||||
;;
|
||||
--enable-gpl)
|
||||
GPL_ENABLED="yes"
|
||||
export GPL_ENABLED="yes"
|
||||
;;
|
||||
--enable-custom-library-*)
|
||||
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
|
||||
|
@ -399,11 +399,7 @@ git checkout libavutil 1>>"${BASEDIR}"/build.log 2>&1
|
||||
# 1. Use thread local log levels
|
||||
${SED_INLINE} 's/static int av_log_level/__thread int av_log_level/g' "${BASEDIR}"/src/"${LIB_NAME}"/libavutil/log.c 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
|
||||
# 2. Set friendly ffmpeg version
|
||||
FFMPEG_VERSION="v$(get_user_friendly_ffmpeg_version)"
|
||||
${SED_INLINE} "s/\$version/$FFMPEG_VERSION/g" "${BASEDIR}"/src/"${LIB_NAME}"/ffbuild/version.sh 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
|
||||
# 3. Enable ffmpeg-kit protocols
|
||||
# 2. Enable ffmpeg-kit protocols
|
||||
if [[ ${NO_FFMPEG_KIT_PROTOCOLS} == "1" ]]; then
|
||||
${SED_INLINE} "s/ av_set_fd_close/\/\/av_set_fd_close/g" "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/ffmpegkit.c 1>>"${BASEDIR}"/build.log 2>&1
|
||||
echo -e "\nINFO: Disabled custom ffmpeg-kit protocols\n" 1>>"${BASEDIR}"/build.log 2>&1
|
||||
@ -525,6 +521,8 @@ overwrite_file "${BASEDIR}"/src/ffmpeg/libavcodec/arm/mathops.h "${FFMPEG_LIBRAR
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/network.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/network.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/os_support.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/os_support.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/url.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/url.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/bprint.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/bprint.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/getenv_utf8.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/getenv_utf8.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/internal.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/internal.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/libm.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/libm.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/reverse.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/reverse.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
@ -485,10 +485,6 @@ fi
|
||||
# 3. Use thread local log levels
|
||||
${SED_INLINE} 's/static int av_log_level/__thread int av_log_level/g' "${BASEDIR}"/src/${LIB_NAME}/libavutil/log.c 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
|
||||
# 4. Set friendly ffmpeg version
|
||||
FFMPEG_VERSION="v$(get_user_friendly_ffmpeg_version)"
|
||||
${SED_INLINE} "s/\$version/$FFMPEG_VERSION/g" "${BASEDIR}"/src/"${LIB_NAME}"/ffbuild/version.sh 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
|
||||
###################################################################
|
||||
|
||||
./configure \
|
||||
@ -625,9 +621,8 @@ create_temporary_framework "libswresample"
|
||||
create_temporary_framework "libswscale"
|
||||
|
||||
${SED_INLINE} 's|$(SLIBNAME_WITH_MAJOR),|$(SLIBPREF)$(FULLNAME).framework/$(SLIBPREF)$(FULLNAME),|g' ${BASEDIR}/src/ffmpeg/ffbuild/config.mak 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
${SED_INLINE} "s|^ALLFFLIBS = .*|ALLFFLIBS = ${FFMPEG_LIBRARY_PATH}/framework|g" ${BASEDIR}/src/ffmpeg/ffbuild/common.mak 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
${SED_INLINE} 's|$(LD_LIB)|-framework lib% |g' ${BASEDIR}/src/ffmpeg/ffbuild/common.mak 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
${SED_INLINE} 's|$(LD_PATH)lib|-F |g' ${BASEDIR}/src/ffmpeg/ffbuild/common.mak 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
${SED_INLINE} "s|\$(LD_PATH)lib%|-F ${FFMPEG_LIBRARY_PATH}/framework|g" ${BASEDIR}/src/ffmpeg/ffbuild/common.mak 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
|
||||
# BUILD FRAMEWORKS AS DYNAMIC LIBRARIES
|
||||
build_ffmpeg
|
||||
@ -646,6 +641,8 @@ overwrite_file "${BASEDIR}"/src/ffmpeg/libavcodec/arm/mathops.h "${FFMPEG_LIBRAR
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/network.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/network.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/os_support.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/os_support.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/url.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/url.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/bprint.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/bprint.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/getenv_utf8.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/getenv_utf8.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/internal.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/internal.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/libm.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/libm.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/reverse.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/reverse.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
@ -671,7 +671,7 @@ either version 3 of the License, or (at your option) any later version."
|
||||
}
|
||||
|
||||
get_ffmpeg_libavcodec_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVCODEC_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavcodec/version.h | sed -e 's|LIBAVCODEC_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVCODEC_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavcodec/version_major.h | sed -e 's|LIBAVCODEC_VERSION_MAJOR||g;s| ||g')
|
||||
local MINOR=$(grep -Eo ' LIBAVCODEC_VERSION_MINOR .*' "${BASEDIR}"/src/ffmpeg/libavcodec/version.h | sed -e 's|LIBAVCODEC_VERSION_MINOR||g;s| ||g')
|
||||
local MICRO=$(grep -Eo ' LIBAVCODEC_VERSION_MICRO .*' "${BASEDIR}"/src/ffmpeg/libavcodec/version.h | sed -e 's|LIBAVCODEC_VERSION_MICRO||g;s| ||g')
|
||||
|
||||
@ -679,13 +679,13 @@ get_ffmpeg_libavcodec_version() {
|
||||
}
|
||||
|
||||
get_ffmpeg_libavcodec_major_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVCODEC_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavcodec/version.h | sed -e 's|LIBAVCODEC_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVCODEC_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavcodec/version_major.h | sed -e 's|LIBAVCODEC_VERSION_MAJOR||g;s| ||g')
|
||||
|
||||
echo "${MAJOR}"
|
||||
}
|
||||
|
||||
get_ffmpeg_libavdevice_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVDEVICE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavdevice/version.h | sed -e 's|LIBAVDEVICE_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVDEVICE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavdevice/version_major.h | sed -e 's|LIBAVDEVICE_VERSION_MAJOR||g;s| ||g')
|
||||
local MINOR=$(grep -Eo ' LIBAVDEVICE_VERSION_MINOR .*' "${BASEDIR}"/src/ffmpeg/libavdevice/version.h | sed -e 's|LIBAVDEVICE_VERSION_MINOR||g;s| ||g')
|
||||
local MICRO=$(grep -Eo ' LIBAVDEVICE_VERSION_MICRO .*' "${BASEDIR}"/src/ffmpeg/libavdevice/version.h | sed -e 's|LIBAVDEVICE_VERSION_MICRO||g;s| ||g')
|
||||
|
||||
@ -693,13 +693,13 @@ get_ffmpeg_libavdevice_version() {
|
||||
}
|
||||
|
||||
get_ffmpeg_libavdevice_major_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVDEVICE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavdevice/version.h | sed -e 's|LIBAVDEVICE_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVDEVICE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavdevice/version_major.h | sed -e 's|LIBAVDEVICE_VERSION_MAJOR||g;s| ||g')
|
||||
|
||||
echo "${MAJOR}"
|
||||
}
|
||||
|
||||
get_ffmpeg_libavfilter_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVFILTER_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavfilter/version.h | sed -e 's|LIBAVFILTER_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVFILTER_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavfilter/version_major.h | sed -e 's|LIBAVFILTER_VERSION_MAJOR||g;s| ||g')
|
||||
local MINOR=$(grep -Eo ' LIBAVFILTER_VERSION_MINOR .*' "${BASEDIR}"/src/ffmpeg/libavfilter/version.h | sed -e 's|LIBAVFILTER_VERSION_MINOR||g;s| ||g')
|
||||
local MICRO=$(grep -Eo ' LIBAVFILTER_VERSION_MICRO .*' "${BASEDIR}"/src/ffmpeg/libavfilter/version.h | sed -e 's|LIBAVFILTER_VERSION_MICRO||g;s| ||g')
|
||||
|
||||
@ -707,13 +707,13 @@ get_ffmpeg_libavfilter_version() {
|
||||
}
|
||||
|
||||
get_ffmpeg_libavfilter_major_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVFILTER_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavfilter/version.h | sed -e 's|LIBAVFILTER_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVFILTER_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavfilter/version_major.h | sed -e 's|LIBAVFILTER_VERSION_MAJOR||g;s| ||g')
|
||||
|
||||
echo "${MAJOR}"
|
||||
}
|
||||
|
||||
get_ffmpeg_libavformat_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVFORMAT_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavformat/version.h | sed -e 's|LIBAVFORMAT_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVFORMAT_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavformat/version_major.h | sed -e 's|LIBAVFORMAT_VERSION_MAJOR||g;s| ||g')
|
||||
local MINOR=$(grep -Eo ' LIBAVFORMAT_VERSION_MINOR .*' "${BASEDIR}"/src/ffmpeg/libavformat/version.h | sed -e 's|LIBAVFORMAT_VERSION_MINOR||g;s| ||g')
|
||||
local MICRO=$(grep -Eo ' LIBAVFORMAT_VERSION_MICRO .*' "${BASEDIR}"/src/ffmpeg/libavformat/version.h | sed -e 's|LIBAVFORMAT_VERSION_MICRO||g;s| ||g')
|
||||
|
||||
@ -721,7 +721,7 @@ get_ffmpeg_libavformat_version() {
|
||||
}
|
||||
|
||||
get_ffmpeg_libavformat_major_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVFORMAT_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavformat/version.h | sed -e 's|LIBAVFORMAT_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVFORMAT_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavformat/version_major.h | sed -e 's|LIBAVFORMAT_VERSION_MAJOR||g;s| ||g')
|
||||
|
||||
echo "${MAJOR}"
|
||||
}
|
||||
@ -735,13 +735,13 @@ get_ffmpeg_libavutil_version() {
|
||||
}
|
||||
|
||||
get_ffmpeg_libavutil_major_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBAVUTIL_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavutil/version.h | sed -e 's|LIBAVUTIL_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBAVUTIL_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libavutil/version_major.h | sed -e 's|LIBAVUTIL_VERSION_MAJOR||g;s| ||g')
|
||||
|
||||
echo "${MAJOR}"
|
||||
}
|
||||
|
||||
get_ffmpeg_libswresample_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBSWRESAMPLE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswresample/version.h | sed -e 's|LIBSWRESAMPLE_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBSWRESAMPLE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswresample/version_major.h | sed -e 's|LIBSWRESAMPLE_VERSION_MAJOR||g;s| ||g')
|
||||
local MINOR=$(grep -Eo ' LIBSWRESAMPLE_VERSION_MINOR .*' "${BASEDIR}"/src/ffmpeg/libswresample/version.h | sed -e 's|LIBSWRESAMPLE_VERSION_MINOR||g;s| ||g')
|
||||
local MICRO=$(grep -Eo ' LIBSWRESAMPLE_VERSION_MICRO .*' "${BASEDIR}"/src/ffmpeg/libswresample/version.h | sed -e 's|LIBSWRESAMPLE_VERSION_MICRO||g;s| ||g')
|
||||
|
||||
@ -749,13 +749,13 @@ get_ffmpeg_libswresample_version() {
|
||||
}
|
||||
|
||||
get_ffmpeg_libswresample_major_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBSWRESAMPLE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswresample/version.h | sed -e 's|LIBSWRESAMPLE_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBSWRESAMPLE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswresample/version_major.h | sed -e 's|LIBSWRESAMPLE_VERSION_MAJOR||g;s| ||g')
|
||||
|
||||
echo "${MAJOR}"
|
||||
}
|
||||
|
||||
get_ffmpeg_libswscale_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBSWSCALE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswscale/version.h | sed -e 's|LIBSWSCALE_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBSWSCALE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswscale/version_major.h | sed -e 's|LIBSWSCALE_VERSION_MAJOR||g;s| ||g')
|
||||
local MINOR=$(grep -Eo ' LIBSWSCALE_VERSION_MINOR .*' "${BASEDIR}"/src/ffmpeg/libswscale/version.h | sed -e 's|LIBSWSCALE_VERSION_MINOR||g;s| ||g')
|
||||
local MICRO=$(grep -Eo ' LIBSWSCALE_VERSION_MICRO .*' "${BASEDIR}"/src/ffmpeg/libswscale/version.h | sed -e 's|LIBSWSCALE_VERSION_MICRO||g;s| ||g')
|
||||
|
||||
@ -763,7 +763,7 @@ get_ffmpeg_libswscale_version() {
|
||||
}
|
||||
|
||||
get_ffmpeg_libswscale_major_version() {
|
||||
local MAJOR=$(grep -Eo ' LIBSWSCALE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswscale/version.h | sed -e 's|LIBSWSCALE_VERSION_MAJOR||g;s| ||g')
|
||||
local MAJOR=$(grep -Eo ' LIBSWSCALE_VERSION_MAJOR .*' "${BASEDIR}"/src/ffmpeg/libswscale/version_major.h | sed -e 's|LIBSWSCALE_VERSION_MAJOR||g;s| ||g')
|
||||
|
||||
echo "${MAJOR}"
|
||||
}
|
||||
@ -2231,11 +2231,6 @@ is_gnu_config_files_up_to_date() {
|
||||
echo $(grep aarch64-apple-darwin config.guess | wc -l 2>>"${BASEDIR}"/build.log)
|
||||
}
|
||||
|
||||
get_user_friendly_ffmpeg_version() {
|
||||
local USER_FRIENDLY_NAME=$(get_library_source "ffmpeg" 4)
|
||||
echo ${USER_FRIENDLY_NAME:1}
|
||||
}
|
||||
|
||||
get_cpu_count() {
|
||||
if [ "$(uname)" == "Darwin" ]; then
|
||||
echo $(sysctl -n hw.logicalcpu)
|
||||
|
@ -355,10 +355,6 @@ git checkout libavutil 1>>"${BASEDIR}"/build.log 2>&1
|
||||
# 1. Use thread local log levels
|
||||
${SED_INLINE} 's/static int av_log_level/__thread int av_log_level/g' "${BASEDIR}"/src/"${LIB_NAME}"/libavutil/log.c 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
|
||||
# 2. Set friendly ffmpeg version
|
||||
FFMPEG_VERSION="v$(get_user_friendly_ffmpeg_version)"
|
||||
${SED_INLINE} "s/\$version/$FFMPEG_VERSION/g" "${BASEDIR}"/src/"${LIB_NAME}"/ffbuild/version.sh 1>>"${BASEDIR}"/build.log 2>&1 || return 1
|
||||
|
||||
###################################################################
|
||||
|
||||
./configure \
|
||||
@ -473,6 +469,8 @@ overwrite_file "${BASEDIR}"/src/ffmpeg/libavcodec/arm/mathops.h "${FFMPEG_LIBRAR
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/network.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/network.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/os_support.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/os_support.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavformat/url.h "${FFMPEG_LIBRARY_PATH}"/include/libavformat/url.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/bprint.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/bprint.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/getenv_utf8.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/getenv_utf8.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/internal.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/internal.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/libm.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/libm.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
overwrite_file "${BASEDIR}"/src/ffmpeg/libavutil/reverse.h "${FFMPEG_LIBRARY_PATH}"/include/libavutil/reverse.h 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
@ -33,9 +33,8 @@ get_library_source() {
|
||||
;;
|
||||
ffmpeg)
|
||||
SOURCE_REPO_URL="https://github.com/tanersener/FFmpeg"
|
||||
SOURCE_ID="30322ebe3c55d0fb18bea4ae04d0fcaf1f97d27f"
|
||||
SOURCE_TYPE="COMMIT"
|
||||
SOURCE_GIT_DESCRIBE="n4.5-dev-3393-g30322ebe3c" # git describe --tags
|
||||
SOURCE_ID="n5.1.1"
|
||||
SOURCE_TYPE="TAG"
|
||||
;;
|
||||
fontconfig)
|
||||
SOURCE_REPO_URL="https://github.com/tanersener/fontconfig"
|
||||
@ -279,8 +278,5 @@ get_library_source() {
|
||||
3)
|
||||
echo "${SOURCE_TYPE}"
|
||||
;;
|
||||
4)
|
||||
echo "${SOURCE_GIT_DESCRIBE}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
ndkVersion "22.1.7171670"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 240451
|
||||
versionName "4.5.1"
|
||||
targetSdkVersion 31
|
||||
versionCode 240510
|
||||
versionName "5.1"
|
||||
project.archivesBaseName = "ffmpeg-kit"
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
compileSdkVersion 31
|
||||
ndkVersion "22.1.7171670"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 30
|
||||
versionCode 160451
|
||||
versionName "4.5.1.LTS"
|
||||
targetSdkVersion 31
|
||||
versionCode 160510
|
||||
versionName "5.1.LTS"
|
||||
project.archivesBaseName = "ffmpeg-kit"
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
|
4
tvos.sh
4
tvos.sh
@ -33,7 +33,7 @@ echo -e "\nINFO: Using SDK ${DETECTED_TVOS_SDK_VERSION} by Xcode provided at $(x
|
||||
echo -e "\nINFO: Build options: $*\n" 1>>"${BASEDIR}"/build.log 2>&1
|
||||
|
||||
# SET DEFAULT BUILD OPTIONS
|
||||
GPL_ENABLED="no"
|
||||
export GPL_ENABLED="no"
|
||||
DISPLAY_HELP=""
|
||||
BUILD_TYPE_ID=""
|
||||
BUILD_FULL=""
|
||||
@ -114,7 +114,7 @@ while [ ! $# -eq 0 ]; do
|
||||
BUILD_FULL="1"
|
||||
;;
|
||||
--enable-gpl)
|
||||
GPL_ENABLED="yes"
|
||||
export GPL_ENABLED="yes"
|
||||
;;
|
||||
--enable-custom-library-*)
|
||||
CUSTOM_LIBRARY_OPTION_KEY=$(echo $1 | sed -e 's/^--enable-custom-//g;s/=.*$//g')
|
||||
|
Loading…
Reference in New Issue
Block a user