Libav
Macros | Enumerations | Functions | Variables
avconv_opt.c File Reference
#include <stdint.h>
#include "avconv.h"
#include "cmdutils.h"
#include "libavformat/avformat.h"
#include "libavcodec/avcodec.h"
#include "libavfilter/avfilter.h"
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/avutil.h"
#include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/fifo.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/pixfmt.h"
#include "cmdutils_common_opts.h"

Go to the source code of this file.

Macros

#define DEFAULT_PASS_LOGFILENAME_PREFIX   "av2pass"
 
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)
 
#define METADATA_CHECK_INDEX(index, nb_elems, desc)
 
#define SET_DICT(type, meta, context, index)
 
#define NEW_STREAM(type, index)
 
#define OFFSET(x)   offsetof(OptionsContext, x)
 

Enumerations

enum  OptGroup { GROUP_OUTFILE, GROUP_INFILE }
 

Functions

static void uninit_options (OptionsContext *o)
 
static void init_options (OptionsContext *o)
 
static AVDictionarystrip_specifiers (AVDictionary *dict)
 
static double parse_frame_aspect_ratio (const char *arg)
 
static int show_hwaccels (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 void parse_meta_type (char *arg, char *type, int *index, const char **stream_spec)
 Parse a metadata specifier passed as 'arg' parameter. More...
 
static int copy_metadata (char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o)
 
static AVCodecfind_codec_or_die (const char *name, enum AVMediaType type, int encoder)
 
static AVCodecchoose_decoder (OptionsContext *o, AVFormatContext *s, AVStream *st)
 
static void add_input_streams (OptionsContext *o, AVFormatContext *ic)
 
static void assert_file_overwrite (const char *filename)
 
static void dump_attachment (AVStream *st, const char *filename)
 
static int open_input_file (OptionsContext *o, const char *filename)
 
static uint8_tget_line (AVIOContext *s)
 
static int get_preset_file_2 (const char *preset_name, const char *codec_name, AVIOContext **s)
 
static int choose_encoder (OptionsContext *o, AVFormatContext *s, OutputStream *ost)
 
static OutputStreamnew_output_stream (OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
 
static void parse_matrix_coeffs (uint16_t *dest, const char *str)
 
static uint8_tread_file (const char *filename)
 
static char * get_ost_filters (OptionsContext *o, AVFormatContext *oc, OutputStream *ost)
 
static OutputStreamnew_video_stream (OptionsContext *o, AVFormatContext *oc)
 
static OutputStreamnew_audio_stream (OptionsContext *o, AVFormatContext *oc)
 
static OutputStreamnew_data_stream (OptionsContext *o, AVFormatContext *oc)
 
static OutputStreamnew_attachment_stream (OptionsContext *o, AVFormatContext *oc)
 
static OutputStreamnew_subtitle_stream (OptionsContext *o, AVFormatContext *oc)
 
static int opt_streamid (void *optctx, const char *opt, const char *arg)
 
static int copy_chapters (InputFile *ifile, OutputFile *ofile, int copy_metadata)
 
static void init_output_filter (OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc)
 
static int init_complex_filters (void)
 
static int open_output_file (OptionsContext *o, const char *filename)
 
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_video_tag (void *optctx, const char *opt, const char *arg)
 
static int opt_audio_tag (void *optctx, const char *opt, const char *arg)
 
static int opt_subtitle_tag (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_vsync (void *optctx, const char *opt, const char *arg)
 
static int opt_channel_layout (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)
 
static int opt_filter_complex_script (void *optctx, const char *opt, const char *arg)
 
void show_help_default (const char *opt, const char *arg)
 Per-avtool specific help handler. More...
 
void show_usage (void)
 
static int open_files (OptionGroupList *l, const char *inout, int(*open_file)(OptionsContext *, const char *))
 
int avconv_parse_options (int argc, char **argv)
 

Variables

const HWAccel hwaccels []
 
int hwaccel_lax_profile_check = 0
 
AVBufferRefhw_device_ctx
 
char * vstats_filename
 
float audio_drift_threshold = 0.1
 
float dts_delta_threshold = 10
 
int audio_volume = 256
 
int audio_sync_method = 0
 
int video_sync_method = VSYNC_AUTO
 
int do_benchmark = 0
 
int do_hex_dump = 0
 
int do_pkt_dump = 0
 
int copy_ts = 0
 
int copy_tb = 1
 
int exit_on_error = 0
 
int print_stats = 1
 
int qp_hist = 0
 
static int file_overwrite = 0
 
static int file_skip = 0
 
static int video_discard = 0
 
static int intra_dc_precision = 8
 
static int using_stdin = 0
 
static int input_sync
 
static const OptionGroupDef groups []
 
const OptionDef options []
 

Macro Definition Documentation

◆ DEFAULT_PASS_LOGFILENAME_PREFIX

#define DEFAULT_PASS_LOGFILENAME_PREFIX   "av2pass"

Definition at line 44 of file avconv_opt.c.

Referenced by new_video_stream().

◆ MATCH_PER_STREAM_OPT

#define MATCH_PER_STREAM_OPT (   name,
  type,
  outvar,
  fmtctx,
  st 
)
Value:
{\
int i, ret;\
for (i = 0; i < o->nb_ ## name; i++) {\
char *spec = o->name[i].specifier;\
if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0)\
outvar = o->name[i].u.type;\
else if (ret < 0)\
exit_program(1);\
}\
}
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
Definition: cmdutils.c:1492
const char * name
Definition: qsvenc.c:44

Definition at line 46 of file avconv_opt.c.

Referenced by add_input_streams(), choose_decoder(), choose_encoder(), get_ost_filters(), new_audio_stream(), new_output_stream(), and new_video_stream().

◆ METADATA_CHECK_INDEX

#define METADATA_CHECK_INDEX (   index,
  nb_elems,
  desc 
)
Value:
if ((index) < 0 || (index) >= (nb_elems)) {\
av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
(desc), (index));\
exit_program(1);\
}
const char * desc
Definition: nvenc.c:101
NULL
Definition: eval.c:55
int index
Definition: gxfenc.c:72
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
Definition: log.h:118

