FFmpeg
Loading...
Searching...
No Matches
ffmpeg_opt.c File Reference
#include "config.h"
#include <stdint.h>
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "cmdutils.h"
#include "opt_common.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/bsf.h"
#include "libavfilter/avfilter.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/mathematics.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/stereo3d.h"
#include "graph/graphprint.h"

Go to the source code of this file.

Data Structures

struct  GlobalOptionsContext
 

Macros

#define OPT_MATCH_PER_STREAM(name, type, opt_type, m)
 
#define OPT_MATCH_PER_STREAM_GROUP(name, type, opt_type, m)
 
#define OFFSET(x)
 

Enumerations

enum  OptGroup { GROUP_OUTFILE , GROUP_INFILE , GROUP_DECODER }
 

Functions

static void uninit_options (OptionsContext *o)
 
static void init_options (OptionsContext *o)
 
static int show_hwaccels (void *optctx, const char *opt, const char *arg)
 
const char * opt_match_per_type_str (const SpecifierOptList *sol, char mediatype)
 
static unsigned opt_match_per_stream (void *logctx, enum OptionType type, const SpecifierOptList *sol, AVFormatContext *fc, AVStream *st)
 
static unsigned opt_match_per_stream_group (void *logctx, enum OptionType type, const SpecifierOptList *sol, AVFormatContext *fc, AVStreamGroup *stg)
 
int view_specifier_parse (const char **pspec, ViewSpecifier *vs)
 
int parse_and_set_vsync (const char *arg, enum VideoSyncMethod *vsync_var, int file_idx, int st_idx)
 
static void correct_input_start_times (void)
 
static int apply_sync_offsets (void)
 
static int opt_filter_threads (void *optctx, const char *opt, const char *arg)
 
static int opt_abort_on (void *optctx, const char *opt, const char *arg)
 
static int opt_stats_period (void *optctx, const char *opt, const char *arg)
 
static int opt_audio_codec (void *optctx, const char *opt, const char *arg)
 
static int opt_video_codec (void *optctx, const char *opt, const char *arg)
 
static int opt_subtitle_codec (void *optctx, const char *opt, const char *arg)
 
static int opt_data_codec (void *optctx, const char *opt, const char *arg)
 
static int opt_map (void *optctx, const char *opt, const char *arg)
 
static int opt_attach (void *optctx, const char *opt, const char *arg)
 
static int opt_sdp_file (void *optctx, const char *opt, const char *arg)
 
static int opt_init_hw_device (void *optctx, const char *opt, const char *arg)
 
static int opt_filter_hw_device (void *optctx, const char *opt, const char *arg)
 
static int opt_recording_timestamp (void *optctx, const char *opt, const char *arg)
 
int find_codec (void *logctx, const char *name, enum AVMediaType type, int encoder, const AVCodec **pcodec)
 
int assert_file_overwrite (const char *filename)
 
static int opt_streamid (void *optctx, const char *opt, const char *arg)
 
static int opt_target (void *optctx, const char *opt, const char *arg)
 
static int opt_vstats_file (void *optctx, const char *opt, const char *arg)
 
static int opt_vstats (void *optctx, const char *opt, const char *arg)
 
static int opt_video_frames (void *optctx, const char *opt, const char *arg)
 
static int opt_audio_frames (void *optctx, const char *opt, const char *arg)
 
static int opt_data_frames (void *optctx, const char *opt, const char *arg)
 
static int opt_default_new (OptionsContext *o, const char *opt, const char *arg)
 
static int opt_preset (void *optctx, const char *opt, const char *arg)
 
static int opt_old2new (void *optctx, const char *opt, const char *arg)
 
static int opt_bitrate (void *optctx, const char *opt, const char *arg)
 
static int opt_qscale (void *optctx, const char *opt, const char *arg)
 
static int opt_profile (void *optctx, const char *opt, const char *arg)
 
static int opt_video_filters (void *optctx, const char *opt, const char *arg)
 
static int opt_audio_filters (void *optctx, const char *opt, const char *arg)
 
static int opt_timecode (void *optctx, const char *opt, const char *arg)
 
static int opt_audio_qscale (void *optctx, const char *opt, const char *arg)
 
static int opt_filter_complex (void *optctx, const char *opt, const char *arg)
 
void show_help_default (const char *opt, const char *arg)
 Per-fftool specific help handler.
 
void show_usage (void)
 
static int open_files (OptionGroupList *l, const char *inout, Scheduler *sch, int(*open_file)(const OptionsContext *, const char *, Scheduler *))
 
int ffmpeg_parse_options (int argc, char **argv, Scheduler *sch)
 
