44 #define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass" 46 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ 49 for (i = 0; i < o->nb_ ## name; i++) {\ 50 char *spec = o->name[i].specifier;\ 51 if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0)\ 52 outvar = o->name[i].u.type;\ 114 int i, *count = (
int*)(so + 1);
115 for (i = 0; i < *count; i++) {
136 memset(o, 0,
sizeof(*o));
153 char *p = strchr(e->
key,
':');
171 p = strchr(arg,
':');
173 x = strtol(arg, &end, 10);
175 y = strtol(end + 1, &end, 10);
177 ar = (double)x / (
double)y;
192 printf(
"Supported hardware acceleration:\n");
194 printf(
"%s\n", hwaccels[i].
name);
224 static int opt_map(
void *optctx,
const char *opt,
const char *arg)
228 int i, negative = 0, file_idx;
229 int sync_file_idx = -1, sync_stream_idx;
242 if (sync = strchr(map,
',')) {
244 sync_file_idx = strtol(sync + 1, &sync, 0);
259 "match any streams.\n", arg);
267 const char *c = map + 1;
276 file_idx = strtol(map, &p, 0);
288 *p ==
':' ? p + 1 : p) > 0)
294 *p ==
':' ? p + 1 : p) <= 0)
302 if (sync_file_idx >= 0) {
321 static int opt_attach(
void *optctx,
const char *opt,
const char *arg)
330 static int opt_vaapi_device(
void *optctx,
const char *opt,
const char *arg)
355 if (*(++arg) && *arg !=
':') {
359 *stream_spec = *arg ==
':' ? arg + 1 :
"";
364 *index = strtol(++arg,
NULL, 0);
379 char type_in, type_out;
380 const char *istream_spec =
NULL, *ostream_spec =
NULL;
381 int idx_in = 0, idx_out = 0;
386 if (type_in ==
'g' || type_out ==
'g')
388 if (type_in ==
's' || type_out ==
's')
390 if (type_in ==
'c' || type_out ==
'c')
397 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\ 398 if ((index) < 0 || (index) >= (nb_elems)) {\ 399 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\ 404 #define SET_DICT(type, meta, context, index)\ 407 meta = &context->metadata;\ 410 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\ 411 meta = &context->chapters[index]->metadata;\ 414 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\ 415 meta = &context->programs[index]->metadata;\ 419 default: av_assert0(0);\ 422 SET_DICT(type_in, meta_in, ic, idx_in);
423 SET_DICT(type_out, meta_out, oc, idx_out);
426 if (type_in ==
's') {
440 if (type_out ==
's') {
457 const char *codec_string = encoder ?
"encoder" :
"decoder";
469 codec_string, codec->
name, desc->
name);
476 if (codec->
type != type) {
485 char *codec_name =
NULL;
506 char *framerate =
NULL, *hwaccel =
NULL, *hwaccel_device =
NULL;
507 char *hwaccel_output_format =
NULL;
508 char *codec_tag =
NULL;
533 uint32_t
tag = strtol(codec_tag, &next, 0);
566 if (!strcmp(hwaccel,
"none"))
568 else if (!strcmp(hwaccel,
"auto"))
572 for (i = 0; hwaccels[i].
name; i++) {
573 if (!strcmp(hwaccels[i].
name, hwaccel)) {
583 for (i = 0; hwaccels[i].
name; i++)
592 if (hwaccel_device) {
599 hwaccel_output_format, ic, st);
600 if (hwaccel_output_format) {
604 "format: %s", hwaccel_output_format);
630 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
635 (!strchr(filename,
':') || filename[1] ==
':' ||
639 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
642 fprintf(stderr,
"Not overwriting - exiting\n");
647 fprintf(stderr,
"File '%s' already exists. Exiting.\n", filename);
706 if (!strcmp(filename,
"-"))
710 !strcmp(filename,
"/dev/stdin");
726 if (file_iformat && file_iformat->
priv_class &&
729 snprintf(buf,
sizeof(buf),
"%d",
737 if (file_iformat && file_iformat->
priv_class &&
834 "input file #%d (%s) is not a decoding option.\n", e->
key,
841 "input file #%d (%s) has not been used for any stream. The most " 842 "likely reason is either wrong type (e.g. a video option with " 843 "no video streams) or that it is a private option of some decoder " 844 "which was not actually used for any stream.\n", e->
key,
860 for (i = 0; i < orig_nb_streams; i++)
878 while ((c =
avio_r8(s)) && c !=
'\n')
890 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
899 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
900 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
904 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
905 i != 1 ?
"" :
"/.avconv", preset_name);
915 char *codec_name =
NULL;
925 "output stream #%d:%d. Default encoder for format %s is " 926 "probably disabled. Please choose an encoder manually.\n",
930 }
else if (!strcmp(codec_name,
"copy"))
952 const char *bsfs =
NULL;
953 char *next, *codec_tag =
NULL;
998 if (!buf[0] || buf[0] ==
'#') {
1002 if (!(arg = strchr(buf,
'='))) {
1014 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1026 while (bsfs && *bsfs) {
1054 uint32_t
tag = strtol(codec_tag, &next, 0);
1090 const char *p = str;
1122 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1142 if (filter_script && filter) {
1162 char *frame_aspect_ratio =
NULL;
1169 if (frame_aspect_ratio)
1173 const char *p =
NULL;
1175 char *frame_pix_fmt =
NULL;
1176 char *intra_matrix =
NULL, *inter_matrix =
NULL;
1217 for (i = 0; p; i++) {
1219 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1263 char logfilename[1024];
1266 snprintf(logfilename,
sizeof(logfilename),
"%s-%d.log",
1270 if (!strcmp(ost->
enc->
name,
"libx264")) {
1274 f = fopen(logfilename,
"wb");
1277 logfilename, strerror(errno));
1282 char *logbuffer =
read_file(logfilename);
1327 char *sample_fmt =
NULL;
1391 p = strchr(idx_str,
':');
1394 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1426 if (in_ch->
end < ts_off)
1428 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1435 out_ch->id = in_ch->
id;
1437 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1438 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1453 switch (ofilter->
type) {
1470 "which is fed from a complex filtergraph. Filtering and streamcopy " 1514 if (!strcmp(filename,
"-"))
1528 if (!file_oformat) {
1534 if (!file_oformat) {
1554 switch (ofilter->
type) {
1565 #define NEW_STREAM(type, index)\ 1567 ost = new_ ## type ## _stream(o, oc);\ 1568 ost->source_index = index;\ 1569 ost->sync_ist = input_streams[index];\ 1570 input_streams[index]->discard = 0;\ 1571 input_streams[index]->st->discard = AVDISCARD_NONE;\ 1576 int area = 0, idx = -1;
1590 int channels = 0, idx = -1;
1636 "in any defined filter graph.\n", map->
linklabel);
1723 "output file #%d (%s) is not an encoding option.\n", e->
key,
1730 "output file #%d (%s) has not been used for any stream. The most " 1731 "likely reason is either wrong type (e.g. a video option with " 1732 "no video streams) or that it is a private option of some encoder " 1733 "which was not actually used for any stream.\n", e->
key,
1751 "Error initializing a simple filtergraph between streams " 1785 "for the output stream #%d:%d, but no information " 1786 "about the input framerate is available. Falling " 1787 "back to a default value of 25fps. Use the -r option " 1788 "if you want a different framerate.\n",
1898 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1902 in_file_index >= 0 ?
1943 const char *stream_spec;
1944 int index = 0, j, ret;
1986 static int opt_target(
void *optctx,
const char *opt,
const char *arg)
1990 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
1992 if (!strncmp(arg,
"pal-", 4)) {
1995 }
else if (!strncmp(arg,
"ntsc-", 5)) {
1998 }
else if (!strncmp(arg,
"film-", 5)) {
2014 }
else if ((fr == 29970) || (fr == 23976)) {
2034 if (!strcmp(arg,
"vcd")) {
2061 }
else if (!strcmp(arg,
"svcd")) {
2083 }
else if (!strcmp(arg,
"dvd")) {
2104 }
else if (!strncmp(arg,
"dv", 2)) {
2109 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2110 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2134 static int opt_vstats(
void *optctx,
const char *opt,
const char *arg)
2137 time_t today2 = time(
NULL);
2138 struct tm *today = localtime(&today2);
2145 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2198 static int opt_vsync(
void *optctx,
const char *opt,
const char *arg)
2212 char layout_str[32];
2215 int ret, channels, ac_str_size;
2223 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2230 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2231 stream_str = strchr(opt,
':');
2232 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2281 int show_advanced = 0, show_avoptions = 0;
2284 if (!strcmp(opt,
"long"))
2286 else if (!strcmp(opt,
"full"))
2287 show_advanced = show_avoptions = 1;
2294 printf(
"Getting help:\n" 2295 " -h -- print basic options\n" 2296 " -h long -- print more options\n" 2297 " -h full -- print all options (including all format and codec specific options, very long)\n" 2298 " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter\n" 2299 " See man %s for detailed description of the options.\n" 2306 "instead of just one file:",
2334 if (show_avoptions) {
2345 printf(
"Hyper fast Audio and Video encoder\n");
2346 printf(
"usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n",
program_name);
2375 "%s.\n", inout, g->
arg);
2380 ret = open_file(&o, g->
arg);
2399 memset(&octx, 0,
sizeof(octx));
2446 #define OFFSET(x) offsetof(OptionsContext, x) 2452 "force format",
"fmt" },
2454 "overwrite output files" },
2456 "never overwrite output files" },
2459 "codec name",
"codec" },
2462 "codec name",
"codec" },
2465 "preset name",
"preset" },
2468 "set input stream mapping",
2469 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2472 "set metadata information of outfile from infile",
2473 "outfile[,metadata]:infile[,metadata]" },
2476 "set chapters mapping",
"input_file_index" },
2479 "record or transcode \"duration\" seconds of audio/video",
2482 "set the limit file size in bytes",
"limit_size" },
2485 "set the start time offset",
"time_off" },
2488 "enable/disable accurate seeking with -ss" },
2491 "set the input ts offset",
"time_off" },
2494 "set the input ts scale",
"scale" },
2496 "add metadata",
"string=string" },
2499 "set the number of data frames to record",
"number" },
2501 "add timings for benchmarking" },
2503 "set max runtime in seconds",
"limit" },
2505 "dump each input packet" },
2507 "when dumping packets, also dump the payload" },
2510 "read input at native frame rate",
"" },
2512 "specify target file type (\"vcd\", \"svcd\", \"dvd\"," 2513 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2515 "video sync method",
"" },
2517 "audio sync method",
"" },
2519 "audio drift threshold",
"threshold" },
2521 "copy timestamps" },
2523 "copy input stream time base when stream copying" },
2526 "finish encoding within shortest input" },
2528 "timestamp discontinuity delta threshold",
"threshold" },
2530 "exit on error",
"error" },
2533 "copy initial non-keyframes" },
2535 "set the number of frames to record",
"number" },
2538 "force codec tag/fourcc",
"fourcc/tag" },
2541 "use fixed quality scale (VBR)",
"q" },
2544 "use fixed quality scale (VBR)",
"q" },
2546 "set stream filterchain",
"filter_list" },
2548 "read stream filtergraph description from a file",
"filename" },
2550 "create a complex filtergraph",
"graph_description" },
2552 "read complex filtergraph description from a file",
"filename" },
2554 "print progress report during encoding", },
2557 "add an attachment to the output file",
"filename" },
2560 "extract an attachment into a file",
"filename" },
2562 OPT_OFFSET, { .off =
OFFSET(
loop) },
"set number of times input stream shall be looped",
"loop count" },
2566 "set the number of video frames to record",
"number" },
2569 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2572 "set frame size (WxH or abbreviation)",
"size" },
2575 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2578 "set pixel format",
"format" },
2582 "discard threshold",
"n" },
2585 "rate control override for specific intervals",
"override" },
2588 "force video codec ('copy' to copy stream)",
"codec" },
2590 "select the pass number (1 or 2)",
"n" },
2593 "select two pass log file name prefix",
"prefix" },
2595 "dump video coding statistics to file" },
2597 "dump video coding statistics to file",
"file" },
2599 "video filters",
"filter list" },
2602 "specify intra matrix coeffs",
"matrix" },
2605 "specify inter matrix coeffs",
"matrix" },
2608 "top=1/bottom=0/auto=-1 field first",
"" },
2610 "intra_dc_precision",
"precision" },
2613 "force video tag/fourcc",
"fourcc/tag" },
2615 "show QP histogram" },
2618 "force the selected framerate, disable the best supported framerate selection" },
2621 "set the value of an outfile streamid",
"streamIndex:value" },
2624 "force key frames at specified timestamps",
"timestamps" },
2627 "use HW accelerated decoding",
"hwaccel name" },
2630 "select a device for HW acceleration",
"devicename" },
2633 "select output format used with HW accelerated decoding",
"format" },
2636 "show available HW acceleration methods" },
2639 "automatically insert correct rotate filters" },
2641 "attempt to decode anyway if HW accelerated decoder's supported profiles do not exactly match the stream" },
2645 "set the number of audio frames to record",
"number" },
2647 "set audio quality (codec-specific)",
"quality", },
2650 "set audio sampling rate (in Hz)",
"rate" },
2653 "set number of audio channels",
"channels" },
2658 "force audio codec ('copy' to copy stream)",
"codec" },
2661 "force audio tag/fourcc",
"fourcc/tag" },
2663 "change audio volume (256=normal)" ,
"volume" },
2666 "set sample format",
"format" },
2669 "set channel layout",
"layout" },
2671 "audio filters",
"filter list" },
2675 "disable subtitle" },
2677 "force subtitle codec ('copy' to copy stream)",
"codec" },
2679 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2686 "set the maximum demux-decode delay",
"seconds" },
2688 "set the initial demux-decode delay",
"seconds" },
2691 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2694 "maximum number of packets that can be buffered while waiting for all streams to initialize",
"packets" },
2698 "force data codec ('copy' to copy stream)",
"codec" },
2702 "set VAAPI hardware device (DRM path or X11 display name)",
"device" },
unsigned int nb_chapters
Number of chapters in AVChapter array.
#define AVERROR_ENCODER_NOT_FOUND
Encoder not found.
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)
uint64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
AVDictionary * resample_opts
static OutputStream * new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
static AVCodec * choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st)
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int file_overwrite
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
static OutputStream * new_audio_stream(OptionsContext *o, AVFormatContext *oc)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
static void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc)
#define AV_LOG_WARNING
Something somehow does not look correct.
static int opt_audio_tag(void *optctx, const char *opt, const char *arg)
Main libavfilter public API header.
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
static const uint8_t frame_size[4]
int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, const OptionGroupDef *groups, int nb_groups)
Split the commandline into an intermediate form convenient for further processing.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
int init_complex_filtergraph(FilterGraph *fg)
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
#define AV_OPT_FLAG_AUDIO_PARAM
int index
stream index in AVFormatContext
int max_muxing_queue_size
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
#define AVIO_FLAG_READ
read-only
static int sync(AVFormatContext *s, uint8_t *header)
Read input until we find the next ident.
const AVBitStreamFilter * av_bsf_get_by_name(const char *name)
#define AVIO_FLAG_WRITE
write-only
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
static int opt_channel_layout(void *optctx, const char *opt, const char *arg)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
float audio_drift_threshold
static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
FilterGraph ** filtergraphs
#define FF_ARRAY_ELEMS(a)
const AVBitStreamFilter ** bitstream_filters
static int opt_video_filters(void *optctx, const char *opt, const char *arg)
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, AVCodec *codec)
Filter out options for given codec.
This struct describes the properties of an encoded stream.
static OutputStream * new_subtitle_stream(OptionsContext *o, AVFormatContext *oc)
SpecifierOpt * frame_pix_fmts
static AVInputFormat * file_iformat
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
int hwaccel_lax_profile_check
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
int avio_check(const char *url, int flags)
Return AVIO_FLAG_* access flags corresponding to the access permissions of the resource in url...
static const uint8_t frame_sizes[]
int copy_initial_nonkeyframes
enum AVSampleFormat sample_fmt
audio sample format
Opaque data information usually continuous.
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions...
#define VSYNC_PASSTHROUGH
int id
unique ID to identify the chapter
int id
Format-specific stream ID.
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVBufferRef * hw_device_ctx
AVStream ** streams
A list of all streams in the file.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
double strtod(const char *, char **)
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
static int init_complex_filters(void)
#define DEFAULT_PASS_LOGFILENAME_PREFIX
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int flags
Flags modifying the (de)muxer behaviour.
static int opt_subtitle_tag(void *optctx, const char *opt, const char *arg)
AVDictionary * resample_opts
#define AV_LOG_VERBOSE
Detailed information.
int vaapi_device_init(const char *device)
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
static int opt_video_tag(void *optctx, const char *opt, const char *arg)
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
struct AVOutputFormat * oformat
The output container format.
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
AVDictionary * format_opts
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
static char * get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost)
const uint64_t * channel_layouts
array of support channel layouts, or NULL if unknown. array is terminated by 0
void show_help_default(const char *opt, const char *arg)
Per-avtool specific help handler.
static int64_t start_time
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
enum AVMediaType codec_type
General type of the encoded data.
int flags
AV_CODEC_FLAG_*.
static void dump_attachment(AVStream *st, const char *filename)
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
HW acceleration through VDA, data[3] contains a CVPixelBufferRef.
float dts_delta_threshold
AVRational avg_frame_rate
Average framerate.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
static void parse_meta_type(char *arg, char *type, int *index, const char **stream_spec)
Parse a metadata specifier passed as 'arg' parameter.
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
int intra_dc_precision
precision of the intra DC coefficient - 8
int qsv_init(AVCodecContext *s)
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
MetadataMap(* meta_data_maps)[2]
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static AVDictionary * strip_specifiers(AVDictionary *dict)
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
int rc_override_count
ratecontrol override, see RcOverride
int void avio_flush(AVIOContext *s)
audio channel layout utility functions
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
const AVIOInterruptCB int_cb
char filename[1024]
input or output filename
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
int vaapi_decode_init(AVCodecContext *avctx)
#define AV_TIME_BASE
Internal time base represented as integer.
SpecifierOpt * audio_channels
uint64_t * channel_layouts
static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)
int av_strcasecmp(const char *a, const char *b)
static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o)
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
int metadata_chapters_manual
enum AVCodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type)
Guess the codec ID based upon muxer and filename.
struct OutputStream * ost
int width
picture width / height.
static int intra_dc_precision
SpecifierOpt * audio_sample_rate
static int opt_data_codec(void *optctx, const char *opt, const char *arg)
static int open_output_file(OptionsContext *o, const char *filename)
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
SpecifierOpt * dump_attachment
A list of option groups that all have the same group type (e.g.
SpecifierOpt * metadata_map
char * specifier
stream/chapter/program/...
AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
static int opt_vstats(void *optctx, const char *opt, const char *arg)
static const OptionGroupDef groups[]
const OptionDef options[]
Usually treated as AVMEDIA_TYPE_DATA.
Opaque data information usually sparse.
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
SpecifierOpt * frame_sizes
int vdpau_init(AVCodecContext *s)
static OutputStream * new_video_stream(OptionsContext *o, AVFormatContext *oc)
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
static void parse_matrix_coeffs(uint16_t *dest, const char *str)
int av_find_nearest_q_idx(AVRational q, const AVRational *q_list)
Find the nearest value in q_list to q.
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
if(ac->has_optimized_func)
static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
const AVClass * avfilter_get_class(void)
A linked-list of the inputs/outputs of the filter chain.
int64_t end
chapter start/end time in time_base units
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
SpecifierOpt * frame_rates
#define AV_LOG_INFO
Standard information.
static const AVBitStreamFilter * bitstream_filters[]
struct InputStream * sync_ist
OutputFile ** output_files
Libavcodec external API header.
enum AVMediaType codec_type
const AVRational * supported_framerates
array of supported framerates, or NULL if any, array is terminated by {0,0}
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static AVCodec * find_codec_or_die(const char *name, enum AVMediaType type, int encoder)
char * av_strdup(const char *s)
Duplicate the string s.
int sample_rate
samples per second
AVIOContext * pb
I/O context.
OutputStream ** output_streams
AVFifoBuffer * muxing_queue
static double parse_frame_aspect_ratio(const char *arg)
static int opt_data_frames(void *optctx, const char *opt, const char *arg)
void avio_w8(AVIOContext *s, int b)
#define AV_OPT_FLAG_VIDEO_PARAM
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
int metadata_streams_manual
const char * attachment_filename
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
a very simple circular buffer FIFO implementation
static int opt_vsync(void *optctx, const char *opt, const char *arg)
static void uninit_options(OptionsContext *o)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
uint16_t * intra_matrix
custom intra quantization matrix
static int open_input_file(OptionsContext *o, const char *filename)
static int opt_video_frames(void *optctx, const char *opt, const char *arg)
Describe the class of an AVClass context structure.
rational number numerator/denominator
const char program_name[]
program name, defined by the program for show_version().
int metadata_global_manual
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
int avconv_parse_options(int argc, char **argv)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
void * grow_array(void *array, int elem_size, int *size, int new_size)
Realloc array to hold new_size elements of elem_size.
static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata)
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
enum AVSampleFormat av_get_sample_fmt(const char *name)
Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
const VDPAUPixFmtMap * map
const char * name
Name of the codec described by this descriptor.
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
uint16_t * inter_matrix
custom inter quantization matrix
This struct describes the properties of a single codec described by an AVCodecID. ...
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
Parse a string and return its corresponding value as a double.
char * name
unique name for this input/output in the list
int global_quality
Global quality for codecs which cannot change it per frame.
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static int opt_map(void *optctx, const char *opt, const char *arg)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
A reference to a data buffer.
int guess_input_channel_layout(InputStream *ist)
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
AVDictionary * codec_opts
AVDictionary * format_opts
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
static int opt_attach(void *optctx, const char *opt, const char *arg)
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
InputStream ** input_streams
static uint8_t * read_file(const char *filename)
int vda_init(AVCodecContext *s)
static int opt_streamid(void *optctx, const char *opt, const char *arg)
const char ** attachments
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required poi...
AVRational time_base
time base in which the start/end timestamps are specified
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
static uint8_t * get_line(AVIOContext *s)
#define GROW_ARRAY(array, nb_elems)
int eof_reached
true if eof reached
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
int channels
number of audio channels
const int * supported_samplerates
array of supported audio samplerates, or NULL if unknown, array is terminated by 0 ...
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
AVDictionary * encoder_opts
static void * av_mallocz_array(size_t nmemb, size_t size)
static enum AVSampleFormat sample_fmts[]
AVDictionary * codec_opts
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0...
static int opt_video_codec(void *optctx, const char *opt, const char *arg)
#define AV_DICT_IGNORE_SUFFIX
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
static int open_files(OptionGroupList *l, const char *inout, int(*open_file)(OptionsContext *, const char *))
AVCodecParameters * codecpar
#define SET_DICT(type, meta, context, index)
int dxva2_init(AVCodecContext *s)
enum AVSampleFormat * sample_fmts
array of supported sample formats, or NULL if unknown, array is terminated by -1
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
static OutputStream * new_attachment_stream(OptionsContext *o, AVFormatContext *oc)
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
enum AVPixelFormat pix_fmts[2]
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static OutputStream * new_data_stream(OptionsContext *o, AVFormatContext *oc)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
void assert_avoptions(AVDictionary *m)
struct SwsContext * sws_opts
This structure stores compressed data.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int opt_target(void *optctx, const char *opt, const char *arg)
#define AV_NOPTS_VALUE
Undefined timestamp value.
static void assert_file_overwrite(const char *filename)
#define NEW_STREAM(type, index)
static void init_options(OptionsContext *o)