44 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
47 for (i = 0; i < o->nb_ ## name; i++) {\
48 char *spec = o->name[i].specifier;\
49 if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0)\
50 outvar = o->name[i].u.type;\
98 int i, *count = (
int*)(so + 1);
99 for (i = 0; i < *count; i++) {
120 memset(o, 0,
sizeof(*o));
137 char *p = strchr(e->
key,
':');
155 p = strchr(arg,
':');
157 x = strtol(arg, &end, 10);
159 y = strtol(end + 1, &end, 10);
161 ar = (double)x / (
double)y;
196 static int opt_map(
void *optctx,
const char *opt,
const char *arg)
200 int i, negative = 0, file_idx;
201 int sync_file_idx = -1, sync_stream_idx;
212 if (sync = strchr(map,
',')) {
214 sync_file_idx = strtol(sync + 1, &sync, 0);
223 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
229 "match any streams.\n", arg);
237 const char *c = map + 1;
246 file_idx = strtol(map, &p, 0);
258 *p ==
':' ? p + 1 : p) > 0)
264 *p ==
':' ? p + 1 : p) <= 0)
272 if (sync_file_idx >= 0) {
291 static int opt_attach(
void *optctx,
const char *opt,
const char *arg)
314 if (*(++arg) && *arg !=
':') {
318 *stream_spec = *arg ==
':' ? arg + 1 :
"";
323 *index = strtol(++arg,
NULL, 0);
338 char type_in, type_out;
339 const char *istream_spec =
NULL, *ostream_spec =
NULL;
340 int idx_in = 0, idx_out = 0;
345 if (type_in ==
'g' || type_out ==
'g')
347 if (type_in ==
's' || type_out ==
's')
349 if (type_in ==
'c' || type_out ==
'c')
356 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
357 if ((index) < 0 || (index) >= (nb_elems)) {\
358 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
363 #define SET_DICT(type, meta, context, index)\
366 meta = &context->metadata;\
369 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
370 meta = &context->chapters[index]->metadata;\
373 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
374 meta = &context->programs[index]->metadata;\
378 default: av_assert0(0);\
381 SET_DICT(type_in, meta_in, ic, idx_in);
382 SET_DICT(type_out, meta_out, oc, idx_out);
385 if (type_in ==
's') {
399 if (type_out ==
's') {
416 const char *codec_string = encoder ?
"encoder" :
"decoder";
428 codec_string, codec->
name, desc->
name);
435 if (codec->
type != type) {
444 char *codec_name =
NULL;
465 char *framerate =
NULL, *hwaccel =
NULL, *hwaccel_device =
NULL;
500 if (!strcmp(hwaccel,
"none"))
502 else if (!strcmp(hwaccel,
"auto"))
506 for (i = 0; hwaccels[i].
name; i++) {
507 if (!strcmp(hwaccels[i].
name, hwaccel)) {
517 for (i = 0; hwaccels[i].
name; i++)
526 if (hwaccel_device) {
557 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
562 (strchr(filename,
':') ==
NULL || filename[1] ==
':' ||
566 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
569 fprintf(stderr,
"Not overwriting - exiting\n");
574 fprintf(stderr,
"File '%s' already exists. Exiting.\n", filename);
633 if (!strcmp(filename,
"-"))
637 !strcmp(filename,
"/dev/stdin");
653 if (file_iformat && file_iformat->
priv_class &&
656 snprintf(buf,
sizeof(buf),
"%d",
664 if (file_iformat && file_iformat->
priv_class &&
758 "input file #%d (%s) is not a decoding option.\n", e->
key,
765 "input file #%d (%s) has not been used for any stream. The most "
766 "likely reason is either wrong type (e.g. a video option with "
767 "no video streams) or that it is a private option of some decoder "
768 "which was not actually used for any stream.\n", e->
key,
784 for (i = 0; i < orig_nb_streams; i++)
802 while ((c =
avio_r8(s)) && c !=
'\n')
814 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
823 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
824 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
828 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
829 i != 1 ?
"" :
"/.avconv", preset_name);
838 char *codec_name =
NULL;
845 }
else if (!strcmp(codec_name,
"copy"))
858 char *bsf =
NULL, *next, *codec_tag =
NULL;
890 if (!buf[0] || buf[0] ==
'#') {
894 if (!(arg = strchr(buf,
'='))) {
906 "Preset %s specified for stream %d:%d, but could not be opened.\n",
922 if (next = strchr(bsf,
','))
929 bsfc_prev->
next = bsfc;
939 uint32_t
tag = strtol(codec_tag, &next, 0);
999 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1019 if (filter_script && filter) {
1039 char *frame_aspect_ratio =
NULL;
1043 video_enc = st->
codec;
1046 if (frame_aspect_ratio)
1050 const char *p =
NULL;
1052 char *frame_pix_fmt =
NULL;
1053 char *intra_matrix =
NULL, *inter_matrix =
NULL;
1094 for (i = 0; p; i++) {
1096 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1164 audio_enc = st->
codec;
1218 subtitle_enc = st->
codec;
1234 p = strchr(idx_str,
':');
1237 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1269 if (in_ch->
end < ts_off)
1271 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1278 out_ch->id = in_ch->
id;
1280 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1281 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1313 "which is fed from a complex filtergraph. Filtering and streamcopy "
1365 if (!strcmp(filename,
"-"))
1379 if (!file_oformat) {
1385 if (!file_oformat) {
1417 #define NEW_STREAM(type, index)\
1419 ost = new_ ## type ## _stream(o, oc);\
1420 ost->source_index = index;\
1421 ost->sync_ist = input_streams[index];\
1422 input_streams[index]->discard = 0;\
1423 input_streams[index]->st->discard = AVDISCARD_NONE;\
1428 int area = 0, idx = -1;
1442 int channels = 0, idx = -1;
1488 "in any defined filter graph.\n", map->
linklabel);
1569 "output file #%d (%s) is not an encoding option.\n", e->
key,
1576 "output file #%d (%s) has not been used for any stream. The most "
1577 "likely reason is either wrong type (e.g. a video option with "
1578 "no video streams) or that it is a private option of some encoder "
1579 "which was not actually used for any stream.\n", e->
key,
1619 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1623 in_file_index >= 0 ?
1664 const char *stream_spec;
1665 int index = 0, j, ret;
1707 static int opt_target(
void *optctx,
const char *opt,
const char *arg)
1711 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
1713 if (!strncmp(arg,
"pal-", 4)) {
1716 }
else if (!strncmp(arg,
"ntsc-", 5)) {
1719 }
else if (!strncmp(arg,
"film-", 5)) {
1736 }
else if ((fr == 29970) || (fr == 23976)) {
1756 if (!strcmp(arg,
"vcd")) {
1783 }
else if (!strcmp(arg,
"svcd")) {
1805 }
else if (!strcmp(arg,
"dvd")) {
1826 }
else if (!strncmp(arg,
"dv", 2)) {
1831 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
1832 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
1856 static int opt_vstats(
void *optctx,
const char *opt,
const char *arg)
1859 time_t today2 = time(
NULL);
1860 struct tm *today = localtime(&today2);
1862 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
1915 static int opt_vsync(
void *optctx,
const char *opt,
const char *arg)
1929 char layout_str[32];
1932 int ret, channels, ac_str_size;
1940 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
1947 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
1948 stream_str = strchr(opt,
':');
1949 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
1998 int show_advanced = 0, show_avoptions = 0;
2001 if (!strcmp(opt,
"long"))
2003 else if (!strcmp(opt,
"full"))
2004 show_advanced = show_avoptions = 1;
2011 printf(
"Getting help:\n"
2012 " -h -- print basic options\n"
2013 " -h long -- print more options\n"
2014 " -h full -- print all options (including all format and codec specific options, very long)\n"
2015 " See man %s for detailed description of the options.\n"
2022 "instead of just one file:",
2050 if (show_avoptions) {
2061 printf(
"Hyper fast Audio and Video encoder\n");
2062 printf(
"usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n",
program_name);
2091 "%s.\n", inout, g->
arg);
2096 ret = open_file(&o, g->
arg);
2115 memset(&octx, 0,
sizeof(octx));
2155 #define OFFSET(x) offsetof(OptionsContext, x)
2161 "force format",
"fmt" },
2163 "overwrite output files" },
2165 "never overwrite output files" },
2168 "codec name",
"codec" },
2171 "codec name",
"codec" },
2174 "preset name",
"preset" },
2177 "set input stream mapping",
2178 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2181 "set metadata information of outfile from infile",
2182 "outfile[,metadata]:infile[,metadata]" },
2185 "set chapters mapping",
"input_file_index" },
2188 "record or transcode \"duration\" seconds of audio/video",
2191 "set the limit file size in bytes",
"limit_size" },
2194 "set the start time offset",
"time_off" },
2197 "enable/disable accurate seeking with -ss" },
2200 "set the input ts offset",
"time_off" },
2203 "set the input ts scale",
"scale" },
2205 "add metadata",
"string=string" },
2208 "set the number of data frames to record",
"number" },
2210 "add timings for benchmarking" },
2212 "set max runtime in seconds",
"limit" },
2214 "dump each input packet" },
2216 "when dumping packets, also dump the payload" },
2219 "read input at native frame rate",
"" },
2221 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2222 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2224 "video sync method",
"" },
2226 "audio sync method",
"" },
2228 "audio drift threshold",
"threshold" },
2230 "copy timestamps" },
2232 "copy input stream time base when stream copying" },
2235 "finish encoding within shortest input" },
2237 "timestamp discontinuity delta threshold",
"threshold" },
2239 "exit on error",
"error" },
2242 "copy initial non-keyframes" },
2244 "set the number of frames to record",
"number" },
2247 "force codec tag/fourcc",
"fourcc/tag" },
2250 "use fixed quality scale (VBR)",
"q" },
2253 "use fixed quality scale (VBR)",
"q" },
2255 "set stream filterchain",
"filter_list" },
2257 "read stream filtergraph description from a file",
"filename" },
2259 "create a complex filtergraph",
"graph_description" },
2261 "read complex filtergraph description from a file",
"filename" },
2263 "print progress report during encoding", },
2266 "add an attachment to the output file",
"filename" },
2269 "extract an attachment into a file",
"filename" },
2273 "set the number of video frames to record",
"number" },
2276 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2279 "set frame size (WxH or abbreviation)",
"size" },
2282 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2285 "set pixel format",
"format" },
2289 "discard threshold",
"n" },
2292 "rate control override for specific intervals",
"override" },
2295 "force video codec ('copy' to copy stream)",
"codec" },
2297 "select the pass number (1 or 2)",
"n" },
2300 "select two pass log file name prefix",
"prefix" },
2302 "dump video coding statistics to file" },
2304 "dump video coding statistics to file",
"file" },
2306 "video filters",
"filter list" },
2309 "specify intra matrix coeffs",
"matrix" },
2312 "specify inter matrix coeffs",
"matrix" },
2315 "top=1/bottom=0/auto=-1 field first",
"" },
2317 "intra_dc_precision",
"precision" },
2320 "force video tag/fourcc",
"fourcc/tag" },
2322 "show QP histogram" },
2325 "force the selected framerate, disable the best supported framerate selection" },
2328 "set the value of an outfile streamid",
"streamIndex:value" },
2331 "force key frames at specified timestamps",
"timestamps" },
2334 "use HW accelerated decoding",
"hwaccel name" },
2337 "select a device for HW acceleration" "devicename" },
2341 "set the number of audio frames to record",
"number" },
2343 "set audio quality (codec-specific)",
"quality", },
2346 "set audio sampling rate (in Hz)",
"rate" },
2349 "set number of audio channels",
"channels" },
2354 "force audio codec ('copy' to copy stream)",
"codec" },
2357 "force audio tag/fourcc",
"fourcc/tag" },
2359 "change audio volume (256=normal)" ,
"volume" },
2362 "set sample format",
"format" },
2365 "set channel layout",
"layout" },
2367 "audio filters",
"filter list" },
2371 "disable subtitle" },
2373 "force subtitle codec ('copy' to copy stream)",
"codec" },
2375 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2382 "set the maximum demux-decode delay",
"seconds" },
2384 "set the initial demux-decode delay",
"seconds" },
2387 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2391 "force data codec ('copy' to copy stream)",
"codec" },