static int opt_progress (void *optctx, const char *opt, const char *arg)
 
int opt_timelimit (void *optctx, const char *opt, const char *arg)
 Limit the execution time.
 

Variables

HWDevicefilter_hw_device
 
char * vstats_filename
 
float dts_delta_threshold = 10
 
float dts_error_threshold = 3600*30
 
float frame_drop_threshold = 0
 
int do_benchmark = 0
 
int do_benchmark_all = 0
 
int do_hex_dump = 0
 
int do_pkt_dump = 0
 
int copy_ts = 0
 
int start_at_zero = 0
 
int copy_tb = -1
 
int debug_ts = 0
 
int exit_on_error = 0
 
int abort_on_flags = 0
 
int print_stats = -1
 
int stdin_interaction = 1
 
float max_error_rate = 2.0/3
 
char * filter_nbthreads
 
int filter_complex_nbthreads = 0
 
int filter_buffered_frames = 0
 
int vstats_version = 2
 
int print_graphs = 0
 
char * print_graphs_file = NULL
 
char * print_graphs_format = NULL
 
int auto_conversion_filters = 1
 
int64_t stats_period = 500000
 
static int file_overwrite = 0
 
static int no_file_overwrite = 0
 
int ignore_unknown_streams = 0
 
int copy_unknown_streams = 0
 
int recast_media = 0
 
static const OptionGroupDef groups []
 
static const char *const alt_channel_layout [] = { "ch_layout", NULL}
 
static const char *const alt_codec [] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL }
 
static const char *const alt_filter [] = { "af", "vf", NULL }
 
static const char *const alt_frames [] = { "aframes", "vframes", "dframes", NULL }
 
static const char *const alt_pre [] = { "apre", "vpre", "spre", NULL}
 
static const char *const alt_qscale [] = { "q", NULL}
 
static const char *const alt_tag [] = { "atag", "vtag", "stag", NULL }
 
const OptionDef options []
 

Macro Definition Documentation

◆ OPT_MATCH_PER_STREAM

#define OPT_MATCH_PER_STREAM ( name,
type,
opt_type,
m )
Value:
void opt_match_per_stream_ ## name(void *logctx, const SpecifierOptList *sol, \
{ \
unsigned ret = opt_match_per_stream(logctx, opt_type, sol, fc, st); \
if (ret > 0) \
*out = sol->opt[ret - 1].u.m; \
}
static FILE * out
static const uint16_t fc[]
Definition dcaenc.h:43
static unsigned opt_match_per_stream(void *logctx, enum OptionType type, const SpecifierOptList *sol, AVFormatContext *fc, AVStream *st)
Definition ffmpeg_opt.c:178
cl_device_type type
const char * name
Definition qsvenc.c:142
Format I/O context.
Definition avformat.h:1333
Stream structure.
Definition avformat.h:766

Definition at line 228 of file ffmpeg_opt.c.

◆ OPT_MATCH_PER_STREAM_GROUP

#define OPT_MATCH_PER_STREAM_GROUP ( name,
type,
opt_type,
m )
Value:
void opt_match_per_stream_group_ ## name(void *logctx, const SpecifierOptList *sol, \
{ \
unsigned ret = opt_match_per_stream_group(logctx, opt_type, sol, fc, stg); \
if (ret > 0) \
*out = sol->opt[ret - 1].u.m; \
}
static unsigned opt_match_per_stream_group(void *logctx, enum OptionType type, const SpecifierOptList *sol, AVFormatContext *fc, AVStreamGroup *stg)
Definition ffmpeg_opt.c:242

Definition at line 292 of file ffmpeg_opt.c.

◆ OFFSET

#define OFFSET ( x)
Value:

Definition at line 1551 of file ffmpeg_opt.c.

Referenced by do_decode(), osq_decode_block(), and osq_init().

Enumeration Type Documentation

◆ OptGroup

enum OptGroup
Enumerator
GROUP_OUTFILE 
GROUP_INFILE 
GROUP_DECODER 

Definition at line 1377 of file ffmpeg_opt.c.

Function Documentation

◆ uninit_options()

static void uninit_options ( OptionsContext * o)
static

Definition at line 99 of file ffmpeg_opt.c.

Referenced by open_files().

◆ init_options()

static void init_options ( OptionsContext * o)
static

Definition at line 135 of file ffmpeg_opt.c.

Referenced by open_files().

◆ show_hwaccels()

static int show_hwaccels ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 153 of file ffmpeg_opt.c.

◆ opt_match_per_type_str()

const char * opt_match_per_type_str ( const SpecifierOptList * sol,
char mediatype )