◆ SET_DICT

#define SET_DICT (   type,
  meta,
  context,
  index 
)
Value:
switch (type) {\
case 'g':\
meta = &context->metadata;\
break;\
case 'c':\
METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
meta = &context->chapters[index]->metadata;\
break;\
case 'p':\
METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
meta = &context->programs[index]->metadata;\
break;\
case 's':\
break; /* handled separately below */ \
default: av_assert0(0);\
}\
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int index
Definition: gxfenc.c:72

Referenced by copy_metadata().

◆ NEW_STREAM

#define NEW_STREAM (   type,
  index 
)
Value:
if (index >= 0) {\
ost = new_ ## type ## _stream(o, oc);\
ost->source_index = index;\
ost->sync_ist = input_streams[index];\
input_streams[index]->discard = 0;\
input_streams[index]->st->discard = AVDISCARD_NONE;\
}
int index
Definition: gxfenc.c:72
InputStream ** input_streams
Definition: avconv.c:97
int discard
Definition: avconv.h:257
discard nothing
Definition: avcodec.h:684

Referenced by open_output_file().

◆ OFFSET

#define OFFSET (   x)    offsetof(OptionsContext, x)

Definition at line 2446 of file avconv_opt.c.

Referenced by g726_reset().

Enumeration Type Documentation

◆ OptGroup

enum OptGroup
Enumerator
GROUP_OUTFILE 
GROUP_INFILE 

Definition at line 2350 of file avconv_opt.c.

Function Documentation

◆ uninit_options()

static void uninit_options ( OptionsContext o)
static

Definition at line 103 of file avconv_opt.c.

Referenced by open_files().

◆ init_options()

static void init_options ( OptionsContext o)
static

Definition at line 134 of file avconv_opt.c.

Referenced by open_files().

◆ strip_specifiers()

static AVDictionary* strip_specifiers ( AVDictionary dict)
static

Definition at line 147 of file avconv_opt.c.

Referenced by open_input_file(), and open_output_file().

◆ parse_frame_aspect_ratio()

