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;\
118 int i, *
count = (
int*)(so + 1);
119 for (i = 0; i < *
count; i++) {
141 memset(o, 0,
sizeof(*o));
159 char *p = strchr(e->
key,
':');
173 "If you are looking for an option to preserve the quality (which is not "
174 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
215 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
219 int i, negative = 0, file_idx;
220 int sync_file_idx = -1, sync_stream_idx = 0;
231 if (sync = strchr(map,
',')) {
233 sync_file_idx = strtol(sync + 1, &sync, 0);
242 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
248 "match any streams.\n", arg);
256 const char *
c = map + 1;
265 file_idx = strtol(map, &p, 0);
277 *p ==
':' ? p + 1 : p) > 0)
283 *p ==
':' ? p + 1 : p) <= 0)
291 if (sync_file_idx >= 0) {
338 n = sscanf(arg,
"%d.%d.%d:%d.%d",
342 if (n != 3 && n != 5) {
344 "[file.stream.channel|-1][:syncfile:syncstream]\n");
392 if (*(++arg) && *arg !=
':') {
396 *stream_spec = *arg ==
':' ? arg + 1 :
"";
401 *index = strtol(++arg, NULL, 0);
416 char type_in, type_out;
417 const char *istream_spec = NULL, *ostream_spec = NULL;
418 int idx_in = 0, idx_out = 0;
424 if (type_out ==
'g' || !*outspec)
426 if (type_out ==
's' || !*outspec)
428 if (type_out ==
'c' || !*outspec)
433 if (type_in ==
'g' || type_out ==
'g')
435 if (type_in ==
's' || type_out ==
's')
437 if (type_in ==
'c' || type_out ==
'c')
444 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
445 if ((index) < 0 || (index) >= (nb_elems)) {\
446 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
451 #define SET_DICT(type, meta, context, index)\
454 meta = &context->metadata;\
457 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
458 meta = &context->chapters[index]->metadata;\
461 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
462 meta = &context->programs[index]->metadata;\
466 default: av_assert0(0);\
469 SET_DICT(type_in, meta_in, ic, idx_in);
470 SET_DICT(type_out, meta_out, oc, idx_out);
473 if (type_in ==
's') {
482 av_log(NULL,
AV_LOG_FATAL,
"Stream specifier %s does not match any streams.\n", istream_spec);
487 if (type_out ==
's') {
506 struct tm time = *gmtime((time_t*)&recording_timestamp);
507 strftime(buf,
sizeof(buf),
"creation_time=%FT%T%z", &time);
511 "tag instead.\n", opt);
518 const char *codec_string = encoder ?
"encoder" :
"decoder";
530 codec_string, codec->
name, desc->
name);
537 if (codec->
type != type) {
546 char *codec_name = NULL;
567 char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
568 char *codec_tag = NULL;
587 uint32_t
tag = strtol(codec_tag, &next, 0);
626 if (!strcmp(hwaccel,
"none"))
628 else if (!strcmp(hwaccel,
"auto"))
632 for (i = 0; hwaccels[i].
name; i++) {
633 if (!strcmp(hwaccels[i].
name, hwaccel)) {
643 for (i = 0; hwaccels[i].
name; i++)
652 if (hwaccel_device) {
673 char *canvas_size = NULL;
697 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
703 if (proto_name && !strcmp(proto_name,
"file") &&
avio_check(filename, 0) == 0) {
705 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
708 signal(SIGINT, SIG_DFL);
778 if (!strcmp(filename,
"-"))
782 strcmp(filename,
"/dev/stdin");
798 if (file_iformat && file_iformat->
priv_class &&
809 if (file_iformat && file_iformat->
priv_class &&
833 if (video_codec_name)
835 if (audio_codec_name)
837 if (subtitle_codec_name)
921 if (!option || foption)
927 "input file #%d (%s) is not a decoding option.\n", e->
key,
934 "input file #%d (%s) has not been used for any stream. The most "
935 "likely reason is either wrong type (e.g. a video option with "
936 "no video streams) or that it is a private option of some decoder "
937 "which was not actually used for any stream.\n", e->
key,
953 for (i = 0; i < orig_nb_streams; i++)
971 while ((c =
avio_r8(s)) && c !=
'\n')
983 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
992 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
993 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
997 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
998 i != 1 ?
"" :
"/.avconv", preset_name);
1007 char *codec_name = NULL;
1014 }
else if (!strcmp(codec_name,
"copy"))
1027 char *bsf = NULL, *next, *codec_tag = NULL;
1060 if (!buf[0] || buf[0] ==
'#') {
1064 if (!(arg = strchr(buf,
'='))) {
1076 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1092 av_log(NULL,
AV_LOG_WARNING,
"Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
1102 if (next = strchr(bsf,
','))
1109 bsfc_prev->
next = bsfc;
1119 uint32_t
tag = strtol(codec_tag, &next, 0);
1143 if (source_index >= 0) {
1156 const char *p = str;
1188 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1224 "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
1225 "Filtering and streamcopy cannot be used together.\n",
1226 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1238 char *frame_rate = NULL, *frame_aspect_ratio = NULL;
1242 video_enc = st->
codec;
1251 if (frame_aspect_ratio) {
1254 q.
num <= 0 || q.
den <= 0) {
1265 const char *p = NULL;
1267 char *frame_pix_fmt = NULL;
1268 char *intra_matrix = NULL, *inter_matrix = NULL;
1269 char *chroma_intra_matrix = NULL;
1281 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1283 if (!*++frame_pix_fmt)
1284 frame_pix_fmt = NULL;
1303 if (chroma_intra_matrix) {
1322 for (i = 0; p; i++) {
1324 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1403 audio_enc = st->
codec;
1410 char *sample_fmt = NULL;
1458 av_log(NULL,
AV_LOG_FATAL,
"Data stream encoding not supported yet (only streamcopy)\n");
1481 subtitle_enc = st->
codec;
1509 p = strchr(idx_str,
':');
1512 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1544 if (in_ch->
end < ts_off)
1546 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1553 out_ch->id = in_ch->
id;
1555 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1556 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1628 "which is fed from a complex filtergraph. Filtering and streamcopy "
1634 const char *opt = ost->
filters ?
"-vf/-af/-filter" :
"-filter_script";
1636 "%s '%s' was specified through the %s option "
1637 "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1638 "%s and -filter_complex cannot be used together for the same stream.\n",
1639 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1707 if (!strcmp(filename,
"-"))
1743 if (!strcmp(file_oformat->
name,
"ffm") &&
1787 int area = 0, idx = -1;
1809 int channels = 0, idx = -1;
1857 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
1954 "output file #%d (%s) is not an encoding option.\n", e->
key,
1961 if (!strcmp(e->
key,
"gop_timecode"))
1965 "output file #%d (%s) has not been used for any stream. The most "
1966 "likely reason is either wrong type (e.g. a video option with "
1967 "no video streams) or that it is a private option of some encoder "
1968 "which was not actually used for any stream.\n", e->
key,
2008 av_log(NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
2012 in_file_index >= 0 ?
2057 const char *stream_spec;
2084 av_log(NULL,
AV_LOG_FATAL,
"Invalid chapter index %d in metadata specifier.\n", index);
2104 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
2106 if (!strncmp(arg,
"pal-", 4)) {
2109 }
else if (!strncmp(arg,
"ntsc-", 5)) {
2112 }
else if (!strncmp(arg,
"film-", 5)) {
2128 }
else if ((fr == 29970) || (fr == 23976)) {
2142 av_log(NULL,
AV_LOG_FATAL,
"Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
2143 av_log(NULL,
AV_LOG_FATAL,
"Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
2148 if (!strcmp(arg,
"vcd")) {
2175 }
else if (!strcmp(arg,
"svcd")) {
2197 }
else if (!strcmp(arg,
"dvd")) {
2219 }
else if (!strncmp(arg,
"dv", 2)) {
2224 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2225 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2248 time_t today2 = time(NULL);
2249 struct tm *today = localtime(&today2);
2251 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2298 char filename[1000],
line[1000], tmp_line[1000];
2299 const char *codec_name = NULL;
2305 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2306 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2313 while (fgets(line,
sizeof(line), f)) {
2314 char *key = tmp_line, *
value, *endptr;
2316 if (strcspn(line,
"#\n\r") == 0)
2318 av_strlcpy(tmp_line, line,
sizeof(tmp_line));
2331 av_log(NULL,
AV_LOG_FATAL,
"%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
2332 filename, line, key, value);
2354 if(!strcmp(opt,
"b")){
2368 if(!strcmp(opt,
"qscale")){
2381 if(!strcmp(opt,
"profile")){
2428 char layout_str[32];
2431 int ret, channels, ac_str_size;
2439 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2446 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2447 stream_str = strchr(opt,
':');
2448 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2497 int show_advanced = 0, show_avoptions = 0;
2500 if (!strcmp(opt,
"long"))
2502 else if (!strcmp(opt,
"full"))
2503 show_advanced = show_avoptions = 1;
2510 printf(
"Getting help:\n"
2511 " -h -- print basic options\n"
2512 " -h long -- print more options\n"
2513 " -h full -- print all options (including all format and codec specific options, very long)\n"
2514 " See man %s for detailed description of the options.\n"
2521 "instead of just one file:",
2549 if (show_avoptions) {
2593 "%s.\n", inout, g->
arg);
2617 memset(&octx, 0,
sizeof(octx));
2662 if (!strcmp(arg,
"-"))
2674 #define OFFSET(x) offsetof(OptionsContext, x)
2680 "force format",
"fmt" },
2682 "overwrite output files" },
2684 "never overwrite output files" },
2687 "codec name",
"codec" },
2690 "codec name",
"codec" },
2693 "preset name",
"preset" },
2696 "set input stream mapping",
2697 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2699 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2702 "set metadata information of outfile from infile",
2703 "outfile[,metadata]:infile[,metadata]" },
2706 "set chapters mapping",
"input_file_index" },
2709 "record or transcode \"duration\" seconds of audio/video",
2712 "record or transcode stop time",
"time_stop" },
2714 "set the limit file size in bytes",
"limit_size" },
2717 "set the start time offset",
"time_off" },
2720 "enable/disable accurate seeking with -ss" },
2723 "set the input ts offset",
"time_off" },
2726 "set the input ts scale",
"scale" },
2728 "set the recording timestamp ('now' to set the current time)",
"time" },
2730 "add metadata",
"string=string" },
2733 "set the number of data frames to record",
"number" },
2735 "add timings for benchmarking" },
2737 "add timings for each task" },
2739 "write program-readable progress information",
"url" },
2741 "enable or disable interaction on standard input" },
2743 "set max runtime in seconds",
"limit" },
2745 "dump each input packet" },
2747 "when dumping packets, also dump the payload" },
2750 "read input at native frame rate",
"" },
2752 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2753 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2755 "video sync method",
"" },
2757 "audio sync method",
"" },
2759 "audio drift threshold",
"threshold" },
2761 "copy timestamps" },
2763 "copy input stream time base when stream copying",
"mode" },
2766 "finish encoding within shortest input" },
2771 "timestamp discontinuity delta threshold",
"threshold" },
2773 "timestamp error delta threshold",
"threshold" },
2775 "exit on error",
"error" },
2778 "copy initial non-keyframes" },
2780 "copy or discard frames before start time" },
2782 "set the number of frames to record",
"number" },
2785 "force codec tag/fourcc",
"fourcc/tag" },
2788 "use fixed quality scale (VBR)",
"q" },
2791 "use fixed quality scale (VBR)",
"q" },
2793 "set profile",
"profile" },
2795 "set stream filtergraph",
"filter_graph" },
2797 "read stream filtergraph description from a file",
"filename" },
2799 "reinit filtergraph on input parameter changes",
"" },
2801 "create a complex filtergraph",
"graph_description" },
2803 "create a complex filtergraph",
"graph_description" },
2805 "read complex filtergraph description from a file",
"filename" },
2807 "print progress report during encoding", },
2810 "add an attachment to the output file",
"filename" },
2813 "extract an attachment into a file",
"filename" },
2815 "print timestamp debugging info" },
2817 "maximum error rate",
"ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success." },
2821 "set the number of video frames to record",
"number" },
2824 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2827 "set frame size (WxH or abbreviation)",
"size" },
2830 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2833 "set pixel format",
"format" },
2835 "set the number of bits per raw sample",
"number" },
2837 "deprecated use -g 1" },
2841 "discard threshold",
"n" },
2844 "rate control override for specific intervals",
"override" },
2847 "force video codec ('copy' to copy stream)",
"codec" },
2853 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2855 "select the pass number (1 to 3)",
"n" },
2858 "select two pass log file name prefix",
"prefix" },
2860 "this option is deprecated, use the yadif filter instead" },
2862 "calculate PSNR of compressed frames" },
2864 "dump video coding statistics to file" },
2866 "dump video coding statistics to file",
"file" },
2868 "set video filters",
"filter_graph" },
2871 "specify intra matrix coeffs",
"matrix" },
2874 "specify inter matrix coeffs",
"matrix" },
2877 "specify intra matrix coeffs",
"matrix" },
2880 "top=1/bottom=0/auto=-1 field first",
"" },
2882 "intra_dc_precision",
"precision" },
2885 "force video tag/fourcc",
"fourcc/tag" },
2887 "show QP histogram" },
2890 "force the selected framerate, disable the best supported framerate selection" },
2893 "set the value of an outfile streamid",
"streamIndex:value" },
2896 "force key frames at specified timestamps",
"timestamps" },
2898 "video bitrate (please use -b:v)",
"bitrate" },
2901 "use HW accelerated decoding",
"hwaccel name" },
2904 "select a device for HW acceleration" "devicename" },
2908 "set the number of audio frames to record",
"number" },
2910 "set audio quality (codec-specific)",
"quality", },
2913 "set audio sampling rate (in Hz)",
"rate" },
2916 "set number of audio channels",
"channels" },
2921 "force audio codec ('copy' to copy stream)",
"codec" },
2924 "force audio tag/fourcc",
"fourcc/tag" },
2926 "change audio volume (256=normal)" ,
"volume" },
2929 "set sample format",
"format" },
2932 "set channel layout",
"layout" },
2934 "set audio filters",
"filter_graph" },
2936 "set the maximum number of channels to try to guess the channel layout" },
2940 "disable subtitle" },
2942 "force subtitle codec ('copy' to copy stream)",
"codec" },
2944 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2946 "fix subtitles duration" },
2948 "set canvas size (WxH or abbreviation)",
"size" },
2952 "deprecated, use -channel",
"channel" },
2954 "deprecated, use -standard",
"standard" },
2959 "set the maximum demux-decode delay",
"seconds" },
2961 "set the initial demux-decode delay",
"seconds" },
2963 "override the options from ffserver",
"" },
2966 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2968 "deprecated",
"audio bitstream_filters" },
2970 "deprecated",
"video bitstream_filters" },
2973 "set the audio options to the indicated preset",
"preset" },
2975 "set the video options to the indicated preset",
"preset" },
2977 "set the subtitle options to the indicated preset",
"preset" },
2979 "set options from indicated preset file",
"filename" },
2982 "force data codec ('copy' to copy stream)",
"codec" },