Definition at line 165 of file ffmpeg_opt.c.

Referenced by ifile_open(), map_auto_subtitle(), and opt_preset().

◆ opt_match_per_stream()

static unsigned opt_match_per_stream ( void * logctx,
enum OptionType type,
const SpecifierOptList * sol,
AVFormatContext * fc,
AVStream * st )
static

Definition at line 178 of file ffmpeg_opt.c.

◆ opt_match_per_stream_group()

static unsigned opt_match_per_stream_group ( void * logctx,
enum OptionType type,
const SpecifierOptList * sol,
AVFormatContext * fc,
AVStreamGroup * stg )
static

Definition at line 242 of file ffmpeg_opt.c.

Referenced by opt_match_per_stream_group().

◆ view_specifier_parse()

int view_specifier_parse ( const char ** pspec,
ViewSpecifier * vs )

Definition at line 306 of file ffmpeg_opt.c.

Referenced by fg_complex_bind_input(), opt_map(), and view_specifier_parse().

◆ parse_and_set_vsync()

int parse_and_set_vsync ( const char * arg,
enum VideoSyncMethod * vsync_var,
int file_idx,
int st_idx )

Definition at line 359 of file ffmpeg_opt.c.

Referenced by new_stream_video().

◆ correct_input_start_times()

static void correct_input_start_times ( void )
static

Definition at line 374 of file ffmpeg_opt.c.

Referenced by ffmpeg_parse_options().

◆ apply_sync_offsets()

static int apply_sync_offsets ( void )
static

Definition at line 411 of file ffmpeg_opt.c.

Referenced by ffmpeg_parse_options().

◆ opt_filter_threads()

static int opt_filter_threads ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 463 of file ffmpeg_opt.c.

◆ opt_abort_on()

static int opt_abort_on ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 470 of file ffmpeg_opt.c.

◆ opt_stats_period()

static int opt_stats_period ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 489 of file ffmpeg_opt.c.

◆ opt_audio_codec()

static int opt_audio_codec ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 507 of file ffmpeg_opt.c.

Referenced by opt_preset(), and opt_target().

◆ opt_video_codec()

static int opt_video_codec ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 513 of file ffmpeg_opt.c.

Referenced by opt_preset(), and opt_target().

◆ opt_subtitle_codec()

static int opt_subtitle_codec ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 519 of file ffmpeg_opt.c.

Referenced by opt_preset().

◆ opt_data_codec()

static int opt_data_codec ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 525 of file ffmpeg_opt.c.

Referenced by opt_preset().

◆ opt_map()

static int opt_map ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 531 of file ffmpeg_opt.c.

◆ opt_attach()

static int opt_attach ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 679 of file ffmpeg_opt.c.

◆ opt_sdp_file()

static int opt_sdp_file ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 693 of file ffmpeg_opt.c.

◆ opt_init_hw_device()

static int opt_init_hw_device ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 731 of file ffmpeg_opt.c.

◆ opt_filter_hw_device()

static int opt_filter_hw_device ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 746 of file ffmpeg_opt.c.

◆ opt_recording_timestamp()

static int opt_recording_timestamp ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 760 of file ffmpeg_opt.c.

◆ find_codec()

int find_codec ( void * logctx,
const char * name,
enum AVMediaType type,
int encoder,
const AVCodec ** pcodec )

Definition at line 783 of file ffmpeg_opt.c.

Referenced by choose_decoder(), choose_encoder(), and ifile_open().

◆ assert_file_overwrite()

int assert_file_overwrite ( const char * filename)

Definition at line 816 of file ffmpeg_opt.c.

Referenced by dump_attachment(), and of_open().

◆ opt_streamid()

static int opt_streamid ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 862 of file ffmpeg_opt.c.

◆ opt_target()

static int opt_target ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 881 of file ffmpeg_opt.c.

◆ opt_vstats_file()

static int opt_vstats_file ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1024 of file ffmpeg_opt.c.

Referenced by opt_vstats().

◆ opt_vstats()

static int opt_vstats ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1031 of file ffmpeg_opt.c.

◆ opt_video_frames()

static int opt_video_frames ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1047 of file ffmpeg_opt.c.

◆ opt_audio_frames()

static int opt_audio_frames ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1053 of file ffmpeg_opt.c.

◆ opt_data_frames()

static int opt_data_frames ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1059 of file ffmpeg_opt.c.

◆ opt_default_new()

static int opt_default_new ( OptionsContext * o,
const char * opt,
const char * arg )
static

Definition at line 1065 of file ffmpeg_opt.c.