static double parse_frame_aspect_ratio ( const char *  arg)
static

Definition at line 164 of file avconv_opt.c.

Referenced by new_video_stream().

◆ show_hwaccels()

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

Definition at line 188 of file avconv_opt.c.

◆ opt_audio_codec()

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

Definition at line 200 of file avconv_opt.c.

Referenced by opt_target().

◆ opt_video_codec()

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

Definition at line 206 of file avconv_opt.c.

Referenced by opt_target().

◆ opt_subtitle_codec()

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

Definition at line 212 of file avconv_opt.c.

◆ opt_data_codec()

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

Definition at line 218 of file avconv_opt.c.

◆ opt_map()

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

Definition at line 224 of file avconv_opt.c.

◆ opt_attach()

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

Definition at line 321 of file avconv_opt.c.

◆ parse_meta_type()

static void parse_meta_type ( char *  arg,
char *  type,
int *  index,
const char **  stream_spec 
)
static

Parse a metadata specifier passed as 'arg' parameter.

Parameters
argmetadata string to parse
typemetadata type is written here – g(lobal)/s(tream)/c(hapter)/p(rogram)
indexfor type c/p, chapter/program index is written here
stream_specfor type s, the stream specifier is written here

Definition at line 347 of file avconv_opt.c.

Referenced by copy_metadata(), and open_output_file().

◆ copy_metadata()

static int copy_metadata ( char *  outspec,
char *  inspec,
AVFormatContext oc,
AVFormatContext ic,
OptionsContext o 
)
static

Definition at line 374 of file avconv_opt.c.

Referenced by open_output_file().

◆ find_codec_or_die()

static AVCodec* find_codec_or_die ( const char *  name,
enum AVMediaType  type,
int  encoder 
)
static

Definition at line 454 of file avconv_opt.c.

Referenced by choose_decoder(), and choose_encoder().

◆ choose_decoder()

static AVCodec* choose_decoder ( OptionsContext o,
AVFormatContext s,
AVStream st 
)
static

Definition at line 483 of file avconv_opt.c.

Referenced by add_input_streams(), and open_input_file().

◆ add_input_streams()

static void add_input_streams ( OptionsContext o,
AVFormatContext ic 
)
static

Definition at line 498 of file avconv_opt.c.

Referenced by open_input_file().

◆ assert_file_overwrite()

static void assert_file_overwrite ( const char *  filename)
static

Definition at line 627 of file avconv_opt.c.

Referenced by dump_attachment(), and open_output_file().

◆ dump_attachment()

static void dump_attachment ( AVStream st,
const char *  filename 
)
static

Definition at line 654 of file avconv_opt.c.

Referenced by open_input_file().

◆ open_input_file()

static int open_input_file ( OptionsContext o,
const char *  filename 
)
static

Definition at line 686 of file avconv_opt.c.

Referenced by avconv_parse_options().

◆ get_line()

static uint8_t* get_line ( AVIOContext s)
static

Definition at line 867 of file avconv_opt.c.

Referenced by new_output_stream().

◆ get_preset_file_2()

static int get_preset_file_2 ( const char *  preset_name,
const char *  codec_name,
AVIOContext **  s 
)
static

Definition at line 886 of file avconv_opt.c.

Referenced by new_output_stream().

◆ choose_encoder()

static int choose_encoder ( OptionsContext o,
AVFormatContext s,
OutputStream ost 
)
static

Definition at line 912 of file avconv_opt.c.

Referenced by new_output_stream().

◆ new_output_stream()

static OutputStream* new_output_stream ( OptionsContext o,
AVFormatContext oc,
enum AVMediaType  type 
)
static

◆ parse_matrix_coeffs()

static void parse_matrix_coeffs ( uint16_t *  dest,
const char *  str 
)
static

Definition at line 1087 of file avconv_opt.c.

Referenced by new_video_stream().

◆ read_file()

static uint8_t* read_file ( const char *  filename)
static

Definition at line 1105 of file avconv_opt.c.

Referenced by get_ost_filters(), new_video_stream(), and opt_filter_complex_script().

