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;\
110 int i, *
count = (
int*)(so + 1);
111 for (i = 0; i < *
count; i++) {
133 memset(o, 0,
sizeof(*o));
151 char *p = strchr(e->
key,
':');
165 "If you are looking for an option to preserve the quality (which is not "
166 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
207 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
211 int i, negative = 0, file_idx;
212 int sync_file_idx = -1, sync_stream_idx = 0;
223 if (sync = strchr(map,
',')) {
225 sync_file_idx = strtol(sync + 1, &sync, 0);
234 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
240 "match any streams.\n", arg);
248 const char *
c = map + 1;
257 file_idx = strtol(map, &p, 0);
269 *p ==
':' ? p + 1 : p) > 0)
275 *p ==
':' ? p + 1 : p) <= 0)
283 if (sync_file_idx >= 0) {
330 n = sscanf(arg,
"%d.%d.%d:%d.%d",
334 if (n != 3 && n != 5) {
336 "[file.stream.channel|-1][:syncfile:syncstream]\n");
384 if (*(++arg) && *arg !=
':') {
388 *stream_spec = *arg ==
':' ? arg + 1 :
"";
393 *index = strtol(++arg, NULL, 0);
408 char type_in, type_out;
409 const char *istream_spec = NULL, *ostream_spec = NULL;
410 int idx_in = 0, idx_out = 0;
416 if (type_out ==
'g' || !*outspec)
418 if (type_out ==
's' || !*outspec)
420 if (type_out ==
'c' || !*outspec)
425 if (type_in ==
'g' || type_out ==
'g')
427 if (type_in ==
's' || type_out ==
's')
429 if (type_in ==
'c' || type_out ==
'c')
436 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
437 if ((index) < 0 || (index) >= (nb_elems)) {\
438 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
443 #define SET_DICT(type, meta, context, index)\
446 meta = &context->metadata;\
449 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
450 meta = &context->chapters[index]->metadata;\
453 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
454 meta = &context->programs[index]->metadata;\
458 default: av_assert0(0);\
461 SET_DICT(type_in, meta_in, ic, idx_in);
462 SET_DICT(type_out, meta_out, oc, idx_out);
465 if (type_in ==
's') {
474 av_log(NULL,
AV_LOG_FATAL,
"Stream specifier %s does not match any streams.\n", istream_spec);
479 if (type_out ==
's') {
498 struct tm time = *gmtime((time_t*)&recording_timestamp);
499 strftime(buf,
sizeof(buf),
"creation_time=%FT%T%z", &time);
503 "tag instead.\n", opt);
510 const char *codec_string = encoder ?
"encoder" :
"decoder";
522 codec_string, codec->
name, desc->
name);
529 if (codec->
type != type) {
538 char *codec_name = NULL;
554 char *next, *codec_tag = NULL;
560 char *framerate = NULL;
578 uint32_t
tag = strtol(codec_tag, &next, 0);
629 char *canvas_size = NULL;
653 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
658 (strchr(filename,
':') == NULL || filename[1] ==
':' ||
662 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
665 signal(SIGINT, SIG_DFL);
735 if (!strcmp(filename,
"-"))
739 strcmp(filename,
"/dev/stdin");
755 if (file_iformat && file_iformat->
priv_class &&
766 if (file_iformat && file_iformat->
priv_class &&
790 if (video_codec_name)
792 if (audio_codec_name)
794 if (subtitle_codec_name)
879 "input file #%d (%s) is not a decoding option.\n", e->
key,
886 "input file #%d (%s) has not been used for any stream. The most "
887 "likely reason is either wrong type (e.g. a video option with "
888 "no video streams) or that it is a private option of some decoder "
889 "which was not actually used for any stream.\n", e->
key,
905 for (i = 0; i < orig_nb_streams; i++)
923 while ((c =
avio_r8(s)) && c !=
'\n')
935 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
944 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
945 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
949 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
950 i != 1 ?
"" :
"/.avconv", preset_name);
959 char *codec_name = NULL;
966 }
else if (!strcmp(codec_name,
"copy"))
979 char *bsf = NULL, *next, *codec_tag = NULL;
1012 if (!buf[0] || buf[0] ==
'#') {
1016 if (!(arg = strchr(buf,
'='))) {
1028 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1044 av_log(NULL,
AV_LOG_WARNING,
"Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
1054 if (next = strchr(bsf,
','))
1061 bsfc_prev->
next = bsfc;
1071 uint32_t
tag = strtol(codec_tag, &next, 0);
1095 if (source_index >= 0) {
1108 const char *p = str;
1140 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1155 char *
filter = NULL, *filter_script = NULL;
1160 if (filter_script && filter) {
1180 char *frame_rate = NULL, *frame_aspect_ratio = NULL;
1184 video_enc = st->
codec;
1193 if (frame_aspect_ratio) {
1196 q.
num <= 0 || q.
den <= 0) {
1204 const char *p = NULL;
1206 char *frame_pix_fmt = NULL;
1207 char *intra_matrix = NULL, *inter_matrix = NULL;
1219 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1221 if (!*++frame_pix_fmt)
1222 frame_pix_fmt = NULL;
1250 for (i = 0; p; i++) {
1252 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1328 audio_enc = st->
codec;
1332 char *sample_fmt = NULL;
1377 av_log(NULL,
AV_LOG_FATAL,
"Data stream encoding not supported yet (only streamcopy)\n");
1400 subtitle_enc = st->
codec;
1428 p = strchr(idx_str,
':');
1431 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1463 if (in_ch->
end < ts_off)
1465 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1472 out_ch->id = in_ch->
id;
1474 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1475 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1547 "which is fed from a complex filtergraph. Filtering and streamcopy "
1614 if (!strcmp(filename,
"-"))
1650 if (!strcmp(file_oformat->
name,
"ffm") &&
1694 int area = 0, idx = -1;
1716 int channels = 0, idx = -1;
1764 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
1861 "output file #%d (%s) is not an encoding option.\n", e->
key,
1868 if (!strcmp(e->
key,
"gop_timecode"))
1872 "output file #%d (%s) has not been used for any stream. The most "
1873 "likely reason is either wrong type (e.g. a video option with "
1874 "no video streams) or that it is a private option of some encoder "
1875 "which was not actually used for any stream.\n", e->
key,
1915 av_log(NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1919 in_file_index >= 0 ?
1964 const char *stream_spec;
1991 av_log(NULL,
AV_LOG_FATAL,
"Invalid chapter index %d in metadata specifier.\n", index);
2011 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
2013 if (!strncmp(arg,
"pal-", 4)) {
2016 }
else if (!strncmp(arg,
"ntsc-", 5)) {
2019 }
else if (!strncmp(arg,
"film-", 5)) {
2035 }
else if ((fr == 29970) || (fr == 23976)) {
2049 av_log(NULL,
AV_LOG_FATAL,
"Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
2050 av_log(NULL,
AV_LOG_FATAL,
"Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
2055 if (!strcmp(arg,
"vcd")) {
2083 }
else if (!strcmp(arg,
"svcd")) {
2105 }
else if (!strcmp(arg,
"dvd")) {
2127 }
else if (!strncmp(arg,
"dv", 2)) {
2132 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2133 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2156 time_t today2 = time(NULL);
2157 struct tm *today = localtime(&today2);
2159 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2206 char filename[1000],
line[1000], tmp_line[1000];
2207 const char *codec_name = NULL;
2213 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2214 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2221 while (fgets(line,
sizeof(line), f)) {
2222 char *key = tmp_line, *
value, *endptr;
2224 if (strcspn(line,
"#\n\r") == 0)
2226 av_strlcpy(tmp_line, line,
sizeof(tmp_line));
2239 av_log(NULL,
AV_LOG_FATAL,
"%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
2240 filename, line, key, value);
2262 if(!strcmp(opt,
"b")){
2276 if(!strcmp(opt,
"qscale")){
2289 if(!strcmp(opt,
"profile")){
2336 char layout_str[32];
2339 int ret, channels, ac_str_size;
2347 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2354 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2355 stream_str = strchr(opt,
':');
2356 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2405 int show_advanced = 0, show_avoptions = 0;
2408 if (!strcmp(opt,
"long"))
2410 else if (!strcmp(opt,
"full"))
2411 show_advanced = show_avoptions = 1;
2418 printf(
"Getting help:\n"
2419 " -h -- print basic options\n"
2420 " -h long -- print more options\n"
2421 " -h full -- print all options (including all format and codec specific options, very long)\n"
2422 " See man %s for detailed description of the options.\n"
2429 "instead of just one file:",
2457 if (show_avoptions) {
2501 "%s.\n", inout, g->
arg);
2525 memset(&octx, 0,
sizeof(octx));
2570 if (!strcmp(arg,
"-"))
2582 #define OFFSET(x) offsetof(OptionsContext, x)
2588 "force format",
"fmt" },
2590 "overwrite output files" },
2592 "never overwrite output files" },
2595 "codec name",
"codec" },
2598 "codec name",
"codec" },
2601 "preset name",
"preset" },
2604 "set input stream mapping",
2605 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2607 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2610 "set metadata information of outfile from infile",
2611 "outfile[,metadata]:infile[,metadata]" },
2614 "set chapters mapping",
"input_file_index" },
2617 "record or transcode \"duration\" seconds of audio/video",
2620 "record or transcode stop time",
"time_stop" },
2622 "set the limit file size in bytes",
"limit_size" },
2625 "set the start time offset",
"time_off" },
2628 "enable/disable accurate seeking with -ss" },
2631 "set the input ts offset",
"time_off" },
2634 "set the input ts scale",
"scale" },
2636 "set the recording timestamp ('now' to set the current time)",
"time" },
2638 "add metadata",
"string=string" },
2641 "set the number of data frames to record",
"number" },
2643 "add timings for benchmarking" },
2645 "add timings for each task" },
2647 "write program-readable progress information",
"url" },
2649 "enable or disable interaction on standard input" },
2651 "set max runtime in seconds",
"limit" },
2653 "dump each input packet" },
2655 "when dumping packets, also dump the payload" },
2658 "read input at native frame rate",
"" },
2660 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2661 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2663 "video sync method",
"" },
2665 "audio sync method",
"" },
2667 "audio drift threshold",
"threshold" },
2669 "copy timestamps" },
2671 "copy input stream time base when stream copying",
"mode" },
2674 "finish encoding within shortest input" },
2679 "timestamp discontinuity delta threshold",
"threshold" },
2681 "timestamp error delta threshold",
"threshold" },
2683 "exit on error",
"error" },
2686 "copy initial non-keyframes" },
2688 "copy or discard frames before start time" },
2690 "set the number of frames to record",
"number" },
2693 "force codec tag/fourcc",
"fourcc/tag" },
2696 "use fixed quality scale (VBR)",
"q" },
2699 "use fixed quality scale (VBR)",
"q" },
2701 "set profile",
"profile" },
2703 "set stream filtergraph",
"filter_graph" },
2705 "read stream filtergraph description from a file",
"filename" },
2707 "reinit filtergraph on input parameter changes",
"" },
2709 "create a complex filtergraph",
"graph_description" },
2711 "create a complex filtergraph",
"graph_description" },
2713 "read complex filtergraph description from a file",
"filename" },
2715 "print progress report during encoding", },
2718 "add an attachment to the output file",
"filename" },
2721 "extract an attachment into a file",
"filename" },
2723 "print timestamp debugging info" },
2725 "maximum error rate",
"ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success." },
2729 "set the number of video frames to record",
"number" },
2732 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2735 "set frame size (WxH or abbreviation)",
"size" },
2738 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2741 "set pixel format",
"format" },
2743 "set the number of bits per raw sample",
"number" },
2745 "deprecated use -g 1" },
2749 "discard threshold",
"n" },
2752 "rate control override for specific intervals",
"override" },
2755 "force video codec ('copy' to copy stream)",
"codec" },
2761 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2763 "select the pass number (1 to 3)",
"n" },
2766 "select two pass log file name prefix",
"prefix" },
2768 "this option is deprecated, use the yadif filter instead" },
2770 "calculate PSNR of compressed frames" },
2772 "dump video coding statistics to file" },
2774 "dump video coding statistics to file",
"file" },
2776 "set video filters",
"filter_graph" },
2779 "specify intra matrix coeffs",
"matrix" },
2782 "specify inter matrix coeffs",
"matrix" },
2785 "top=1/bottom=0/auto=-1 field first",
"" },
2787 "intra_dc_precision",
"precision" },
2790 "force video tag/fourcc",
"fourcc/tag" },
2792 "show QP histogram" },
2795 "force the selected framerate, disable the best supported framerate selection" },
2798 "set the value of an outfile streamid",
"streamIndex:value" },
2801 "force key frames at specified timestamps",
"timestamps" },
2803 "video bitrate (please use -b:v)",
"bitrate" },
2807 "set the number of audio frames to record",
"number" },
2809 "set audio quality (codec-specific)",
"quality", },
2812 "set audio sampling rate (in Hz)",
"rate" },
2815 "set number of audio channels",
"channels" },
2820 "force audio codec ('copy' to copy stream)",
"codec" },
2823 "force audio tag/fourcc",
"fourcc/tag" },
2825 "change audio volume (256=normal)" ,
"volume" },
2828 "set sample format",
"format" },
2831 "set channel layout",
"layout" },
2833 "set audio filters",
"filter_graph" },
2835 "set the maximum number of channels to try to guess the channel layout" },
2839 "disable subtitle" },
2841 "force subtitle codec ('copy' to copy stream)",
"codec" },
2843 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2845 "fix subtitles duration" },
2847 "set canvas size (WxH or abbreviation)",
"size" },
2851 "deprecated, use -channel",
"channel" },
2853 "deprecated, use -standard",
"standard" },
2858 "set the maximum demux-decode delay",
"seconds" },
2860 "set the initial demux-decode delay",
"seconds" },
2862 "override the options from ffserver",
"" },
2865 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2867 "deprecated",
"audio bitstream_filters" },
2869 "deprecated",
"video bitstream_filters" },
2872 "set the audio options to the indicated preset",
"preset" },
2874 "set the video options to the indicated preset",
"preset" },
2876 "set the subtitle options to the indicated preset",
"preset" },
2878 "set options from indicated preset file",
"filename" },
2881 "force data codec ('copy' to copy stream)",
"codec" },