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;\
111 int i, *
count = (
int*)(so + 1);
112 for (i = 0; i < *
count; i++) {
139 memset(o, 0,
sizeof(*o));
144 "-t is not an input option, keeping it for the next output;"
145 " consider fixing your command line.\n");
161 char *p = strchr(e->
key,
':');
175 "If you are looking for an option to preserve the quality (which is not "
176 "what -%s was for), use -qscale 0 or an equivalent quality factor option.\n",
217 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
221 int i, negative = 0, file_idx;
222 int sync_file_idx = -1, sync_stream_idx = 0;
233 if (sync = strchr(map,
',')) {
235 sync_file_idx = strtol(sync + 1, &sync, 0);
244 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
250 "match any streams.\n", arg);
258 const char *
c = map + 1;
267 file_idx = strtol(map, &p, 0);
279 *p ==
':' ? p + 1 : p) > 0)
285 *p ==
':' ? p + 1 : p) <= 0)
293 if (sync_file_idx >= 0) {
340 n = sscanf(arg,
"%d.%d.%d:%d.%d",
344 if (n != 3 && n != 5) {
346 "[file.stream.channel|-1][:syncfile:syncstream]\n");
394 if (*(++arg) && *arg !=
':') {
398 *stream_spec = *arg ==
':' ? arg + 1 :
"";
403 *index = strtol(++arg, NULL, 0);
418 char type_in, type_out;
419 const char *istream_spec = NULL, *ostream_spec = NULL;
420 int idx_in = 0, idx_out = 0;
426 if (type_out ==
'g' || !*outspec)
428 if (type_out ==
's' || !*outspec)
430 if (type_out ==
'c' || !*outspec)
435 if (type_in ==
'g' || type_out ==
'g')
437 if (type_in ==
's' || type_out ==
's')
439 if (type_in ==
'c' || type_out ==
'c')
446 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
447 if ((index) < 0 || (index) >= (nb_elems)) {\
448 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
453 #define SET_DICT(type, meta, context, index)\
456 meta = &context->metadata;\
459 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
460 meta = &context->chapters[index]->metadata;\
463 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
464 meta = &context->programs[index]->metadata;\
468 default: av_assert0(0);\
471 SET_DICT(type_in, meta_in, ic, idx_in);
472 SET_DICT(type_out, meta_out, oc, idx_out);
475 if (type_in ==
's') {
484 av_log(NULL,
AV_LOG_FATAL,
"Stream specifier %s does not match any streams.\n", istream_spec);
489 if (type_out ==
's') {
508 struct tm time = *gmtime((time_t*)&recording_timestamp);
509 strftime(buf,
sizeof(buf),
"creation_time=%FT%T%z", &time);
513 "tag instead.\n", opt);
520 const char *codec_string = encoder ?
"encoder" :
"decoder";
532 codec_string, codec->
name, desc->
name);
539 if (codec->
type != type) {
548 char *codec_name = NULL;
564 char *next, *codec_tag = NULL;
570 char *framerate = NULL;
588 uint32_t
tag = strtol(codec_tag, &next, 0);
639 char *canvas_size = NULL;
663 (strchr(filename,
':') == NULL || filename[1] ==
':' ||
667 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
670 signal(SIGINT, SIG_DFL);
740 if (!strcmp(filename,
"-"))
744 strcmp(filename,
"/dev/stdin");
760 if (file_iformat && file_iformat->
priv_class &&
771 if (file_iformat && file_iformat->
priv_class &&
872 "input file #%d (%s) is not a decoding option.\n", e->
key,
879 "input file #%d (%s) has not been used for any stream. The most "
880 "likely reason is either wrong type (e.g. a video option with "
881 "no video streams) or that it is a private option of some decoder "
882 "which was not actually used for any stream.\n", e->
key,
898 for (i = 0; i < orig_nb_streams; i++)
916 while ((c =
avio_r8(s)) && c !=
'\n')
928 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
937 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
938 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
942 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
943 i != 1 ?
"" :
"/.avconv", preset_name);
952 char *codec_name = NULL;
959 }
else if (!strcmp(codec_name,
"copy"))
972 char *bsf = NULL, *next, *codec_tag = NULL;
1005 if (!buf[0] || buf[0] ==
'#') {
1009 if (!(arg = strchr(buf,
'='))) {
1021 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1037 av_log(NULL,
AV_LOG_WARNING,
"Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n");
1047 if (next = strchr(bsf,
','))
1054 bsfc_prev->
next = bsfc;
1064 uint32_t
tag = strtol(codec_tag, &next, 0);
1088 if (source_index >= 0) {
1101 const char *p = str;
1133 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1148 char *
filter = NULL, *filter_script = NULL;
1153 if (filter_script && filter) {
1173 char *frame_rate = NULL, *frame_aspect_ratio = NULL;
1177 video_enc = st->
codec;
1186 if (frame_aspect_ratio) {
1189 q.
num <= 0 || q.
den <= 0) {
1197 const char *p = NULL;
1199 char *frame_pix_fmt = NULL;
1200 char *intra_matrix = NULL, *inter_matrix = NULL;
1212 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1214 if (!*++frame_pix_fmt)
1215 frame_pix_fmt = NULL;
1243 for (i = 0; p; i++) {
1245 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1321 audio_enc = st->
codec;
1325 char *sample_fmt = NULL;
1370 av_log(NULL,
AV_LOG_FATAL,
"Data stream encoding not supported yet (only streamcopy)\n");
1393 subtitle_enc = st->
codec;
1421 p = strchr(idx_str,
':');
1424 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1455 if (in_ch->
end < ts_off)
1457 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1464 out_ch->id = in_ch->
id;
1466 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1467 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1539 "which is fed from a complex filtergraph. Filtering and streamcopy "
1605 if (!strcmp(filename,
"-"))
1641 if (!strcmp(file_oformat->
name,
"ffm") &&
1685 int area = 0, idx = -1;
1707 int channels = 0, idx = -1;
1755 "in any defined filter graph, or was already used elsewhere.\n", map->
linklabel);
1852 "output file #%d (%s) is not an encoding option.\n", e->
key,
1859 if (!strcmp(e->
key,
"gop_timecode"))
1863 "output file #%d (%s) has not been used for any stream. The most "
1864 "likely reason is either wrong type (e.g. a video option with "
1865 "no video streams) or that it is a private option of some encoder "
1866 "which was not actually used for any stream.\n", e->
key,
1906 av_log(NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1910 in_file_index >= 0 ?
1955 const char *stream_spec;
1982 av_log(NULL,
AV_LOG_FATAL,
"Invalid chapter index %d in metadata specifier.\n", index);
2002 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
2004 if (!strncmp(arg,
"pal-", 4)) {
2007 }
else if (!strncmp(arg,
"ntsc-", 5)) {
2010 }
else if (!strncmp(arg,
"film-", 5)) {
2026 }
else if ((fr == 29970) || (fr == 23976)) {
2040 av_log(NULL,
AV_LOG_FATAL,
"Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n");
2041 av_log(NULL,
AV_LOG_FATAL,
"Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n");
2046 if (!strcmp(arg,
"vcd")) {
2074 }
else if (!strcmp(arg,
"svcd")) {
2096 }
else if (!strcmp(arg,
"dvd")) {
2118 }
else if (!strncmp(arg,
"dv", 2)) {
2123 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
2124 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
2147 time_t today2 = time(NULL);
2148 struct tm *today = localtime(&today2);
2150 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
2197 char filename[1000],
line[1000], tmp_line[1000];
2198 const char *codec_name = NULL;
2204 if (!(f =
get_preset_file(filename,
sizeof(filename), arg, *opt ==
'f', codec_name))) {
2205 if(!strncmp(arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
2212 while (fgets(line,
sizeof(line), f)) {
2213 char *key = tmp_line, *
value, *endptr;
2215 if (strcspn(line,
"#\n\r") == 0)
2217 av_strlcpy(tmp_line, line,
sizeof(tmp_line));
2230 av_log(NULL,
AV_LOG_FATAL,
"%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n",
2231 filename, line, key, value);
2253 if(!strcmp(opt,
"b")){
2267 if(!strcmp(opt,
"qscale")){
2280 if(!strcmp(opt,
"profile")){
2327 char layout_str[32];
2330 int ret, channels, ac_str_size;
2338 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
2345 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
2346 stream_str = strchr(opt,
':');
2347 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2396 int show_advanced = 0, show_avoptions = 0;
2399 if (!strcmp(opt,
"long"))
2401 else if (!strcmp(opt,
"full"))
2402 show_advanced = show_avoptions = 1;
2409 printf(
"Getting help:\n"
2410 " -h -- print basic options\n"
2411 " -h long -- print more options\n"
2412 " -h full -- print all options (including all format and codec specific options, very long)\n"
2413 " See man %s for detailed description of the options.\n"
2420 "instead of just one file:",
2448 if (show_avoptions) {
2490 "%s.\n", inout, g->
arg);
2514 memset(&octx, 0,
sizeof(octx));
2559 if (!strcmp(arg,
"-"))
2571 #define OFFSET(x) offsetof(OptionsContext, x)
2577 "force format",
"fmt" },
2579 "overwrite output files" },
2581 "do not overwrite output files" },
2584 "codec name",
"codec" },
2587 "codec name",
"codec" },
2590 "preset name",
"preset" },
2593 "set input stream mapping",
2594 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2596 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
2599 "set metadata information of outfile from infile",
2600 "outfile[,metadata]:infile[,metadata]" },
2603 "set chapters mapping",
"input_file_index" },
2605 "record or transcode \"duration\" seconds of audio/video",
2608 "record or transcode stop time",
"time_stop" },
2610 "set the limit file size in bytes",
"limit_size" },
2613 "set the start time offset",
"time_off" },
2616 "set the input ts offset",
"time_off" },
2619 "set the input ts scale",
"scale" },
2621 "set the recording timestamp ('now' to set the current time)",
"time" },
2623 "add metadata",
"string=string" },
2626 "set the number of data frames to record",
"number" },
2628 "add timings for benchmarking" },
2630 "add timings for each task" },
2632 "write program-readable progress information",
"url" },
2634 "enable or disable interaction on standard input" },
2636 "set max runtime in seconds",
"limit" },
2638 "dump each input packet" },
2640 "when dumping packets, also dump the payload" },
2643 "read input at native frame rate",
"" },
2645 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2646 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2648 "video sync method",
"" },
2650 "audio sync method",
"" },
2652 "audio drift threshold",
"threshold" },
2654 "copy timestamps" },
2656 "copy input stream time base when stream copying",
"mode" },
2659 "finish encoding within shortest input" },
2664 "timestamp discontinuity delta threshold",
"threshold" },
2666 "timestamp error delta threshold",
"threshold" },
2668 "exit on error",
"error" },
2671 "copy initial non-keyframes" },
2673 "copy or discard frames before start time" },
2675 "set the number of frames to record",
"number" },
2678 "force codec tag/fourcc",
"fourcc/tag" },
2681 "use fixed quality scale (VBR)",
"q" },
2684 "use fixed quality scale (VBR)",
"q" },
2686 "set profile",
"profile" },
2688 "set stream filtergraph",
"filter_graph" },
2690 "read stream filtergraph description from a file",
"filename" },
2692 "reinit filtergraph on input parameter changes",
"" },
2694 "create a complex filtergraph",
"graph_description" },
2696 "create a complex filtergraph",
"graph_description" },
2698 "read complex filtergraph description from a file",
"filename" },
2700 "print progress report during encoding", },
2703 "add an attachment to the output file",
"filename" },
2706 "extract an attachment into a file",
"filename" },
2708 "print timestamp debugging info" },
2712 "set the number of video frames to record",
"number" },
2715 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2718 "set frame size (WxH or abbreviation)",
"size" },
2721 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2724 "set pixel format",
"format" },
2726 "set the number of bits per raw sample",
"number" },
2728 "deprecated use -g 1" },
2732 "discard threshold",
"n" },
2735 "rate control override for specific intervals",
"override" },
2738 "force video codec ('copy' to copy stream)",
"codec" },
2744 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
2746 "select the pass number (1 to 3)",
"n" },
2749 "select two pass log file name prefix",
"prefix" },
2751 "this option is deprecated, use the yadif filter instead" },
2753 "calculate PSNR of compressed frames" },
2755 "dump video coding statistics to file" },
2757 "dump video coding statistics to file",
"file" },
2759 "set video filters",
"filter_graph" },
2762 "specify intra matrix coeffs",
"matrix" },
2765 "specify inter matrix coeffs",
"matrix" },
2768 "top=1/bottom=0/auto=-1 field first",
"" },
2770 "intra_dc_precision",
"precision" },
2773 "force video tag/fourcc",
"fourcc/tag" },
2775 "show QP histogram" },
2778 "force the selected framerate, disable the best supported framerate selection" },
2781 "set the value of an outfile streamid",
"streamIndex:value" },
2784 "force key frames at specified timestamps",
"timestamps" },
2786 "video bitrate (please use -b:v)",
"bitrate" },
2790 "set the number of audio frames to record",
"number" },
2792 "set audio quality (codec-specific)",
"quality", },
2795 "set audio sampling rate (in Hz)",
"rate" },
2798 "set number of audio channels",
"channels" },
2803 "force audio codec ('copy' to copy stream)",
"codec" },
2806 "force audio tag/fourcc",
"fourcc/tag" },
2808 "change audio volume (256=normal)" ,
"volume" },
2811 "set sample format",
"format" },
2814 "set channel layout",
"layout" },
2816 "set audio filters",
"filter_graph" },
2818 "set the maximum number of channels to try to guess the channel layout" },
2822 "disable subtitle" },
2824 "force subtitle codec ('copy' to copy stream)",
"codec" },
2826 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2828 "fix subtitles duration" },
2830 "set canvas size (WxH or abbreviation)",
"size" },
2834 "deprecated, use -channel",
"channel" },
2836 "deprecated, use -standard",
"standard" },
2841 "set the maximum demux-decode delay",
"seconds" },
2843 "set the initial demux-decode delay",
"seconds" },
2845 "override the options from ffserver",
"" },
2848 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2850 "deprecated",
"audio bitstream_filters" },
2852 "deprecated",
"video bitstream_filters" },
2855 "set the audio options to the indicated preset",
"preset" },
2857 "set the video options to the indicated preset",
"preset" },
2859 "set the subtitle options to the indicated preset",
"preset" },
2861 "set options from indicated preset file",
"filename" },
2864 "force data codec ('copy' to copy stream)",
"codec" },