26 #include "libavformat/avformat.h"
28 #include "libavcodec/avcodec.h"
30 #include "libavfilter/avfilter.h"
32 #include "libavutil/avassert.h"
33 #include "libavutil/avstring.h"
34 #include "libavutil/avutil.h"
35 #include "libavutil/channel_layout.h"
36 #include "libavutil/intreadwrite.h"
37 #include "libavutil/fifo.h"
38 #include "libavutil/mathematics.h"
39 #include "libavutil/opt.h"
40 #include "libavutil/parseutils.h"
41 #include "libavutil/pixdesc.h"
42 #include "libavutil/pixfmt.h"
44 #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
47 for (i = 0; i < o->nb_ ## name; i++) {\
48 char *spec = o->name[i].specifier;\
49 if ((ret = check_stream_specifier(fmtctx, st, spec)) > 0)\
50 outvar = o->name[i].u.type;\
104 int i, *count = (
int*)(so + 1);
105 for (i = 0; i < *count; i++) {
126 memset(o, 0,
sizeof(*o));
143 char *p = strchr(e->
key,
':');
161 p = strchr(arg,
':');
163 x = strtol(arg, &end, 10);
165 y = strtol(end + 1, &end, 10);
167 ar = (double)x / (
double)y;
202 static int opt_map(
void *optctx,
const char *opt,
const char *arg)
206 int i, negative = 0, file_idx;
207 int sync_file_idx = -1, sync_stream_idx;
218 if (sync = strchr(map,
',')) {
220 sync_file_idx = strtol(sync + 1, &sync, 0);
229 input_files[sync_file_idx]->ctx->streams[i], sync) == 1) {
235 "match any streams.\n", arg);
243 const char *c = map + 1;
252 file_idx = strtol(map, &p, 0);
264 *p ==
':' ? p + 1 : p) > 0)
270 *p ==
':' ? p + 1 : p) <= 0)
278 if (sync_file_idx >= 0) {
297 static int opt_attach(
void *optctx,
const char *opt,
const char *arg)
320 if (*(++arg) && *arg !=
':') {
324 *stream_spec = *arg ==
':' ? arg + 1 :
"";
329 *index = strtol(++arg,
NULL, 0);
344 char type_in, type_out;
345 const char *istream_spec =
NULL, *ostream_spec =
NULL;
346 int idx_in = 0, idx_out = 0;
351 if (type_in ==
'g' || type_out ==
'g')
353 if (type_in ==
's' || type_out ==
's')
355 if (type_in ==
'c' || type_out ==
'c')
362 #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
363 if ((index) < 0 || (index) >= (nb_elems)) {\
364 av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
369 #define SET_DICT(type, meta, context, index)\
372 meta = &context->metadata;\
375 METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
376 meta = &context->chapters[index]->metadata;\
379 METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
380 meta = &context->programs[index]->metadata;\
384 default: av_assert0(0);\
387 SET_DICT(type_in, meta_in, ic, idx_in);
388 SET_DICT(type_out, meta_out, oc, idx_out);
391 if (type_in ==
's') {
405 if (type_out ==
's') {
422 const char *codec_string = encoder ?
"encoder" :
"decoder";
434 codec_string, codec->
name, desc->
name);
441 if (codec->
type != type) {
450 char *codec_name =
NULL;
471 char *framerate =
NULL, *hwaccel =
NULL, *hwaccel_device =
NULL;
472 char *codec_tag =
NULL;
491 uint32_t
tag = strtol(codec_tag, &next, 0);
528 if (!strcmp(hwaccel,
"none"))
530 else if (!strcmp(hwaccel,
"auto"))
534 for (i = 0; hwaccels[i].
name; i++) {
535 if (!strcmp(hwaccels[i].
name, hwaccel)) {
545 for (i = 0; hwaccels[i].
name; i++)
554 if (hwaccel_device) {
585 fprintf(stderr,
"Error, both -y and -n supplied. Exiting.\n");
590 (!strchr(filename,
':') || filename[1] ==
':' ||
594 fprintf(stderr,
"File '%s' already exists. Overwrite ? [y/N] ", filename);
597 fprintf(stderr,
"Not overwriting - exiting\n");
602 fprintf(stderr,
"File '%s' already exists. Exiting.\n", filename);
661 if (!strcmp(filename,
"-"))
665 !strcmp(filename,
"/dev/stdin");
681 if (file_iformat && file_iformat->
priv_class &&
684 snprintf(buf,
sizeof(buf),
"%d",
692 if (file_iformat && file_iformat->
priv_class &&
786 "input file #%d (%s) is not a decoding option.\n", e->
key,
793 "input file #%d (%s) has not been used for any stream. The most "
794 "likely reason is either wrong type (e.g. a video option with "
795 "no video streams) or that it is a private option of some decoder "
796 "which was not actually used for any stream.\n", e->
key,
812 for (i = 0; i < orig_nb_streams; i++)
830 while ((c =
avio_r8(s)) && c !=
'\n')
842 const char *base[3] = { getenv(
"AVCONV_DATADIR"),
851 snprintf(filename,
sizeof(filename),
"%s%s/%s-%s.avpreset", base[i],
852 i != 1 ?
"" :
"/.avconv", codec_name, preset_name);
856 snprintf(filename,
sizeof(filename),
"%s%s/%s.avpreset", base[i],
857 i != 1 ?
"" :
"/.avconv", preset_name);
866 char *codec_name =
NULL;
873 }
else if (!strcmp(codec_name,
"copy"))
886 char *bsf =
NULL, *next, *codec_tag =
NULL;
926 if (!buf[0] || buf[0] ==
'#') {
930 if (!(arg = strchr(buf,
'='))) {
942 "Preset %s specified for stream %d:%d, but could not be opened.\n",
955 if (next = strchr(bsf,
','))
962 bsfc_prev->
next = bsfc;
972 uint32_t
tag = strtol(codec_tag, &next, 0);
1000 const char *p = str;
1032 while ((ret =
avio_read(pb, buf,
sizeof(buf))) > 0)
1052 if (filter_script && filter) {
1072 char *frame_aspect_ratio =
NULL;
1079 if (frame_aspect_ratio)
1083 const char *p =
NULL;
1085 char *frame_pix_fmt =
NULL;
1086 char *intra_matrix =
NULL, *inter_matrix =
NULL;
1127 for (i = 0; p; i++) {
1129 int e = sscanf(p,
"%d,%d,%d", &start, &end, &q);
1265 p = strchr(idx_str,
':');
1268 "Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
1300 if (in_ch->
end < ts_off)
1302 if (rt != INT64_MAX && in_ch->
start > rt + ts_off)
1309 out_ch->id = in_ch->
id;
1311 out_ch->start =
FFMAX(0, in_ch->
start - ts_off);
1312 out_ch->end =
FFMIN(rt, in_ch->
end - ts_off);
1344 "which is fed from a complex filtergraph. Filtering and streamcopy "
1396 if (!strcmp(filename,
"-"))
1410 if (!file_oformat) {
1416 if (!file_oformat) {
1448 #define NEW_STREAM(type, index)\
1450 ost = new_ ## type ## _stream(o, oc);\
1451 ost->source_index = index;\
1452 ost->sync_ist = input_streams[index];\
1453 input_streams[index]->discard = 0;\
1454 input_streams[index]->st->discard = AVDISCARD_NONE;\
1459 int area = 0, idx = -1;
1473 int channels = 0, idx = -1;
1519 "in any defined filter graph.\n", map->
linklabel);
1600 "output file #%d (%s) is not an encoding option.\n", e->
key,
1607 "output file #%d (%s) has not been used for any stream. The most "
1608 "likely reason is either wrong type (e.g. a video option with "
1609 "no video streams) or that it is a private option of some encoder "
1610 "which was not actually used for any stream.\n", e->
key,
1650 av_log(
NULL,
AV_LOG_FATAL,
"Invalid input file index %d while processing metadata maps\n", in_file_index);
1654 in_file_index >= 0 ?
1695 const char *stream_spec;
1696 int index = 0, j, ret;
1738 static int opt_target(
void *optctx,
const char *opt,
const char *arg)
1742 static const char *
const frame_rates[] = {
"25",
"30000/1001",
"24000/1001" };
1744 if (!strncmp(arg,
"pal-", 4)) {
1747 }
else if (!strncmp(arg,
"ntsc-", 5)) {
1750 }
else if (!strncmp(arg,
"film-", 5)) {
1767 }
else if ((fr == 29970) || (fr == 23976)) {
1787 if (!strcmp(arg,
"vcd")) {
1814 }
else if (!strcmp(arg,
"svcd")) {
1836 }
else if (!strcmp(arg,
"dvd")) {
1857 }
else if (!strncmp(arg,
"dv", 2)) {
1862 parse_option(o,
"pix_fmt", !strncmp(arg,
"dv50", 4) ?
"yuv422p" :
1863 norm ==
PAL ?
"yuv420p" :
"yuv411p",
options);
1887 static int opt_vstats(
void *optctx,
const char *opt,
const char *arg)
1890 time_t today2 = time(
NULL);
1891 struct tm *today = localtime(&today2);
1893 snprintf(filename,
sizeof(filename),
"vstats_%02d%02d%02d.log", today->tm_hour, today->tm_min,
1946 static int opt_vsync(
void *optctx,
const char *opt,
const char *arg)
1960 char layout_str[32];
1963 int ret, channels, ac_str_size;
1971 snprintf(layout_str,
sizeof(layout_str),
"%"PRIu64, layout);
1978 snprintf(layout_str,
sizeof(layout_str),
"%d", channels);
1979 stream_str = strchr(opt,
':');
1980 ac_str_size = 3 + (stream_str ? strlen(stream_str) : 0);
2029 int show_advanced = 0, show_avoptions = 0;
2032 if (!strcmp(opt,
"long"))
2034 else if (!strcmp(opt,
"full"))
2035 show_advanced = show_avoptions = 1;
2042 printf(
"Getting help:\n"
2043 " -h -- print basic options\n"
2044 " -h long -- print more options\n"
2045 " -h full -- print all options (including all format and codec specific options, very long)\n"
2046 " See man %s for detailed description of the options.\n"
2053 "instead of just one file:",
2081 if (show_avoptions) {
2092 printf(
"Hyper fast Audio and Video encoder\n");
2093 printf(
"usage: %s [options] [[infile options] -i infile]... {[outfile options] outfile}...\n",
program_name);
2122 "%s.\n", inout, g->
arg);
2127 ret = open_file(&o, g->
arg);
2146 memset(&octx, 0,
sizeof(octx));
2186 #define OFFSET(x) offsetof(OptionsContext, x)
2192 "force format",
"fmt" },
2194 "overwrite output files" },
2196 "never overwrite output files" },
2199 "codec name",
"codec" },
2202 "codec name",
"codec" },
2205 "preset name",
"preset" },
2208 "set input stream mapping",
2209 "[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
2212 "set metadata information of outfile from infile",
2213 "outfile[,metadata]:infile[,metadata]" },
2216 "set chapters mapping",
"input_file_index" },
2219 "record or transcode \"duration\" seconds of audio/video",
2222 "set the limit file size in bytes",
"limit_size" },
2225 "set the start time offset",
"time_off" },
2228 "enable/disable accurate seeking with -ss" },
2231 "set the input ts offset",
"time_off" },
2234 "set the input ts scale",
"scale" },
2236 "add metadata",
"string=string" },
2239 "set the number of data frames to record",
"number" },
2241 "add timings for benchmarking" },
2243 "set max runtime in seconds",
"limit" },
2245 "dump each input packet" },
2247 "when dumping packets, also dump the payload" },
2250 "read input at native frame rate",
"" },
2252 "specify target file type (\"vcd\", \"svcd\", \"dvd\","
2253 " \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)",
"type" },
2255 "video sync method",
"" },
2257 "audio sync method",
"" },
2259 "audio drift threshold",
"threshold" },
2261 "copy timestamps" },
2263 "copy input stream time base when stream copying" },
2266 "finish encoding within shortest input" },
2268 "timestamp discontinuity delta threshold",
"threshold" },
2270 "exit on error",
"error" },
2273 "copy initial non-keyframes" },
2275 "set the number of frames to record",
"number" },
2278 "force codec tag/fourcc",
"fourcc/tag" },
2281 "use fixed quality scale (VBR)",
"q" },
2284 "use fixed quality scale (VBR)",
"q" },
2286 "set stream filterchain",
"filter_list" },
2288 "read stream filtergraph description from a file",
"filename" },
2290 "create a complex filtergraph",
"graph_description" },
2292 "read complex filtergraph description from a file",
"filename" },
2294 "print progress report during encoding", },
2297 "add an attachment to the output file",
"filename" },
2300 "extract an attachment into a file",
"filename" },
2304 "set the number of video frames to record",
"number" },
2307 "set frame rate (Hz value, fraction or abbreviation)",
"rate" },
2310 "set frame size (WxH or abbreviation)",
"size" },
2313 "set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)",
"aspect" },
2316 "set pixel format",
"format" },
2320 "discard threshold",
"n" },
2323 "rate control override for specific intervals",
"override" },
2326 "force video codec ('copy' to copy stream)",
"codec" },
2328 "select the pass number (1 or 2)",
"n" },
2331 "select two pass log file name prefix",
"prefix" },
2333 "dump video coding statistics to file" },
2335 "dump video coding statistics to file",
"file" },
2337 "video filters",
"filter list" },
2340 "specify intra matrix coeffs",
"matrix" },
2343 "specify inter matrix coeffs",
"matrix" },
2346 "top=1/bottom=0/auto=-1 field first",
"" },
2348 "intra_dc_precision",
"precision" },
2351 "force video tag/fourcc",
"fourcc/tag" },
2353 "show QP histogram" },
2356 "force the selected framerate, disable the best supported framerate selection" },
2359 "set the value of an outfile streamid",
"streamIndex:value" },
2362 "force key frames at specified timestamps",
"timestamps" },
2365 "use HW accelerated decoding",
"hwaccel name" },
2368 "select a device for HW acceleration" "devicename" },
2372 "set the number of audio frames to record",
"number" },
2374 "set audio quality (codec-specific)",
"quality", },
2377 "set audio sampling rate (in Hz)",
"rate" },
2380 "set number of audio channels",
"channels" },
2385 "force audio codec ('copy' to copy stream)",
"codec" },
2388 "force audio tag/fourcc",
"fourcc/tag" },
2390 "change audio volume (256=normal)" ,
"volume" },
2393 "set sample format",
"format" },
2396 "set channel layout",
"layout" },
2398 "audio filters",
"filter list" },
2402 "disable subtitle" },
2404 "force subtitle codec ('copy' to copy stream)",
"codec" },
2406 ,
"force subtitle tag/fourcc",
"fourcc/tag" },
2413 "set the maximum demux-decode delay",
"seconds" },
2415 "set the initial demux-decode delay",
"seconds" },
2418 "A comma-separated list of bitstream filters",
"bitstream_filters" },
2422 "force data codec ('copy' to copy stream)",
"codec" },
unsigned int nb_chapters
Number of chapters in AVChapter array.
int parse_optgroup(void *optctx, OptionGroup *g)
Parse an options group and write results into optctx.
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)
AVDictionary * resample_opts
static OutputStream * new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type)
static AVCodec * choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st)
static int file_overwrite
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
static OutputStream * new_audio_stream(OptionsContext *o, AVFormatContext *oc)
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
#define CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
static void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc)
#define AV_LOG_WARNING
Something somehow does not look correct.
static int opt_audio_tag(void *optctx, const char *opt, const char *arg)
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
char * av_strdup(const char *s) av_malloc_attrib
Duplicate the string s.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
#define CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
const char * name
Name of the codec described by this descriptor.
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.
void avfilter_inout_free(AVFilterInOut **inout)
Free the supplied list of AVFilterInOut and set *inout to NULL.
int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
Check if the given stream matches a stream specifier.
const AVCodecDescriptor * avcodec_descriptor_get_by_name(const char *name)
AVCodecContext * codec
Codec context associated with this stream.
enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx)
Get the type of an AVFilterPad.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
static int sync(AVFormatContext *s, uint8_t *header)
Read input until we find the next ident.
static int configure_complex_filters(void)
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 int opt_channel_layout(void *optctx, const char *opt, const char *arg)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
AVBitStreamFilterContext * bitstream_filters
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
float audio_drift_threshold
static int opt_vstats_file(void *optctx, const char *opt, const char *arg)
AVFilterContext * filter_ctx
filter context associated to this input/output
FilterGraph ** filtergraphs
static int opt_video_filters(void *optctx, const char *opt, const char *arg)
enum AVPixelFormat av_get_pix_fmt(const char *name)
Return the pixel format corresponding to name.
struct AVBitStreamFilterContext * next
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
Copy the settings of the source AVCodecContext into the destination AVCodecContext.
AVDictionary * filter_codec_opts(AVDictionary *opts, enum AVCodecID codec_id, AVFormatContext *s, AVStream *st, AVCodec *codec)
Filter out options for given codec.
static OutputStream * new_subtitle_stream(OptionsContext *o, AVFormatContext *oc)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static void choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost)
SpecifierOpt * frame_pix_fmts
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static AVInputFormat * file_iformat
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void uninit_parse_context(OptionParseContext *octx)
Free all allocated memory in an OptionParseContext.
static const uint8_t frame_sizes[]
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...
int copy_initial_nonkeyframes
enum AVSampleFormat sample_fmt
audio sample format
Opaque data information usually continuous.
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...
#define CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
#define VSYNC_PASSTHROUGH
int id
unique ID to identify the chapter
int id
Format-specific stream ID.
AVCodec * avcodec_find_decoder_by_name(const char *name)
Find a registered decoder with the specified name.
static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
const char * name
Name of the codec implementation.
double strtod(const char *, char **)
#define AV_OPT_FLAG_VIDEO_PARAM
int flags
Flags modifying the (de)muxer behaviour.
static int opt_subtitle_tag(void *optctx, const char *opt, const char *arg)
AVDictionary * resample_opts
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
#define AV_LOG_VERBOSE
Detailed information.
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.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
void av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
static int opt_video_tag(void *optctx, const char *opt, const char *arg)
AVDictionary ** setup_find_stream_info_opts(AVFormatContext *s, AVDictionary *codec_opts)
Setup AVCodecContext options for avformat_find_stream_info().
AVDictionary * format_opts
int configure_filtergraph(FilterGraph *fg)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const
Rescale a 64-bit integer by 2 rational numbers.
static const uint8_t frame_size[4]
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, streams, container, programs, metadata, side data, codec and time base.
static char * get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost)
void show_help_default(const char *opt, const char *arg)
Per-avtool specific help handler.
static int64_t start_time
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define AV_OPT_FLAG_AUDIO_PARAM
char filename[1024]
input or output filename
static int opt_filter_complex(void *optctx, const char *opt, const char *arg)
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
void av_dict_free(AVDictionary **m)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
static void dump_attachment(AVStream *st, const char *filename)
int parse_option(void *optctx, const char *opt, const char *arg, const OptionDef *options)
Parse one given option.
#define CODEC_FLAG_QSCALE
Use fixed qscale.
float dts_delta_threshold
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.
int av_parse_video_rate(AVRational *rate, const char *str)
Parse str and store the detected values in *rate.
static void parse_meta_type(char *arg, char *type, int *index, const char **stream_spec)
Parse a metadata specifier passed as 'arg' parameter.
uint64_t channel_layout
Audio channel layout.
const AVClass * avcodec_get_class(void)
Get the AVClass for AVCodecContext.
int intra_dc_precision
precision of the intra DC coefficient - 8
MetadataMap(* meta_data_maps)[2]
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static AVDictionary * strip_specifiers(AVDictionary *dict)
int rc_override_count
ratecontrol override, see RcOverride
const AVIOInterruptCB int_cb
#define AV_TIME_BASE
Internal time base represented as integer.
SpecifierOpt * audio_channels
void * av_realloc(void *ptr, size_t size) 1(2)
Allocate or reallocate a block of memory.
static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s)
int av_strcasecmp(const char *a, const char *b)
static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
uint16_t * intra_matrix
custom intra quantization matrix
int metadata_chapters_manual
enum AVCodecID av_guess_codec(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.
struct OutputStream * ost
int width
picture width / height.
static int intra_dc_precision
SpecifierOpt * audio_sample_rate
AVStream ** streams
A list of all streams in the file.
static int opt_data_codec(void *optctx, const char *opt, const char *arg)
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int open_output_file(OptionsContext *o, const char *filename)
SpecifierOpt * dump_attachment
A list of option groups that all have the same group type (e.g.
#define FF_ARRAY_ELEMS(a)
SpecifierOpt * metadata_map
char * specifier
stream/chapter/program/...
static int opt_vstats(void *optctx, const char *opt, const char *arg)
static const OptionGroupDef groups[]
char * name
unique name for this input/output in the list
const OptionDef options[]
Usually treated as AVMEDIA_TYPE_DATA.
Opaque data information usually sparse.
int opt_timelimit(void *optctx, const char *opt, const char *arg)
Limit the execution time.
SpecifierOpt * frame_sizes
int vdpau_init(AVCodecContext *s)
static OutputStream * new_video_stream(OptionsContext *o, AVFormatContext *oc)
static void parse_matrix_coeffs(uint16_t *dest, const char *str)
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.
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
static int opt_audio_filters(void *optctx, const char *opt, const char *arg)
if(ac->has_optimized_func)
static int opt_audio_codec(void *optctx, const char *opt, const char *arg)
A linked-list of the inputs/outputs of the filter chain.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
int64_t end
chapter start/end time in time_base units
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
SpecifierOpt * frame_rates
#define AV_LOG_INFO
Standard information.
struct InputStream * sync_ist
OutputFile ** output_files
const AVClass * avfilter_get_class(void)
enum AVMediaType codec_type
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
static AVCodec * find_codec_or_die(const char *name, enum AVMediaType type, int encoder)
int sample_rate
samples per second
const AVClass * sws_get_class(void)
Get the AVClass for swsContext.
OutputStream ** output_streams
static double parse_frame_aspect_ratio(const char *arg)
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.
static int opt_data_frames(void *optctx, const char *opt, const char *arg)
HW acceleration through VDA, data[3] contains a CVPixelBufferRef.
main external API structure.
int av_filename_number_test(const char *filename)
Check whether filename actually is a numbered sequence generator.
int metadata_streams_manual
const char * attachment_filename
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int opt_vsync(void *optctx, const char *opt, const char *arg)
AVIOContext * pb
I/O context.
static void uninit_options(OptionsContext *o)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static int open_input_file(OptionsContext *o, const char *filename)
static int opt_video_frames(void *optctx, const char *opt, const char *arg)
Describe the class of an AVClass context structure.
int pad_idx
index of the filt_ctx pad to use for linking
const char program_name[]
program name, defined by the program for show_version().
int metadata_global_manual
static int opt_subtitle_codec(void *optctx, const char *opt, const char *arg)
int avconv_parse_options(int argc, char **argv)
void * grow_array(void *array, int elem_size, int *size, int new_size)
Realloc array to hold new_size elements of elem_size.
AVDictionary * metadata
Metadata that applies to the whole file.
static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata)
enum AVSampleFormat av_get_sample_fmt(const char *name)
Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE on error.
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...
This struct describes the properties of a single codec described by an AVCodecID. ...
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.
int global_quality
Global quality for codecs which cannot change it per frame.
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static int opt_map(void *optctx, const char *opt, const char *arg)
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_dlog(ac->avr,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
int guess_input_channel_layout(InputStream *ist)
static int opt_filter_complex_script(void *optctx, const char *opt, const char *arg)
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...
const AVClass * avformat_get_class(void)
Get the AVClass for AVFormatContext.
struct FilterGraph * graph
AVDictionary * codec_opts
AVDictionary * format_opts
static int opt_attach(void *optctx, const char *opt, const char *arg)
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
InputStream ** input_streams
static uint8_t * read_file(const char *filename)
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int vda_init(AVCodecContext *s)
static int opt_streamid(void *optctx, const char *opt, const char *arg)
const char ** attachments
#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 poi...
AVRational time_base
time base in which the start/end timestamps are specified
static int opt_audio_qscale(void *optctx, const char *opt, const char *arg)
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
#define AV_OPT_FLAG_ENCODING_PARAM
a generic parameter which can be set by the user for muxing or encoding
static uint8_t * get_line(AVIOContext *s)
struct AVOutputFormat * oformat
The output container format.
#define GROW_ARRAY(array, nb_elems)
int eof_reached
true if eof reached
int channels
number of audio channels
AVOutputFormat * av_guess_format(const char *short_name, const char *filename, const char *mime_type)
Return the output format in the list of registered output formats which best matches the provided par...
AVFilterPad * output_pads
array of output pads
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 configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
uint16_t * inter_matrix
custom inter quantization matrix
void show_help_children(const AVClass *class, int flags)
Show help for all options with given flags in class and all its children.
static int opt_audio_frames(void *optctx, const char *opt, const char *arg)
AVDictionary * encoder_opts
AVDictionary * codec_opts
int64_t duration
Duration of the stream, in AV_TIME_BASE fractional seconds.
int read_yesno(void)
Return a positive value if a line read from standard input starts with [yY], otherwise return 0...
static int opt_video_codec(void *optctx, const char *opt, const char *arg)
#define AV_DICT_IGNORE_SUFFIX
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
static int open_files(OptionGroupList *l, const char *inout, int(*open_file)(OptionsContext *, const char *))
#define SET_DICT(type, meta, context, index)
int dxva2_init(AVCodecContext *s)
static OutputStream * new_attachment_stream(OptionsContext *o, AVFormatContext *oc)
enum AVPixelFormat pix_fmts[2]
static OutputStream * new_data_stream(OptionsContext *o, AVFormatContext *oc)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
void assert_avoptions(AVDictionary *m)
AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
struct SwsContext * sws_opts
static int opt_target(void *optctx, const char *opt, const char *arg)
AVBitStreamFilterContext * av_bitstream_filter_init(const char *name)
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
static void assert_file_overwrite(const char *filename)
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
#define NEW_STREAM(type, index)
static void init_options(OptionsContext *o)