Referenced by opt_preset().

◆ opt_preset()

static int opt_preset ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1085 of file ffmpeg_opt.c.

◆ opt_old2new()

static int opt_old2new ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1144 of file ffmpeg_opt.c.

◆ opt_bitrate()

static int opt_bitrate ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1156 of file ffmpeg_opt.c.

◆ opt_qscale()

static int opt_qscale ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1172 of file ffmpeg_opt.c.

◆ opt_profile()

static int opt_profile ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1189 of file ffmpeg_opt.c.

◆ opt_video_filters()

static int opt_video_filters ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1201 of file ffmpeg_opt.c.

◆ opt_audio_filters()

static int opt_audio_filters ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1207 of file ffmpeg_opt.c.

◆ opt_timecode()

static int opt_timecode ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1213 of file ffmpeg_opt.c.

◆ opt_audio_qscale()

static int opt_audio_qscale ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1227 of file ffmpeg_opt.c.

◆ opt_filter_complex()

static int opt_filter_complex ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1233 of file ffmpeg_opt.c.

◆ show_help_default()

void show_help_default ( const char * opt,
const char * arg )

Per-fftool specific help handler.

Implemented in each fftool, called by show_help().

Definition at line 1253 of file ffmpeg_opt.c.

◆ show_usage()

void show_usage ( void )

Definition at line 1370 of file ffmpeg_opt.c.

Referenced by main(), and show_help_default().

◆ open_files()

static int open_files ( OptionGroupList * l,
const char * inout,
Scheduler * sch,
int(* open_file )(const OptionsContext *, const char *, Scheduler *) )
static

Definition at line 1389 of file ffmpeg_opt.c.

Referenced by ffmpeg_parse_options().

◆ ffmpeg_parse_options()

int ffmpeg_parse_options ( int argc,
char ** argv,
Scheduler * sch )

Definition at line 1424 of file ffmpeg_opt.c.

Referenced by main().

◆ opt_progress()

static int opt_progress ( void * optctx,
const char * opt,
const char * arg )
static

Definition at line 1506 of file ffmpeg_opt.c.

◆ opt_timelimit()

int opt_timelimit ( void * optctx,
const char * opt,
const char * arg )

Limit the execution time.

Definition at line 1523 of file ffmpeg_opt.c.

Variable Documentation

◆ filter_hw_device

HWDevice* filter_hw_device

Definition at line 52 of file ffmpeg_opt.c.

Referenced by hw_device_for_filter(), and opt_filter_hw_device().

◆ vstats_filename

char* vstats_filename

Definition at line 54 of file ffmpeg_opt.c.

Referenced by encode_frame(), ffmpeg_cleanup(), opt_vstats_file(), and update_video_stats().

◆ dts_delta_threshold

float dts_delta_threshold = 10

Definition at line 56 of file ffmpeg_opt.c.

Referenced by ts_discontinuity_detect().

◆ dts_error_threshold

float dts_error_threshold = 3600*30

Definition at line 57 of file ffmpeg_opt.c.

Referenced by ts_discontinuity_detect(), and video_sync_process().

◆ frame_drop_threshold

float frame_drop_threshold = 0

Definition at line 59 of file ffmpeg_opt.c.

Referenced by video_sync_process().

◆ do_benchmark

int do_benchmark = 0

Definition at line 60 of file ffmpeg_opt.c.

Referenced by ffmpeg_cleanup(), and main().

◆ do_benchmark_all

int do_benchmark_all = 0

Definition at line 61 of file ffmpeg_opt.c.

Referenced by update_benchmark().

◆ do_hex_dump

int do_hex_dump = 0

Definition at line 62 of file ffmpeg_opt.c.

Referenced by input_thread().

◆ do_pkt_dump

int do_pkt_dump = 0

Definition at line 63 of file ffmpeg_opt.c.

Referenced by input_thread().

◆ copy_ts

◆ start_at_zero

◆ copy_tb

int copy_tb = -1

Definition at line 66 of file ffmpeg_opt.c.

◆ debug_ts

◆ exit_on_error

◆ abort_on_flags

int abort_on_flags = 0

Definition at line 69 of file ffmpeg_opt.c.

Referenced by check_written(), and opt_abort_on().

◆ print_stats

int print_stats = -1

Definition at line 70 of file ffmpeg_opt.c.

Referenced by print_report(), sga_read_packet(), try_packet(), uninit(), uninit(), and uninit().

◆ stdin_interaction

int stdin_interaction = 1

Definition at line 71 of file ffmpeg_opt.c.

Referenced by assert_file_overwrite(), ifile_open(), term_init(), and transcode().

