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);
804 if (!strcmp(filename,
"-"))
808 strcmp(filename,
"/dev/stdin");
824 if (file_iformat && file_iformat->
priv_class &&
835 if (file_iformat && file_iformat->
priv_class &&
859 if (video_codec_name)
861 if (audio_codec_name)
863 if (subtitle_codec_name)
949 if (!option || foption)
955 "input file #%d (%s) is not a decoding option.\n", e->
key,
962 "input file #%d (%s) has not been used for any stream. The most "
963 "likely reason is either wrong type (e.g. a video option with "
964 "no video streams) or that it is a private option of some decoder "
965 "which was not actually used for any stream.\n", e->
key,
981 for (i = 0; i < orig_nb_streams; i++)
999 while ((c =
avio_r8(s)) && c !=
'\n')
1010 char filename[1000];
1011 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
1020 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
1021 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
1025 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
1026 i != 1 ?
"" :
"/.avconv", preset_name);
1035 char *codec_name = NULL;
1042 }
else if (!strcmp(codec_name,
"copy"))
1055 char *bsf = NULL, *next, *codec_tag = NULL;
1096 if (!buf[0] || buf[0] ==
'#') {
1100 if (!(arg = strchr(buf,
'='))) {
1112 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1125 av_log(NULL,
AV_LOG_WARNING,
"Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
1135 if (next = strchr(bsf,
','))
1142 bsfc_prev->
next = bsfc;
1152 uint32_t
tag = strtol(codec_tag, &next, 0);
1176 if (source_index >= 0) {
1189 const char *p = str;
1221 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1257 "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
1258 "Filtering and streamcopy cannot be used together.\n",
1259 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1271 char *frame_rate = NULL, *frame_aspect_ratio = NULL;
1284 if (frame_aspect_ratio) {
1287 q.
num <= 0 || q.
den <= 0) {
1298 const char *p = NULL;
1300 char *frame_pix_fmt = NULL;
1301 char *intra_matrix = NULL, *inter_matrix = NULL;
1302 char *chroma_intra_matrix = NULL;
1314 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1316 if (!*++frame_pix_fmt)
1317 frame_pix_fmt = NULL;
1336 if (chroma_intra_matrix) {
1355 for (i = 0; p; i++) {
1357 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1442 char *sample_fmt = NULL;
1472 av_log(NULL,
AV_LOG_FATAL,
"Cannot determine input stream for channel mapping %d.%d\n",
1502 av_log(NULL,
AV_LOG_FATAL,
"Data stream encoding not supported yet (only streamcopy)\n");
1553 p = strchr(idx_str,
':');
1556 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1588 if (in_ch->
end < ts_off)
1590 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1597 out_ch->id = in_ch->
id;
1599 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1600 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1673 "which is fed from a complex filtergraph. Filtering and streamcopy "
1679 const char *opt = ost->
filters ?
"-vf/-af/-filter" :
"-filter_script";
1681 "%s '%s' was specified through the %s option "
1682 "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1683 "%s and -filter_complex cannot be used together for the same stream.\n",
1684 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1752 if (!strcmp(filename,
"-"))
1788 if (!strcmp(file_oformat->
name,
"ffm") &&
1832 int area = 0, idx = -1;
1854 int channels = 0, idx = -1;
1902 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
1999 "output file #%d (%s) is not an encoding option.\n", e->
key,
2006 if (!strcmp(e->
key,
"gop_timecode"))
2010 "output file #%d (%s) has not been used for any stream. The most "
2011 "likely reason is either wrong type (e.g. a video option with "
2012 "no video streams) or that it is a private option of some encoder "
2013 "which was not actually used for any stream.\n", e->
key,
2053 av_log(NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
2057 in_file_index >= 0 ?
2096 if (!output_streams[i]->stream_copy)
2097 av_dict_set(&output_streams[i]->st->metadata,
"encoder", NULL, 0);
2104 const char *stream_spec;
2131 av_log(NULL,
AV_LOG_FATAL,
"Invalid chapter index %d in metadata specifier.\n", index);
2151 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
2153 if (!strncmp(arg,
"pal-", 4)) {
2156 }
else if (!strncmp(arg,
"ntsc-", 5)) {
2159 }
else if (!strncmp(arg,
"film-", 5)) {
2175 }
else if ((fr == 29970) || (fr == 23976)) {
2189 av_log(NULL,
AV_LOG_FATAL,
"Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
2190 av_log(NULL,
AV_LOG_FATAL,
"Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
2195 if (!strcmp(arg,
"vcd")) {
2222 }
else if (!strcmp(arg,
"svcd")) {
2244 }
else if (!strcmp(arg,
"dvd")) {
2266 }
else if (!strncmp(arg,
"dv", 2)) {
2271 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2272 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2295 time_t today2 = time(NULL);
2296 struct tm *today = localtime(&today2);
2298 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2345 char filename[1000],
line[1000], tmp_line[1000];
2346 const char *codec_name = NULL;
2352 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2353 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2360 while (fgets(line,
sizeof(line), f)) {
2361 char *key = tmp_line, *
value, *endptr;
2363 if (strcspn(line,
"#\n\r") == 0)
2365 av_strlcpy(tmp_line, line,
sizeof(tmp_line));
2378 av_log(NULL,
AV_LOG_FATAL,
"%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
2379 filename, line, key, value);
2402 if(!strcmp(opt,
"ab")){
2405 }
else if(!strcmp(opt,
"b")){
2419 if(!strcmp(opt,
"qscale")){
2432 if(!strcmp(opt,
"profile")){
2479 char layout_str[32];
2482 int ret, channels, ac_str_size;
2490 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2497 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2498 stream_str = strchr(opt,
':');
2499 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2548 int show_advanced = 0, show_avoptions = 0;
2551 if (!strcmp(opt,
"long"))
2553 else if (!strcmp(opt,
"full"))
2554 show_advanced = show_avoptions = 1;
2561 printf(
"Getting help:\n"
2562 " -h -- print basic options\n"
2563 " -h long -- print more options\n"
2564 " -h full -- print all options (including all format and codec specific options, very long)\n"
2565 " See man %s for detailed description of the options.\n"
2572 "instead of just one file:",
2600 if (show_avoptions) {
2644 "%s.\n", inout, g->
arg);
2668 memset(&octx, 0,
sizeof(octx));
2713 if (!strcmp(arg,
"-"))
2725 #define OFFSET(x) offsetof(OptionsContext, x)
2731 "force format",
"fmt" },
2733 "overwrite output files" },
2735 "never overwrite output files" },
2738 "codec name",
"codec" },
2741 "codec name",
"codec" },
2744 "preset name",
"preset" },
2747 "set input stream mapping",
2748 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2750 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2753 "set metadata information of outfile from infile",
2754 "outfile[,metadata]:infile[,metadata]" },
2757 "set chapters mapping",
"input_file_index" },
2760 "record or transcode \"duration\" seconds of audio/video",
2763 "record or transcode stop time",
"time_stop" },
2765 "set the limit file size in bytes",
"limit_size" },
2768 "set the start time offset",
"time_off" },
2771 "enable/disable accurate seeking with -ss" },
2774 "set the input ts offset",
"time_off" },
2777 "set the input ts scale",
"scale" },
2779 "set the recording timestamp ('now' to set the current time)",
"time" },
2781 "add metadata",
"string=string" },
2784 "set the number of data frames to record",
"number" },
2786 "add timings for benchmarking" },
2788 "add timings for each task" },
2790 "write program-readable progress information",
"url" },
2792 "enable or disable interaction on standard input" },
2794 "set max runtime in seconds",
"limit" },
2796 "dump each input packet" },
2798 "when dumping packets, also dump the payload" },
2801 "read input at native frame rate",
"" },
2803 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2804 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2806 "video sync method",
"" },
2808 "audio sync method",
"" },
2810 "audio drift threshold",
"threshold" },
2812 "copy timestamps" },
2814 "copy input stream time base when stream copying",
"mode" },
2817 "finish encoding within shortest input" },
2822 "timestamp discontinuity delta threshold",
"threshold" },
2824 "timestamp error delta threshold",
"threshold" },
2826 "exit on error",
"error" },
2829 "copy initial non-keyframes" },
2831 "copy or discard frames before start time" },
2833 "set the number of frames to record",
"number" },
2836 "force codec tag/fourcc",
"fourcc/tag" },
2839 "use fixed quality scale (VBR)",
"q" },
2842 "use fixed quality scale (VBR)",
"q" },
2844 "set profile",
"profile" },
2846 "set stream filtergraph",
"filter_graph" },
2848 "read stream filtergraph description from a file",
"filename" },
2850 "reinit filtergraph on input parameter changes",
"" },
2852 "create a complex filtergraph",
"graph_description" },
2854 "create a complex filtergraph",
"graph_description" },
2856 "read complex filtergraph description from a file",
"filename" },
2858 "print progress report during encoding", },
2861 "add an attachment to the output file",
"filename" },
2864 "extract an attachment into a file",
"filename" },
2866 "print timestamp debugging info" },
2868 "maximum error rate",
"ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success." },
2875 "set the number of video frames to record",
"number" },
2878 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2881 "set frame size (WxH or abbreviation)",
"size" },
2884 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2887 "set pixel format",
"format" },
2889 "set the number of bits per raw sample",
"number" },
2891 "deprecated use -g 1" },
2896 "rate control override for specific intervals",
"override" },
2899 "force video codec ('copy' to copy stream)",
"codec" },
2905 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2907 "select the pass number (1 to 3)",
"n" },
2910 "select two pass log file name prefix",
"prefix" },
2912 "this option is deprecated, use the yadif filter instead" },
2914 "calculate PSNR of compressed frames" },
2916 "dump video coding statistics to file" },
2918 "dump video coding statistics to file",
"file" },
2920 "set video filters",
"filter_graph" },
2923 "specify intra matrix coeffs",
"matrix" },
2926 "specify inter matrix coeffs",
"matrix" },
2929 "specify intra matrix coeffs",
"matrix" },
2932 "top=1/bottom=0/auto=-1 field first",
"" },
2935 "force video tag/fourcc",
"fourcc/tag" },
2937 "show QP histogram" },
2940 "force the selected framerate, disable the best supported framerate selection" },
2943 "set the value of an outfile streamid",
"streamIndex:value" },
2946 "force key frames at specified timestamps",
"timestamps" },
2948 "audio bitrate (please use -b:a)",
"bitrate" },
2950 "video bitrate (please use -b:v)",
"bitrate" },
2953 "use HW accelerated decoding",
"hwaccel name" },
2956 "select a device for HW acceleration" "devicename" },
2960 "set the number of audio frames to record",
"number" },
2962 "set audio quality (codec-specific)",
"quality", },
2965 "set audio sampling rate (in Hz)",
"rate" },
2968 "set number of audio channels",
"channels" },
2973 "force audio codec ('copy' to copy stream)",
"codec" },
2976 "force audio tag/fourcc",
"fourcc/tag" },
2978 "change audio volume (256=normal)" ,
"volume" },
2981 "set sample format",
"format" },
2984 "set channel layout",
"layout" },
2986 "set audio filters",
"filter_graph" },
2988 "set the maximum number of channels to try to guess the channel layout" },
2992 "disable subtitle" },
2994 "force subtitle codec ('copy' to copy stream)",
"codec" },
2996 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2998 "fix subtitles duration" },
3000 "set canvas size (WxH or abbreviation)",
"size" },
3004 "deprecated, use -channel",
"channel" },
3006 "deprecated, use -standard",
"standard" },
3011 "set the maximum demux-decode delay",
"seconds" },
3013 "set the initial demux-decode delay",
"seconds" },
3015 "override the options from ffserver",
"" },
3018 "A comma-separated list of bitstream filters",
"bitstream_filters" },
3020 "deprecated",
"audio bitstream_filters" },
3022 "deprecated",
"video bitstream_filters" },
3025 "set the audio options to the indicated preset",
"preset" },
3027 "set the video options to the indicated preset",
"preset" },
3029 "set the subtitle options to the indicated preset",
"preset" },
3031 "set options from indicated preset file",
"filename" },
3034 "force data codec ('copy' to copy stream)",
"codec" },