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;\
57 #define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
60 for (i = 0; i < o->nb_ ## name; i++) {\
61 char *spec = o->name[i].specifier;\
62 if (!strcmp(spec, mediatype))\
63 outvar = o->name[i].u.type;\
111 int i, *count = (
int*)(so + 1);
112 for (i = 0; i < *count; i++) {
138 memset(o, 0,
sizeof(*o));
143 "-t is not an input option, keeping it for the next output;"
144 " consider fixing your command line.\n");
158 static int opt_pad(
void *optctx,
const char *opt,
const char *
arg)
167 "If you are looking for an option to preserve the quality (which is not "
168 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
209 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
213 int i, negative = 0, file_idx;
214 int sync_file_idx = -1, sync_stream_idx = 0;
225 if (sync = strchr(map,
',')) {
227 sync_file_idx = strtol(sync + 1, &sync, 0);
236 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
242 "match any streams.\n", arg);
250 const char *
c = map + 1;
259 file_idx = strtol(map, &p, 0);
271 *p ==
':' ? p + 1 : p) > 0)
277 *p ==
':' ? p + 1 : p) <= 0)
285 if (sync_file_idx >= 0) {
332 n = sscanf(arg,
"%d.%d.%d:%d.%d",
336 if (n != 3 && n != 5) {
338 "[file.stream.channel|-1][:syncfile:syncstream]\n");
386 if (*(++arg) && *arg !=
':') {
390 *stream_spec = *arg ==
':' ? arg + 1 :
"";
395 *index = strtol(++arg,
NULL, 0);
410 char type_in, type_out;
411 const char *istream_spec =
NULL, *ostream_spec =
NULL;
412 int idx_in = 0, idx_out = 0;
418 if (type_out ==
'g' || !*outspec)
420 if (type_out ==
's' || !*outspec)
422 if (type_out ==
'c' || !*outspec)
427 if (type_in ==
'g' || type_out ==
'g')
429 if (type_in ==
's' || type_out ==
's')
431 if (type_in ==
'c' || type_out ==
'c')
438 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
439 if ((index) < 0 || (index) >= (nb_elems)) {\
440 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
445 #define SET_DICT(type, meta, context, index)\
448 meta = &context->metadata;\
451 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
452 meta = &context->chapters[index]->metadata;\
455 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
456 meta = &context->programs[index]->metadata;\
460 default: av_assert0(0);\
463 SET_DICT(type_in, meta_in, ic, idx_in);
464 SET_DICT(type_out, meta_out, oc, idx_out);
467 if (type_in ==
's') {
481 if (type_out ==
's') {
500 struct tm time = *gmtime((time_t*)&recording_timestamp);
501 strftime(buf,
sizeof(buf),
"creation_time=%FT%T%z", &time);
505 "tag instead.\n", opt);
512 const char *codec_string = encoder ?
"encoder" :
"decoder";
524 codec_string, codec->
name, desc->
name);
531 if (codec->
type != type) {
540 char *codec_name =
NULL;
556 char *next, *codec_tag =
NULL;
562 char *framerate =
NULL;
580 uint32_t
tag = strtol(codec_tag, &next, 0);
645 (strchr(filename,
':') ==
NULL || filename[1] ==
':' ||
649 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
652 signal(SIGINT, SIG_DFL);
719 if (!strcmp(filename,
"-"))
723 strcmp(filename,
"/dev/stdin");
739 if (file_iformat && file_iformat->
priv_class &&
750 if (file_iformat && file_iformat->
priv_class &&
842 for (i = 0; i < orig_nb_streams; i++)
860 while ((c =
avio_r8(s)) && c !=
'\n')
872 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
881 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
882 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
886 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
887 i != 1 ?
"" :
"/.avconv", preset_name);
896 char *codec_name =
NULL;
903 }
else if (!strcmp(codec_name,
"copy"))
916 char *bsf =
NULL, *next, *codec_tag =
NULL;
948 if (!buf[0] || buf[0] ==
'#') {
952 if (!(arg = strchr(buf,
'='))) {
964 "Preset %s specified for stream %d:%d, but could not be opened.\n",
981 if (next = strchr(bsf,
','))
988 bsfc_prev->
next = bsfc;
998 uint32_t
tag = strtol(codec_tag, &next, 0);
1019 if (source_index >= 0) {
1031 const char *p = str;
1050 char *frame_rate =
NULL;
1054 video_enc = st->
codec;
1063 const char *p =
NULL;
1065 char *frame_aspect_ratio =
NULL, *frame_pix_fmt =
NULL;
1066 char *intra_matrix =
NULL, *inter_matrix =
NULL;
1078 if (frame_aspect_ratio) {
1081 q.
num <= 0 || q.
den <= 0) {
1090 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1092 if (!*++frame_pix_fmt)
1093 frame_pix_fmt =
NULL;
1121 for (i = 0; p; i++) {
1123 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1197 audio_enc = st->
codec;
1201 char *sample_fmt =
NULL;
1202 const char *
filters =
"anull";
1267 subtitle_enc = st->
codec;
1295 p = strchr(idx_str,
':');
1298 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1329 if (in_ch->
end < ts_off)
1331 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1338 out_ch->id = in_ch->
id;
1340 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1341 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1416 "which is fed from a complex filtergraph. Filtering and streamcopy "
1452 if (!strcmp(filename,
"-"))
1482 if (!strcmp(file_oformat->
name,
"ffm") &&
1517 int area = 0, idx = -1;
1539 int channels = 0, idx = -1;
1588 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
1713 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1717 in_file_index >= 0 ?
1762 const char *stream_spec;
1763 int index = 0, j, ret = 0;
1809 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
1811 if (!strncmp(arg,
"pal-", 4)) {
1814 }
else if (!strncmp(arg,
"ntsc-", 5)) {
1817 }
else if (!strncmp(arg,
"film-", 5)) {
1833 }
else if ((fr == 29970) || (fr == 23976)) {
1853 if (!strcmp(arg,
"vcd")) {
1881 }
else if (!strcmp(arg,
"svcd")) {
1903 }
else if (!strcmp(arg,
"dvd")) {
1925 }
else if (!strncmp(arg,
"dv", 2)) {
1930 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
1931 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
1954 time_t today2 = time(
NULL);
1955 struct tm *today = localtime(&today2);
1957 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2004 char filename[1000],
line[1000], tmp_line[1000];
2005 const char *codec_name =
NULL;
2011 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2012 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2019 while (fgets(line,
sizeof(line), f)) {
2020 char *key = tmp_line, *
value, *endptr;
2022 if (strcspn(line,
"#\n\r") == 0)
2024 strcpy(tmp_line, line);
2038 filename, line, key, value);
2060 if(!strcmp(opt,
"b")){
2074 if(!strcmp(opt,
"qscale")){
2087 if(!strcmp(opt,
"profile")){
2141 char layout_str[32];
2144 int ret, channels, ac_str_size;
2152 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2159 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2160 stream_str = strchr(opt,
':');
2161 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2194 int show_advanced = 0, show_avoptions = 0;
2197 if (!strcmp(opt,
"long"))
2199 else if (!strcmp(opt,
"full"))
2200 show_advanced = show_avoptions = 1;
2207 printf(
"Getting help:\n"
2208 " -h -- print basic options\n"
2209 " -h long -- print more options\n"
2210 " -h full -- print all options (including all format and codec specific options, very long)\n"
2211 " See man %s for detailed description of the options.\n"
2218 "instead of just one file:",
2246 if (show_avoptions) {
2288 "%s.\n", inout, g->
arg);
2312 memset(&octx, 0,
sizeof(octx));
2357 if (!strcmp(arg,
"-"))
2369 #define OFFSET(x) offsetof(OptionsContext, x)
2374 "force format",
"fmt" },
2376 "overwrite output files" },
2378 "do not overwrite output files" },
2380 "codec name",
"codec" },
2382 "codec name",
"codec" },
2384 "preset name",
"preset" },
2386 "set input stream mapping",
2387 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2389 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2391 "set metadata information of outfile from infile",
2392 "outfile[,metadata]:infile[,metadata]" },
2394 "set chapters mapping",
"input_file_index" },
2396 "record or transcode \"duration\" seconds of audio/video",
2399 "set the limit file size in bytes",
"limit_size" },
2401 "set the start time offset",
"time_off" },
2403 "set the input ts offset",
"time_off" },
2405 "set the input ts scale",
"scale" },
2407 "set the recording timestamp ('now' to set the current time)",
"time" },
2409 "add metadata",
"string=string" },
2411 "set the number of data frames to record",
"number" },
2413 "add timings for benchmarking" },
2415 "add timings for each task" },
2417 "write program-readable progress information",
"url" },
2419 "enable or disable interaction on standard input" },
2421 "set max runtime in seconds",
"limit" },
2423 "dump each input packet" },
2425 "when dumping packets, also dump the payload" },
2427 "read input at native frame rate",
"" },
2429 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2430 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2432 "video sync method",
"" },
2434 "audio sync method",
"" },
2436 "audio drift threshold",
"threshold" },
2438 "copy timestamps" },
2440 "copy input stream time base when stream copying",
"mode" },
2442 "finish encoding within shortest input" },
2444 "timestamp discontinuity delta threshold",
"threshold" },
2446 "timestamp error delta threshold",
"threshold" },
2448 "exit on error",
"error" },
2450 "copy initial non-keyframes" },
2452 "copy or discard frames before start time" },
2454 "set the number of frames to record",
"number" },
2456 "force codec tag/fourcc",
"fourcc/tag" },
2458 "use fixed quality scale (VBR)",
"q" },
2460 "use fixed quality scale (VBR)",
"q" },
2462 "set profile",
"profile" },
2464 "set stream filterchain",
"filter_list" },
2466 "reinit filtergraph on input parameter changes",
"" },
2468 "create a complex filtergraph",
"graph_description" },
2470 "print progress report during encoding", },
2472 "add an attachment to the output file",
"filename" },
2474 "extract an attachment into a file",
"filename" },
2476 "print timestamp debugging info" },
2480 "set the number of video frames to record",
"number" },
2482 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2484 "set frame size (WxH or abbreviation)",
"size" },
2486 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2488 "set pixel format",
"format" },
2490 "set the number of bits per raw sample",
"number" },
2492 "Removed, use the crop filter instead",
"size" },
2494 "Removed, use the crop filter instead",
"size" },
2496 "Removed, use the crop filter instead",
"size" },
2498 "Removed, use the crop filter instead",
"size" },
2500 "Removed, use the pad filter instead",
"size" },
2502 "Removed, use the pad filter instead",
"size" },
2504 "Removed, use the pad filter instead",
"size" },
2506 "Removed, use the pad filter instead",
"size" },
2508 "Removed, use the pad filter instead",
"color" },
2510 "deprecated use -g 1" },
2514 "discard threshold",
"n" },
2516 "rate control override for specific intervals",
"override" },
2518 "force video codec ('copy' to copy stream)",
"codec" },
2524 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2526 "select the pass number (1 to 3)",
"n" },
2528 "select two pass log file name prefix",
"prefix" },
2530 "this option is deprecated, use the yadif filter instead" },
2532 "calculate PSNR of compressed frames" },
2534 "dump video coding statistics to file" },
2536 "dump video coding statistics to file",
"file" },
2538 "video filters",
"filter list" },
2540 "specify intra matrix coeffs",
"matrix" },
2542 "specify inter matrix coeffs",
"matrix" },
2544 "top=1/bottom=0/auto=-1 field first",
"" },
2546 "intra_dc_precision",
"precision" },
2548 "force video tag/fourcc",
"fourcc/tag" },
2550 "show QP histogram" },
2552 "force the selected framerate, disable the best supported framerate selection" },
2554 "set the value of an outfile streamid",
"streamIndex:value" },
2556 { .off =
OFFSET(forced_key_frames) },
2557 "force key frames at specified timestamps",
"timestamps" },
2559 "video bitrate (please use -b:v)",
"bitrate" },
2563 "set the number of audio frames to record",
"number" },
2565 "set audio quality (codec-specific)",
"quality", },
2567 "set audio sampling rate (in Hz)",
"rate" },
2569 "set number of audio channels",
"channels" },
2573 "force audio codec ('copy' to copy stream)",
"codec" },
2575 "force audio tag/fourcc",
"fourcc/tag" },
2577 "change audio volume (256=normal)" ,
"volume" },
2579 "set sample format",
"format" },
2581 "set channel layout",
"layout" },
2583 "audio filters",
"filter list" },
2587 "disable subtitle" },
2589 "force subtitle codec ('copy' to copy stream)",
"codec" },
2591 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2593 "fix subtitles duration" },
2597 "deprecated, use -channel",
"channel" },
2599 "deprecated, use -standard",
"standard" },
2604 "set the maximum demux-decode delay",
"seconds" },
2606 "set the initial demux-decode delay",
"seconds" },
2609 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2611 "deprecated",
"audio bitstream_filters" },
2613 "deprecated",
"video bitstream_filters" },
2616 "set the audio options to the indicated preset",
"preset" },
2618 "set the video options to the indicated preset",
"preset" },
2620 "set the subtitle options to the indicated preset",
"preset" },
2622 "set options from indicated preset file",
"filename" },
2625 "force data codec ('copy' to copy stream)",
"codec" },