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++) {
139 memset(o, 0,
sizeof(*o));
144 "-t is not an input option, keeping it for the next output;"
145 " consider fixing your command line.\n");
157 "If you are looking for an option to preserve the quality (which is not "
158 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
199 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
203 int i, negative = 0, file_idx;
204 int sync_file_idx = -1, sync_stream_idx = 0;
215 if (sync = strchr(map,
',')) {
217 sync_file_idx = strtol(sync + 1, &sync, 0);
226 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
232 "match any streams.\n", arg);
240 const char *
c = map + 1;
249 file_idx = strtol(map, &p, 0);
261 *p ==
':' ? p + 1 : p) > 0)
267 *p ==
':' ? p + 1 : p) <= 0)
275 if (sync_file_idx >= 0) {
322 n = sscanf(arg,
"%d.%d.%d:%d.%d",
326 if (n != 3 && n != 5) {
328 "[file.stream.channel|-1][:syncfile:syncstream]\n");
376 if (*(++arg) && *arg !=
':') {
380 *stream_spec = *arg ==
':' ? arg + 1 :
"";
385 *index = strtol(++arg,
NULL, 0);
400 char type_in, type_out;
401 const char *istream_spec =
NULL, *ostream_spec =
NULL;
402 int idx_in = 0, idx_out = 0;
408 if (type_out ==
'g' || !*outspec)
410 if (type_out ==
's' || !*outspec)
412 if (type_out ==
'c' || !*outspec)
417 if (type_in ==
'g' || type_out ==
'g')
419 if (type_in ==
's' || type_out ==
's')
421 if (type_in ==
'c' || type_out ==
'c')
428 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
429 if ((index) < 0 || (index) >= (nb_elems)) {\
430 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
435 #define SET_DICT(type, meta, context, index)\
438 meta = &context->metadata;\
441 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
442 meta = &context->chapters[index]->metadata;\
445 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
446 meta = &context->programs[index]->metadata;\
450 default: av_assert0(0);\
453 SET_DICT(type_in, meta_in, ic, idx_in);
454 SET_DICT(type_out, meta_out, oc, idx_out);
457 if (type_in ==
's') {
471 if (type_out ==
's') {
490 struct tm time = *gmtime((time_t*)&recording_timestamp);
491 strftime(buf,
sizeof(buf),
"creation_time=%FT%T%z", &time);
495 "tag instead.\n", opt);
502 const char *codec_string = encoder ?
"encoder" :
"decoder";
514 codec_string, codec->
name, desc->
name);
521 if (codec->
type != type) {
530 char *codec_name =
NULL;
546 char *next, *codec_tag =
NULL;
552 char *framerate =
NULL;
570 uint32_t
tag = strtol(codec_tag, &next, 0);
637 (strchr(filename,
':') ==
NULL || filename[1] ==
':' ||
641 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
644 signal(SIGINT, SIG_DFL);
711 if (!strcmp(filename,
"-"))
715 strcmp(filename,
"/dev/stdin");
731 if (file_iformat && file_iformat->
priv_class &&
742 if (file_iformat && file_iformat->
priv_class &&
834 for (i = 0; i < orig_nb_streams; i++)
852 while ((c =
avio_r8(s)) && c !=
'\n')
864 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
873 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
874 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
878 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
879 i != 1 ?
"" :
"/.avconv", preset_name);
888 char *codec_name =
NULL;
895 }
else if (!strcmp(codec_name,
"copy"))
908 char *bsf =
NULL, *next, *codec_tag =
NULL;
940 if (!buf[0] || buf[0] ==
'#') {
944 if (!(arg = strchr(buf,
'='))) {
956 "Preset %s specified for stream %d:%d, but could not be opened.\n",
975 if (next = strchr(bsf,
','))
982 bsfc_prev->
next = bsfc;
992 uint32_t
tag = strtol(codec_tag, &next, 0);
1016 if (source_index >= 0) {
1028 const char *p = str;
1047 char *frame_rate =
NULL;
1051 video_enc = st->
codec;
1060 const char *p =
NULL;
1062 char *frame_aspect_ratio =
NULL, *frame_pix_fmt =
NULL;
1063 char *intra_matrix =
NULL, *inter_matrix =
NULL;
1075 if (frame_aspect_ratio) {
1078 q.
num <= 0 || q.
den <= 0) {
1087 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1089 if (!*++frame_pix_fmt)
1090 frame_pix_fmt =
NULL;
1118 for (i = 0; p; i++) {
1120 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1194 audio_enc = st->
codec;
1198 char *sample_fmt =
NULL;
1199 const char *
filters =
"anull";
1264 subtitle_enc = st->
codec;
1292 p = strchr(idx_str,
':');
1295 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1326 if (in_ch->
end < ts_off)
1328 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1335 out_ch->id = in_ch->
id;
1337 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1338 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1413 "which is fed from a complex filtergraph. Filtering and streamcopy "
1449 if (!strcmp(filename,
"-"))
1479 if (!strcmp(file_oformat->
name,
"ffm") &&
1514 int area = 0, idx = -1;
1536 int channels = 0, idx = -1;
1585 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
1725 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1729 in_file_index >= 0 ?
1774 const char *stream_spec;
1775 int index = 0, j, ret = 0;
1821 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
1823 if (!strncmp(arg,
"pal-", 4)) {
1826 }
else if (!strncmp(arg,
"ntsc-", 5)) {
1829 }
else if (!strncmp(arg,
"film-", 5)) {
1845 }
else if ((fr == 29970) || (fr == 23976)) {
1865 if (!strcmp(arg,
"vcd")) {
1893 }
else if (!strcmp(arg,
"svcd")) {
1915 }
else if (!strcmp(arg,
"dvd")) {
1937 }
else if (!strncmp(arg,
"dv", 2)) {
1942 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
1943 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
1966 time_t today2 = time(
NULL);
1967 struct tm *today = localtime(&today2);
1969 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2016 char filename[1000],
line[1000], tmp_line[1000];
2017 const char *codec_name =
NULL;
2023 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2024 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2031 while (fgets(line,
sizeof(line), f)) {
2032 char *key = tmp_line, *
value, *endptr;
2034 if (strcspn(line,
"#\n\r") == 0)
2036 strcpy(tmp_line, line);
2050 filename, line, key, value);
2072 if(!strcmp(opt,
"b")){
2086 if(!strcmp(opt,
"qscale")){
2099 if(!strcmp(opt,
"profile")){
2132 #if FF_API_DEINTERLACE
2133 static int opt_deinterlace(
void *optctx,
const char *opt,
const char *
arg)
2155 char layout_str[32];
2158 int ret, channels, ac_str_size;
2166 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2173 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2174 stream_str = strchr(opt,
':');
2175 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2208 int show_advanced = 0, show_avoptions = 0;
2211 if (!strcmp(opt,
"long"))
2213 else if (!strcmp(opt,
"full"))
2214 show_advanced = show_avoptions = 1;
2221 printf(
"Getting help:\n"
2222 " -h -- print basic options\n"
2223 " -h long -- print more options\n"
2224 " -h full -- print all options (including all format and codec specific options, very long)\n"
2225 " See man %s for detailed description of the options.\n"
2232 "instead of just one file:",
2260 if (show_avoptions) {
2302 "%s.\n", inout, g->
arg);
2326 memset(&octx, 0,
sizeof(octx));
2371 if (!strcmp(arg,
"-"))
2383 #define OFFSET(x) offsetof(OptionsContext, x)
2388 "force format",
"fmt" },
2390 "overwrite output files" },
2392 "do not overwrite output files" },
2394 "codec name",
"codec" },
2396 "codec name",
"codec" },
2398 "preset name",
"preset" },
2400 "set input stream mapping",
2401 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2403 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2405 "set metadata information of outfile from infile",
2406 "outfile[,metadata]:infile[,metadata]" },
2408 "set chapters mapping",
"input_file_index" },
2410 "record or transcode \"duration\" seconds of audio/video",
2413 "record or transcode stop time",
"time_stop" },
2415 "set the limit file size in bytes",
"limit_size" },
2417 "set the start time offset",
"time_off" },
2419 "set the input ts offset",
"time_off" },
2421 "set the input ts scale",
"scale" },
2423 "set the recording timestamp ('now' to set the current time)",
"time" },
2425 "add metadata",
"string=string" },
2427 "set the number of data frames to record",
"number" },
2429 "add timings for benchmarking" },
2431 "add timings for each task" },
2433 "write program-readable progress information",
"url" },
2435 "enable or disable interaction on standard input" },
2437 "set max runtime in seconds",
"limit" },
2439 "dump each input packet" },
2441 "when dumping packets, also dump the payload" },
2443 "read input at native frame rate",
"" },
2445 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2446 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2448 "video sync method",
"" },
2450 "audio sync method",
"" },
2452 "audio drift threshold",
"threshold" },
2454 "copy timestamps" },
2456 "copy input stream time base when stream copying",
"mode" },
2458 "finish encoding within shortest input" },
2460 "timestamp discontinuity delta threshold",
"threshold" },
2462 "timestamp error delta threshold",
"threshold" },
2464 "exit on error",
"error" },
2466 "copy initial non-keyframes" },
2468 "copy or discard frames before start time" },
2470 "set the number of frames to record",
"number" },
2472 "force codec tag/fourcc",
"fourcc/tag" },
2474 "use fixed quality scale (VBR)",
"q" },
2476 "use fixed quality scale (VBR)",
"q" },
2478 "set profile",
"profile" },
2480 "set stream filtergraph",
"filter_graph" },
2482 "reinit filtergraph on input parameter changes",
"" },
2484 "create a complex filtergraph",
"graph_description" },
2486 "print progress report during encoding", },
2488 "add an attachment to the output file",
"filename" },
2490 "extract an attachment into a file",
"filename" },
2492 "print timestamp debugging info" },
2496 "set the number of video frames to record",
"number" },
2498 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2500 "set frame size (WxH or abbreviation)",
"size" },
2502 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2504 "set pixel format",
"format" },
2506 "set the number of bits per raw sample",
"number" },
2508 "deprecated use -g 1" },
2512 "discard threshold",
"n" },
2514 "rate control override for specific intervals",
"override" },
2516 "force video codec ('copy' to copy stream)",
"codec" },
2522 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2524 "select the pass number (1 to 3)",
"n" },
2526 "select two pass log file name prefix",
"prefix" },
2527 #if FF_API_DEINTERLACE
2529 "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 "set video filters",
"filter_graph" },
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 "set audio filters",
"filter_graph" },
2585 "set the maximum number of channels to try to guess the channel layout" },
2589 "disable subtitle" },
2591 "force subtitle codec ('copy' to copy stream)",
"codec" },
2593 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2595 "fix subtitles duration" },
2599 "deprecated, use -channel",
"channel" },
2601 "deprecated, use -standard",
"standard" },
2606 "set the maximum demux-decode delay",
"seconds" },
2608 "set the initial demux-decode delay",
"seconds" },
2611 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2613 "deprecated",
"audio bitstream_filters" },
2615 "deprecated",
"video bitstream_filters" },
2618 "set the audio options to the indicated preset",
"preset" },
2620 "set the video options to the indicated preset",
"preset" },
2622 "set the subtitle options to the indicated preset",
"preset" },
2624 "set options from indicated preset file",
"filename" },
2627 "force data codec ('copy' to copy stream)",
"codec" },