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;\
56 #define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
59 for (i = 0; i < o->nb_ ## name; i++) {\
60 char *spec = o->name[i].specifier;\
61 if (!strcmp(spec, mediatype))\
62 outvar = o->name[i].u.type;\
122 int i, *
count = (
int*)(so + 1);
123 for (i = 0; i < *
count; i++) {
145 memset(o, 0,
sizeof(*o));
163 char *p = strchr(e->
key,
':');
177 "If you are looking for an option to preserve the quality (which is not "
178 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
219 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
223 int i, negative = 0, file_idx;
224 int sync_file_idx = -1, sync_stream_idx = 0;
235 if (sync = strchr(map,
',')) {
237 sync_file_idx = strtol(sync + 1, &sync, 0);
246 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
252 "match any streams.\n", arg);
260 const char *
c = map + 1;
269 file_idx = strtol(map, &p, 0);
281 *p ==
':' ? p + 1 : p) > 0)
287 *p ==
':' ? p + 1 : p) <= 0)
295 if (sync_file_idx >= 0) {
342 n = sscanf(arg,
"%d.%d.%d:%d.%d",
346 if (n != 3 && n != 5) {
348 "[file.stream.channel|-1][:syncfile:syncstream]\n");
396 if (*(++arg) && *arg !=
':') {
400 *stream_spec = *arg ==
':' ? arg + 1 :
"";
405 *index = strtol(++arg, NULL, 0);
420 char type_in, type_out;
421 const char *istream_spec = NULL, *ostream_spec = NULL;
422 int idx_in = 0, idx_out = 0;
428 if (type_out ==
'g' || !*outspec)
430 if (type_out ==
's' || !*outspec)
432 if (type_out ==
'c' || !*outspec)
437 if (type_in ==
'g' || type_out ==
'g')
439 if (type_in ==
's' || type_out ==
's')
441 if (type_in ==
'c' || type_out ==
'c')
448 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
449 if ((index) < 0 || (index) >= (nb_elems)) {\
450 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
455 #define SET_DICT(type, meta, context, index)\
458 meta = &context->metadata;\
461 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
462 meta = &context->chapters[index]->metadata;\
465 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
466 meta = &context->programs[index]->metadata;\
470 default: av_assert0(0);\
473 SET_DICT(type_in, meta_in, ic, idx_in);
474 SET_DICT(type_out, meta_out, oc, idx_out);
477 if (type_in ==
's') {
486 av_log(NULL,
AV_LOG_FATAL,
"Stream specifier %s does not match any streams.\n", istream_spec);
491 if (type_out ==
's') {
510 struct tm time = *gmtime((time_t*)&recording_timestamp);
511 strftime(buf,
sizeof(buf),
"creation_time=%FT%T%z", &time);
515 "tag instead.\n", opt);
522 const char *codec_string = encoder ?
"encoder" :
"decoder";
534 codec_string, codec->
name, desc->
name);
541 if (codec->
type != type) {
550 char *codec_name = NULL;
571 char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
572 char *codec_tag = NULL;
574 char *discard_str = NULL;
593 uint32_t
tag = strtol(codec_tag, &next, 0);
652 if (!strcmp(hwaccel,
"none"))
654 else if (!strcmp(hwaccel,
"auto"))
658 for (i = 0; hwaccels[i].
name; i++) {
659 if (!strcmp(hwaccels[i].
name, hwaccel)) {
669 for (i = 0; hwaccels[i].
name; i++)
678 if (hwaccel_device) {
699 char *canvas_size = NULL;
723 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
729 if (proto_name && !strcmp(proto_name,
"file") &&
avio_check(filename, 0) == 0) {
731 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
734 signal(SIGINT, SIG_DFL);
803 if (!strcmp(filename,
"-"))
807 strcmp(filename,
"/dev/stdin");
822 if (file_iformat && file_iformat->
priv_class &&
831 if (file_iformat && file_iformat->
priv_class &&
855 if (video_codec_name)
857 if (audio_codec_name)
859 if (subtitle_codec_name)
946 if (!option || foption)
952 "input file #%d (%s) is not a decoding option.\n", e->
key,
959 "input file #%d (%s) has not been used for any stream. The most "
960 "likely reason is either wrong type (e.g. a video option with "
961 "no video streams) or that it is a private option of some decoder "
962 "which was not actually used for any stream.\n", e->
key,
978 for (i = 0; i < orig_nb_streams; i++)
996 while ((c =
avio_r8(s)) && c !=
'\n')
1007 char filename[1000];
1008 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
1017 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
1018 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
1022 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
1023 i != 1 ?
"" :
"/.avconv", preset_name);
1032 char *codec_name = NULL;
1039 }
else if (!strcmp(codec_name,
"copy"))
1052 char *bsf = NULL, *next, *codec_tag = NULL;
1093 if (!buf[0] || buf[0] ==
'#') {
1097 if (!(arg = strchr(buf,
'='))) {
1109 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1122 av_log(NULL,
AV_LOG_WARNING,
"Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
1132 if (next = strchr(bsf,
','))
1139 bsfc_prev->
next = bsfc;
1149 uint32_t
tag = strtol(codec_tag, &next, 0);
1173 if (source_index >= 0) {
1186 const char *p = str;
1218 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1254 "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
1255 "Filtering and streamcopy cannot be used together.\n",
1256 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1268 char *frame_rate = NULL, *frame_aspect_ratio = NULL;
1281 if (frame_aspect_ratio) {
1284 q.
num <= 0 || q.
den <= 0) {
1295 const char *p = NULL;
1297 char *frame_pix_fmt = NULL;
1298 char *intra_matrix = NULL, *inter_matrix = NULL;
1299 char *chroma_intra_matrix = NULL;
1311 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1313 if (!*++frame_pix_fmt)
1314 frame_pix_fmt = NULL;
1333 if (chroma_intra_matrix) {
1352 for (i = 0; p; i++) {
1354 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1439 char *sample_fmt = NULL;
1469 av_log(NULL,
AV_LOG_FATAL,
"Cannot determine input stream for channel mapping %d.%d\n",
1501 av_log(NULL,
AV_LOG_FATAL,
"Data stream encoding not supported yet (only streamcopy)\n");
1552 p = strchr(idx_str,
':');
1555 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1587 if (in_ch->
end < ts_off)
1589 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1596 out_ch->id = in_ch->
id;
1598 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1599 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1672 "which is fed from a complex filtergraph. Filtering and streamcopy "
1678 const char *opt = ost->
filters ?
"-vf/-af/-filter" :
"-filter_script";
1680 "%s '%s' was specified through the %s option "
1681 "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1682 "%s and -filter_complex cannot be used together for the same stream.\n",
1683 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1751 if (!strcmp(filename,
"-"))
1787 if (!strcmp(file_oformat->
name,
"ffm") &&
1831 int area = 0, idx = -1;
1853 int channels = 0, idx = -1;
1876 int input_props = 0, output_props = 0;
1879 if (input_descriptor)
1881 if (output_descriptor)
1883 if (subtitle_codec_name ||
1884 input_props & output_props ||
1886 input_descriptor && output_descriptor &&
1887 (!input_descriptor->
props ||
1888 !output_descriptor->
props)) {
1920 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
2016 if (!option || foption)
2022 "output file #%d (%s) is not an encoding option.\n", e->
key,
2029 if (!strcmp(e->
key,
"gop_timecode"))
2033 "output file #%d (%s) has not been used for any stream. The most "
2034 "likely reason is either wrong type (e.g. a video option with "
2035 "no video streams) or that it is a private option of some encoder "
2036 "which was not actually used for any stream.\n", e->
key,
2074 av_log(NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
2078 in_file_index >= 0 ?
2117 if (!output_streams[i]->stream_copy)
2118 av_dict_set(&output_streams[i]->st->metadata,
"encoder", NULL, 0);
2125 const char *stream_spec;
2152 av_log(NULL,
AV_LOG_FATAL,
"Invalid chapter index %d in metadata specifier.\n", index);
2172 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
2174 if (!strncmp(arg,
"pal-", 4)) {
2177 }
else if (!strncmp(arg,
"ntsc-", 5)) {
2180 }
else if (!strncmp(arg,
"film-", 5)) {
2197 }
else if ((fr == 29970) || (fr == 23976)) {
2211 av_log(NULL,
AV_LOG_FATAL,
"Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
2212 av_log(NULL,
AV_LOG_FATAL,
"Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
2217 if (!strcmp(arg,
"vcd")) {
2244 }
else if (!strcmp(arg,
"svcd")) {
2266 }
else if (!strcmp(arg,
"dvd")) {
2288 }
else if (!strncmp(arg,
"dv", 2)) {
2293 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2294 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2321 time_t today2 = time(NULL);
2322 struct tm *today = localtime(&today2);
2324 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2371 char filename[1000],
line[1000], tmp_line[1000];
2372 const char *codec_name = NULL;
2378 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2379 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2386 while (fgets(line,
sizeof(line), f)) {
2387 char *key = tmp_line, *
value, *endptr;
2389 if (strcspn(line,
"#\n\r") == 0)
2391 av_strlcpy(tmp_line, line,
sizeof(tmp_line));
2404 av_log(NULL,
AV_LOG_FATAL,
"%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
2405 filename, line, key, value);
2428 if(!strcmp(opt,
"ab")){
2431 }
else if(!strcmp(opt,
"b")){
2445 if(!strcmp(opt,
"qscale")){
2458 if(!strcmp(opt,
"profile")){
2505 char layout_str[32];
2508 int ret, channels, ac_str_size;
2516 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2523 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2524 stream_str = strchr(opt,
':');
2525 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2574 int show_advanced = 0, show_avoptions = 0;
2577 if (!strcmp(opt,
"long"))
2579 else if (!strcmp(opt,
"full"))
2580 show_advanced = show_avoptions = 1;
2587 printf(
"Getting help:\n"
2588 " -h -- print basic options\n"
2589 " -h long -- print more options\n"
2590 " -h full -- print all options (including all format and codec specific options, very long)\n"
2591 " See man %s for detailed description of the options.\n"
2598 "instead of just one file:",
2626 if (show_avoptions) {
2670 "%s.\n", inout, g->
arg);
2694 memset(&octx, 0,
sizeof(octx));
2739 if (!strcmp(arg,
"-"))
2751 #define OFFSET(x) offsetof(OptionsContext, x)
2757 "force format",
"fmt" },
2759 "overwrite output files" },
2761 "never overwrite output files" },
2764 "codec name",
"codec" },
2767 "codec name",
"codec" },
2770 "preset name",
"preset" },
2773 "set input stream mapping",
2774 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2776 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2779 "set metadata information of outfile from infile",
2780 "outfile[,metadata]:infile[,metadata]" },
2783 "set chapters mapping",
"input_file_index" },
2786 "record or transcode \"duration\" seconds of audio/video",
2789 "record or transcode stop time",
"time_stop" },
2791 "set the limit file size in bytes",
"limit_size" },
2794 "set the start time offset",
"time_off" },
2797 "enable/disable accurate seeking with -ss" },
2800 "set the input ts offset",
"time_off" },
2803 "set the input ts scale",
"scale" },
2805 "set the recording timestamp ('now' to set the current time)",
"time" },
2807 "add metadata",
"string=string" },
2810 "set the number of data frames to record",
"number" },
2812 "add timings for benchmarking" },
2814 "add timings for each task" },
2816 "write program-readable progress information",
"url" },
2818 "enable or disable interaction on standard input" },
2820 "set max runtime in seconds",
"limit" },
2822 "dump each input packet" },
2824 "when dumping packets, also dump the payload" },
2827 "read input at native frame rate",
"" },
2829 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2830 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2832 "video sync method",
"" },
2834 "audio sync method",
"" },
2836 "audio drift threshold",
"threshold" },
2838 "copy timestamps" },
2840 "copy input stream time base when stream copying",
"mode" },
2843 "finish encoding within shortest input" },
2848 "timestamp discontinuity delta threshold",
"threshold" },
2850 "timestamp error delta threshold",
"threshold" },
2852 "exit on error",
"error" },
2855 "copy initial non-keyframes" },
2857 "copy or discard frames before start time" },
2859 "set the number of frames to record",
"number" },
2862 "force codec tag/fourcc",
"fourcc/tag" },
2865 "use fixed quality scale (VBR)",
"q" },
2868 "use fixed quality scale (VBR)",
"q" },
2870 "set profile",
"profile" },
2872 "set stream filtergraph",
"filter_graph" },
2874 "read stream filtergraph description from a file",
"filename" },
2876 "reinit filtergraph on input parameter changes",
"" },
2878 "create a complex filtergraph",
"graph_description" },
2880 "create a complex filtergraph",
"graph_description" },
2882 "read complex filtergraph description from a file",
"filename" },
2884 "print progress report during encoding", },
2887 "add an attachment to the output file",
"filename" },
2890 "extract an attachment into a file",
"filename" },
2892 "print timestamp debugging info" },
2894 "maximum error rate",
"ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success." },
2901 "set the number of video frames to record",
"number" },
2904 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2907 "set frame size (WxH or abbreviation)",
"size" },
2910 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2913 "set pixel format",
"format" },
2915 "set the number of bits per raw sample",
"number" },
2917 "deprecated use -g 1" },
2922 "rate control override for specific intervals",
"override" },
2925 "force video codec ('copy' to copy stream)",
"codec" },
2931 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2933 "select the pass number (1 to 3)",
"n" },
2936 "select two pass log file name prefix",
"prefix" },
2938 "this option is deprecated, use the yadif filter instead" },
2940 "calculate PSNR of compressed frames" },
2942 "dump video coding statistics to file" },
2944 "dump video coding statistics to file",
"file" },
2946 "set video filters",
"filter_graph" },
2949 "specify intra matrix coeffs",
"matrix" },
2952 "specify inter matrix coeffs",
"matrix" },
2955 "specify intra matrix coeffs",
"matrix" },
2958 "top=1/bottom=0/auto=-1 field first",
"" },
2961 "force video tag/fourcc",
"fourcc/tag" },
2963 "show QP histogram" },
2966 "force the selected framerate, disable the best supported framerate selection" },
2969 "set the value of an outfile streamid",
"streamIndex:value" },
2972 "force key frames at specified timestamps",
"timestamps" },
2974 "audio bitrate (please use -b:a)",
"bitrate" },
2976 "video bitrate (please use -b:v)",
"bitrate" },
2979 "use HW accelerated decoding",
"hwaccel name" },
2982 "select a device for HW acceleration" "devicename" },
2986 "set the number of audio frames to record",
"number" },
2988 "set audio quality (codec-specific)",
"quality", },
2991 "set audio sampling rate (in Hz)",
"rate" },
2994 "set number of audio channels",
"channels" },
2999 "force audio codec ('copy' to copy stream)",
"codec" },
3002 "force audio tag/fourcc",
"fourcc/tag" },
3004 "change audio volume (256=normal)" ,
"volume" },
3007 "set sample format",
"format" },
3010 "set channel layout",
"layout" },
3012 "set audio filters",
"filter_graph" },
3014 "set the maximum number of channels to try to guess the channel layout" },
3018 "disable subtitle" },
3020 "force subtitle codec ('copy' to copy stream)",
"codec" },
3022 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
3024 "fix subtitles duration" },
3026 "set canvas size (WxH or abbreviation)",
"size" },
3030 "deprecated, use -channel",
"channel" },
3032 "deprecated, use -standard",
"standard" },
3037 "set the maximum demux-decode delay",
"seconds" },
3039 "set the initial demux-decode delay",
"seconds" },
3041 "override the options from ffserver",
"" },
3044 "A comma-separated list of bitstream filters",
"bitstream_filters" },
3046 "deprecated",
"audio bitstream_filters" },
3048 "deprecated",
"video bitstream_filters" },
3051 "set the audio options to the indicated preset",
"preset" },
3053 "set the video options to the indicated preset",
"preset" },
3055 "set the subtitle options to the indicated preset",
"preset" },
3057 "set options from indicated preset file",
"filename" },
3060 "force data codec ('copy' to copy stream)",
"codec" },