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;\
123 int i, *
count = (
int*)(so + 1);
124 for (i = 0; i < *
count; i++) {
146 memset(o, 0,
sizeof(*o));
164 char *p = strchr(e->
key,
':');
178 "If you are looking for an option to preserve the quality (which is not "
179 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
220 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
224 int i, negative = 0, file_idx;
225 int sync_file_idx = -1, sync_stream_idx = 0;
236 if (sync = strchr(map,
',')) {
238 sync_file_idx = strtol(sync + 1, &sync, 0);
247 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
253 "match any streams.\n", arg);
261 const char *
c = map + 1;
270 file_idx = strtol(map, &p, 0);
282 *p ==
':' ? p + 1 : p) > 0)
288 *p ==
':' ? p + 1 : p) <= 0)
296 if (sync_file_idx >= 0) {
343 n = sscanf(arg,
"%d.%d.%d:%d.%d",
347 if (n != 3 && n != 5) {
349 "[file.stream.channel|-1][:syncfile:syncstream]\n");
397 if (*(++arg) && *arg !=
':') {
401 *stream_spec = *arg ==
':' ? arg + 1 :
"";
406 *index = strtol(++arg, NULL, 0);
421 char type_in, type_out;
422 const char *istream_spec = NULL, *ostream_spec = NULL;
423 int idx_in = 0, idx_out = 0;
429 if (type_out ==
'g' || !*outspec)
431 if (type_out ==
's' || !*outspec)
433 if (type_out ==
'c' || !*outspec)
438 if (type_in ==
'g' || type_out ==
'g')
440 if (type_in ==
's' || type_out ==
's')
442 if (type_in ==
'c' || type_out ==
'c')
449 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
450 if ((index) < 0 || (index) >= (nb_elems)) {\
451 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
456 #define SET_DICT(type, meta, context, index)\
459 meta = &context->metadata;\
462 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
463 meta = &context->chapters[index]->metadata;\
466 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
467 meta = &context->programs[index]->metadata;\
471 default: av_assert0(0);\
474 SET_DICT(type_in, meta_in, ic, idx_in);
475 SET_DICT(type_out, meta_out, oc, idx_out);
478 if (type_in ==
's') {
487 av_log(NULL,
AV_LOG_FATAL,
"Stream specifier %s does not match any streams.\n", istream_spec);
492 if (type_out ==
's') {
511 struct tm time = *gmtime((time_t*)&recording_timestamp);
512 if (!strftime(buf,
sizeof(buf),
"creation_time=%FT%T%z", &time))
517 "tag instead.\n", opt);
524 const char *codec_string = encoder ?
"encoder" :
"decoder";
536 codec_string, codec->
name, desc->
name);
543 if (codec->
type != type) {
552 char *codec_name = NULL;
573 char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
574 char *codec_tag = NULL;
576 char *discard_str = NULL;
595 uint32_t
tag = strtol(codec_tag, &next, 0);
654 if (!strcmp(hwaccel,
"none"))
656 else if (!strcmp(hwaccel,
"auto"))
660 for (i = 0; hwaccels[i].
name; i++) {
661 if (!strcmp(hwaccels[i].
name, hwaccel)) {
671 for (i = 0; hwaccels[i].
name; i++)
680 if (hwaccel_device) {
701 char *canvas_size = NULL;
725 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
731 if (proto_name && !strcmp(proto_name,
"file") &&
avio_check(filename, 0) == 0) {
733 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
736 signal(SIGINT, SIG_DFL);
797 int scan_all_pmts_set = 0;
806 if (!strcmp(filename,
"-"))
810 strcmp(filename,
"/dev/stdin");
825 if (file_iformat && file_iformat->
priv_class &&
834 if (file_iformat && file_iformat->
priv_class &&
858 if (video_codec_name)
860 if (audio_codec_name)
862 if (subtitle_codec_name)
870 scan_all_pmts_set = 1;
878 if (scan_all_pmts_set)
955 if (!option || foption)
961 "input file #%d (%s) is not a decoding option.\n", e->
key,
968 "input file #%d (%s) has not been used for any stream. The most "
969 "likely reason is either wrong type (e.g. a video option with "
970 "no video streams) or that it is a private option of some decoder "
971 "which was not actually used for any stream.\n", e->
key,
987 for (i = 0; i < orig_nb_streams; i++)
1005 while ((c =
avio_r8(s)) && c !=
'\n')
1016 char filename[1000];
1017 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
1026 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
1027 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
1031 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
1032 i != 1 ?
"" :
"/.avconv", preset_name);
1041 char *codec_name = NULL;
1048 }
else if (!strcmp(codec_name,
"copy"))
1061 char *bsf = NULL, *next, *codec_tag = NULL;
1102 if (!buf[0] || buf[0] ==
'#') {
1106 if (!(arg = strchr(buf,
'='))) {
1118 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1131 av_log(NULL,
AV_LOG_WARNING,
"Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
1142 if (next = strchr(bsf,
','))
1144 if (arg = strchr(bsf,
'='))
1151 bsfc_prev->
next = bsfc;
1162 uint32_t
tag = strtol(codec_tag, &next, 0);
1186 if (source_index >= 0) {
1199 const char *p = str;
1231 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1267 "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
1268 "Filtering and streamcopy cannot be used together.\n",
1269 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1281 char *frame_rate = NULL, *frame_aspect_ratio = NULL;
1293 av_log(NULL,
AV_LOG_ERROR,
"Using -vsync 0 and -r can produce invalid output files\n");
1296 if (frame_aspect_ratio) {
1299 q.
num <= 0 || q.
den <= 0) {
1310 const char *p = NULL;
1312 char *frame_pix_fmt = NULL;
1313 char *intra_matrix = NULL, *inter_matrix = NULL;
1314 char *chroma_intra_matrix = NULL;
1326 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1328 if (!*++frame_pix_fmt)
1329 frame_pix_fmt = NULL;
1348 if (chroma_intra_matrix) {
1367 for (i = 0; p; i++) {
1369 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1454 char *sample_fmt = NULL;
1484 av_log(NULL,
AV_LOG_FATAL,
"Cannot determine input stream for channel mapping %d.%d\n",
1516 av_log(NULL,
AV_LOG_FATAL,
"Data stream encoding not supported yet (only streamcopy)\n");
1567 p = strchr(idx_str,
':');
1570 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1602 if (in_ch->
end < ts_off)
1604 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1611 out_ch->id = in_ch->
id;
1613 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1614 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1638 const char *enc_config;
1696 "which is fed from a complex filtergraph. Filtering and streamcopy "
1702 const char *opt = ost->
filters ?
"-vf/-af/-filter" :
"-filter_script";
1704 "%s '%s' was specified through the %s option "
1705 "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1706 "%s and -filter_complex cannot be used together for the same stream.\n",
1707 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1775 if (!strcmp(filename,
"-"))
1811 if (!strcmp(file_oformat->
name,
"ffm") &&
1855 int area = 0, idx = -1;
1877 int channels = 0, idx = -1;
1900 int input_props = 0, output_props = 0;
1903 if (input_descriptor)
1905 if (output_descriptor)
1907 if (subtitle_codec_name ||
1908 input_props & output_props ||
1910 input_descriptor && output_descriptor &&
1911 (!input_descriptor->
props ||
1912 !output_descriptor->
props)) {
1944 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
2040 if (!option || foption)
2046 "output file #%d (%s) is not an encoding option.\n", e->
key,
2053 if (!strcmp(e->
key,
"gop_timecode"))
2057 "output file #%d (%s) has not been used for any stream. The most "
2058 "likely reason is either wrong type (e.g. a video option with "
2059 "no video streams) or that it is a private option of some encoder "
2060 "which was not actually used for any stream.\n", e->
key,
2098 av_log(NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
2102 in_file_index >= 0 ?
2141 if (!output_streams[i]->stream_copy)
2142 av_dict_set(&output_streams[i]->st->metadata,
"encoder", NULL, 0);
2149 const char *stream_spec;
2176 av_log(NULL,
AV_LOG_FATAL,
"Invalid chapter index %d in metadata specifier.\n", index);
2196 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
2198 if (!strncmp(arg,
"pal-", 4)) {
2201 }
else if (!strncmp(arg,
"ntsc-", 5)) {
2204 }
else if (!strncmp(arg,
"film-", 5)) {
2221 }
else if ((fr == 29970) || (fr == 23976)) {
2235 av_log(NULL,
AV_LOG_FATAL,
"Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
2236 av_log(NULL,
AV_LOG_FATAL,
"Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
2241 if (!strcmp(arg,
"vcd")) {
2268 }
else if (!strcmp(arg,
"svcd")) {
2290 }
else if (!strcmp(arg,
"dvd")) {
2312 }
else if (!strncmp(arg,
"dv", 2)) {
2317 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2318 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2345 time_t today2 = time(NULL);
2346 struct tm *today = localtime(&today2);
2348 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2395 char filename[1000],
line[1000], tmp_line[1000];
2396 const char *codec_name = NULL;
2402 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2403 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2410 while (fgets(line,
sizeof(line), f)) {
2411 char *key = tmp_line, *
value, *endptr;
2413 if (strcspn(line,
"#\n\r") == 0)
2415 av_strlcpy(tmp_line, line,
sizeof(tmp_line));
2428 av_log(NULL,
AV_LOG_FATAL,
"%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
2429 filename, line, key, value);
2452 if(!strcmp(opt,
"ab")){
2455 }
else if(!strcmp(opt,
"b")){
2469 if(!strcmp(opt,
"qscale")){
2482 if(!strcmp(opt,
"profile")){
2529 char layout_str[32];
2532 int ret, channels, ac_str_size;
2540 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2547 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2548 stream_str = strchr(opt,
':');
2549 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2598 int show_advanced = 0, show_avoptions = 0;
2601 if (!strcmp(opt,
"long"))
2603 else if (!strcmp(opt,
"full"))
2604 show_advanced = show_avoptions = 1;
2611 printf(
"Getting help:\n"
2612 " -h -- print basic options\n"
2613 " -h long -- print more options\n"
2614 " -h full -- print all options (including all format and codec specific options, very long)\n"
2615 " See man %s for detailed description of the options.\n"
2622 "instead of just one file:",
2650 if (show_avoptions) {
2694 "%s.\n", inout, g->
arg);
2718 memset(&octx, 0,
sizeof(octx));
2763 if (!strcmp(arg,
"-"))
2775 #define OFFSET(x) offsetof(OptionsContext, x)
2781 "force format",
"fmt" },
2783 "overwrite output files" },
2785 "never overwrite output files" },
2788 "codec name",
"codec" },
2791 "codec name",
"codec" },
2794 "preset name",
"preset" },
2797 "set input stream mapping",
2798 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2800 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2803 "set metadata information of outfile from infile",
2804 "outfile[,metadata]:infile[,metadata]" },
2807 "set chapters mapping",
"input_file_index" },
2810 "record or transcode \"duration\" seconds of audio/video",
2813 "record or transcode stop time",
"time_stop" },
2815 "set the limit file size in bytes",
"limit_size" },
2818 "set the start time offset",
"time_off" },
2821 "enable/disable accurate seeking with -ss" },
2824 "set the input ts offset",
"time_off" },
2827 "set the input ts scale",
"scale" },
2829 "set the recording timestamp ('now' to set the current time)",
"time" },
2831 "add metadata",
"string=string" },
2834 "set the number of data frames to output",
"number" },
2836 "add timings for benchmarking" },
2838 "add timings for each task" },
2840 "write program-readable progress information",
"url" },
2842 "enable or disable interaction on standard input" },
2844 "set max runtime in seconds",
"limit" },
2846 "dump each input packet" },
2848 "when dumping packets, also dump the payload" },
2851 "read input at native frame rate",
"" },
2853 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2854 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2856 "video sync method",
"" },
2858 "audio sync method",
"" },
2860 "audio drift threshold",
"threshold" },
2862 "copy timestamps" },
2864 "shift input timestamps to start at 0 when using copyts" },
2866 "copy input stream time base when stream copying",
"mode" },
2869 "finish encoding within shortest input" },
2874 "timestamp discontinuity delta threshold",
"threshold" },
2876 "timestamp error delta threshold",
"threshold" },
2878 "exit on error",
"error" },
2881 "copy initial non-keyframes" },
2883 "copy or discard frames before start time" },
2885 "set the number of frames to output",
"number" },
2888 "force codec tag/fourcc",
"fourcc/tag" },
2891 "use fixed quality scale (VBR)",
"q" },
2894 "use fixed quality scale (VBR)",
"q" },
2896 "set profile",
"profile" },
2898 "set stream filtergraph",
"filter_graph" },
2900 "read stream filtergraph description from a file",
"filename" },
2902 "reinit filtergraph on input parameter changes",
"" },
2904 "create a complex filtergraph",
"graph_description" },
2906 "create a complex filtergraph",
"graph_description" },
2908 "read complex filtergraph description from a file",
"filename" },
2910 "print progress report during encoding", },
2913 "add an attachment to the output file",
"filename" },
2916 "extract an attachment into a file",
"filename" },
2918 "print timestamp debugging info" },
2920 "maximum error rate",
"ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success." },
2927 "set the number of video frames to output",
"number" },
2930 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2933 "set frame size (WxH or abbreviation)",
"size" },
2936 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2939 "set pixel format",
"format" },
2941 "set the number of bits per raw sample",
"number" },
2943 "deprecated use -g 1" },
2948 "rate control override for specific intervals",
"override" },
2951 "force video codec ('copy' to copy stream)",
"codec" },
2957 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2959 "select the pass number (1 to 3)",
"n" },
2962 "select two pass log file name prefix",
"prefix" },
2964 "this option is deprecated, use the yadif filter instead" },
2966 "calculate PSNR of compressed frames" },
2968 "dump video coding statistics to file" },
2970 "dump video coding statistics to file",
"file" },
2972 "set video filters",
"filter_graph" },
2975 "specify intra matrix coeffs",
"matrix" },
2978 "specify inter matrix coeffs",
"matrix" },
2981 "specify intra matrix coeffs",
"matrix" },
2984 "top=1/bottom=0/auto=-1 field first",
"" },
2987 "force video tag/fourcc",
"fourcc/tag" },
2989 "show QP histogram" },
2992 "force the selected framerate, disable the best supported framerate selection" },
2995 "set the value of an outfile streamid",
"streamIndex:value" },
2998 "force key frames at specified timestamps",
"timestamps" },
3000 "audio bitrate (please use -b:a)",
"bitrate" },
3002 "video bitrate (please use -b:v)",
"bitrate" },
3005 "use HW accelerated decoding",
"hwaccel name" },
3008 "select a device for HW acceleration" "devicename" },
3015 "set the number of audio frames to output",
"number" },
3017 "set audio quality (codec-specific)",
"quality", },
3020 "set audio sampling rate (in Hz)",
"rate" },
3023 "set number of audio channels",
"channels" },
3028 "force audio codec ('copy' to copy stream)",
"codec" },
3031 "force audio tag/fourcc",
"fourcc/tag" },
3033 "change audio volume (256=normal)" ,
"volume" },
3036 "set sample format",
"format" },
3039 "set channel layout",
"layout" },
3041 "set audio filters",
"filter_graph" },
3043 "set the maximum number of channels to try to guess the channel layout" },
3047 "disable subtitle" },
3049 "force subtitle codec ('copy' to copy stream)",
"codec" },
3051 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
3053 "fix subtitles duration" },
3055 "set canvas size (WxH or abbreviation)",
"size" },
3059 "deprecated, use -channel",
"channel" },
3061 "deprecated, use -standard",
"standard" },
3066 "set the maximum demux-decode delay",
"seconds" },
3068 "set the initial demux-decode delay",
"seconds" },
3070 "override the options from ffserver",
"" },
3073 "A comma-separated list of bitstream filters",
"bitstream_filters" },
3075 "deprecated",
"audio bitstream_filters" },
3077 "deprecated",
"video bitstream_filters" },
3080 "set the audio options to the indicated preset",
"preset" },
3082 "set the video options to the indicated preset",
"preset" },
3084 "set the subtitle options to the indicated preset",
"preset" },
3086 "set options from indicated preset file",
"filename" },
3089 "force data codec ('copy' to copy stream)",
"codec" },