◆ max_error_rate

float max_error_rate = 2.0/3

Definition at line 72 of file ffmpeg_opt.c.

Referenced by decoder_thread().

◆ filter_nbthreads

char* filter_nbthreads

◆ filter_complex_nbthreads

int filter_complex_nbthreads = 0

Definition at line 74 of file ffmpeg_opt.c.

Referenced by configure_filtergraph().

◆ filter_buffered_frames

int filter_buffered_frames = 0

Definition at line 75 of file ffmpeg_opt.c.

Referenced by configure_filtergraph().

◆ vstats_version

int vstats_version = 2

Definition at line 76 of file ffmpeg_opt.c.

Referenced by update_video_stats().

◆ print_graphs

int print_graphs = 0

Definition at line 77 of file ffmpeg_opt.c.

Referenced by ffmpeg_cleanup(), filter_thread(), and print_filtergraphs_priv().

◆ print_graphs_file

char* print_graphs_file = NULL

Definition at line 78 of file ffmpeg_opt.c.

Referenced by ffmpeg_cleanup(), filter_thread(), and print_filtergraphs_priv().

◆ print_graphs_format

char* print_graphs_format = NULL

Definition at line 79 of file ffmpeg_opt.c.

Referenced by ffmpeg_cleanup(), and init_graphprint().

◆ auto_conversion_filters

int auto_conversion_filters = 1

Definition at line 80 of file ffmpeg_opt.c.

Referenced by fg_create().

◆ stats_period

int64_t stats_period = 500000

Definition at line 81 of file ffmpeg_opt.c.

Referenced by opt_stats_period(), print_report(), and transcode().

◆ file_overwrite

int file_overwrite = 0
static

Definition at line 84 of file ffmpeg_opt.c.

Referenced by assert_file_overwrite().

◆ no_file_overwrite

int no_file_overwrite = 0
static

Definition at line 85 of file ffmpeg_opt.c.

Referenced by assert_file_overwrite().

◆ ignore_unknown_streams

int ignore_unknown_streams = 0

Definition at line 86 of file ffmpeg_opt.c.

Referenced by map_manual().

◆ copy_unknown_streams

int copy_unknown_streams = 0

Definition at line 87 of file ffmpeg_opt.c.

Referenced by map_manual().

◆ recast_media

int recast_media = 0

Definition at line 88 of file ffmpeg_opt.c.

Referenced by choose_decoder(), and find_codec().

◆ groups

const OptionGroupDef groups[]
static
Initial value:
= {
[GROUP_OUTFILE] = { "output url", NULL, OPT_OUTPUT },
[GROUP_INFILE] = { "input url", "i", OPT_INPUT },
[GROUP_DECODER] = { "loopback decoder", "dec", OPT_DECODER },
}
#define OPT_INPUT
Definition cmdutils.h:237
#define OPT_OUTPUT
Definition cmdutils.h:238
#define OPT_DECODER
Definition cmdutils.h:248
#define NULL
Definition coverity.c:32
@ GROUP_OUTFILE
@ GROUP_INFILE
@ GROUP_DECODER

Definition at line 1383 of file ffmpeg_opt.c.

Referenced by decode_delta_j(), ffmpeg_parse_options(), init_parse_context(), match_group_separator(), read_coeffs_coarse(), split_commandline(), and translate_shuffle().

◆ alt_channel_layout

const char* const alt_channel_layout[] = { "ch_layout", NULL}
static

Definition at line 1543 of file ffmpeg_opt.c.

◆ alt_codec

const char* const alt_codec[] = { "c", "acodec", "vcodec", "scodec", "dcodec", NULL }
static

Definition at line 1544 of file ffmpeg_opt.c.

◆ alt_filter

const char* const alt_filter[] = { "af", "vf", NULL }
static

Definition at line 1545 of file ffmpeg_opt.c.

◆ alt_frames

const char* const alt_frames[] = { "aframes", "vframes", "dframes", NULL }
static

Definition at line 1546 of file ffmpeg_opt.c.

◆ alt_pre

const char* const alt_pre[] = { "apre", "vpre", "spre", NULL}
static

Definition at line 1547 of file ffmpeg_opt.c.

◆ alt_qscale

const char* const alt_qscale[] = { "q", NULL}
static

Definition at line 1548 of file ffmpeg_opt.c.

◆ alt_tag

const char* const alt_tag[] = { "atag", "vtag", "stag", NULL }
static

Definition at line 1549 of file ffmpeg_opt.c.

◆ options

const OptionDef options[]

Definition at line 1552 of file ffmpeg_opt.c.