55 #if HAVE_SYS_RESOURCE_H
57 #include <sys/types.h>
58 #include <sys/resource.h>
59 #elif HAVE_GETPROCESSTIMES
62 #if HAVE_GETPROCESSMEMORYINFO
68 #include <sys/select.h>
97 static int transcoding_finished;
100 #define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
153 for (j = 0; j < filtergraphs[i]->
nb_inputs; j++) {
158 for (j = 0; j < filtergraphs[i]->
nb_outputs; j++) {
163 av_freep(&filtergraphs[i]->graph_desc);
189 av_freep(&output_streams[i]->forced_keyframes);
190 av_freep(&output_streams[i]->avfilter);
191 av_freep(&output_streams[i]->logfile_prefix);
202 av_freep(&input_streams[i]->filters);
203 av_freep(&input_streams[i]->hwaccel_device);
238 const char *codec_string = encoder ?
"encoder" :
"decoder";
241 "results.\nAdd '-strict experimental' if you want to use it.\n",
242 codec_string, c->
name);
246 codec_string, codec->
name);
271 int min_dec = INT_MAX, min_inc = INT_MAX;
283 int fmt_diff = 32 * abs(dfmt - efmt);
290 }
else if (dfmt > efmt) {
291 if (fmt_diff < min_inc) {
296 if (fmt_diff < min_dec) {
359 "%d:%d; previous: %"PRId64
", current: %"PRId64
"; ",
366 "in incorrect timestamps in the output file.\n",
436 int subtitle_out_max_size = 1024 * 1024;
437 int subtitle_out_size, nb, i;
451 subtitle_out =
av_malloc(subtitle_out_max_size);
462 for (i = 0; i < nb; i++) {
473 subtitle_out_max_size, sub);
474 if (subtitle_out_size < 0) {
480 pkt.
data = subtitle_out;
481 pkt.
size = subtitle_out_size;
500 int ret, format_video_sync;
575 *frame_size = pkt.
size;
595 return -10.0 * log(d) / log(10.0);
602 double ti1, bitrate, avg_bitrate;
627 avg_bitrate = (double)(
video_size * 8) / ti1 / 1000.0;
628 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
629 (
double)
video_size / 1024, ti1, bitrate, avg_bitrate);
704 int64_t min_pts = INT64_MAX;
708 int64_t pts = output_streams[i]->
sync_opts;
710 if (!output_streams[i]->
filter || output_streams[i]->finished)
713 pts =
av_rescale_q(pts, output_streams[i]->st->codec->time_base,
717 ost = output_streams[i];
737 }
else if (ret ==
AVERROR(EAGAIN))
751 int frame_number, vid, i;
752 double bitrate, ti1, pts;
753 static int64_t last_time = -1;
754 static int qp_histogram[52];
759 if (!is_last_report) {
763 if (last_time == -1) {
767 if ((cur_time - last_time) < 500000)
773 oc = output_files[0]->
ctx;
778 if (total_size < 0) {
782 "avio_tell() failed: %s\n", errbuf);
791 ost = output_streams[i];
796 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"q=%2.1f ", q);
799 float t = (
av_gettime() - timer_start) / 1000000.0;
802 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"frame=%5d fps=%3d q=%3.1f ",
803 frame_number, (t > 1) ? (
int)(frame_number / t + 0.5) : 0, q);
805 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"L");
811 for (j = 0; j < 32; j++)
812 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%X", (
int)
lrintf(
log2(qp_histogram[j] + 1)));
816 double error, error_sum = 0;
817 double scale, scale_sum = 0;
818 char type[3] = {
'Y',
'U',
'V' };
819 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"PSNR=");
820 for (j = 0; j < 3; j++) {
821 if (is_last_report) {
822 error = enc->
error[j];
823 scale = enc->
width * enc->
height * 255.0 * 255.0 * frame_number;
832 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%c:%2.2f ", type[j],
psnr(error / scale));
834 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"*:%2.2f ",
psnr(error_sum / scale_sum));
840 if ((pts < ti1) && (pts > 0))
846 bitrate = (double)(total_size * 8) / ti1 / 1000.0;
848 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
849 "size=%8.0fkB time=%0.2f bitrate=%6.1fkbits/s",
850 (
double)total_size / 1024, ti1, bitrate);
853 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" dup=%d drop=%d",
860 if (is_last_report) {
865 percent = 100.0 * (total_size - raw) / raw;
868 av_log(
NULL,
AV_LOG_INFO,
"video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
884 int stop_encoding = 0;
921 ret = encode(enc, &pkt,
NULL, &got_packet);
1013 opkt.
dts -= ost_tb_start_time;
1046 char layout_name[256];
1063 int i, ret, err = 0, resample_changed;
1072 if (!*got_output || ret < 0) {
1085 decoded_frame->
pts = pkt->
pts;
1093 if (resample_changed) {
1094 char layout1[64], layout2[64];
1098 "layout for Input Stream #%d.%d\n", ist->
file_index,
1110 "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:%s to rate:%d fmt:%s ch:%d chl:%s\n",
1134 for (i = 0; i < ist->nb_filters; i++) {
1135 if (i < ist->nb_filters - 1) {
1136 f = ist->filter_frame;
1150 return err < 0 ? err : ret;
1156 int i, ret = 0, err = 0, resample_changed;
1165 decoded_frame, got_output, pkt);
1166 if (!*got_output || ret < 0) {
1191 if (resample_changed) {
1193 "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
1215 if (i < ist->nb_filters - 1) {
1231 return err < 0 ? err : ret;
1238 &subtitle, got_output, pkt);
1289 "Multiple frames in a packet from stream %d\n", pkt->
stream_index);
1368 avc[i] = output_files[i]->ctx;
1371 printf(
"SDP:\n%s\n", sdp);
1380 if (
hwaccels[i].pix_fmt == pix_fmt)
1391 for (p = pix_fmts; *p != -1; p++) {
1404 ret = hwaccel->
init(s);
1408 "%s hwaccel requested for input stream #%d:%d, "
1409 "but cannot be initialized.\n", hwaccel->
name,
1440 snprintf(error, error_len,
"Decoder (codec id %d) not found for input stream #%d:%d",
1471 snprintf(error, error_len,
1472 "Error while opening decoder for input stream "
1512 for (p = kf; *p; p++)
1523 for (i = 0; i < n; i++) {
1524 char *next = strchr(p,
',');
1538 int ret = 0, i, j, k;
1556 oc = output_files[i]->
ctx;
1572 ost = output_streams[i];
1597 if (extra_size > INT_MAX) {
1671 snprintf(error,
sizeof(error),
"Automatic encoder selection "
1672 "failed for output stream #%d:%d. Default encoder for "
1673 "format %s is probably disabled. Please choose an "
1704 "for the output stream #%d:%d, but no information "
1705 "about the input framerate is available. Falling "
1706 "back to a default value of 25fps. Use the -r option "
1707 "if you want a different framerate.\n",
1771 snprintf(logfilename,
sizeof(logfilename),
"%s-%d.log",
1775 if (!strcmp(ost->
enc->
name,
"libx264")) {
1779 f = fopen(logfilename,
"wb");
1782 logfilename, strerror(errno));
1788 size_t logbuffer_size;
1803 ost = output_streams[i];
1824 snprintf(error,
sizeof(error),
"Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height",
1831 "It takes bits/s as argument, not kbits/s\n");
1861 oc = output_files[i]->
ctx;
1866 snprintf(error,
sizeof(error),
1867 "Could not write header for output file #%d "
1868 "(incorrect codec parameters ?): %s",
1883 av_dump_format(output_files[i]->ctx, i, output_files[i]->ctx->filename, 1);
1889 ist = input_streams[i];
1896 if (nb_filtergraphs > 1)
1904 ost = output_streams[i];
1916 if (nb_filtergraphs > 1)
1983 int64_t ipts_min = INT64_MAX;
1993 if (ipts < ipts_min) {
2004 static void *input_thread(
void *arg)
2009 while (!transcoding_finished && ret >= 0) {
2034 static void free_input_threads(
void)
2041 transcoding_finished = 1;
2047 if (!f->fifo || f->joined)
2069 static int init_input_threads(
void)
2073 if (nb_input_files == 1)
2127 if (nb_input_files > 1)
2128 return get_input_packet_mt(f, pkt);
2137 if (input_files[i]->eagain)
2146 input_files[i]->eagain = 0;
2198 ist = input_streams[ifile->
ist_index + i];
2224 goto discard_packet;
2228 goto discard_packet;
2248 "timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
2275 int ret, i, need_input = 1;
2279 int64_t timer_start;
2291 if ((ret = init_input_threads()) < 0)
2322 free_input_threads();
2327 ist = input_streams[i];
2339 os = output_files[i]->
ctx;
2348 ost = output_streams[i];
2357 ist = input_streams[i];
2370 free_input_threads();
2373 if (output_streams) {
2375 ost = output_streams[i];
2396 struct rusage rusage;
2398 getrusage(RUSAGE_SELF, &rusage);
2399 return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
2400 #elif HAVE_GETPROCESSTIMES
2402 FILETIME c, e, k, u;
2403 proc = GetCurrentProcess();
2404 GetProcessTimes(proc, &c, &e, &k, &u);
2405 return ((int64_t) u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
2413 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
2414 struct rusage rusage;
2415 getrusage(RUSAGE_SELF, &rusage);
2416 return (int64_t)rusage.ru_maxrss * 1024;
2417 #elif HAVE_GETPROCESSMEMORYINFO
2419 PROCESS_MEMORY_COUNTERS memcounters;
2420 proc = GetCurrentProcess();
2421 memcounters.cb =
sizeof(memcounters);
2422 GetProcessMemoryInfo(proc, &memcounters,
sizeof(memcounters));
2423 return memcounters.PeakPagefileUsage;
2462 fprintf(stderr,
"At least one output file must be specified\n");
2472 printf(
"bench: utime=%0.3fs maxrss=%ikB\n", ti / 1000000.0, maxrss);
uint64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
static int need_output(void)
const struct AVCodec * codec
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int transcode_init(void)
static int check_output_constraints(InputStream *ist, OutputStream *ost)
static int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
int64_t avio_size(AVIOContext *s)
Get the filesize.
void av_free_packet(AVPacket *pkt)
Free a packet.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int got_eagain(void)
This structure describes decoded (raw) audio or video data.
static void pthread_join(pthread_t thread, void **value_ptr)
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
uint64_t error[AV_NUM_DATA_POINTERS]
error
#define CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
#define CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
Main libavfilter public API header.
static void flush_encoders(void)
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
#define CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
Memory buffer source API.
AVFrame * coded_frame
the picture in the bitstream
void show_banner(void)
Print the program banner to stderr.
int avfilter_graph_config(AVFilterGraph *graphctx, void *log_ctx)
Check validity and configure all the links and formats in the graph.
static void term_exit(void)
int h
agreed upon image height
static int nb_frames_drop
int ist_in_filtergraph(FilterGraph *fg, InputStream *ist)
AVCodecParserContext * parser
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int index
stream index in AVFormatContext
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVBitStreamFilterContext * bitstream_filters
FilterGraph * init_simple_filtergraph(InputStream *ist, OutputStream *ost)
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
FilterGraph ** filtergraphs
#define FF_ARRAY_ELEMS(a)
int av_usleep(unsigned usec)
Sleep for a period of time.
int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time...
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
int av_dup_packet(AVPacket *pkt)
four components are given, that's all.
static volatile int received_sigterm
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
void init_pts_correction(PtsCorrectionContext *ctx)
Reset the state of the PtsCorrectionContext.
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
float dts_delta_threshold
enum AVAudioServiceType audio_service_type
Type of service that the audio stream conveys.
unsigned int nb_stream_indexes
#define AV_LOG_QUIET
Print no output.
#define CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int copy_initial_nonkeyframes
static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
enum AVSampleFormat sample_fmt
audio sample format
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Opaque data information usually continuous.
static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr)
int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
miscellaneous OS support macros and functions.
#define VSYNC_PASSTHROUGH
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream ** streams
A list of all streams in the file.
int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of video.
void avfilter_register_all(void)
Initialize the filter system.
static double av_q2d(AVRational a)
Convert rational to double.
static void term_init(void)
AVDictionary * resample_opts
int avformat_network_init(void)
Do global initialization of network components.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
static int pthread_create(pthread_t *thread, const void *unused_attr, void *(*start_routine)(void *), void *arg)
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
int interlaced_frame
The content of the picture is interlaced.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
external api for the swscale stuff
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
enum AVDiscard discard
selects which program to discard and which to feed to the caller
char * stats_out
pass1 encoding statistics output buffer
static FILE * vstats_file
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
struct AVBitStreamFilterContext * next
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
unsigned int * stream_index
static int decode_interrupt_cb(void *ctx)
struct AVOutputFormat * oformat
The output container format.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int configure_filtergraph(FilterGraph *fg)
static void pthread_cond_signal(pthread_cond_t *cond)
void av_buffer_default_free(void *opaque, uint8_t *data)
Default free callback, which calls av_free() on the buffer data.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static void abort_codec_experimental(AVCodec *c, int encoder)
static const uint8_t frame_size[4]
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts)
Main libavdevice API header.
Callback for checking whether to abort blocking functions.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
static int64_t start_time
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int64_t extra_size
int sample_rate
samples per second
#define CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
enum AVSampleFormat request_sample_fmt
Used to request a sample format from the decoder.
static int pthread_mutex_init(pthread_mutex_t *m, void *attr)
static int pthread_mutex_unlock(pthread_mutex_t *m)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
void av_bitstream_filter_close(AVBitStreamFilterContext *bsf)
static void update_sample_fmt(AVCodecContext *dec, AVCodec *dec_codec, AVCodecContext *enc)
void av_dict_free(AVDictionary **pm)
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.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
int rc_max_rate
maximum bitrate
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
int main(int argc, char **argv)
const char * name
Name of the codec implementation.
int(* init)(AVCodecContext *s)
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
AVRational avg_frame_rate
Average framerate.
New fields can be added to the end with minor version bumps.
static char logfilename[1024]
int flags
A combination of AV_PKT_FLAG values.
uint64_t channel_layout
Audio channel layout.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare 2 timestamps each in its own timebases.
uint32_t end_display_time
int64_t guess_correct_pts(PtsCorrectionContext *ctx, int64_t reordered_pts, int64_t dts)
Attempt to guess proper monotonic timestamps for decoded video frames which might have incorrect time...
int64_t pts
Same as packet pts, in AV_TIME_BASE.
AVCodecContext * codec
Codec context associated with this stream.
int rc_buffer_size
decoder bitstream buffer size
uint64_t channel_layout
Channel layout of the audio data.
int w
agreed upon image width
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int bit_rate
the average bitrate
static int64_t audio_size
audio channel layout utility functions
AVRational av_d2q(double d, int max)
Convert a double precision floating point number to a rational.
static void do_audio_out(AVFormatContext *s, OutputStream *ost, AVFrame *frame)
enum AVPictureType pict_type
Picture type of the frame.
const AVIOInterruptCB int_cb
char filename[1024]
input or output filename
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static InputStream * get_input_stream(OutputStream *ost)
#define AV_TIME_BASE
Internal time base represented as integer.
int width
picture width / height.
static void do_video_stats(OutputStream *ost, int frame_size)
int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples)
Same as av_buffersink_get_frame(), but with the ability to specify the number of samples read...
static void do_video_out(AVFormatContext *s, OutputStream *ost, AVFrame *in_picture, int *frame_size)
void av_parser_close(AVCodecParserContext *s)
static av_always_inline av_const long int lrintf(float x)
enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt)
Get the packed alternative form of the given sample format.
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
static int get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
#define CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
static void do_subtitle_out(AVFormatContext *s, OutputStream *ost, InputStream *ist, AVSubtitle *sub, int64_t pts)
static volatile int received_nb_signals
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Opaque data information usually sparse.
enum AVPixelFormat pix_fmt
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
preferred ID for MPEG-1/2 video decoding
int av_find_nearest_q_idx(AVRational q, const AVRational *q_list)
Find the nearest value in q_list to q.
int format
agreed upon media format
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it...
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
if(ac->has_optimized_func)
static void print_sdp(void)
int64_t av_gettime(void)
Get the current time in microseconds.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int frame_size
Number of samples per channel in an audio frame.
static void parse_forced_key_frames(char *kf, OutputStream *ost, AVCodecContext *avctx)
static int pthread_mutex_lock(pthread_mutex_t *m)
static int output_packet(InputStream *ist, const AVPacket *pkt)
int av_fifo_space(AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
static int64_t getmaxrss(void)
#define AV_LOG_INFO
Standard information.
int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe)
uint64_t error[AV_NUM_DATA_POINTERS]
error
AVCodecParserContext * av_parser_init(int codec_id)
struct InputStream * sync_ist
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
OutputFile ** output_files
enum AVMediaType codec_type
int me_threshold
Motion estimation threshold below which no motion estimation is performed, but instead the user speci...
const AVRational * supported_framerates
array of supported framerates, or NULL if any, array is terminated by {0,0}
#define DEFAULT_PASS_LOGFILENAME_PREFIX
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_opt_set_dict(void *obj, AVDictionary **options)
int sample_rate
samples per second
static void avconv_cleanup(int ret)
AVIOContext * pb
I/O context.
OutputStream ** output_streams
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
static int check_recording_time(OutputStream *ost)
static double psnr(double d)
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
const int program_birth_year
program birth year, defined by the program for show_banner()
const char * attachment_filename
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
a very simple circular buffer FIFO implementation
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Replacements for frequently missing libm functions.
int avconv_parse_options(int argc, char **argv)
struct AVBitStreamFilter * filter
int sample_rate
Sample rate of the audio data.
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
static const AVFilterPad inputs[]
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
rational number numerator/denominator
const char program_name[]
program name, defined by the program for show_version().
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 decode_video(InputStream *ist, AVPacket *pkt, int *got_output)
static int64_t getutime(void)
discard useless packets like 0 size packets in avi
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
This callback is called at the beginning of each frame to get data buffer(s) for it.
AVRational sample_aspect_ratio
agreed upon sample aspect ratio
static int poll_filter(OutputStream *ost)
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
Read the file with name filename, and put its content in a newly allocated 0-terminated buffer...
int global_quality
Global quality for codecs which cannot change it per frame.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
static const uint16_t scale[4]
enum AVMediaType type
filter media type
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
static int process_input(void)
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
const OptionDef options[]
static int poll_filters(void)
static const HWAccel * get_hwaccel(enum AVPixelFormat pix_fmt)
static int get_input_packet(InputFile *f, AVPacket *pkt)
int64_t pkt_dts
DTS copied from the AVPacket that triggered returning this frame.
int guess_input_channel_layout(InputStream *ist)
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 av_fifo_size(AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
struct FilterGraph * graph
static void reset_eagain(void)
InputStream ** input_streams
int disposition
AV_DISPOSITION_* bit field.
uint32_t start_display_time
AVSampleFormat
Audio Sample Formats.
#define CODEC_CAP_EXPERIMENTAL
Codec is experimental and is thus avoided in favor of non experimental encoders.
static InputFile * select_input_file(void)
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int thread_safe_callbacks
Set by the client if its custom get_buffer() callback can be called synchronously from another thread...
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
struct AVInputFormat * iformat
The input container format.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
int top_field_first
If the content is interlaced, is top field displayed first.
struct AVFrac pts
encoding: pts generation when outputting stream
int channels
number of audio channels
static int64_t video_size
struct AVCodecParserContext * parser
void av_log_set_flags(int arg)
static int transcode(void)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, AVPacket *avpkt)
Decode the video frame of size avpkt->size from avpkt->data into picture.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int frame_number
Frame counter, set by libavcodec.
int repeat_pict
This field is used for proper frame duration computation in lavf.
enum AVFieldOrder field_order
Field order.
#define AV_DICT_IGNORE_SUFFIX
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
enum AVSampleFormat * sample_fmts
array of supported sample formats, or NULL if unknown, array is terminated by -1
static void sigterm_handler(int sig)
static int init_input_stream(int ist_index, char *error, int error_len)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, AVStream *st)
Send a nice dump of a packet to the log.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
void assert_avoptions(AVDictionary *m)
int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
Get a frame with filtered data from sink and put it in frame.
AVPixelFormat
Pixel format.
This structure stores compressed data.
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
static void print_report(int is_last_report, int64_t timer_start)
int nb_samples
number of audio samples (per channel) described by this frame
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void * opaque
Private data of the user, can be used to carry app specific stuff.
#define AV_NOPTS_VALUE
Undefined timestamp value.
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
uint8_t * subtitle_header
Header containing style information for text subtitles.
int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Decode the audio frame of size avpkt->size from avpkt->data into frame.