◆ get_ost_filters()

static char* get_ost_filters ( OptionsContext o,
AVFormatContext oc,
OutputStream ost 
)
static

Definition at line 1133 of file avconv_opt.c.

Referenced by new_audio_stream(), and new_video_stream().

◆ new_video_stream()

static OutputStream* new_video_stream ( OptionsContext o,
AVFormatContext oc 
)
static

Definition at line 1157 of file avconv_opt.c.

Referenced by init_output_filter(), and open_output_file().

◆ new_audio_stream()

static OutputStream* new_audio_stream ( OptionsContext o,
AVFormatContext oc 
)
static

Definition at line 1314 of file avconv_opt.c.

Referenced by init_output_filter(), and open_output_file().

◆ new_data_stream()

static OutputStream* new_data_stream ( OptionsContext o,
AVFormatContext oc 
)
static

Definition at line 1348 of file avconv_opt.c.

Referenced by open_output_file().

◆ new_attachment_stream()

static OutputStream* new_attachment_stream ( OptionsContext o,
AVFormatContext oc 
)
static

Definition at line 1361 of file avconv_opt.c.

Referenced by open_output_file().

◆ new_subtitle_stream()

static OutputStream* new_subtitle_stream ( OptionsContext o,
AVFormatContext oc 
)
static

Definition at line 1369 of file avconv_opt.c.

Referenced by open_output_file().

◆ opt_streamid()

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

Definition at line 1383 of file avconv_opt.c.

◆ copy_chapters()

static int copy_chapters ( InputFile ifile,
OutputFile ofile,
int  copy_metadata 
)
static

Definition at line 1405 of file avconv_opt.c.

Referenced by open_output_file().

◆ init_output_filter()

static void init_output_filter ( OutputFilter ofilter,
OptionsContext o,
AVFormatContext oc 
)
static

Definition at line 1448 of file avconv_opt.c.

Referenced by open_output_file().

◆ init_complex_filters()

static int init_complex_filters ( void  )
static

Definition at line 1478 of file avconv_opt.c.

Referenced by avconv_parse_options().

◆ open_output_file()

static int open_output_file ( OptionsContext o,
const char *  filename 
)
static

Definition at line 1490 of file avconv_opt.c.

Referenced by avconv_parse_options().

◆ opt_target()

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

Definition at line 1986 of file avconv_opt.c.

◆ opt_vstats_file()

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

Definition at line 2127 of file avconv_opt.c.

Referenced by opt_vstats().

◆ opt_vstats()

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

Definition at line 2134 of file avconv_opt.c.

◆ opt_video_frames()

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

Definition at line 2150 of file avconv_opt.c.

◆ opt_audio_frames()

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

Definition at line 2156 of file avconv_opt.c.

◆ opt_data_frames()

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

Definition at line 2162 of file avconv_opt.c.

◆ opt_video_tag()

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

Definition at line 2168 of file avconv_opt.c.

◆ opt_audio_tag()

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

Definition at line 2174 of file avconv_opt.c.

◆ opt_subtitle_tag()

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

Definition at line 2180 of file avconv_opt.c.

◆ opt_video_filters()

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

Definition at line 2186 of file avconv_opt.c.

◆ opt_audio_filters()

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

Definition at line 2192 of file avconv_opt.c.

◆ opt_vsync()

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

Definition at line 2198 of file avconv_opt.c.

◆ opt_channel_layout()

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

Definition at line 2209 of file avconv_opt.c.

◆ opt_audio_qscale()

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

Definition at line 2245 of file avconv_opt.c.

◆ opt_filter_complex()

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

Definition at line 2251 of file avconv_opt.c.

◆ opt_filter_complex_script()

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

Definition at line 2263 of file avconv_opt.c.

◆ show_help_default()

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

Per-avtool specific help handler.

Implemented in each avtool, called by show_help().

Definition at line 2277 of file avconv_opt.c.

Referenced by show_help().

◆ show_usage()

void show_usage ( void  )

Definition at line 2343 of file avconv_opt.c.

Referenced by main(), and show_help_default().

◆ open_files()

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

