Go to the documentation of this file.
48 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
92 const char *opt_name,
int flag)
111 char *codec_name =
NULL;
123 "Default encoder for format %s (codec %s) is "
124 "probably disabled. Please choose an encoder manually.\n",
128 }
else if (strcmp(codec_name,
"copy")) {
153 char *env_avconv_datadir =
getenv_utf8(
"AVCONV_DATADIR");
155 const char *
base[3] = { env_avconv_datadir,
164 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset",
base[
i],
165 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
169 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset",
base[
i],
170 i != 1 ?
"" :
"/.avconv", preset_name);
229 const char **pstr,
char delim)
231 const char *
str = *pstr;
245 for (idx = 0; *
str; idx++,
str++) {
246 if (
str[0] ==
'\\' &&
str[1])
248 else if (*
str == delim)
268 const char *path,
const char *fmt_spec)
270 static const struct {
275 int need_input_data:1;
295 const char *next = fmt_spec;
315 c->str_len = val_len;
329 "Empty formatting directive in: %s\n", fmt_spec);
335 "Missing closing brace in: %s\n", fmt_spec);
345 if (!strcmp(
val, fmt_specs[
i].
str)) {
346 if ((pre && fmt_specs[
i].post_only) || (!pre && fmt_specs[
i].pre_only)) {
348 "Format directive '%s' may only be used %s-encoding\n",
349 val, pre ?
"post" :
"pre");
354 c->type = fmt_specs[
i].type;
356 if (fmt_specs[
i].need_input_data) {
358 ost->ist->want_frame_data = 1;
361 "Format directive '%s' is unavailable, because "
362 "this output stream has no associated input stream\n",
430 const char *bsfs =
NULL, *time_base =
NULL;
431 char *next, *codec_tag =
NULL;
472 if (!
ost->filtered_frame)
483 const char *enc_stats_pre =
NULL, *enc_stats_post =
NULL, *mux_stats =
NULL;
497 if (!buf[0] || buf[0] ==
'#')
499 if (!(
arg = strchr(buf,
'='))) {
505 }
while (!
s->eof_reached);
511 "Preset %s specified, but could not be opened.\n",
preset);
518 const char *
format =
"{fidx} {sidx} {n} {t}";
528 if (enc_stats_post &&
530 const char *
format =
"{fidx} {sidx} {n} {t}";
542 const char *
format =
"{fidx} {sidx} {n} {t}";
557 }
else if (
ost->enc_ctx) {
566 q.
num <= 0 || q.
den <= 0) {
581 ost->enc_timebase = q;
594 ost->copy_prior_start = -1;
608 uint32_t
tag = strtol(codec_tag, &next, 0);
613 ost->enc_ctx->codec_tag =
tag;
617 if (
ost->enc_ctx && qscale >= 0) {
651 ost->copy_initial_nonkeyframes, oc, st);
661 if (
ost->filters_script &&
ost->filters) {
666 if (
ost->filters_script)
668 else if (
ost->filters)
678 if (
ost->filters_script ||
ost->filters) {
680 "%s '%s' was defined, but codec copy was selected.\n"
681 "Filtering and streamcopy cannot be used together.\n",
682 ost->filters ?
"Filtergraph" :
"Filtergraph script",
683 ost->filters ?
ost->filters :
ost->filters_script);
699 "Syntax error in matrix \"%s\" at coeff %d\n",
str,
i);
711 char *frame_rate =
NULL, *max_frame_rate =
NULL, *frame_aspect_ratio =
NULL;
728 if (frame_rate && max_frame_rate) {
734 if (frame_aspect_ratio) {
737 q.
num <= 0 || q.
den <= 0) {
741 ost->frame_aspect_ratio = q;
749 const char *p =
NULL, *fps_mode =
NULL;
751 char *frame_pix_fmt =
NULL;
752 char *intra_matrix =
NULL, *inter_matrix =
NULL;
753 char *chroma_intra_matrix =
NULL;
764 if (frame_pix_fmt && *frame_pix_fmt ==
'+') {
765 ost->keep_pix_fmt = 1;
766 if (!*++frame_pix_fmt)
767 frame_pix_fmt =
NULL;
782 if (chroma_intra_matrix) {
797 for (
i = 0; p;
i++) {
799 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
847 if (
ost->logfile_prefix &&
853 char logfilename[1024];
857 for (
int i = 0;
i <=
ost->file_index;
i++)
860 snprintf(logfilename,
sizeof(logfilename),
"%s-%d.log",
861 ost->logfile_prefix ?
ost->logfile_prefix :
864 if (!strcmp(
ost->enc_ctx->codec->name,
"libx264")) {
868 char *logbuffer =
file_read(logfilename);
881 "Cannot write log file '%s' for pass-1 encoding: %s\n",
882 logfilename, strerror(errno));
892 ost->top_field_first = -1;
900 if ((
ost->frame_rate.num ||
ost->max_frame_rate.num) &&
904 "together a non-CFR -vsync/-fps_mode. This is contradictory.\n");
909 if (
ost->frame_rate.num ||
ost->max_frame_rate.num) {
923 if (
ifile->nb_streams == 1 &&
ifile->input_ts_offset == 0)
938 if (!
ost->last_frame)
963 char *sample_fmt =
NULL;
974 #if FF_API_OLD_CHANNEL_LAYOUT
983 #if FF_API_OLD_CHANNEL_LAYOUT
1008 #if FFMPEG_OPT_MAP_CHANNEL
1012 if ((
map->ofile_idx == -1 ||
ost->file_index ==
map->ofile_idx) &&
1013 (
map->ostream_idx == -1 ||
ost->st->
index ==
map->ostream_idx)) {
1016 if (
map->channel_idx == -1) {
1018 }
else if (!
ost->ist) {
1028 ost->audio_channels_mapped + 1,
1029 sizeof(*
ost->audio_channels_map)
1033 ost->audio_channels_map[
ost->audio_channels_mapped++] =
map->channel_idx;
1104 switch (ofilter->
type) {
1113 ost->filter = ofilter;
1118 if (!
ost->enc_ctx) {
1120 "from a complex filtergraph. Filtering and streamcopy "
1121 "cannot be used together.\n");
1125 if (
ost->avfilter && (
ost->filters ||
ost->filters_script)) {
1126 const char *opt =
ost->filters ?
"-vf/-af/-filter" :
"-filter_script";
1128 "%s '%s' was specified through the %s option "
1129 "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1130 "%s and -filter_complex cannot be used together for the same stream.\n",
1131 ost->filters ?
"Filtergraph" :
"Filtergraph script",
1132 ost->filters ?
ost->filters :
ost->filters_script,
1155 int file_best_score = 0;
1156 for (
int i = 0;
i <
ifile->nb_streams;
i++) {
1170 if (score > file_best_score) {
1173 file_best_score = score;
1174 file_best_ist = ist;
1177 if (file_best_ist) {
1178 if((qcr ==
MKTAG(
'A',
'P',
'I',
'C')) ||
1181 if (file_best_score > best_score) {
1182 best_score = file_best_score;
1183 best_ist = file_best_ist;
1204 int file_best_score = 0;
1205 for (
int i = 0;
i <
ifile->nb_streams;
i++) {
1216 if (score > file_best_score) {
1217 file_best_score = score;
1218 file_best_ist = ist;
1221 if (file_best_ist) {
1223 if (file_best_score > best_score) {
1224 best_score = file_best_score;
1225 best_ist = file_best_ist;
1250 int input_props = 0, output_props = 0;
1255 if (input_descriptor)
1257 if (output_descriptor)
1260 input_props & output_props ||
1262 input_descriptor && output_descriptor &&
1263 (!input_descriptor->
props ||
1264 !output_descriptor->
props)) {
1284 ist->st->codecpar->codec_id ==
codec_id )
1296 if (
map->linklabel) {
1305 if (
out && !strcmp(
out->name,
map->linklabel)) {
1314 "in any defined filter graph, or was already used elsewhere.\n",
map->linklabel);
1322 map->file_index,
map->stream_index);
1347 "Cannot map stream #%d:%d - unsupported type.\n",
1348 map->file_index,
map->stream_index);
1351 "If you want unsupported types ignored instead "
1352 "of failing, please use the -ignore_unknown option\n"
1353 "If you want them copied, please use -copy_unknown\n");
1367 uint8_t *attachment;
1418 switch (ofilter->
type) {
1429 if (!auto_disable_v)
1431 if (!auto_disable_a)
1433 if (!auto_disable_s)
1435 if (!auto_disable_d)
1454 int nb_av_enc = 0, nb_interleaved = 0;
1455 int limit_frames = 0, limit_frames_av_enc = 0;
1457 #define IS_AV_ENC(ost, type) \
1458 (ost->enc_ctx && (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO))
1459 #define IS_INTERLEAVED(type) (type != AVMEDIA_TYPE_ATTACHMENT)
1466 ost->sq_idx_encode = -1;
1467 ost->sq_idx_mux = -1;
1476 if (!((nb_interleaved > 1 && of->
shortest) ||
1477 (nb_interleaved > 0 && limit_frames)))
1483 if ((of->
shortest && nb_av_enc > 1) || limit_frames_av_enc) {
1498 if (
ost->sq_idx_encode < 0)
1499 return ost->sq_idx_encode;
1512 if (nb_interleaved > nb_av_enc) {
1531 if (
ost->sq_idx_mux < 0)
1532 return ost->sq_idx_mux;
1540 #undef IS_INTERLEAVED
1556 const char *to_dealloc = p2;
1571 if (!strcmp(
key,
"program_num"))
1572 progid = strtol(p2,
NULL, 0);
1584 const char *to_dealloc = p2;
1593 "No '=' character in program string %s.\n",
1601 if (!strcmp(
key,
"title")) {
1603 }
else if (!strcmp(
key,
"program_num")) {
1604 }
else if (!strcmp(
key,
"st")) {
1605 int st_num = strtol(p2,
NULL, 0);
1625 char *
type,
int *
index,
const char **stream_spec)
1633 if (*(++
arg) && *
arg !=
':') {
1637 *stream_spec = *
arg ==
':' ?
arg + 1 :
"";
1641 if (*(++
arg) ==
':')
1658 const char *stream_spec;
1674 #if FFMPEG_ROTATION_METADATA
1679 ost->rotate_overridden = 1;
1680 ost->rotate_override_value = theta;
1684 "Conversion of a 'rotate' metadata key to a "
1685 "proper display matrix rotation is deprecated. "
1686 "See -display_rotation for setting rotation "
1691 #if FFMPEG_ROTATION_METADATA
1739 if (!
c->ch_layouts) {
1747 for (
i = 0;
c->ch_layouts[
i].nb_channels;
i++) {
1748 if (
c->ch_layouts[
i].nb_channels ==
ost->enc_ctx->ch_layout.nb_channels)
1751 if (
c->ch_layouts[
i].nb_channels) {
1775 for (
i = 0;
i <
is->nb_chapters;
i++) {
1780 int64_t rt = (
ofile->recording_time == INT64_MAX) ? INT64_MAX :
1784 if (in_ch->
end < ts_off)
1786 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1793 out_ch->id = in_ch->
id;
1795 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1796 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1807 const char *outspec,
const char *inspec,
1808 int *metadata_global_manual,
int *metadata_streams_manual,
1815 char type_in, type_out;
1816 const char *istream_spec =
NULL, *ostream_spec =
NULL;
1817 int idx_in = 0, idx_out = 0;
1822 if (type_in ==
'g' || type_out ==
'g')
1823 *metadata_global_manual = 1;
1824 if (type_in ==
's' || type_out ==
's')
1825 *metadata_streams_manual = 1;
1826 if (type_in ==
'c' || type_out ==
'c')
1827 *metadata_chapters_manual = 1;
1833 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
1834 if ((index) < 0 || (index) >= (nb_elems)) {\
1835 av_log(mux, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
1840 #define SET_DICT(type, meta, context, index)\
1843 meta = &context->metadata;\
1846 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
1847 meta = &context->chapters[index]->metadata;\
1850 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
1851 meta = &context->programs[index]->metadata;\
1855 default: av_assert0(0);\
1858 SET_DICT(type_in, meta_in, ic, idx_in);
1859 SET_DICT(type_out, meta_out, oc, idx_out);
1862 if (type_in ==
's') {
1871 av_log(mux,
AV_LOG_FATAL,
"Stream specifier %s does not match any streams.\n", istream_spec);
1876 if (type_out ==
's') {
1895 int metadata_global_manual = 0;
1896 int metadata_streams_manual = 0;
1897 int metadata_chapters_manual = 0;
1906 "processing metadata maps\n", in_file_index);
1912 &metadata_global_manual, &metadata_streams_manual,
1913 &metadata_chapters_manual, o);
1918 if (chapters_input_file == INT_MAX) {
1920 chapters_input_file = -1;
1923 chapters_input_file =
i;
1928 chapters_input_file);
1932 if (chapters_input_file >= 0)
1934 !metadata_chapters_manual);
1947 if (!metadata_streams_manual)
1967 int have_manual = 0;
1970 const char **dispositions;
1984 have_manual |= !!dispositions[
i];
1998 const char *disp = dispositions[
i];
2020 have_default[
type] = 1;
2041 return FFDIFFSIGN(*(
const int64_t *)
a, *(
const int64_t *)
b);
2051 for (p = spec; *p; p++)
2060 for (
i = 0;
i < n;
i++) {
2061 char *next = strchr(p,
',');
2066 if (!memcmp(p,
"chapters", 8)) {
2071 if (nb_ch > INT_MAX -
size ||
2077 for (j = 0; j < nb_ch; j++) {
2102 const char *forced_keyframes =
NULL;
2107 ost->enc_ctx && forced_keyframes))
2110 if (!strncmp(forced_keyframes,
"expr:", 5)) {
2115 "Invalid force_key_frames expression '%s'\n", forced_keyframes + 5);
2118 ost->kf.expr_const_values[
FKF_N] = 0;
2125 }
else if (!strcmp(forced_keyframes,
"source")) {
2127 }
else if (!strcmp(forced_keyframes,
"source_no_drop")) {
2169 if (!strcmp(e->
key,
"gop_timecode"))
2173 "for any stream. The most likely reason is either wrong type "
2174 "(e.g. a video option with no video streams) or that it is a "
2175 "private option of some encoder which was not actually used for "
2183 const Muxer *mux = obj;
2220 if (stop_time != INT64_MAX && recording_time != INT64_MAX) {
2221 stop_time = INT64_MAX;
2225 if (stop_time != INT64_MAX && recording_time == INT64_MAX) {
2243 if (!strcmp(filename,
"-"))
2260 if (recording_time != INT64_MAX)
2283 if (
ost->enc_ctx &&
ost->ist) {
2293 "Error initializing a simple filtergraph\n");
2297 }
else if (
ost->ist) {
2298 ost->ist->processing_needed = 1;
2305 switch (
ost->enc_ctx->codec_type) {
2307 f->frame_rate =
ost->frame_rate;
2308 f->width =
ost->enc_ctx->width;
2309 f->height =
ost->enc_ctx->height;
2311 f->format =
ost->enc_ctx->pix_fmt;
2313 f->formats =
c->pix_fmts;
2318 f->format =
ost->enc_ctx->sample_fmt;
2320 f->formats =
c->sample_fmts;
2322 if (
ost->enc_ctx->sample_rate) {
2323 f->sample_rate =
ost->enc_ctx->sample_rate;
2325 f->sample_rates =
c->supported_samplerates;
2327 if (
ost->enc_ctx->ch_layout.nb_channels) {
2329 }
else if (
c->ch_layouts) {
2330 f->ch_layouts =
c->ch_layouts;
static int choose_encoder(const OptionsContext *o, AVFormatContext *s, OutputStream *ost, const AVCodec **enc)
static void parse_forced_key_frames(KeyframeForceCtx *kf, const Muxer *mux, const char *spec)
static FILE * fopen_utf8(const char *path, const char *mode)
static const char *const opt_name_filters[]
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_BPRINT_SIZE_UNLIMITED
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
static const char *const opt_name_max_muxing_queue_size[]
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 MuxStream * ms_from_ost(OutputStream *ost)
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
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 MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)
enum AVMediaType codec_type
General type of the encoded data.
static const char *const opt_name_muxing_queue_data_threshold[]
static OutputStream * new_subtitle_stream(Muxer *mux, const OptionsContext *o, InputStream *ist)
int sample_rate
samples per second
@ KF_FORCE_SOURCE_NO_DROP
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
The official guide to swscale for confused that is
unsigned int nb_chapters
Number of chapters in AVChapter array.
static const char *const opt_name_enc_stats_pre[]
static enum AVSampleFormat sample_fmts[]
static void parse_matrix_coeffs(void *logctx, uint16_t *dest, const char *str)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
#define MATCH_PER_TYPE_OPT(name, type, outvar, fmtctx, mediatype)
void sq_limit_frames(SyncQueue *sq, unsigned int stream_idx, uint64_t frames)
Limit the number of output frames for stream with index stream_idx to max_frames.
#define IS_INTERLEAVED(type)
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
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.
InputStream * ist_iter(InputStream *prev)
int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global)
int max_muxing_queue_size
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.
AVStream ** streams
A list of all streams in the file.
static void map_auto_video(Muxer *mux, const OptionsContext *o)
size_t muxing_queue_data_threshold
static const char * subtitle_codec_name
static const char *const opt_name_disposition[]
static const char *const opt_name_sample_fmts[]
static int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts)
static const char *const opt_name_max_frames[]
static const char *const opt_name_mux_stats[]
#define AV_DICT_APPEND
If the entry already exists, append to it.
static const char *const opt_name_fix_sub_duration_heartbeat[]
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...
#define IS_AV_ENC(ost, type)
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
static const char *const opt_name_qscale[]
static void set_channel_layout(OutputFilter *f, OutputStream *ost)
enum AVChannelOrder order
Channel order used in this layout.
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
int nb_channels
Number of channels in this layout.
static int enc_stats_init(OutputStream *ost, EncStats *es, int pre, const char *path, const char *fmt_spec)
int64_t avio_size(AVIOContext *s)
Get the filesize.
static const char *const opt_name_apad[]
static int set_dispositions(Muxer *mux, const OptionsContext *o)
static OutputStream * new_audio_stream(Muxer *mux, const OptionsContext *o, InputStream *ist)
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)
int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
static void of_add_programs(Muxer *mux, const OptionsContext *o)
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
#define SET_DICT(type, meta, context, index)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
static void of_add_metadata(OutputFile *of, AVFormatContext *oc, const OptionsContext *o)
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...
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.
void assert_file_overwrite(const char *filename)
const struct AVCodec * codec
static const Preset presets[]
static const char *const opt_name_audio_channels[]
AVChannelLayout ch_layout
Audio channel layout.
void report_and_exit(int ret)
Reports an error corresponding to the provided AVERROR code and calls exit_program() with the corresp...
static Muxer * mux_alloc(void)
static const char *const opt_name_audio_ch_layouts[]
static const char *const opt_name_audio_sample_rate[]
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
static int setup_sync_queues(Muxer *mux, AVFormatContext *oc, int64_t buf_size_us)
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
AVProgram * av_new_program(AVFormatContext *ac, int id)
static EncStatsFile * enc_stats_files
int nb_audio_channel_maps
#define FFDIFFSIGN(x, y)
Comparator.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
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.
#define FF_ARRAY_ELEMS(a)
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,...
static const uint16_t mask[17]
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.
static const AVClass output_stream_class
EncStatsComponent * components
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
char * specifier
stream/chapter/program/...
This struct describes the properties of a single codec described by an AVCodecID.
static MuxStream * mux_stream_alloc(Muxer *mux, enum AVMediaType type)
static const char *const opt_name_enc_stats_post_fmt[]
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
static void init_output_filter(OutputFilter *ofilter, const OptionsContext *o, Muxer *mux)
int mux_check_init(Muxer *mux)
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
static int enc_stats_get_file(AVIOContext **io, const char *path)
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 const AVClass output_file_class
static void of_add_attachments(Muxer *mux, const OptionsContext *o)
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
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.
static char * get_line(AVIOContext *s, AVBPrint *bprint)
#define filters(fmt, type, inverse, clp, inverset, clip, one, clip_fn, packed)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static const char * output_stream_item_name(void *obj)
#define AVIO_FLAG_WRITE
write-only
struct OutputStream * ost
int ignore_unknown_streams
static const char *const opt_name_enc_stats_pre_fmt[]
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static const char *const opt_name_intra_matrices[]
static void create_streams(Muxer *mux, const OptionsContext *o)
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
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.
int sq_add_stream(SyncQueue *sq, int limiting)
Add a new stream to the sync queue.
AVDictionary * encoder_opts
@ AVDISCARD_ALL
discard all
#define av_realloc_f(p, o, n)
AVDictionary * format_opts
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static char * get_ost_filters(const OptionsContext *o, AVFormatContext *oc, OutputStream *ost)
Describe the class of an AVClass context structure.
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
static const char *const opt_name_inter_matrices[]
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
#define DEFAULT_PASS_LOGFILENAME_PREFIX
static void map_manual(Muxer *mux, const OptionsContext *o, const StreamMap *map)
static int nb_enc_stats_files
Rational number (pair of numerator and denominator).
static const char *const opt_name_forced_key_frames[]
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)
static const char *const opt_name_time_bases[]
static void check_streamcopy_filters(const OptionsContext *o, AVFormatContext *oc, OutputStream *ost, enum AVMediaType type)
static void validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt)
#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
uint64_t av_get_channel_layout(const char *name)
Return a channel layout id that matches name, or 0 if no match is found.
AVChannelLayout ch_layout
Audio only.
int of_open(const OptionsContext *o, const char *filename)
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 const char *const opt_name_chroma_intra_matrices[]
#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...
AVCodecID
Identify the syntax and semantics of the bitstream.
static const char *const opt_name_frame_pix_fmts[]
int extradata_size
Size of the extradata content in bytes.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static const char *const opt_name_filter_scripts[]
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
static const uint8_t frame_sizes[]
static const char *const opt_name_mux_stats_fmt[]
static const char *const opt_name_bits_per_raw_sample[]
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
OutputFile ** output_files
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static const char *const opt_name_frame_sizes[]
static int64_t start_time
char * url
input or output URL.
enum AVSampleFormat sample_fmt
audio sample format
#define AV_NOPTS_VALUE
Undefined timestamp value.
int event_flags
Flags indicating events happening on the stream, a combination of AVSTREAM_EVENT_FLAG_*.
static const char *const opt_name_pass[]
uint16_t * chroma_intra_matrix
custom intra quantization matrix
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
void * allocate_array_elem(void *ptr, size_t elem_size, int *nb_elems)
Atomically add a new element to an array of pointers, i.e.
void of_enc_stats_close(void)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
int avio_r8(AVIOContext *s)
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate an array through a pointer to a pointer.
AVDictionary * strip_specifiers(const AVDictionary *dict)
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 const char *const opt_name_enc_stats_post[]
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.
static const char *const opt_name_autoscale[]
void av_channel_layout_default(AVChannelLayout *ch_layout, int nb_channels)
Get the default channel layout for a given number of channels.
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...
int av_channel_layout_from_string(AVChannelLayout *channel_layout, const char *str)
Initialize a channel layout from a given string description.
#define i(width, name, range_min, range_max)
SpecifierOpt * metadata_map
int64_t id
unique ID to identify the chapter
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.
const AVCodec * find_codec_or_die(void *logctx, const char *name, enum AVMediaType type, int encoder)
float shortest_buf_duration
#define av_malloc_array(a, b)
static void map_auto_audio(Muxer *mux, const OptionsContext *o)
static const char *const opt_name_frame_aspect_ratios[]
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static const char *const opt_name_enc_time_bases[]
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, const AVCodec *codec)
Filter out options for given codec.
@ AVMEDIA_TYPE_ATTACHMENT
Opaque data information usually sparse.
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.
const char * name
Name of the codec implementation.
FilterGraph ** filtergraphs
const AVIOInterruptCB int_cb
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void * av_calloc(size_t nmemb, size_t size)
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
static OutputStream * new_unknown_stream(Muxer *mux, const OptionsContext *o, InputStream *ist)
int id
Format-specific stream ID.
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
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.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
static const char * output_file_item_name(void *obj)
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
AudioChannelMap * audio_channel_maps
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.
#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.
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.
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
@ AV_CLASS_CATEGORY_MUXER
static OutputStream * new_attachment_stream(Muxer *mux, const OptionsContext *o, InputStream *ist)
static void map_auto_subtitle(Muxer *mux, const OptionsContext *o)
static void map_auto_data(Muxer *mux, const OptionsContext *o)
static int copy_metadata(Muxer *mux, AVFormatContext *ic, const char *outspec, const char *inspec, int *metadata_global_manual, int *metadata_streams_manual, int *metadata_chapters_manual, const OptionsContext *o)
static OutputStream * new_output_stream(Muxer *mux, const OptionsContext *o, enum AVMediaType type, InputStream *ist)
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...
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static const char *const opt_name_passlogfiles[]
static const char *const opt_name_rc_overrides[]
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
enum VideoSyncMethod video_sync_method
#define GROW_ARRAY(array, nb_elems)
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
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
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 unescape(char **pdst, size_t *dst_len, const char **pstr, char delim)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
const VDPAUPixFmtMap * map
static int compare_int64(const void *a, const void *b)
static void copy_meta(Muxer *mux, const OptionsContext *o)
const char ** attachments
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
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
char * file_read(const char *filename)
char * name
unique name for this input/output in the list
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.
static int check_opt_bitexact(void *ctx, const AVDictionary *opts, const char *opt_name, int flag)
const char *const forced_keyframes_const_names[]
#define MKTAG(a, b, c, d)
static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
const AVOutputFormat * format
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
static const char *const opt_name_copy_initial_nonkeyframes[]
AVRational time_base
time base in which the start/end timestamps are specified
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
A linked-list of the inputs/outputs of the filter chain.
static const char *const opt_name_fps_mode[]
static const char *const opt_name_bitstream_filters[]
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 OutputStream * new_video_stream(Muxer *mux, const OptionsContext *o, InputStream *ist)
static void parse_meta_type(void *logctx, const char *arg, char *type, int *index, const char **stream_spec)
Parse a metadata specifier passed as 'arg' parameter.
const AVDictionaryEntry * av_dict_iterate(const AVDictionary *m, const AVDictionaryEntry *prev)
Iterate over a dictionary.
SyncQueue * sq_alloc(enum SyncQueueType type, int64_t buf_size_us)
Allocate a sync queue of the given type.
static const char *const opt_name_presets[]
static int copy_chapters(InputFile *ifile, OutputFile *ofile, AVFormatContext *os, int copy_metadata)
static const char *const opt_name_max_frame_rates[]
static OutputStream * new_data_stream(Muxer *mux, const OptionsContext *o, InputStream *ist)
static const char *const opt_name_copy_prior_start[]
static const char *const opt_name_force_fps[]
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.