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;\
125 int i, *
count = (
int*)(so + 1);
126 for (i = 0; i < *
count; i++) {
148 memset(o, 0,
sizeof(*o));
166 char *p = strchr(e->
key,
':');
180 "If you are looking for an option to preserve the quality (which is not "
181 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
222 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
226 int i, negative = 0, file_idx;
227 int sync_file_idx = -1, sync_stream_idx = 0;
240 if (sync = strchr(map,
',')) {
242 sync_file_idx = strtol(sync + 1, &sync, 0);
251 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
257 "match any streams.\n", arg);
265 const char *
c = map + 1;
274 file_idx = strtol(map, &p, 0);
286 *p ==
':' ? p + 1 : p) > 0)
292 *p ==
':' ? p + 1 : p) <= 0)
300 if (sync_file_idx >= 0) {
347 n = sscanf(arg,
"%d.%d.%d:%d.%d",
351 if (n != 3 && n != 5) {
353 "[file.stream.channel|-1][:syncfile:syncstream]\n");
408 if (*(++arg) && *arg !=
':') {
412 *stream_spec = *arg ==
':' ? arg + 1 :
"";
417 *index = strtol(++arg,
NULL, 0);
432 char type_in, type_out;
433 const char *istream_spec =
NULL, *ostream_spec =
NULL;
434 int idx_in = 0, idx_out = 0;
440 if (type_out ==
'g' || !*outspec)
442 if (type_out ==
's' || !*outspec)
444 if (type_out ==
'c' || !*outspec)
449 if (type_in ==
'g' || type_out ==
'g')
451 if (type_in ==
's' || type_out ==
's')
453 if (type_in ==
'c' || type_out ==
'c')
460 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
461 if ((index) < 0 || (index) >= (nb_elems)) {\
462 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
467 #define SET_DICT(type, meta, context, index)\
470 meta = &context->metadata;\
473 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
474 meta = &context->chapters[index]->metadata;\
477 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
478 meta = &context->programs[index]->metadata;\
482 default: av_assert0(0);\
485 SET_DICT(type_in, meta_in, ic, idx_in);
486 SET_DICT(type_out, meta_out, oc, idx_out);
489 if (type_in ==
's') {
503 if (type_out ==
's') {
522 struct tm time = *gmtime((time_t*)&recording_timestamp);
523 if (!strftime(buf,
sizeof(buf),
"creation_time=%Y-%m-%dT%H:%M:%S%z", &time))
528 "tag instead.\n", opt);
535 const char *codec_string = encoder ?
"encoder" :
"decoder";
547 codec_string, codec->
name, desc->
name);
554 if (codec->
type != type) {
563 char *codec_name =
NULL;
584 char *framerate =
NULL, *hwaccel =
NULL, *hwaccel_device =
NULL;
585 char *codec_tag =
NULL;
587 char *discard_str =
NULL;
606 uint32_t
tag = strtol(codec_tag, &next, 0);
665 if (!strcmp(hwaccel,
"none"))
667 else if (!strcmp(hwaccel,
"auto"))
671 for (i = 0; hwaccels[i].
name; i++) {
672 if (!strcmp(hwaccels[i].
name, hwaccel)) {
682 for (i = 0; hwaccels[i].
name; i++)
691 if (hwaccel_device) {
712 char *canvas_size =
NULL;
736 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
742 if (proto_name && !strcmp(proto_name,
"file") &&
avio_check(filename, 0) == 0) {
744 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
747 signal(SIGINT, SIG_DFL);
808 char * data_codec_name =
NULL;
809 int scan_all_pmts_set = 0;
818 if (!strcmp(filename,
"-"))
822 strcmp(filename,
"/dev/stdin");
837 if (file_iformat && file_iformat->
priv_class &&
846 if (file_iformat && file_iformat->
priv_class &&
873 if (video_codec_name)
875 if (audio_codec_name)
877 if (subtitle_codec_name)
887 scan_all_pmts_set = 1;
895 if (scan_all_pmts_set)
975 if (!option || foption)
981 "input file #%d (%s) is not a decoding option.\n", e->
key,
988 "input file #%d (%s) has not been used for any stream. The most "
989 "likely reason is either wrong type (e.g. a video option with "
990 "no video streams) or that it is a private option of some decoder "
991 "which was not actually used for any stream.\n", e->
key,
1007 for (i = 0; i < orig_nb_streams; i++)
1025 while ((c =
avio_r8(s)) && c !=
'\n')
1036 char filename[1000];
1037 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
1046 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
1047 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
1051 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
1052 i != 1 ?
"" :
"/.avconv", preset_name);
1061 char *codec_name =
NULL;
1068 }
else if (!strcmp(codec_name,
"copy"))
1081 char *bsf =
NULL, *next, *codec_tag =
NULL;
1122 if (!buf[0] || buf[0] ==
'#') {
1126 if (!(arg = strchr(buf,
'='))) {
1138 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1162 if (next = strchr(bsf,
','))
1164 if (arg = strchr(bsf,
'='))
1171 bsfc_prev->
next = bsfc;
1182 uint32_t
tag = strtol(codec_tag, &next, 0);
1209 if (source_index >= 0) {
1222 const char *p = str;
1254 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1290 "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
1291 "Filtering and streamcopy cannot be used together.\n",
1292 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1304 char *frame_rate =
NULL, *frame_aspect_ratio =
NULL;
1319 if (frame_aspect_ratio) {
1322 q.
num <= 0 || q.
den <= 0) {
1333 const char *p =
NULL;
1335 char *frame_pix_fmt =
NULL;
1336 char *intra_matrix =
NULL, *inter_matrix =
NULL;
1337 char *chroma_intra_matrix =
NULL;
1349 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1351 if (!*++frame_pix_fmt)
1352 frame_pix_fmt =
NULL;
1371 if (chroma_intra_matrix) {
1390 for (i = 0; p; i++) {
1392 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1480 char *sample_fmt =
NULL;
1593 p = strchr(idx_str,
':');
1596 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1628 if (in_ch->
end < ts_off)
1630 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1637 out_ch->id = in_ch->
id;
1639 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1640 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1664 const char *enc_config;
1722 "which is fed from a complex filtergraph. Filtering and streamcopy "
1728 const char *opt = ost->
filters ?
"-vf/-af/-filter" :
"-filter_script";
1730 "%s '%s' was specified through the %s option "
1731 "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1732 "%s and -filter_complex cannot be used together for the same stream.\n",
1733 ost->
filters ?
"Filtergraph" :
"Filtergraph script",
1801 if (!strcmp(filename,
"-"))
1837 if (!strcmp(file_oformat->
name,
"ffm") &&
1881 int area = 0, idx = -1;
1903 int channels = 0, idx = -1;
1926 int input_props = 0, output_props = 0;
1929 if (input_descriptor)
1931 if (output_descriptor)
1933 if (subtitle_codec_name ||
1934 input_props & output_props ||
1936 input_descriptor && output_descriptor &&
1937 (!input_descriptor->
props ||
1938 !output_descriptor->
props)) {
1978 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
2074 if (!option || foption)
2080 "output file #%d (%s) is not an encoding option.\n", e->
key,
2087 if (!strcmp(e->
key,
"gop_timecode"))
2091 "output file #%d (%s) has not been used for any stream. The most "
2092 "likely reason is either wrong type (e.g. a video option with "
2093 "no video streams) or that it is a private option of some encoder "
2094 "which was not actually used for any stream.\n", e->
key,
2132 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
2136 in_file_index >= 0 ?
2175 if (!output_streams[i]->stream_copy)
2183 const char *stream_spec;
2230 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
2232 if (!strncmp(arg,
"pal-", 4)) {
2235 }
else if (!strncmp(arg,
"ntsc-", 5)) {
2238 }
else if (!strncmp(arg,
"film-", 5)) {
2255 }
else if ((fr == 29970) || (fr == 23976)) {
2275 if (!strcmp(arg,
"vcd")) {
2302 }
else if (!strcmp(arg,
"svcd")) {
2324 }
else if (!strcmp(arg,
"dvd")) {
2346 }
else if (!strncmp(arg,
"dv", 2)) {
2351 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2352 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2379 time_t today2 = time(
NULL);
2380 struct tm *today = localtime(&today2);
2382 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2429 char filename[1000],
line[1000], tmp_line[1000];
2430 const char *codec_name =
NULL;
2436 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2437 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2444 while (fgets(line,
sizeof(line), f)) {
2445 char *key = tmp_line, *
value, *endptr;
2447 if (strcspn(line,
"#\n\r") == 0)
2449 av_strlcpy(tmp_line, line,
sizeof(tmp_line));
2463 filename, line, key, value);
2486 if(!strcmp(opt,
"ab")){
2489 }
else if(!strcmp(opt,
"b")){
2503 if(!strcmp(opt,
"qscale")){
2516 if(!strcmp(opt,
"profile")){
2563 char layout_str[32];
2566 int ret, channels, ac_str_size;
2574 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2581 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2582 stream_str = strchr(opt,
':');
2583 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2632 int show_advanced = 0, show_avoptions = 0;
2635 if (!strcmp(opt,
"long"))
2637 else if (!strcmp(opt,
"full"))
2638 show_advanced = show_avoptions = 1;
2645 printf(
"Getting help:\n"
2646 " -h -- print basic options\n"
2647 " -h long -- print more options\n"
2648 " -h full -- print all options (including all format and codec specific options, very long)\n"
2649 " See man %s for detailed description of the options.\n"
2656 "instead of just one file:",
2684 if (show_avoptions) {
2728 "%s.\n", inout, g->
arg);
2752 memset(&octx, 0,
sizeof(octx));
2797 if (!strcmp(arg,
"-"))
2809 #define OFFSET(x) offsetof(OptionsContext, x)
2815 "force format",
"fmt" },
2817 "overwrite output files" },
2819 "never overwrite output files" },
2822 "codec name",
"codec" },
2825 "codec name",
"codec" },
2828 "preset name",
"preset" },
2831 "set input stream mapping",
2832 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2834 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2837 "set metadata information of outfile from infile",
2838 "outfile[,metadata]:infile[,metadata]" },
2841 "set chapters mapping",
"input_file_index" },
2844 "record or transcode \"duration\" seconds of audio/video",
2847 "record or transcode stop time",
"time_stop" },
2849 "set the limit file size in bytes",
"limit_size" },
2852 "set the start time offset",
"time_off" },
2855 "enable/disable accurate seeking with -ss" },
2858 "set the input ts offset",
"time_off" },
2861 "set the input ts scale",
"scale" },
2863 "set the recording timestamp ('now' to set the current time)",
"time" },
2865 "add metadata",
"string=string" },
2868 "set the number of data frames to output",
"number" },
2870 "add timings for benchmarking" },
2872 "add timings for each task" },
2874 "write program-readable progress information",
"url" },
2876 "enable or disable interaction on standard input" },
2878 "set max runtime in seconds",
"limit" },
2880 "dump each input packet" },
2882 "when dumping packets, also dump the payload" },
2885 "read input at native frame rate",
"" },
2887 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2888 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2890 "video sync method",
"" },
2892 "frame drop threshold",
"" },
2894 "audio sync method",
"" },
2896 "audio drift threshold",
"threshold" },
2898 "copy timestamps" },
2900 "shift input timestamps to start at 0 when using copyts" },
2902 "copy input stream time base when stream copying",
"mode" },
2905 "finish encoding within shortest input" },
2910 "timestamp discontinuity delta threshold",
"threshold" },
2912 "timestamp error delta threshold",
"threshold" },
2914 "exit on error",
"error" },
2917 "copy initial non-keyframes" },
2919 "copy or discard frames before start time" },
2921 "set the number of frames to output",
"number" },
2924 "force codec tag/fourcc",
"fourcc/tag" },
2927 "use fixed quality scale (VBR)",
"q" },
2930 "use fixed quality scale (VBR)",
"q" },
2932 "set profile",
"profile" },
2934 "set stream filtergraph",
"filter_graph" },
2936 "read stream filtergraph description from a file",
"filename" },
2938 "reinit filtergraph on input parameter changes",
"" },
2940 "create a complex filtergraph",
"graph_description" },
2942 "create a complex filtergraph",
"graph_description" },
2944 "read complex filtergraph description from a file",
"filename" },
2946 "print progress report during encoding", },
2949 "add an attachment to the output file",
"filename" },
2952 "extract an attachment into a file",
"filename" },
2954 "print timestamp debugging info" },
2956 "maximum error rate",
"ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success." },
2962 "disposition",
"" },
2964 { .off =
OFFSET(thread_queue_size) },
2965 "set the maximum number of queued packets from the demuxer" },
2969 "set the number of video frames to output",
"number" },
2972 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2975 "set frame size (WxH or abbreviation)",
"size" },
2978 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2981 "set pixel format",
"format" },
2983 "set the number of bits per raw sample",
"number" },
2985 "deprecated use -g 1" },
2990 "rate control override for specific intervals",
"override" },
2993 "force video codec ('copy' to copy stream)",
"codec" },
2999 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
3001 "select the pass number (1 to 3)",
"n" },
3004 "select two pass log file name prefix",
"prefix" },
3006 "this option is deprecated, use the yadif filter instead" },
3008 "calculate PSNR of compressed frames" },
3010 "dump video coding statistics to file" },
3012 "dump video coding statistics to file",
"file" },
3014 "set video filters",
"filter_graph" },
3017 "specify intra matrix coeffs",
"matrix" },
3020 "specify inter matrix coeffs",
"matrix" },
3023 "specify intra matrix coeffs",
"matrix" },
3026 "top=1/bottom=0/auto=-1 field first",
"" },
3029 "force video tag/fourcc",
"fourcc/tag" },
3031 "show QP histogram" },
3034 "force the selected framerate, disable the best supported framerate selection" },
3037 "set the value of an outfile streamid",
"streamIndex:value" },
3040 "force key frames at specified timestamps",
"timestamps" },
3042 "audio bitrate (please use -b:a)",
"bitrate" },
3044 "video bitrate (please use -b:v)",
"bitrate" },
3047 "use HW accelerated decoding",
"hwaccel name" },
3050 "select a device for HW acceleration" "devicename" },
3057 "set the number of audio frames to output",
"number" },
3059 "set audio quality (codec-specific)",
"quality", },
3062 "set audio sampling rate (in Hz)",
"rate" },
3065 "set number of audio channels",
"channels" },
3070 "force audio codec ('copy' to copy stream)",
"codec" },
3073 "force audio tag/fourcc",
"fourcc/tag" },
3075 "change audio volume (256=normal)" ,
"volume" },
3078 "set sample format",
"format" },
3081 "set channel layout",
"layout" },
3083 "set audio filters",
"filter_graph" },
3085 "set the maximum number of channels to try to guess the channel layout" },
3089 "disable subtitle" },
3091 "force subtitle codec ('copy' to copy stream)",
"codec" },
3093 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
3095 "fix subtitles duration" },
3097 "set canvas size (WxH or abbreviation)",
"size" },
3101 "deprecated, use -channel",
"channel" },
3103 "deprecated, use -standard",
"standard" },
3108 "set the maximum demux-decode delay",
"seconds" },
3110 "set the initial demux-decode delay",
"seconds" },
3112 "override the options from ffserver",
"" },
3114 "specify a file in which to print sdp information",
"file" },
3117 "A comma-separated list of bitstream filters",
"bitstream_filters" },
3119 "deprecated",
"audio bitstream_filters" },
3121 "deprecated",
"video bitstream_filters" },
3124 "set the audio options to the indicated preset",
"preset" },
3126 "set the video options to the indicated preset",
"preset" },
3128 "set the subtitle options to the indicated preset",
"preset" },
3130 "set options from indicated preset file",
"filename" },
3133 "force data codec ('copy' to copy stream)",
"codec" },