Definition at line 2360 of file avconv_opt.c.

Referenced by avconv_parse_options().

◆ avconv_parse_options()

int avconv_parse_options ( int  argc,
char **  argv 
)

Definition at line 2393 of file avconv_opt.c.

Referenced by main().

Variable Documentation

◆ hwaccels

const HWAccel hwaccels[]
Initial value:
= {
{ 0 },
}

Definition at line 58 of file avconv_opt.c.

Referenced by get_hwaccel().

◆ hwaccel_lax_profile_check

int hwaccel_lax_profile_check = 0

Definition at line 76 of file avconv_opt.c.

Referenced by vaapi_build_decoder_config().

◆ hw_device_ctx

AVBufferRef* hw_device_ctx

◆ vstats_filename

char* vstats_filename

Definition at line 79 of file avconv_opt.c.

Referenced by avconv_cleanup(), do_video_stats(), opt_vstats_file(), and poll_filter().

◆ audio_drift_threshold

float audio_drift_threshold = 0.1

Definition at line 81 of file avconv_opt.c.

Referenced by configure_input_audio_filter().

◆ dts_delta_threshold

float dts_delta_threshold = 10

Definition at line 82 of file avconv_opt.c.

Referenced by process_input().

◆ audio_volume

int audio_volume = 256

Definition at line 84 of file avconv_opt.c.

Referenced by configure_input_audio_filter().

◆ audio_sync_method

int audio_sync_method = 0

Definition at line 85 of file avconv_opt.c.

Referenced by configure_input_audio_filter(), and do_audio_out().

◆ video_sync_method

int video_sync_method = VSYNC_AUTO

Definition at line 86 of file avconv_opt.c.

Referenced by do_video_out(), open_output_file(), and opt_vsync().

◆ do_benchmark

int do_benchmark = 0

Definition at line 87 of file avconv_opt.c.

Referenced by main().

◆ do_hex_dump

int do_hex_dump = 0

Definition at line 88 of file avconv_opt.c.

Referenced by process_input().

◆ do_pkt_dump

int do_pkt_dump = 0

Definition at line 89 of file avconv_opt.c.

Referenced by process_input().

◆ copy_ts

int copy_ts = 0

Definition at line 90 of file avconv_opt.c.

Referenced by open_input_file(), and process_input().

◆ copy_tb

int copy_tb = 1

Definition at line 91 of file avconv_opt.c.

◆ exit_on_error

int exit_on_error = 0

Definition at line 92 of file avconv_opt.c.

Referenced by do_subtitle_out(), process_input(), process_input_packet(), and write_packet().

◆ print_stats

int print_stats = 1

Definition at line 93 of file avconv_opt.c.

Referenced by print_report().

◆ qp_hist

int qp_hist = 0

Definition at line 94 of file avconv_opt.c.

Referenced by print_report().

◆ file_overwrite

int file_overwrite = 0
static

Definition at line 96 of file avconv_opt.c.

Referenced by assert_file_overwrite().

◆ file_skip

int file_skip = 0
static

Definition at line 97 of file avconv_opt.c.

Referenced by assert_file_overwrite().

◆ video_discard

int video_discard = 0
static

Definition at line 98 of file avconv_opt.c.

◆ intra_dc_precision

int intra_dc_precision = 8
static

Definition at line 99 of file avconv_opt.c.

Referenced by new_video_stream().

◆ using_stdin

int using_stdin = 0
static

Definition at line 100 of file avconv_opt.c.

Referenced by assert_file_overwrite(), and open_input_file().

◆ input_sync

int input_sync
static

Definition at line 101 of file avconv_opt.c.

◆ groups

const OptionGroupDef groups[]
static
Initial value:
= {
[GROUP_OUTFILE] = { "output file", NULL, OPT_OUTPUT },
[GROUP_INFILE] = { "input file", "i", OPT_INPUT },
}
#define OPT_OUTPUT
Definition: cmdutils.h:163
NULL
Definition: eval.c:55
#define OPT_INPUT
Definition: cmdutils.h:162

Definition at line 2355 of file avconv_opt.c.

◆ options

const OptionDef options[]