45 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
48 for (i = 0; i < o->nb_ ## name; i++) {\
49 char *spec = o->name[i].specifier;\
50 if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0)\
51 outvar = o->name[i].u.type;\
92 int i, *count = (
int*)(so + 1);
93 for (i = 0; i < *count; i++) {
114 memset(o, 0,
sizeof(*o));
129 p = strchr(arg,
':');
131 x = strtol(arg, &end, 10);
133 y = strtol(end + 1, &end, 10);
135 ar = (double)x / (
double)y;
170 static int opt_map(
void *optctx,
const char *opt,
const char *arg)
174 int i, negative = 0, file_idx;
175 int sync_file_idx = -1, sync_stream_idx;
186 if (sync = strchr(map,
',')) {
188 sync_file_idx = strtol(sync + 1, &sync, 0);
197 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
203 "match any streams.\n", arg);
211 const char *c = map + 1;
220 file_idx = strtol(map, &p, 0);
232 *p ==
':' ? p + 1 : p) > 0)
238 *p ==
':' ? p + 1 : p) <= 0)
246 if (sync_file_idx >= 0) {
265 static int opt_attach(
void *optctx,
const char *opt,
const char *arg)
288 if (*(++arg) && *arg !=
':') {
292 *stream_spec = *arg ==
':' ? arg + 1 :
"";
297 *index = strtol(++arg,
NULL, 0);
312 char type_in, type_out;
313 const char *istream_spec =
NULL, *ostream_spec =
NULL;
314 int idx_in = 0, idx_out = 0;
319 if (type_in ==
'g' || type_out ==
'g')
321 if (type_in ==
's' || type_out ==
's')
323 if (type_in ==
'c' || type_out ==
'c')
330 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
331 if ((index) < 0 || (index) >= (nb_elems)) {\
332 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
337 #define SET_DICT(type, meta, context, index)\
340 meta = &context->metadata;\
343 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
344 meta = &context->chapters[index]->metadata;\
347 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
348 meta = &context->programs[index]->metadata;\
352 default: av_assert0(0);\
355 SET_DICT(type_in, meta_in, ic, idx_in);
356 SET_DICT(type_out, meta_out, oc, idx_out);
359 if (type_in ==
's') {
373 if (type_out ==
's') {
390 const char *codec_string = encoder ?
"encoder" :
"decoder";
402 codec_string, codec->
name, desc->
name);
409 if (codec->
type != type) {
418 char *codec_name =
NULL;
439 char *framerate =
NULL;
496 (strchr(filename,
':') ==
NULL || filename[1] ==
':' ||
500 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
503 fprintf(stderr,
"Not overwriting - exiting\n");
508 fprintf(stderr,
"File '%s' already exists. Exiting.\n", filename);
564 if (!strcmp(filename,
"-"))
568 !strcmp(filename,
"/dev/stdin");
584 if (file_iformat && file_iformat->
priv_class &&
587 snprintf(buf,
sizeof(buf),
"%d",
595 if (file_iformat && file_iformat->
priv_class &&
677 for (i = 0; i < orig_nb_streams; i++)
695 while ((c =
avio_r8(s)) && c !=
'\n')
707 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
716 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
717 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
721 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
722 i != 1 ?
"" :
"/.avconv", preset_name);
731 char *codec_name =
NULL;
738 }
else if (!strcmp(codec_name,
"copy"))
751 char *bsf =
NULL, *next, *codec_tag =
NULL;
783 if (!buf[0] || buf[0] ==
'#') {
787 if (!(arg = strchr(buf,
'='))) {
799 "Preset %s specified for stream %d:%d, but could not be opened.\n",
813 if (next = strchr(bsf,
','))
820 bsfc_prev->
next = bsfc;
830 uint32_t
tag = strtol(codec_tag, &next, 0);
877 video_enc = st->
codec;
880 const char *p =
NULL;
882 char *frame_aspect_ratio =
NULL, *frame_pix_fmt =
NULL;
883 char *intra_matrix =
NULL, *inter_matrix =
NULL;
884 const char *filters =
"null";
901 if (frame_aspect_ratio)
929 for (i = 0; p; i++) {
931 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
997 audio_enc = st->
codec;
1002 const char *filters =
"anull";
1050 subtitle_enc = st->
codec;
1066 p = strchr(idx_str,
':');
1069 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1100 if (in_ch->
end < ts_off)
1102 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1109 out_ch->id = in_ch->
id;
1111 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1112 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1144 "which is fed from a complex filtergraph. Filtering and streamcopy "
1180 if (!strcmp(filename,
"-"))
1191 if (!file_oformat) {
1197 if (!file_oformat) {
1229 #define NEW_STREAM(type, index)\
1231 ost = new_ ## type ## _stream(o, oc);\
1232 ost->source_index = index;\
1233 ost->sync_ist = input_streams[index];\
1234 input_streams[index]->discard = 0;\
1235 input_streams[index]->st->discard = AVDISCARD_NONE;\
1240 int area = 0, idx = -1;
1254 int channels = 0, idx = -1;
1300 "in any defined filter graph.\n", map->
linklabel);
1412 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1416 in_file_index >= 0 ?
1457 const char *stream_spec;
1458 int index = 0, j, ret;
1500 static int opt_target(
void *optctx,
const char *opt,
const char *arg)
1504 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
1506 if (!strncmp(arg,
"pal-", 4)) {
1509 }
else if (!strncmp(arg,
"ntsc-", 5)) {
1512 }
else if (!strncmp(arg,
"film-", 5)) {
1528 }
else if ((fr == 29970) || (fr == 23976)) {
1548 if (!strcmp(arg,
"vcd")) {
1575 }
else if (!strcmp(arg,
"svcd")) {
1597 }
else if (!strcmp(arg,
"dvd")) {
1618 }
else if (!strncmp(arg,
"dv", 2)) {
1623 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
1624 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
1644 static int opt_vstats(
void *optctx,
const char *opt,
const char *arg)
1647 time_t today2 = time(
NULL);
1648 struct tm *today = localtime(&today2);
1650 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
1703 static int opt_vsync(
void *optctx,
const char *opt,
const char *arg)
1735 char layout_str[32];
1738 int ret, channels, ac_str_size;
1746 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
1753 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
1754 stream_str = strchr(opt,
':');
1755 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
1788 int show_advanced = 0, show_avoptions = 0;
1791 if (!strcmp(opt,
"long"))
1793 else if (!strcmp(opt,
"full"))
1794 show_advanced = show_avoptions = 1;
1801 printf(
"Getting help:\n"
1802 " -h -- print basic options\n"
1803 " -h long -- print more options\n"
1804 " -h full -- print all options (including all format and codec specific options, very long)\n"
1805 " See man %s for detailed description of the options.\n"
1812 "instead of just one file:",
1840 if (show_avoptions) {
1850 printf(
"Hyper fast Audio and Video encoder\n");
1851 printf(
"usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n",
program_name);
1880 "%s.\n", inout, g->
arg);
1885 ret = open_file(&o, g->
arg);
1904 memset(&octx, 0,
sizeof(octx));
1944 #define OFFSET(x) offsetof(OptionsContext, x)
1949 "force format",
"fmt" },
1951 "overwrite output files" },
1953 "codec name",
"codec" },
1955 "codec name",
"codec" },
1957 "preset name",
"preset" },
1959 "set input stream mapping",
1960 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
1962 "set metadata information of outfile from infile",
1963 "outfile[,metadata]:infile[,metadata]" },
1965 "set chapters mapping",
"input_file_index" },
1967 "record or transcode \"duration\" seconds of audio/video",
1970 "set the limit file size in bytes",
"limit_size" },
1972 "set the start time offset",
"time_off" },
1974 "set the input ts offset",
"time_off" },
1976 "set the input ts scale",
"scale" },
1978 "add metadata",
"string=string" },
1980 "set the number of data frames to record",
"number" },
1982 "add timings for benchmarking" },
1984 "set max runtime in seconds",
"limit" },
1986 "dump each input packet" },
1988 "when dumping packets, also dump the payload" },
1990 "read input at native frame rate",
"" },
1992 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
1993 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
1995 "video sync method",
"" },
1997 "audio sync method",
"" },
1999 "audio drift threshold",
"threshold" },
2001 "copy timestamps" },
2003 "copy input stream time base when stream copying" },
2005 "finish encoding within shortest input" },
2007 "timestamp discontinuity delta threshold",
"threshold" },
2009 "exit on error",
"error" },
2011 "copy initial non-keyframes" },
2013 "set the number of frames to record",
"number" },
2015 "force codec tag/fourcc",
"fourcc/tag" },
2017 "use fixed quality scale (VBR)",
"q" },
2019 "use fixed quality scale (VBR)",
"q" },
2021 "set stream filterchain",
"filter_list" },
2023 "create a complex filtergraph",
"graph_description" },
2025 "print progress report during encoding", },
2027 "add an attachment to the output file",
"filename" },
2029 "extract an attachment into a file",
"filename" },
2031 "set CPU flags mask",
"mask" },
2035 "set the number of video frames to record",
"number" },
2037 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2039 "set frame size (WxH or abbreviation)",
"size" },
2041 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2043 "set pixel format",
"format" },
2047 "discard threshold",
"n" },
2049 "rate control override for specific intervals",
"override" },
2051 "force video codec ('copy' to copy stream)",
"codec" },
2053 "select the pass number (1 or 2)",
"n" },
2055 "select two pass log file name prefix",
"prefix" },
2057 "this option is deprecated, use the yadif filter instead" },
2059 "dump video coding statistics to file" },
2061 "dump video coding statistics to file",
"file" },
2063 "video filters",
"filter list" },
2065 "specify intra matrix coeffs",
"matrix" },
2067 "specify inter matrix coeffs",
"matrix" },
2069 "top=1/bottom=0/auto=-1 field first",
"" },
2071 "intra_dc_precision",
"precision" },
2073 "force video tag/fourcc",
"fourcc/tag" },
2075 "show QP histogram" },
2077 "force the selected framerate, disable the best supported framerate selection" },
2079 "set the value of an outfile streamid",
"streamIndex:value" },
2081 { .off =
OFFSET(forced_key_frames) },
"force key frames at specified timestamps",
"timestamps" },
2085 "set the number of audio frames to record",
"number" },
2087 "set audio quality (codec-specific)",
"quality", },
2089 "set audio sampling rate (in Hz)",
"rate" },
2091 "set number of audio channels",
"channels" },
2095 "force audio codec ('copy' to copy stream)",
"codec" },
2097 "force audio tag/fourcc",
"fourcc/tag" },
2099 "change audio volume (256=normal)" ,
"volume" },
2101 "set sample format",
"format" },
2103 "set channel layout",
"layout" },
2105 "audio filters",
"filter list" },
2109 "disable subtitle" },
2111 "force subtitle codec ('copy' to copy stream)",
"codec" },
2113 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2120 "set the maximum demux-decode delay",
"seconds" },
2122 "set the initial demux-decode delay",
"seconds" },
2125 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2129 "force data codec ('copy' to copy stream)",
"codec" },