Go to the documentation of this file.
25 #if HAVE_SYS_RESOURCE_H
27 #include <sys/resource.h>
56 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
58 #define SPECIFIER_OPT_FMT_str "%s"
59 #define SPECIFIER_OPT_FMT_i "%i"
60 #define SPECIFIER_OPT_FMT_i64 "%"PRId64
61 #define SPECIFIER_OPT_FMT_ui64 "%"PRIu64
62 #define SPECIFIER_OPT_FMT_f "%f"
63 #define SPECIFIER_OPT_FMT_dbl "%lf"
113 #define WARN_MULTIPLE_OPT_USAGE(name, type, so, st)\
115 char namestr[128] = "";\
116 const char *spec = so->specifier && so->specifier[0] ? so->specifier : "";\
117 for (i = 0; opt_name_##name[i]; i++)\
118 av_strlcatf(namestr, sizeof(namestr), "-%s%s", opt_name_##name[i], opt_name_##name[i+1] ? (opt_name_##name[i+2] ? ", " : " or ") : "");\
119 av_log(NULL, AV_LOG_WARNING, "Multiple %s options specified for stream %d, only the last option '-%s%s%s "SPECIFIER_OPT_FMT_##type"' will be used.\n",\
120 namestr, st->index, opt_name_##name[0], spec[0] ? ":" : "", spec, so->u.type);\
123 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
125 int i, ret, matches = 0;\
127 for (i = 0; i < o->nb_ ## name; i++) {\
128 char *spec = o->name[i].specifier;\
129 if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0) {\
130 outvar = o->name[i].u.type;\
137 WARN_MULTIPLE_OPT_USAGE(name, type, so, st);\
140 #define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)\
143 for (i = 0; i < o->nb_ ## name; i++) {\
144 char *spec = o->name[i].specifier;\
145 if (!strcmp(spec, mediatype))\
146 outvar = o->name[i].u.type;\
200 void *dst = (uint8_t*)o + po->
u.
off;
204 int i, *count = (
int*)(so + 1);
205 for (
i = 0;
i < *count;
i++) {
227 memset(o, 0,
sizeof(*o));
245 printf(
"Hardware acceleration methods:\n");
260 char *p = strchr(e->
key,
':');
278 else if (!is_global) {
286 " use a string argument as described in the manual.\n");
296 int64_t self_start_time, ref_start_time, self_seek_start, ref_seek_start;
297 int start_times_set = 1;
299 if (self->input_sync_ref == -1 || self->input_sync_ref ==
i)
continue;
300 if (self->input_sync_ref >=
nb_input_files || self->input_sync_ref < -1) {
301 av_log(
NULL,
AV_LOG_FATAL,
"-isync for input %d references non-existent input %d.\n",
i, self->input_sync_ref);
311 if (
ref->input_sync_ref != -1 &&
ref->input_sync_ref != self->input_sync_ref) {
312 av_log(
NULL,
AV_LOG_ERROR,
"-isync for input %d references a resynced input %d. Sync not set.\n",
i, self->input_sync_ref);
317 self_start_time =
self->ctx->start_time_realtime;
318 ref_start_time =
ref->ctx->start_time_realtime;
320 self_start_time =
self->ctx->start_time;
321 ref_start_time =
ref->ctx->start_time;
326 if (start_times_set) {
327 self_seek_start =
self->start_time ==
AV_NOPTS_VALUE ? 0 :
self->start_time;
330 adjustment = (self_start_time - ref_start_time) + !
copy_ts*(self_seek_start - ref_seek_start) +
ref->input_ts_offset;
332 self->ts_offset += adjustment;
334 av_log(
NULL,
AV_LOG_INFO,
"Adjusted ts offset for Input #%d by %"PRId64
" us to sync with Input #%d.\n",
i, adjustment, self->input_sync_ref);
336 av_log(
NULL,
AV_LOG_INFO,
"Unable to identify start times for Inputs #%d and %d both. No sync adjustment made.\n",
i, self->input_sync_ref);
364 const AVClass *pclass = &
class;
373 if (user_stats_period <= 0) {
408 static int opt_map(
void *optctx,
const char *opt,
const char *
arg)
412 int i, negative = 0, file_idx, disabled = 0;
413 int sync_file_idx = -1, sync_stream_idx = 0;
427 if (sync = strchr(
map,
',')) {
429 sync_file_idx = strtol(sync + 1, &sync, 0);
444 "match any streams.\n",
arg);
457 const char *
c =
map + 1;
466 if (allow_unused = strchr(
map,
'?'))
468 file_idx = strtol(
map, &p, 0);
480 *p ==
':' ? p + 1 : p) > 0)
486 *p ==
':' ? p + 1 : p) <= 0)
498 if (sync_file_idx >= 0) {
511 }
else if (disabled) {
513 "To ignore this, add a trailing '?' to the map.\n",
arg);
517 "To ignore this, add a trailing '?' to the map.\n",
arg);
560 n = sscanf(
arg,
"%d.%d.%d:%d.%d",
564 if (n != 3 && n != 5) {
566 "[file.stream.channel|-1][:syncfile:syncstream]\n");
592 if (allow_unused = strchr(mapchan,
'?'))
601 "To ignore this, add a trailing '?' to the map_channel.\n",
619 static int opt_vaapi_device(
void *optctx,
const char *opt,
const char *
arg)
621 const char *prefix =
"vaapi:";
634 static int opt_qsv_device(
void *optctx,
const char *opt,
const char *
arg)
636 const char *prefix =
"qsv=__qsv_device:hw_any,child_device=";
652 if (!strcmp(
arg,
"list")) {
654 printf(
"Supported hardware device types:\n");
694 if (*(++
arg) && *
arg !=
':') {
698 *stream_spec = *
arg ==
':' ?
arg + 1 :
"";
718 char type_in, type_out;
719 const char *istream_spec =
NULL, *ostream_spec =
NULL;
720 int idx_in = 0, idx_out = 0;
726 if (type_out ==
'g' || !*outspec)
728 if (type_out ==
's' || !*outspec)
730 if (type_out ==
'c' || !*outspec)
735 if (type_in ==
'g' || type_out ==
'g')
737 if (type_in ==
's' || type_out ==
's')
739 if (type_in ==
'c' || type_out ==
'c')
746 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
747 if ((index) < 0 || (index) >= (nb_elems)) {\
748 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
753 #define SET_DICT(type, meta, context, index)\
756 meta = &context->metadata;\
759 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
760 meta = &context->chapters[index]->metadata;\
763 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
764 meta = &context->programs[index]->metadata;\
768 default: av_assert0(0);\
771 SET_DICT(type_in, meta_in, ic, idx_in);
772 SET_DICT(type_out, meta_out, oc, idx_out);
775 if (type_in ==
's') {
789 if (type_out ==
's') {
808 struct tm time = *gmtime((time_t*)&recording_timestamp);
809 if (!strftime(buf,
sizeof(buf),
"creation_time=%Y-%m-%dT%H:%M:%S%z", &time))
814 "tag instead.\n", opt);
821 const char *
codec_string = encoder ?
"encoder" :
"decoder";
849 char *codec_name =
NULL;
873 const char *hwaccel =
NULL;
874 char *hwaccel_output_format =
NULL;
875 char *codec_tag =
NULL;
877 char *discard_str =
NULL;
900 uint32_t
tag = strtol(codec_tag, &next, 0);
974 hwaccel_output_format, ic, st);
976 if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel,
"cuvid")) {
978 "WARNING: defaulting hwaccel_output_format to cuda for compatibility "
979 "with old commandlines. This behaviour is DEPRECATED and will be removed "
980 "in the future. Please explicitly set \"-hwaccel_output_format cuda\".\n");
982 }
else if (!hwaccel_output_format && hwaccel && !strcmp(hwaccel,
"qsv")) {
984 "WARNING: defaulting hwaccel_output_format to qsv for compatibility "
985 "with old commandlines. This behaviour is DEPRECATED and will be removed "
986 "in the future. Please explicitly set \"-hwaccel_output_format qsv\".\n");
988 }
else if (hwaccel_output_format) {
992 "format: %s", hwaccel_output_format);
1000 if (!strcmp(hwaccel,
"nvdec") || !strcmp(hwaccel,
"cuvid"))
1003 if (!strcmp(hwaccel,
"none"))
1005 else if (!strcmp(hwaccel,
"auto"))
1030 if (hwaccel_device) {
1046 char *canvas_size =
NULL;
1078 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
1083 if (proto_name && !strcmp(proto_name,
"file") &&
avio_check(filename, 0) == 0) {
1085 fprintf(stderr,
"File '%s' already exists. Overwrite? [y/N] ", filename);
1088 signal(SIGINT, SIG_DFL);
1102 if (proto_name && !strcmp(proto_name,
"file")) {
1107 if (!strcmp(filename, file->
ctx->
url)) {
1128 filename = e->
value;
1160 char * data_codec_name =
NULL;
1161 int scan_all_pmts_set = 0;
1185 if (!strcmp(filename,
"-"))
1189 strcmp(filename,
"/dev/stdin");
1246 if (data_codec_name)
1261 scan_all_pmts_set = 1;
1271 if (scan_all_pmts_set)
1288 for (
i = 0;
i < orig_nb_streams;
i++)
1327 int64_t seek_timestamp = timestamp;
1330 int dts_heuristic = 0;
1338 if (dts_heuristic) {
1372 if (
f->readrate < 0.0f) {
1376 if (
f->readrate &&
f->rate_emu) {
1411 "input file #%d (%s) is not a decoding option.\n", e->
key,
1418 "input file #%d (%s) has not been used for any stream. The most "
1419 "likely reason is either wrong type (e.g. a video option with "
1420 "no video streams) or that it is a private option of some decoder "
1421 "which was not actually used for any stream.\n", e->
key,
1459 char filename[1000];
1460 char *env_avconv_datadir =
getenv_utf8(
"AVCONV_DATADIR");
1462 const char *
base[3] = { env_avconv_datadir,
1471 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset",
base[
i],
1472 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
1476 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset",
base[
i],
1477 i != 1 ?
"" :
"/.avconv", preset_name);
1489 char *codec_name =
NULL;
1499 "output stream #%d:%d. Default encoder for format %s (codec %s) is "
1500 "probably disabled. Please choose an encoder manually.\n",
1505 }
else if (!strcmp(codec_name,
"copy"))
1506 ost->stream_copy = 1;
1511 ost->encoding_needed = !
ost->stream_copy;
1514 ost->stream_copy = 1;
1515 ost->encoding_needed = 0;
1526 const char *bsfs =
NULL, *time_base =
NULL;
1527 char *next, *codec_tag =
NULL;
1555 if (!
ost->enc_ctx) {
1559 ost->enc_ctx->codec_type =
type;
1562 if (!
ost->ref_par) {
1568 if (!
ost->filtered_frame)
1590 if (!buf[0] || buf[0] ==
'#')
1592 if (!(
arg = strchr(buf,
'='))) {
1598 }
while (!
s->eof_reached);
1604 "Preset %s specified for stream %d:%d, but could not be opened.\n",
1620 q.
num <= 0 || q.
den <= 0) {
1635 ost->enc_timebase = q;
1638 ost->max_frames = INT64_MAX;
1648 ost->copy_prior_start = -1;
1652 if (bsfs && *bsfs) {
1662 uint32_t
tag = strtol(codec_tag, &next, 0);
1666 ost->enc_ctx->codec_tag =
tag;
1678 ost->max_muxing_queue_size = 128;
1681 ost->muxing_queue_data_size = 0;
1683 ost->muxing_queue_data_threshold = 50*1024*1024;
1698 ost->source_index = source_index;
1699 if (source_index >= 0) {
1707 if (!
ost->muxing_queue)
1711 ost->copy_initial_nonkeyframes, oc, st);
1719 const char *p =
str;
1764 if (
ost->filters_script &&
ost->filters) {
1770 if (
ost->filters_script)
1772 else if (
ost->filters)
1782 if (
ost->filters_script ||
ost->filters) {
1784 "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
1785 "Filtering and streamcopy cannot be used together.\n",
1786 ost->filters ?
"Filtergraph" :
"Filtergraph script",
1787 ost->filters ?
ost->filters :
ost->filters_script,
1798 char *frame_rate =
NULL, *max_frame_rate =
NULL, *frame_aspect_ratio =
NULL;
1802 video_enc =
ost->enc_ctx;
1816 if (frame_rate && max_frame_rate) {
1821 if ((frame_rate || max_frame_rate) &&
1823 av_log(
NULL,
AV_LOG_ERROR,
"Using -vsync passthrough and -r/-fpsmax can produce invalid output files\n");
1826 if (frame_aspect_ratio) {
1829 q.
num <= 0 || q.
den <= 0) {
1833 ost->frame_aspect_ratio = q;
1839 if (!
ost->stream_copy) {
1840 const char *p =
NULL;
1842 char *frame_pix_fmt =
NULL;
1843 char *intra_matrix =
NULL, *inter_matrix =
NULL;
1844 char *chroma_intra_matrix =
NULL;
1855 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
1856 ost->keep_pix_fmt = 1;
1857 if (!*++frame_pix_fmt)
1858 frame_pix_fmt =
NULL;
1875 if (chroma_intra_matrix) {
1894 for (
i = 0; p;
i++) {
1896 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1940 if (
ost->logfile_prefix &&
1945 char logfilename[1024];
1948 snprintf(logfilename,
sizeof(logfilename),
"%s-%d.log",
1949 ost->logfile_prefix ?
ost->logfile_prefix :
1952 if (!strcmp(
ost->enc->name,
"libx264")) {
1956 char *logbuffer =
read_file(logfilename);
1969 "Cannot write log file '%s' for pass-1 encoding: %s\n",
1970 logfilename, strerror(errno));
1979 if (
ost->forced_keyframes)
1984 ost->top_field_first = -1;
2006 if (
ifile->nb_streams == 1 &&
ifile->input_ts_offset == 0)
2021 if (!
ost->last_frame)
2025 if (
ost->stream_copy)
2041 audio_enc =
ost->enc_ctx;
2047 if (!
ost->stream_copy) {
2050 char *sample_fmt =
NULL;
2061 #if FF_API_OLD_CHANNEL_LAYOUT
2070 #if FF_API_OLD_CHANNEL_LAYOUT
2098 if ((
map->ofile_idx == -1 ||
ost->file_index ==
map->ofile_idx) &&
2099 (
map->ostream_idx == -1 ||
ost->st->
index ==
map->ostream_idx)) {
2102 if (
map->channel_idx == -1) {
2104 }
else if (
ost->source_index < 0) {
2114 ost->audio_channels_mapped + 1,
2115 sizeof(*
ost->audio_channels_map)
2119 ost->audio_channels_map[
ost->audio_channels_mapped++] =
map->channel_idx;
2125 if (
ost->stream_copy)
2136 if (!
ost->stream_copy) {
2149 if (!
ost->stream_copy) {
2160 ost->stream_copy = 1;
2173 subtitle_enc =
ost->enc_ctx;
2177 if (!
ost->stream_copy) {
2199 p = strchr(idx_str,
':');
2202 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
2225 for (
i = 0;
i <
is->nb_chapters;
i++) {
2230 int64_t rt = (
ofile->recording_time == INT64_MAX) ? INT64_MAX :
2234 if (in_ch->
end < ts_off)
2236 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
2243 out_ch->id = in_ch->
id;
2245 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
2246 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
2260 int have_manual = 0;
2270 if (
ost->source_index >= 0) {
2287 #if LIBAVFORMAT_VERSION_MAJOR >= 60
2315 have_default[
type] = 1;
2327 switch (ofilter->
type) {
2336 ost->filter = ofilter;
2341 if (
ost->stream_copy) {
2343 "which is fed from a complex filtergraph. Filtering and streamcopy "
2344 "cannot be used together.\n",
ost->file_index,
ost->
index);
2348 if (
ost->avfilter && (
ost->filters ||
ost->filters_script)) {
2349 const char *opt =
ost->filters ?
"-vf/-af/-filter" :
"-filter_script";
2351 "%s '%s' was specified through the %s option "
2352 "for output stream %d:%d, which is fed from a complex filtergraph.\n"
2353 "%s and -filter_complex cannot be used together for the same stream.\n",
2354 ost->filters ?
"Filtergraph" :
"Filtergraph script",
2355 ost->filters ?
ost->filters :
ost->filters_script,
2388 if (!
ost->enc->ch_layouts) {
2396 for (
i = 0;
ost->enc->ch_layouts[
i].nb_channels;
i++) {
2397 if (
ost->enc->ch_layouts[
i].nb_channels ==
ost->enc_ctx->ch_layout.nb_channels)
2400 if (
ost->enc->ch_layouts[
i].nb_channels) {
2447 if (!strcmp(filename,
"-"))
2476 switch (ofilter->
type) {
2491 int best_score = 0, idx = -1;
2495 int file_best_score = 0, file_best_idx = -1;
2496 for (
i = 0;
i <
ifile->nb_streams;
i++) {
2507 score > file_best_score) {
2510 file_best_score = score;
2511 file_best_idx =
ifile->ist_index +
i;
2514 if (file_best_idx >= 0) {
2517 if (file_best_score > best_score) {
2518 best_score = file_best_score;
2519 idx = file_best_idx;
2529 int best_score = 0, idx = -1;
2532 int file_best_score = 0, file_best_idx = -1;
2533 for (
i = 0;
i <
ifile->nb_streams;
i++) {
2542 score > file_best_score) {
2543 file_best_score = score;
2544 file_best_idx =
ifile->ist_index +
i;
2547 if (file_best_idx >= 0) {
2549 if (file_best_score > best_score) {
2550 best_score = file_best_score;
2551 idx = file_best_idx;
2569 int input_props = 0, output_props = 0;
2574 if (input_descriptor)
2576 if (output_descriptor)
2579 input_props & output_props ||
2581 input_descriptor && output_descriptor &&
2582 (!input_descriptor->
props ||
2583 !output_descriptor->
props)) {
2607 if (
map->linklabel) {
2616 if (
out && !strcmp(
out->name,
map->linklabel)) {
2625 "in any defined filter graph, or was already used elsewhere.\n",
map->linklabel);
2635 map->file_index,
map->stream_index);
2661 "Cannot map stream #%d:%d - unsupported type.\n",
2662 map->file_index,
map->stream_index);
2665 "If you want unsupported types ignored instead "
2666 "of failing, please use the -ignore_unknown option\n"
2667 "If you want them copied, please use -copy_unknown\n");
2673 +
map->sync_stream_index];
2681 uint8_t *attachment;
2705 ost->stream_copy = 0;
2744 "output file #%d (%s) is not an encoding option.\n", e->
key,
2751 if (!strcmp(e->
key,
"gop_timecode"))
2755 "output file #%d (%s) has not been used for any stream. The most "
2756 "likely reason is either wrong type (e.g. a video option with "
2757 "no video streams) or that it is a private option of some encoder "
2758 "which was not actually used for any stream.\n", e->
key,
2767 if (
ost->encoding_needed &&
ost->source_index >= 0) {
2777 "Error initializing a simple filtergraph between streams "
2783 }
else if (
ost->stream_copy &&
ost->source_index >= 0) {
2791 switch (
ost->enc_ctx->codec_type) {
2793 f->frame_rate =
ost->frame_rate;
2794 f->width =
ost->enc_ctx->width;
2795 f->height =
ost->enc_ctx->height;
2797 f->format =
ost->enc_ctx->pix_fmt;
2799 f->formats =
ost->enc->pix_fmts;
2804 f->format =
ost->enc_ctx->sample_fmt;
2806 f->formats =
ost->enc->sample_fmts;
2808 if (
ost->enc_ctx->sample_rate) {
2809 f->sample_rate =
ost->enc_ctx->sample_rate;
2811 f->sample_rates =
ost->enc->supported_samplerates;
2813 if (
ost->enc_ctx->ch_layout.nb_channels) {
2815 }
else if (
ost->enc->ch_layouts) {
2816 f->ch_layouts =
ost->enc->ch_layouts;
2833 "No input streams but output needs an input stream\n");
2862 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
2866 in_file_index >= 0 ?
2921 const char *to_dealloc = p2;
2936 if (!strcmp(
key,
"program_num"))
2937 progid = strtol(p2,
NULL, 0);
2947 const char *to_dealloc = p2;
2956 "No '=' character in program string %s.\n",
2964 if (!strcmp(
key,
"title")) {
2966 }
else if (!strcmp(
key,
"program_num")) {
2967 }
else if (!strcmp(
key,
"st")) {
2968 int st_num = strtol(p2,
NULL, 0);
2983 const char *stream_spec;
3003 ost->rotate_overridden = 1;
3004 ost->rotate_override_value = theta;
3053 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
3055 if (!strncmp(
arg,
"pal-", 4)) {
3058 }
else if (!strncmp(
arg,
"ntsc-", 5)) {
3061 }
else if (!strncmp(
arg,
"film-", 5)) {
3078 }
else if ((fr == 29970) || (fr == 23976)) {
3098 if (!strcmp(
arg,
"vcd")) {
3125 }
else if (!strcmp(
arg,
"svcd")) {
3147 }
else if (!strcmp(
arg,
"dvd")) {
3169 }
else if (!strncmp(
arg,
"dv", 2)) {
3175 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
3202 time_t today2 = time(
NULL);
3203 struct tm *today = localtime(&today2);
3210 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
3257 char filename[1000],
line[1000], tmp_line[1000];
3258 const char *codec_name =
NULL;
3265 if(!strncmp(
arg,
"libx264-lossless", strlen(
"libx264-lossless"))){
3273 char *
key = tmp_line, *
value, *endptr;
3275 if (strcspn(
line,
"#\n\r") == 0)
3317 if(!strcmp(opt,
"ab")){
3320 }
else if(!strcmp(opt,
"b")){
3334 if(!strcmp(opt,
"qscale")){
3349 if(!strcmp(opt,
"profile")){
3431 int show_advanced = 0, show_avoptions = 0;
3434 if (!strcmp(opt,
"long"))
3436 else if (!strcmp(opt,
"full"))
3437 show_advanced = show_avoptions = 1;
3445 " -h -- print basic options\n"
3446 " -h long -- print more options\n"
3447 " -h full -- print all options (including all format and codec specific options, very long)\n"
3448 " -h type=name -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocol\n"
3449 " See man %s for detailed description of the options.\n"
3456 "instead of just one file):",
3484 if (show_avoptions) {
3491 #if CONFIG_SWRESAMPLE
3513 [GROUP_INFILE] = {
"input url",
"i",
OPT_INPUT },
3531 "%s.\n", inout,
g->arg);
3556 memset(&octx, 0,
sizeof(octx));
3610 static int opt_progress(
void *optctx,
const char *opt,
const char *
arg)
3615 if (!strcmp(
arg,
"-"))
3631 struct rlimit rl = { lim, lim + 1 };
3632 if (setrlimit(RLIMIT_CPU, &rl))
3633 perror(
"setrlimit");
3640 #define OFFSET(x) offsetof(OptionsContext, x)
3646 "force format",
"fmt" },
3648 "overwrite output files" },
3650 "never overwrite output files" },
3652 "Ignore unknown stream types" },
3654 "Copy unknown stream types" },
3656 "allow recasting stream type in order to force a decoder of different media type" },
3659 "codec name",
"codec" },
3662 "codec name",
"codec" },
3665 "preset name",
"preset" },
3668 "set input stream mapping",
3669 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
3671 "map an audio channel from one stream to another",
"file.stream.channel[:syncfile.syncstream]" },
3674 "set metadata information of outfile from infile",
3675 "outfile[,metadata]:infile[,metadata]" },
3678 "set chapters mapping",
"input_file_index" },
3681 "record or transcode \"duration\" seconds of audio/video",
3684 "record or transcode stop time",
"time_stop" },
3686 "set the limit file size in bytes",
"limit_size" },
3689 "set the start time offset",
"time_off" },
3692 "set the start time offset relative to EOF",
"time_off" },
3695 "enable/disable seeking by timestamp with -ss" },
3698 "enable/disable accurate seeking with -ss" },
3701 "Indicate the input index for sync reference",
"sync ref" },
3704 "set the input ts offset",
"time_off" },
3707 "set the input ts scale",
"scale" },
3709 "set the recording timestamp ('now' to set the current time)",
"time" },
3711 "add metadata",
"string=string" },
3713 "add program with specified streams",
"title=string:st=number..." },
3716 "set the number of data frames to output",
"number" },
3718 "add timings for benchmarking" },
3720 "add timings for each task" },
3722 "write program-readable progress information",
"url" },
3724 "enable or disable interaction on standard input" },
3726 "set max runtime in seconds in CPU user time",
"limit" },
3728 "dump each input packet" },
3730 "when dumping packets, also dump the payload" },
3733 "read input at native frame rate; equivalent to -readrate 1",
"" },
3736 "read input at specified rate",
"speed" },
3738 "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
3739 "with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")",
"type" },
3741 "set video sync method globally; deprecated, use -fps_mode",
"" },
3743 "frame drop threshold",
"" },
3745 "audio sync method",
"" },
3747 "audio drift threshold",
"threshold" },
3749 "copy timestamps" },
3751 "shift input timestamps to start at 0 when using copyts" },
3753 "copy input stream time base when stream copying",
"mode" },
3756 "finish encoding within shortest input" },
3764 "timestamp discontinuity delta threshold",
"threshold" },
3766 "timestamp error delta threshold",
"threshold" },
3768 "exit on error",
"error" },
3770 "abort on the specified condition flags",
"flags" },
3773 "copy initial non-keyframes" },
3775 "copy or discard frames before start time" },
3777 "set the number of frames to output",
"number" },
3780 "force codec tag/fourcc",
"fourcc/tag" },
3783 "use fixed quality scale (VBR)",
"q" },
3786 "use fixed quality scale (VBR)",
"q" },
3788 "set profile",
"profile" },
3790 "set stream filtergraph",
"filter_graph" },
3792 "number of non-complex filter threads" },
3794 "read stream filtergraph description from a file",
"filename" },
3796 "reinit filtergraph on input parameter changes",
"" },
3798 "create a complex filtergraph",
"graph_description" },
3800 "number of threads for -filter_complex" },
3802 "create a complex filtergraph",
"graph_description" },
3804 "read complex filtergraph description from a file",
"filename" },
3806 "enable automatic conversion filters globally" },
3808 "print progress report during encoding", },
3810 "set the period at which ffmpeg updates stats and -progress output",
"time" },
3813 "add an attachment to the output file",
"filename" },
3816 "extract an attachment into a file",
"filename" },
3818 OPT_OFFSET, { .off =
OFFSET(
loop) },
"set number of times input stream shall be looped",
"loop count" },
3820 "print timestamp debugging info" },
3822 "ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.",
"maximum error rate" },
3828 "disposition",
"" },
3830 { .off =
OFFSET(thread_queue_size) },
3831 "set the maximum number of queued packets from the demuxer" },
3833 "read and decode the streams to fill missing information with heuristics" },
3835 { .off =
OFFSET(bits_per_raw_sample) },
3836 "set the number of bits per raw sample",
"number" },
3840 "set the number of video frames to output",
"number" },
3843 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
3846 "set max frame rate (Hz value, fraction or abbreviation)",
"rate" },
3849 "set frame size (WxH or abbreviation)",
"size" },
3852 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
3855 "set pixel format",
"format" },
3860 "rate control override for specific intervals",
"override" },
3863 "force video codec ('copy' to copy stream)",
"codec" },
3865 "set initial TimeCode value.",
"hh:mm:ss[:;.]ff" },
3867 "select the pass number (1 to 3)",
"n" },
3870 "select two pass log file name prefix",
"prefix" },
3872 "calculate PSNR of compressed frames" },
3874 "dump video coding statistics to file" },
3876 "dump video coding statistics to file",
"file" },
3878 "Version of the vstats format to use."},
3880 "set video filters",
"filter_graph" },
3883 "specify intra matrix coeffs",
"matrix" },
3886 "specify inter matrix coeffs",
"matrix" },
3889 "specify intra matrix coeffs",
"matrix" },
3892 "top=1/bottom=0/auto=-1 field first",
"" },
3895 "force video tag/fourcc",
"fourcc/tag" },
3897 "show QP histogram" },
3900 "set framerate mode for matching video streams; overrides vsync" },
3903 "force the selected framerate, disable the best supported framerate selection" },
3906 "set the value of an outfile streamid",
"streamIndex:value" },
3909 "force key frames at specified timestamps",
"timestamps" },
3911 "audio bitrate (please use -b:a)",
"bitrate" },
3913 "video bitrate (please use -b:v)",
"bitrate" },
3916 "use HW accelerated decoding",
"hwaccel name" },
3919 "select a device for HW acceleration",
"devicename" },
3922 "select output format used with HW accelerated decoding",
"format" },
3924 "show available HW acceleration methods" },
3927 "automatically insert correct rotate filters" },
3930 "automatically insert a scale filter at the end of the filter graph" },
3934 "set the number of audio frames to output",
"number" },
3936 "set audio quality (codec-specific)",
"quality", },
3939 "set audio sampling rate (in Hz)",
"rate" },
3942 "set number of audio channels",
"channels" },
3947 "force audio codec ('copy' to copy stream)",
"codec" },
3950 "force audio tag/fourcc",
"fourcc/tag" },
3952 "change audio volume (256=normal)" ,
"volume" },
3955 "set sample format",
"format" },
3958 "set channel layout",
"layout" },
3961 "set channel layout",
"layout" },
3963 "set audio filters",
"filter_graph" },
3965 "set the maximum number of channels to try to guess the channel layout" },
3969 "disable subtitle" },
3971 "force subtitle codec ('copy' to copy stream)",
"codec" },
3973 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
3975 "fix subtitles duration" },
3977 "set canvas size (WxH or abbreviation)",
"size" },
3981 "set the maximum demux-decode delay",
"seconds" },
3983 "set the initial demux-decode delay",
"seconds" },
3985 "specify a file in which to print sdp information",
"file" },
3988 "set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)",
"ratio" },
3990 "set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
3991 "two special values are defined - "
3992 "0 = use frame rate (video) or sample rate (audio),"
3993 "-1 = match source time base",
"ratio" },
3996 "A comma-separated list of bitstream filters",
"bitstream_filters" },
3998 "deprecated",
"audio bitstream_filters" },
4000 "deprecated",
"video bitstream_filters" },
4003 "set the audio options to the indicated preset",
"preset" },
4005 "set the video options to the indicated preset",
"preset" },
4007 "set the subtitle options to the indicated preset",
"preset" },
4009 "set options from indicated preset file",
"filename" },
4012 "maximum number of packets that can be buffered while waiting for all streams to initialize",
"packets" },
4014 "set the threshold after which max_muxing_queue_size is taken into account",
"bytes" },
4018 "force data codec ('copy' to copy stream)",
"codec" },
4024 "set VAAPI hardware device (DRM path or X11 display name)",
"device" },
4029 "set QSV hardware device (DirectX adapter index, DRM path or X11 display name)",
"device"},
4033 "initialise hardware device",
"args" },
4035 "set hardware device used when filtering",
"device" },
static void error(const char *err)
static FILE * fopen_utf8(const char *path, const char *mode)
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
static int ignore_unknown_streams
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
static OutputStream * new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index)
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C program
static int opt_abort_on(void *optctx, const char *opt, const char *arg)
SpecifierOpt * dump_attachment
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AV_OPT_FLAG_VIDEO_PARAM
enum AVMediaType codec_type
General type of the encoded data.
static void dump_attachment(AVStream *st, const char *filename)
static int opt_video_filters(void *optctx, const char *opt, const char *arg)
void show_help_default(const char *opt, const char *arg)
Per-fftool specific help handler.
#define SET_DICT(type, meta, context, index)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int sample_rate
samples per second
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
char * av_get_token(const char **buf, const char *term)
Unescape the given string until a non escaped terminating char, and return the token corresponding to...
The official guide to swscale for confused that is
unsigned int nb_chapters
Number of chapters in AVChapter array.
This struct describes the properties of an encoded stream.
#define ALLOC_ARRAY_ELEM(array, nb_elems)
#define u(width, name, range_min, range_max)
static enum AVSampleFormat sample_fmts[]
static int opt_old2new(void *optctx, const char *opt, const char *arg)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o)
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
static const char *const opt_name_frame_aspect_ratios[]
void remove_avoptions(AVDictionary **a, AVDictionary *b)
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static const char *const opt_name_frame_pix_fmts[]
char * av_asprintf(const char *fmt,...)
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
uint16_t * intra_matrix
custom intra quantization matrix Must be allocated with the av_malloc() family of functions,...
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
const char program_name[]
program name, defined by the program for show_version().
static int no_file_overwrite
static int opt_default_new(OptionsContext *o, const char *opt, const char *arg)
int64_t start_time
start time in microseconds == AV_TIME_BASE units
const AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
static const char *const opt_name_top_field_first[]
int auto_conversion_filters
static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
int ffmpeg_parse_options(int argc, char **argv)
AVStream ** streams
A list of all streams in the file.
static const char *const opt_name_max_frames[]
static int copy_unknown_streams
static const char * subtitle_codec_name
AVRational avg_frame_rate
Average framerate.
static const char *const opt_name_bitstream_filters[]
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
AVDictionary * format_opts
#define AV_DICT_APPEND
If the entry already exists, append to it.
static const char *const opt_name_presets[]
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
HWDevice * filter_hw_device
enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name)
Look up an AVHWDeviceType by name.
static const char *const opt_name_autorotate[]
#define AV_LOG_VERBOSE
Detailed information.
static const char *const opt_name_reinit_filters[]
AVIOContext * progress_avio
static int opt_filter_hw_device(void *optctx, const char *opt, const char *arg)
static void freeenv_utf8(char *var)
#define AV_NOWARN_DEPRECATED(code)
Disable warnings about deprecated features This is useful for sections of code kept for backward comp...
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev)
Iterate over supported device types.
SpecifierOpt * audio_channels
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
enum AVChannelOrder order
Channel order used in this layout.
static OutputStream * new_attachment_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
int hw_device_init_from_string(const char *arg, HWDevice **dev)
enum AVCodecID video_codec_id
Forced video codec_id.
int nb_channels
Number of channels in this layout.
#define AV_OPT_FLAG_FILTERING_PARAM
a generic parameter which can be set by the user for filtering
int64_t avio_size(AVIOContext *s)
Get the filesize.
static const AVInputFormat * file_iformat
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
static int subtitle_disable
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
static const char *const opt_name_ts_scale[]
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
static const char *const opt_name_fix_sub_duration[]
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
double parse_number_or_die(const char *context, const char *numstr, int type, double min, double max)
Parse a string and return its corresponding value as a double.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
static int opt_filter_threads(void *optctx, const char *opt, const char *arg)
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
static const char *const opt_name_max_muxing_queue_size[]
A list of option groups that all have the same group type (e.g.
static void uninit_options(OptionsContext *o)
static const Preset presets[]
static int opt_timecode(void *optctx, const char *opt, const char *arg)
AVChannelLayout ch_layout
Audio channel layout.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc, const OutputStream *ost, enum AVMediaType type)
static int opt_data_frames(void *optctx, const char *opt, const char *arg)
static char * get_line(AVIOContext *s, AVBPrint *bprint)
@ AVDISCARD_NONE
discard nothing
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
AVProgram * av_new_program(AVFormatContext *ac, int id)
static int set_dispositions(OutputFile *of, AVFormatContext *ctx)
static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
static const char *const opt_name_hwaccels[]
int nb_audio_channel_maps
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
static int input_stream_potentially_available
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int metadata_chapters_manual
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
static int init_complex_filters(void)
#define FF_ARRAY_ELEMS(a)
#define ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM
static OutputStream * new_audio_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
const AVCodec * subtitle_codec
Forced subtitle codec.
AVDictionary * codec_opts
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate,...
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)
static void parse_matrix_coeffs(uint16_t *dest, const char *str)
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static int opt_attach(void *optctx, const char *opt, const char *arg)
static const uint16_t mask[17]
static int opt_recording_timestamp(void *optctx, const char *opt, const char *arg)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, int std_compliance)
Test if the given container can store a codec.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
int64_t end
chapter start/end time in time_base units
InputStream ** input_streams
char * specifier
stream/chapter/program/...
This struct describes the properties of a single codec described by an AVCodecID.
static const char *const opt_name_frame_rates[]
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
int split_commandline(OptionParseContext *octx, int argc, char *argv[], const OptionDef *options, const OptionGroupDef *groups, int nb_groups)
Split the commandline into an intermediate form convenient for further processing.
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size)
Read contents of h into print buffer, up to max_size bytes, or up to EOF.
static const char *const opt_name_rc_overrides[]
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
int flags
Flags modifying the (de)muxer behaviour.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
static void parse_meta_type(char *arg, char *type, int *index, const char **stream_spec)
Parse a metadata specifier passed as 'arg' parameter.
const struct AVInputFormat * iformat
The input container format.
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
static OutputStream * new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
SpecifierOpt * audio_ch_layouts
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AVIO_FLAG_WRITE
write-only
struct OutputStream * ost
int metadata_streams_manual
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static OutputStream * new_data_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
static const char *const opt_name_codec_names[]
static const char *const opt_name_pass[]
#define AV_OPT_FLAG_BSF_PARAM
a generic parameter which can be set by the user for bit stream filtering
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
void assert_avoptions(AVDictionary *m)
static int opt_video_frames(void *optctx, const char *opt, const char *arg)
#define AV_OPT_FLAG_AUDIO_PARAM
static const char *const opt_name_canvas_sizes[]
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
static void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc)
OutputStream ** output_streams
@ AVDISCARD_ALL
discard all
#define av_realloc_f(p, o, n)
enum AVCodecID audio_codec_id
Forced audio codec_id.
AVDictionary * format_opts
static int opt_target(void *optctx, const char *opt, const char *arg)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
static int open_file(AVFormatContext *avf, unsigned fileno)
static int opt_profile(void *optctx, const char *opt, const char *arg)
#define LIBAVUTIL_VERSION_INT
static void assert_file_overwrite(const char *filename)
Describe the class of an AVClass context structure.
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
const AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
static const char *const opt_name_copy_initial_nonkeyframes[]
const AVClass * av_bsf_get_class(void)
Get the AVClass for AVBSFContext.
SpecifierOpt * frame_sizes
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Rational number (pair of numerator and denominator).
static int open_input_file(OptionsContext *o, const char *filename)
const char * av_default_item_name(void *ptr)
Return the context name.
int metadata_global_manual
AVIOContext * pb
I/O context.
#define AV_CODEC_PROP_BITMAP_SUB
Subtitle codec is bitmap based Decoded AVSubtitle data can be read from the AVSubtitleRect->pict fiel...
static char * getenv_utf8(const char *varname)
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
int av_parse_ratio(AVRational *q, const char *str, int max, int log_offset, void *log_ctx)
Parse str and store the parsed ratio in q.
SpecifierOpt * max_frames
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
const AVCodec * audio_codec
Forced audio codec.
AVChannelLayout ch_layout
Audio only.
static int find_stream_info
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
static const char *const opt_name_guess_layout_max[]
static const char *const opt_name_max_frame_rates[]
#define AV_OPT_SEARCH_FAKE_OBJ
The obj passed to av_opt_find() is fake – only a double pointer to AVClass instead of a required poin...
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
AVCodecID
Identify the syntax and semantics of the bitstream.
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int extradata_size
Size of the extradata content in bytes.
static int opt_streamid(void *optctx, const char *opt, const char *arg)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static int opt_preset(void *optctx, const char *opt, const char *arg)
static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
AVDictionary * codec_opts
const AVCodec * data_codec
Forced data codec.
const OptionDef options[]
static int opt_bitrate(void *optctx, const char *opt, const char *arg)
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
static const uint8_t frame_sizes[]
static const char *const opt_name_audio_sample_rate[]
static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
static const AVCodec * find_codec_or_die(const char *name, enum AVMediaType type, int encoder)
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)
OutputFile ** output_files
static int opt_map(void *optctx, const char *opt, const char *arg)
static const AVCodec * choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st)
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static int64_t start_time
char * url
input or output URL.
FILE * get_preset_file(char *filename, size_t filename_size, const char *preset_name, int is_path, const char *codec_name)
Get a file corresponding to a preset file.
enum AVSampleFormat sample_fmt
audio sample format
static int open_output_file(OptionsContext *o, const char *filename)
static int file_overwrite
static const char *const opt_name_filters[]
int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
Seek to timestamp ts.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
int event_flags
Flags indicating events happening on the stream, a combination of AVSTREAM_EVENT_FLAG_*.
int avio_check(const char *url, int flags)
Return AVIO_FLAG_* access flags corresponding to the access permissions of the resource in url,...
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
uint16_t * chroma_intra_matrix
custom intra quantization matrix
printf("static const uint8_t my_array[100] = {\n")
static const char *const opt_name_filter_scripts[]
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static int opt_sdp_file(void *optctx, const char *opt, const char *arg)
static const char *const opt_name_chroma_intra_matrices[]
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
int avio_r8(AVIOContext *s)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
static const char *const opt_name_passlogfiles[]
void check_filter_outputs(void)
static char * get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost)
static int opt_data_codec(void *optctx, const char *opt, const char *arg)
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
static void init_options(OptionsContext *o)
static const char *const opt_name_frame_sizes[]
int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str)
Parse str and put in width_ptr and height_ptr the detected values.
SpecifierOpt * frame_rates
enum VideoSyncMethod video_sync_method
#define AV_LOG_INFO
Standard information.
static const char * video_codec_name
static const char *const opt_name_enc_time_bases[]
int guess_input_channel_layout(InputStream *ist)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel layout
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
int av_parse_video_rate(AVRational *rate, const char *arg)
Parse str and store the detected values in *rate.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
static const char *const opt_name_audio_ch_layouts[]
int init_complex_filtergraph(FilterGraph *fg)
static int apply_sync_offsets(void)
#define i(width, name, range_min, range_max)
static const char *const opt_name_autoscale[]
SpecifierOpt * metadata_map
int64_t id
unique ID to identify the chapter
static const char *const opt_name_audio_channels[]
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
enum AVSampleFormat av_get_sample_fmt(const char *name)
Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
#define AV_TIME_BASE
Internal time base represented as integer.
static const char *const opt_name_muxing_queue_data_threshold[]
SpecifierOpt * audio_sample_rate
static int opt_video_codec(void *optctx, const char *opt, const char *arg)
static const char *const opt_name_sample_fmts[]
static int opt_qscale(void *optctx, const char *opt, const char *arg)
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec)
Filter out options for given codec.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static OutputStream * new_unknown_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
static int opt_vstats(void *optctx, const char *opt, const char *arg)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
New fields can be added to the end with minor version bumps.
AVCodecParameters * avcodec_parameters_alloc(void)
Allocate a new AVCodecParameters and set its fields to default values (unknown/invalid/0).
const char * name
Name of the codec implementation.
float dts_error_threshold
static const char *const opt_name_bits_per_raw_sample[]
FilterGraph ** filtergraphs
const AVIOInterruptCB int_cb
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
static int opt_map_channel(void *optctx, const char *opt, const char *arg)
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
FF_ENABLE_DEPRECATION_WARNINGS int av_channel_layout_from_mask(AVChannelLayout *channel_layout, uint64_t mask)
Initialize a native channel layout from a bitmask indicating which channels are present.
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
static const char *const opt_name_force_fps[]
int id
Format-specific stream ID.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
double av_strtod(const char *numstr, char **tail)
Parse the string in numstr and return its value as a double.
const struct AVOutputFormat * oformat
The output container format.
int av_opt_eval_int(void *obj, const AVOption *o, const char *val, int *int_out)
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
AudioChannelMap * audio_channel_maps
#define AV_INPUT_BUFFER_PADDING_SIZE
enum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name, const char *filename, const char *mime_type, enum AVMediaType type)
Guess the codec ID based upon muxer and filename.
#define CMDUTILS_COMMON_OPTIONS
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
enum AVCodecID data_codec_id
Forced Data codec_id.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
main external API structure.
int index
stream index in AVFormatContext
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
static const char *const opt_name_time_bases[]
static const char * audio_codec_name
float audio_drift_threshold
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
static char * read_file(const char *filename)
static const char *const opt_name_forced_key_frames[]
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static const char *const opt_name_hwaccel_output_formats[]
static int ref[MAX_W *MAX_W]
static AVDictionary * strip_specifiers(AVDictionary *dict)
SpecifierOpt * frame_pix_fmts
const AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
int avio_open(AVIOContext **s, const char *url, int flags)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
#define GROW_ARRAY(array, nb_elems)
static const char *const opt_name_fps_mode[]
static int opt_vsync(void *optctx, const char *opt, const char *arg)
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set that converts the value to a string and stores it.
#define AVIO_FLAG_READ
read-only
static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)
enum AVMediaType codec_type
int opt_default(void *optctx, const char *opt, const char *arg)
Fallback for options that are not explicitly handled, these will be parsed through AVOptions.
char * av_strdup(const char *s)
Duplicate a string.
#define AVERROR_ENCODER_NOT_FOUND
Encoder not found.
int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf_lst)
Parse string describing list of bitstream filters and create single AVBSFContext describing the whole...
static int opt_stats_period(void *optctx, const char *opt, const char *arg)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int video_delay
Video only.
static const char *const opt_name_intra_matrices[]
const VDPAUPixFmtMap * map
const char ** attachments
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
static int copy_chapters(InputFile *ifile, OutputFile *ofile, AVFormatContext *os, int copy_metadata)
static const char *const opt_name_copy_prior_start[]
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
uint16_t * inter_matrix
custom inter quantization matrix Must be allocated with the av_malloc() family of functions,...
int rc_override_count
ratecontrol override, see RcOverride
static const char *const opt_name_apad[]
char * name
unique name for this input/output in the list
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
int width
picture width / height.
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
Parse a string specifying a time and return its corresponding value as a number of microseconds.
float frame_drop_threshold
void * grow_array(void *array, int elem_size, int *size, int new_size)
Realloc array to hold new_size elements of elem_size.
#define flags(name, subs,...)
static const char *const opt_name_disposition[]
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds.
#define MKTAG(a, b, c, d)
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
const AVOutputFormat * format
static const char *const opt_name_qscale[]
void show_help_options(const OptionDef *options, const char *msg, int req_flags, int rej_flags, int alt_flags)
Print help for all options matching specified flags.
const AVClass * av_stream_get_class(void)
Get the AVClass for AVStream.
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
static void set_channel_layout(OutputFilter *f, OutputStream *ost)
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
AVRational time_base
time base in which the start/end timestamps are specified
static const char *const opt_name_hwaccel_devices[]
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
static const char *const opt_name_discard[]
HWDevice * hw_device_get_by_name(const char *name)
const AVClass * avfilter_get_class(void)
A linked-list of the inputs/outputs of the filter chain.
#define AVERROR_PROTOCOL_NOT_FOUND
Protocol not found.
#define ABORT_ON_FLAG_EMPTY_OUTPUT
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
static const char *const opt_name_inter_matrices[]
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
static int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
static const char *const opt_name_codec_tags[]
const AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
float dts_delta_threshold
static OutputStream * new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, int source_index)
const AVCodec * video_codec
Forced video codec.
#define DEFAULT_PASS_LOGFILENAME_PREFIX
int filter_complex_nbthreads
enum AVCodecID subtitle_codec_id
Forced subtitle codec_id.