ffmpeg.c File Reference
#include "config.h"
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <errno.h>
#include <signal.h>
#include <limits.h>
#include <unistd.h>
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavutil/opt.h"
#include "libavcodec/audioconvert.h"
#include "libavutil/audioconvert.h"
#include "libavutil/parseutils.h"
#include "libavutil/samplefmt.h"
#include "libavutil/colorspace.h"
#include "libavutil/fifo.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/dict.h"
#include "libavutil/mathematics.h"
#include "libavutil/pixdesc.h"
#include "libavutil/avstring.h"
#include "libavutil/libm.h"
#include "libavformat/os_support.h"
#include <time.h>
#include "cmdutils.h"
#include "libavutil/avassert.h"
#include "cmdutils_common_opts.h"

Go to the source code of this file.

Data Structures

struct  StreamMap
struct  MetadataMap
 select an input file for an output file More...
struct  ChapterMap
struct  OutputStream
struct  InputStream
struct  InputFile

Macros

#define MAX_FILES   100
#define QSCALE_NONE   -99999
#define DEFAULT_PASS_LOGFILENAME_PREFIX   "ffmpeg2pass"
#define MAX_AUDIO_PACKET_SIZE   (128 * 1024)
#define MAKE_SFMT_PAIR(a, b)   ((a)+AV_SAMPLE_FMT_NB*(b))
#define AV_DELAY_MAX   0.100
#define METADATA_CHECK_INDEX(index, nb_elems, desc)

Typedefs

typedef struct StreamMap StreamMap
typedef struct MetadataMap MetadataMap
 select an input file for an output file
typedef struct ChapterMap ChapterMap
typedef struct OutputStream OutputStream
typedef struct InputStream InputStream
typedef struct InputFile InputFile

Functions

static void term_exit (void)
static void sigterm_handler (int sig)
static void term_init (void)
static int decode_interrupt_cb (void)
void exit_program (int ret)
 Do all the necessary cleanup and abort.
static void assert_avoptions (AVDictionary *m)
static void assert_codec_experimental (AVCodecContext *c, int encoder)
static void choose_sample_fmt (AVStream *st, AVCodec *codec)
static void update_sample_fmt (AVCodecContext *dec, AVCodec *dec_codec, AVCodecContext *enc)
 Update the requested input sample format based on the output sample format.
static void choose_sample_rate (AVStream *st, AVCodec *codec)
static void choose_pixel_fmt (AVStream *st, AVCodec *codec)
static OutputStreamnew_output_stream (AVFormatContext *oc, int file_idx, AVCodec *codec)
static int read_avserver_streams (AVFormatContext *s, const char *filename)
static double get_sync_ipts (const OutputStream *ost)
static void write_frame (AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc)
static void do_audio_out (AVFormatContext *s, OutputStream *ost, InputStream *ist, unsigned char *buf, int size)
static void pre_process_video_frame (InputStream *ist, AVPicture *picture, void **bufp)
static void do_subtitle_out (AVFormatContext *s, OutputStream *ost, InputStream *ist, AVSubtitle *sub, int64_t pts)
static void do_video_out (AVFormatContext *s, OutputStream *ost, InputStream *ist, AVFrame *in_picture, int *frame_size, float quality)
static double psnr (double d)
static void do_video_stats (AVFormatContext *os, OutputStream *ost, int frame_size)
static void print_report (AVFormatContext **output_files, OutputStream **ost_table, int nb_ostreams, int is_last_report)
static void generate_silence (uint8_t *buf, enum AVSampleFormat sample_fmt, size_t size)
static int output_packet (InputStream *ist, int ist_index, OutputStream **ost_table, int nb_ostreams, const AVPacket *pkt)
static void print_sdp (AVFormatContext **avc, int n)
static int copy_chapters (int infile, int outfile)
static void parse_forced_key_frames (char *kf, OutputStream *ost, AVCodecContext *avctx)
static int transcode (AVFormatContext **output_files, int nb_output_files, InputFile *input_files, int nb_input_files, StreamMap *stream_maps, int nb_stream_maps)
static int opt_format (const char *opt, const char *arg)
static int opt_video_rc_override_string (const char *opt, const char *arg)
static int opt_me_threshold (const char *opt, const char *arg)
static int opt_verbose (const char *opt, const char *arg)
static int opt_frame_rate (const char *opt, const char *arg)
static int opt_frame_crop (const char *opt, const char *arg)
static int opt_frame_size (const char *opt, const char *arg)
static int opt_pad (const char *opt, const char *arg)
static int opt_frame_pix_fmt (const char *opt, const char *arg)
static int opt_frame_aspect_ratio (const char *opt, const char *arg)
static int opt_metadata (const char *opt, const char *arg)
static int opt_qscale (const char *opt, const char *arg)
static int opt_top_field_first (const char *opt, const char *arg)
static int opt_thread_count (const char *opt, const char *arg)
static int opt_audio_sample_fmt (const char *opt, const char *arg)
static int opt_audio_rate (const char *opt, const char *arg)
static int opt_audio_channels (const char *opt, const char *arg)
static int opt_video_channel (const char *opt, const char *arg)
static int opt_video_standard (const char *opt, const char *arg)
static int opt_codec (int *pstream_copy, char **pcodec_name, int codec_type, const char *arg)
static int opt_audio_codec (const char *opt, const char *arg)
static int opt_video_codec (const char *opt, const char *arg)
static int opt_subtitle_codec (const char *opt, const char *arg)
static int opt_data_codec (const char *opt, const char *arg)
static int opt_codec_tag (const char *opt, const char *arg)
static int opt_map (const char *opt, const char *arg)
static void parse_meta_type (char *arg, char *type, int *index, char **endptr)
static int opt_map_metadata (const char *opt, const char *arg)
static int opt_map_meta_data (const char *opt, const char *arg)
static int opt_map_chapters (const char *opt, const char *arg)
static int opt_input_ts_scale (const char *opt, const char *arg)
static int opt_recording_time (const char *opt, const char *arg)
static int opt_start_time (const char *opt, const char *arg)
static int opt_recording_timestamp (const char *opt, const char *arg)
static int opt_input_ts_offset (const char *opt, const char *arg)
static enum CodecID find_codec_or_die (const char *name, int type, int encoder)
static int opt_input_file (const char *opt, const char *filename)
static void check_inputs (int *has_video_ptr, int *has_audio_ptr, int *has_subtitle_ptr, int *has_data_ptr)
static void new_video_stream (AVFormatContext *oc, int file_idx)
static void new_audio_stream (AVFormatContext *oc, int file_idx)
static void new_data_stream (AVFormatContext *oc, int file_idx)
static void new_subtitle_stream (AVFormatContext *oc, int file_idx)
static int opt_new_stream (const char *opt, const char *arg)
static int opt_streamid (const char *opt, const char *arg)
static void opt_output_file (void *optctx, const char *filename)
static int opt_pass (const char *opt, const char *arg)
static int64_t getutime (void)
static int64_t getmaxrss (void)
static void parse_matrix_coeffs (uint16_t *dest, const char *str)
static void opt_inter_matrix (const char *arg)
static void opt_intra_matrix (const char *arg)
static void show_usage (void)
static void show_help (void)
static int opt_target (const char *opt, const char *arg)
static int opt_vstats_file (const char *opt, const char *arg)
static int opt_vstats (const char *opt, const char *arg)
static int opt_bsf (const char *opt, const char *arg)
static int opt_preset (const char *opt, const char *arg)
int main (int argc, char **argv)

Variables

const char program_name [] = "ffmpeg"
 program name, defined by the program for show_version().
const int program_birth_year = 2000
 program birth year, defined by the program for show_banner()
static const OptionDef options []
static const char * last_asked_format = NULL
static double * ts_scale
static int nb_ts_scale
static AVFormatContextoutput_files [MAX_FILES]
static AVDictionaryoutput_opts [MAX_FILES]
static int nb_output_files = 0
static StreamMapstream_maps = NULL
static int nb_stream_maps
static MetadataMap(* meta_data_maps )[2] = NULL
static int nb_meta_data_maps
static int metadata_global_autocopy = 1
static int metadata_streams_autocopy = 1
static int metadata_chapters_autocopy = 1
static ChapterMapchapter_maps = NULL
static int nb_chapter_maps
static int * streamid_map = NULL
static int nb_streamid_map = 0
static int frame_width = 0
static int frame_height = 0
static float frame_aspect_ratio = 0
static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE
static enum AVSampleFormat audio_sample_fmt = AV_SAMPLE_FMT_NONE
static int max_frames [4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX}
static AVRational frame_rate
static float video_qscale = 0
static uint16_t * intra_matrix = NULL
static uint16_t * inter_matrix = NULL
static const char * video_rc_override_string = NULL
static int video_disable = 0
static int video_discard = 0
static char * video_codec_name = NULL
static unsigned int video_codec_tag = 0
static char * video_language = NULL
static int same_quality = 0
static int do_deinterlace = 0
static int top_field_first = -1
static int me_threshold = 0
static int intra_dc_precision = 8
static int loop_input = 0
static int loop_output = AVFMT_NOOUTPUTLOOP
static int qp_hist = 0
static int intra_only = 0
static int audio_sample_rate = 0
static float audio_qscale = QSCALE_NONE
static int audio_disable = 0
static int audio_channels = 0
static char * audio_codec_name = NULL
static unsigned int audio_codec_tag = 0
static char * audio_language = NULL
static int subtitle_disable = 0
static char * subtitle_codec_name = NULL
static char * subtitle_language = NULL
static unsigned int subtitle_codec_tag = 0
static int data_disable = 0
static char * data_codec_name = NULL
static unsigned int data_codec_tag = 0
static float mux_preload = 0.5
static float mux_max_delay = 0.7
static int64_t recording_time = INT64_MAX
static int64_t start_time = 0
static int64_t input_ts_offset = 0
static int file_overwrite = 0
static AVDictionarymetadata
static int do_benchmark = 0
static int do_hex_dump = 0
static int do_pkt_dump = 0
static int do_psnr = 0
static int do_pass = 0
static char * pass_logfilename_prefix = NULL
static int audio_stream_copy = 0
static int video_stream_copy = 0
static int subtitle_stream_copy = 0
static int data_stream_copy = 0
static int video_sync_method = -1
static int audio_sync_method = 0
static float audio_drift_threshold = 0.1
static int copy_ts = 0
static int copy_tb
static int opt_shortest = 0
static char * vstats_filename
static FILE * vstats_file
static int opt_programid = 0
static int copy_initial_nonkeyframes = 0
static int rate_emu = 0
static int audio_volume = 256
static int exit_on_error = 0
static int using_stdin = 0
static int verbose = 1
static int thread_count = 1
static int64_t video_size = 0
static int64_t audio_size = 0
static int64_t extra_size = 0
static int nb_frames_dup = 0
static int nb_frames_drop = 0
static int input_sync
static uint64_t limit_filesize = 0
static int force_fps = 0
static char * forced_key_frames = NULL
static float dts_delta_threshold = 10
static int64_t timer_start
static uint8_t * audio_buf
static uint8_t * audio_out
static unsigned int allocated_audio_out_size
static unsigned int allocated_audio_buf_size
static short * samples
static AVBitStreamFilterContextvideo_bitstream_filters = NULL
static AVBitStreamFilterContextaudio_bitstream_filters = NULL
static AVBitStreamFilterContextsubtitle_bitstream_filters = NULL
static OutputStream ** output_streams_for_file [MAX_FILES] = { NULL }
static int nb_output_streams_for_file [MAX_FILES] = { 0 }
static InputStreaminput_streams = NULL
static int nb_input_streams = 0
static InputFileinput_files = NULL
static int nb_input_files = 0
static volatile int received_sigterm = 0
static volatile int received_nb_signals = 0
static int bit_buffer_size = 1024*256
static uint8_t * bit_buffer = NULL

Macro Definition Documentation

#define AV_DELAY_MAX   0.100

Definition at line 1040 of file ffmpeg.c.

#define DEFAULT_PASS_LOGFILENAME_PREFIX   "ffmpeg2pass"

Definition at line 239 of file ffmpeg.c.

Referenced by transcode().

#define MAKE_SFMT_PAIR (   a,
  b 
)    ((a)+AV_SAMPLE_FMT_NB*(b))
#define MAX_AUDIO_PACKET_SIZE   (128 * 1024)

Definition at line 754 of file ffmpeg.c.

#define MAX_FILES   100

Definition at line 104 of file ffmpeg.c.

Referenced by transcode().

#define METADATA_CHECK_INDEX (   index,
  nb_elems,
  desc 
)
Value:
if ((index) < 0 || (index) >= (nb_elems)) {\
snprintf(error, sizeof(error), "Invalid %s index %d while processing metadata maps\n",\
(desc), (index));\
ret = AVERROR(EINVAL);\
goto dump_format;\
}
#define QSCALE_NONE   -99999

Definition at line 161 of file ffmpeg.c.

Referenced by new_audio_stream().

Typedef Documentation

typedef struct ChapterMap ChapterMap
typedef struct InputFile InputFile
typedef struct InputStream InputStream
typedef struct MetadataMap MetadataMap

select an input file for an output file

typedef struct OutputStream OutputStream
typedef struct StreamMap StreamMap

Function Documentation

static void assert_avoptions ( AVDictionary m)
static

Definition at line 508 of file ffmpeg.c.

Referenced by opt_input_file(), and transcode().

static void assert_codec_experimental ( AVCodecContext c,
int  encoder 
)
static

Definition at line 517 of file ffmpeg.c.

Referenced by transcode().

static void check_inputs ( int *  has_video_ptr,
int *  has_audio_ptr,
int *  has_subtitle_ptr,
int *  has_data_ptr 
)
static

Definition at line 3354 of file ffmpeg.c.

Referenced by opt_output_file().

static void choose_pixel_fmt ( AVStream st,
AVCodec codec 
)
static

Definition at line 613 of file ffmpeg.c.

Referenced by read_avserver_streams(), and transcode().

static void choose_sample_fmt ( AVStream st,
AVCodec codec 
)
static

Definition at line 534 of file ffmpeg.c.

Referenced by read_avserver_streams(), and transcode().

static void choose_sample_rate ( AVStream st,
AVCodec codec 
)
static

Definition at line 593 of file ffmpeg.c.

Referenced by transcode().

static int copy_chapters ( int  infile,
int  outfile 
)
static

Definition at line 1863 of file ffmpeg.c.

Referenced by transcode().

static int decode_interrupt_cb ( void  )
static

Definition at line 444 of file ffmpeg.c.

Referenced by main().

static void do_audio_out ( AVFormatContext s,
OutputStream ost,
InputStream ist,
unsigned char *  buf,
int  size 
)
static

Definition at line 756 of file ffmpeg.c.

Referenced by output_packet().

static void do_subtitle_out ( AVFormatContext s,
OutputStream ost,
InputStream ist,
AVSubtitle sub,
int64_t  pts 
)
static

Definition at line 1042 of file ffmpeg.c.

Referenced by output_packet().

static void do_video_out ( AVFormatContext s,
OutputStream ost,
InputStream ist,
AVFrame in_picture,
int *  frame_size,
float  quality 
)
static

Definition at line 1108 of file ffmpeg.c.

Referenced by output_packet().

static void do_video_stats ( AVFormatContext os,
OutputStream ost,
int  frame_size 
)
static

Definition at line 1285 of file ffmpeg.c.

Referenced by output_packet().

void exit_program ( int  ret)

Do all the necessary cleanup and abort.

This function is implemented in the avtools, not cmdutils.

Definition at line 449 of file ffmpeg.c.

static enum CodecID find_codec_or_die ( const char *  name,
int  type,
int  encoder 
)
static

Definition at line 3114 of file ffmpeg.c.

Referenced by new_audio_stream(), new_subtitle_stream(), new_video_stream(), and opt_input_file().

static void generate_silence ( uint8_t *  buf,
enum AVSampleFormat  sample_fmt,
size_t  size 
)
static

Definition at line 1444 of file ffmpeg.c.

Referenced by output_packet().

static double get_sync_ipts ( const OutputStream ost)
static

Definition at line 716 of file ffmpeg.c.

Referenced by do_audio_out(), and do_video_out().

static int64_t getmaxrss ( void  )
static

Definition at line 3873 of file ffmpeg.c.

Referenced by main().

static int64_t getutime ( void  )
static

Definition at line 3855 of file ffmpeg.c.

Referenced by main().

int main ( int  argc,
char **  argv 
)

Definition at line 4356 of file ffmpeg.c.

static void new_audio_stream ( AVFormatContext oc,
int  file_idx 
)
static

Definition at line 3528 of file ffmpeg.c.

Referenced by opt_new_stream(), and opt_output_file().

static void new_data_stream ( AVFormatContext oc,
int  file_idx 
)
static

Definition at line 3589 of file ffmpeg.c.

Referenced by opt_new_stream(), and opt_output_file().

static OutputStream* new_output_stream ( AVFormatContext oc,
int  file_idx,
AVCodec codec 
)
static
static void new_subtitle_stream ( AVFormatContext oc,
int  file_idx 
)
static

Definition at line 3620 of file ffmpeg.c.

Referenced by opt_new_stream(), and opt_output_file().

static void new_video_stream ( AVFormatContext oc,
int  file_idx 
)
static

Definition at line 3397 of file ffmpeg.c.

Referenced by opt_new_stream(), and opt_output_file().

static int opt_audio_channels ( const char *  opt,
const char *  arg 
)
static

Definition at line 2899 of file ffmpeg.c.

static int opt_audio_codec ( const char *  opt,
const char *  arg 
)
static

Definition at line 2931 of file ffmpeg.c.

Referenced by opt_preset(), and opt_target().

static int opt_audio_rate ( const char *  opt,
const char *  arg 
)
static

Definition at line 2893 of file ffmpeg.c.

static int opt_audio_sample_fmt ( const char *  opt,
const char *  arg 
)
static

Definition at line 2875 of file ffmpeg.c.

static int opt_bsf ( const char *  opt,
const char *  arg 
)
static

Definition at line 4160 of file ffmpeg.c.

static int opt_codec ( int *  pstream_copy,
char **  pcodec_name,
int  codec_type,
const char *  arg 
)
static

Definition at line 2919 of file ffmpeg.c.

Referenced by opt_audio_codec(), opt_data_codec(), opt_subtitle_codec(), and opt_video_codec().

static int opt_codec_tag ( const char *  opt,
const char *  arg 
)
static

Definition at line 2951 of file ffmpeg.c.

static int opt_data_codec ( const char *  opt,
const char *  arg 
)
static

Definition at line 2946 of file ffmpeg.c.

Referenced by opt_preset().

static int opt_format ( const char *  opt,
const char *  arg 
)
static

Definition at line 2741 of file ffmpeg.c.

Referenced by opt_target().

static int opt_frame_aspect_ratio ( const char *  opt,
const char *  arg 
)
static

Definition at line 2809 of file ffmpeg.c.

static int opt_frame_crop ( const char *  opt,
const char *  arg 
)
static

Definition at line 2774 of file ffmpeg.c.

static int opt_frame_pix_fmt ( const char *  opt,
const char *  arg 
)
static

Definition at line 2794 of file ffmpeg.c.

Referenced by opt_target().

static int opt_frame_rate ( const char *  opt,
const char *  arg 
)
static

Definition at line 2765 of file ffmpeg.c.

Referenced by opt_target().

static int opt_frame_size ( const char *  opt,
const char *  arg 
)
static

Definition at line 2780 of file ffmpeg.c.

Referenced by opt_target().

static int opt_input_file ( const char *  opt,
const char *  filename 
)
static

Definition at line 3135 of file ffmpeg.c.

static int opt_input_ts_offset ( const char *  opt,
const char *  arg 
)
static

Definition at line 3108 of file ffmpeg.c.

static int opt_input_ts_scale ( const char *  opt,
const char *  arg 
)
static

Definition at line 3067 of file ffmpeg.c.

static void opt_inter_matrix ( const char *  arg)
static

Definition at line 3908 of file ffmpeg.c.

static void opt_intra_matrix ( const char *  arg)
static

Definition at line 3914 of file ffmpeg.c.

static int opt_map ( const char *  opt,
const char *  arg 
)
static

Definition at line 2969 of file ffmpeg.c.

static int opt_map_chapters ( const char *  opt,
const char *  arg 
)
static

Definition at line 3051 of file ffmpeg.c.

static int opt_map_meta_data ( const char *  opt,
const char *  arg 
)
static

Definition at line 3044 of file ffmpeg.c.

static int opt_map_metadata ( const char *  opt,
const char *  arg 
)
static

Definition at line 3016 of file ffmpeg.c.

Referenced by opt_map_meta_data().

static int opt_me_threshold ( const char *  opt,
const char *  arg 
)
static

Definition at line 2753 of file ffmpeg.c.

static int opt_metadata ( const char *  opt,
const char *  arg 
)
static

Definition at line 2834 of file ffmpeg.c.

Referenced by opt_recording_timestamp().

static int opt_new_stream ( const char *  opt,
const char *  arg 
)
static

Definition at line 3668 of file ffmpeg.c.

static void opt_output_file ( void optctx,
const char *  filename 
)
static

Definition at line 3708 of file ffmpeg.c.

Referenced by main().

static int opt_pad ( const char *  opt,
const char *  arg 
)
static

Definition at line 2789 of file ffmpeg.c.

static int opt_pass ( const char *  opt,
const char *  arg 
)
static

Definition at line 3849 of file ffmpeg.c.

static int opt_preset ( const char *  opt,
const char *  arg 
)
static

Definition at line 4181 of file ffmpeg.c.

static int opt_qscale ( const char *  opt,
const char *  arg 
)
static

Definition at line 2849 of file ffmpeg.c.

static int opt_recording_time ( const char *  opt,
const char *  arg 
)
static

Definition at line 3083 of file ffmpeg.c.

static int opt_recording_timestamp ( const char *  opt,
const char *  arg 
)
static

Definition at line 3095 of file ffmpeg.c.

static int opt_start_time ( const char *  opt,
const char *  arg 
)
static

Definition at line 3089 of file ffmpeg.c.

static int opt_streamid ( const char *  opt,
const char *  arg 
)
static

Definition at line 3687 of file ffmpeg.c.

static int opt_subtitle_codec ( const char *  opt,
const char *  arg 
)
static

Definition at line 2941 of file ffmpeg.c.

Referenced by opt_preset().

static int opt_target ( const char *  opt,
const char *  arg 
)
static

Definition at line 3997 of file ffmpeg.c.

static int opt_thread_count ( const char *  opt,
const char *  arg 
)
static

Definition at line 2865 of file ffmpeg.c.

static int opt_top_field_first ( const char *  opt,
const char *  arg 
)
static

Definition at line 2859 of file ffmpeg.c.

static int opt_verbose ( const char *  opt,
const char *  arg 
)
static

Definition at line 2759 of file ffmpeg.c.

static int opt_video_channel ( const char *  opt,
const char *  arg 
)
static

Definition at line 2905 of file ffmpeg.c.

static int opt_video_codec ( const char *  opt,
const char *  arg 
)
static

Definition at line 2936 of file ffmpeg.c.

Referenced by opt_preset(), and opt_target().

static int opt_video_rc_override_string ( const char *  opt,
const char *  arg 
)
static

Definition at line 2747 of file ffmpeg.c.

static int opt_video_standard ( const char *  opt,
const char *  arg 
)
static

Definition at line 2912 of file ffmpeg.c.

static int opt_vstats ( const char *  opt,
const char *  arg 
)
static

Definition at line 4149 of file ffmpeg.c.

static int opt_vstats_file ( const char *  opt,
const char *  arg 
)
static

Definition at line 4142 of file ffmpeg.c.

Referenced by opt_vstats().

static int output_packet ( InputStream ist,
int  ist_index,
OutputStream **  ost_table,
int  nb_ostreams,
const AVPacket pkt 
)
static

Definition at line 1453 of file ffmpeg.c.

Referenced by transcode().

static void parse_forced_key_frames ( char *  kf,
OutputStream ost,
AVCodecContext avctx 
)
static

Definition at line 1903 of file ffmpeg.c.

Referenced by new_video_stream().

static void parse_matrix_coeffs ( uint16_t *  dest,
const char *  str 
)
static

Definition at line 3891 of file ffmpeg.c.

Referenced by opt_inter_matrix(), and opt_intra_matrix().

static void parse_meta_type ( char *  arg,
char *  type,
int *  index,
char **  endptr 
)
static

Definition at line 2995 of file ffmpeg.c.

Referenced by opt_map_metadata().

static void pre_process_video_frame ( InputStream ist,
AVPicture picture,
void **  bufp 
)
static

Definition at line 1000 of file ffmpeg.c.

Referenced by output_packet().

static void print_report ( AVFormatContext **  output_files,
OutputStream **  ost_table,
int  nb_ostreams,
int  is_last_report 
)
static

Definition at line 1322 of file ffmpeg.c.

Referenced by transcode().

static void print_sdp ( AVFormatContext **  avc,
int  n 
)
static

Definition at line 1854 of file ffmpeg.c.

Referenced by transcode().

static double psnr ( double  d)
static

Definition at line 1281 of file ffmpeg.c.

Referenced by do_video_stats(), and print_report().

static int read_avserver_streams ( AVFormatContext s,
const char *  filename 
)
static

Definition at line 675 of file ffmpeg.c.

Referenced by opt_output_file().

static void show_help ( void  )
static

Definition at line 3927 of file ffmpeg.c.

static void show_usage ( void  )
static

Definition at line 3920 of file ffmpeg.c.

Referenced by main(), and show_help().

static void sigterm_handler ( int  sig)
static

Definition at line 428 of file ffmpeg.c.

Referenced by term_init().

static void term_exit ( void  )
static

Definition at line 419 of file ffmpeg.c.

Referenced by sigterm_handler().

static void term_init ( void  )
static

Definition at line 435 of file ffmpeg.c.

Referenced by transcode().

static int transcode ( AVFormatContext **  output_files,
int  nb_output_files,
InputFile input_files,
int  nb_input_files,
StreamMap stream_maps,
int  nb_stream_maps 
)
static

Definition at line 1929 of file ffmpeg.c.

Referenced by main().

static void update_sample_fmt ( AVCodecContext dec,
AVCodec dec_codec,
AVCodecContext enc 
)
static

Update the requested input sample format based on the output sample format.

This is currently only used to request float output from decoders which support multiple sample formats, one of which is AV_SAMPLE_FMT_FLT. Ideally this will be removed in the future when decoders do not do format conversion and only output in their native format.

Definition at line 560 of file ffmpeg.c.

Referenced by transcode().

static void write_frame ( AVFormatContext s,
AVPacket pkt,
AVCodecContext avctx,
AVBitStreamFilterContext bsfc 
)
static

Definition at line 722 of file ffmpeg.c.

Referenced by do_audio_out(), do_subtitle_out(), do_video_out(), and output_packet().

Variable Documentation

unsigned int allocated_audio_buf_size
static

Definition at line 231 of file ffmpeg.c.

Referenced by do_audio_out(), exit_program(), and output_packet().

unsigned int allocated_audio_out_size
static

Definition at line 231 of file ffmpeg.c.

Referenced by do_audio_out(), and exit_program().

AVBitStreamFilterContext* audio_bitstream_filters = NULL
static

Definition at line 236 of file ffmpeg.c.

Referenced by new_audio_stream().

uint8_t* audio_buf
static

Definition at line 229 of file ffmpeg.c.

Referenced by do_audio_out(), exit_program(), and output_packet().

int audio_channels = 0
static
char* audio_codec_name = NULL
static
unsigned int audio_codec_tag = 0
static

Definition at line 166 of file ffmpeg.c.

Referenced by new_audio_stream(), and opt_codec_tag().

int audio_disable = 0
static

Definition at line 163 of file ffmpeg.c.

Referenced by new_audio_stream(), opt_input_file(), and opt_output_file().

float audio_drift_threshold = 0.1
static

Definition at line 198 of file ffmpeg.c.

Referenced by do_audio_out().

char* audio_language = NULL
static

Definition at line 167 of file ffmpeg.c.

Referenced by new_audio_stream().

uint8_t* audio_out
static

Definition at line 230 of file ffmpeg.c.

Referenced by do_audio_out(), and exit_program().

float audio_qscale = QSCALE_NONE
static

Definition at line 162 of file ffmpeg.c.

Referenced by new_audio_stream().

enum AVSampleFormat audio_sample_fmt = AV_SAMPLE_FMT_NONE
static

Definition at line 135 of file ffmpeg.c.

Referenced by new_audio_stream(), opt_audio_sample_fmt(), opt_input_file(), and opt_output_file().

int audio_sample_rate = 0
static
int64_t audio_size = 0
static

Definition at line 216 of file ffmpeg.c.

Referenced by do_audio_out(), output_packet(), and print_report().

int audio_stream_copy = 0
static
int audio_sync_method = 0
static

Definition at line 197 of file ffmpeg.c.

Referenced by do_audio_out(), and transcode().

int audio_volume = 256
static

Definition at line 209 of file ffmpeg.c.

Referenced by output_packet(), and transcode().

uint8_t* bit_buffer = NULL
static

Definition at line 1106 of file ffmpeg.c.

Referenced by do_video_out(), output_packet(), and transcode().

int bit_buffer_size = 1024*256
static

Definition at line 1105 of file ffmpeg.c.

Referenced by do_video_out(), output_packet(), and transcode().

ChapterMap* chapter_maps = NULL
static

Definition at line 124 of file ffmpeg.c.

int copy_initial_nonkeyframes = 0
static

Definition at line 205 of file ffmpeg.c.

Referenced by new_video_stream(), and output_packet().

int copy_tb
static

Definition at line 200 of file ffmpeg.c.

Referenced by transcode().

int copy_ts = 0
static

Definition at line 199 of file ffmpeg.c.

Referenced by opt_input_file(), and transcode().

char* data_codec_name = NULL
static

Definition at line 175 of file ffmpeg.c.

Referenced by exit_program(), new_data_stream(), opt_data_codec(), and opt_output_file().

unsigned int data_codec_tag = 0
static

Definition at line 176 of file ffmpeg.c.

Referenced by new_data_stream().

int data_disable = 0
static

Definition at line 174 of file ffmpeg.c.

Referenced by new_data_stream(), and opt_output_file().

int data_stream_copy = 0
static

Definition at line 195 of file ffmpeg.c.

Referenced by new_data_stream(), opt_data_codec(), and opt_output_file().

int do_benchmark = 0
static

Definition at line 186 of file ffmpeg.c.

Referenced by main().

int do_deinterlace = 0
static

Definition at line 148 of file ffmpeg.c.

Referenced by pre_process_video_frame().

int do_hex_dump = 0
static

Definition at line 187 of file ffmpeg.c.

Referenced by transcode().

int do_pass = 0
static

Definition at line 190 of file ffmpeg.c.

Referenced by new_video_stream(), and opt_pass().

int do_pkt_dump = 0
static

Definition at line 188 of file ffmpeg.c.

Referenced by transcode().

int do_psnr = 0
static

Definition at line 189 of file ffmpeg.c.

Referenced by new_video_stream().

float dts_delta_threshold = 10
static

Definition at line 225 of file ffmpeg.c.

Referenced by transcode().

int exit_on_error = 0
static

Definition at line 211 of file ffmpeg.c.

Referenced by do_audio_out(), do_subtitle_out(), transcode(), and write_frame().

int64_t extra_size = 0
static

Definition at line 217 of file ffmpeg.c.

Referenced by print_report(), and transcode().

int file_overwrite = 0
static

Definition at line 184 of file ffmpeg.c.

Referenced by opt_output_file().

int force_fps = 0
static

Definition at line 222 of file ffmpeg.c.

Referenced by new_video_stream(), and transcode().

char* forced_key_frames = NULL
static

Definition at line 223 of file ffmpeg.c.

Referenced by new_video_stream(), and opt_output_file().

float frame_aspect_ratio = 0
static

Definition at line 133 of file ffmpeg.c.

Referenced by new_video_stream(), and opt_frame_aspect_ratio().

int frame_height = 0
static
enum PixelFormat frame_pix_fmt = PIX_FMT_NONE
static

Definition at line 134 of file ffmpeg.c.

Referenced by new_video_stream(), opt_frame_pix_fmt(), and opt_input_file().

int frame_width = 0
static
InputFile* input_files = NULL
static

Definition at line 330 of file ffmpeg.c.

InputStream* input_streams = NULL
static

Definition at line 328 of file ffmpeg.c.

int input_sync
static

Definition at line 220 of file ffmpeg.c.

Referenced by transcode().

int64_t input_ts_offset = 0
static

Definition at line 183 of file ffmpeg.c.

Referenced by opt_input_file(), and opt_input_ts_offset().

uint16_t* inter_matrix = NULL
static

Definition at line 140 of file ffmpeg.c.

Referenced by avcodec_copy_context(), exit_program(), new_video_stream(), and opt_inter_matrix().

int intra_dc_precision = 8
static

Definition at line 151 of file ffmpeg.c.

Referenced by new_video_stream().

uint16_t* intra_matrix = NULL
static

Definition at line 139 of file ffmpeg.c.

Referenced by avcodec_copy_context(), exit_program(), new_video_stream(), and opt_intra_matrix().

int intra_only = 0
static

Definition at line 159 of file ffmpeg.c.

Referenced by build_frame_code(), and new_video_stream().

const char* last_asked_format = NULL
static

Definition at line 106 of file ffmpeg.c.

Referenced by opt_format(), opt_input_file(), and opt_output_file().

uint64_t limit_filesize = 0
static

Definition at line 221 of file ffmpeg.c.

Referenced by transcode().

int loop_input = 0
static

Definition at line 152 of file ffmpeg.c.

Referenced by opt_input_file().

int loop_output = AVFMT_NOOUTPUTLOOP
static

Definition at line 153 of file ffmpeg.c.

Referenced by opt_output_file().

int max_frames[4] = {INT_MAX, INT_MAX, INT_MAX, INT_MAX}
static
int me_threshold = 0
static

Definition at line 150 of file ffmpeg.c.

Referenced by do_video_out(), new_video_stream(), opt_input_file(), and opt_me_threshold().

MetadataMap(* meta_data_maps)[2] = NULL
static

Definition at line 118 of file ffmpeg.c.

Referenced by exit_program(), opt_map_metadata(), and transcode().

AVDictionary* metadata
static

Definition at line 185 of file ffmpeg.c.

Referenced by decode_info_header(), mxf_parse_structural_metadata(), and mxf_read_header().

int metadata_chapters_autocopy = 1
static

Definition at line 122 of file ffmpeg.c.

Referenced by copy_chapters(), and opt_map_metadata().

int metadata_global_autocopy = 1
static

Definition at line 120 of file ffmpeg.c.

Referenced by opt_map_metadata(), and transcode().

int metadata_streams_autocopy = 1
static

Definition at line 121 of file ffmpeg.c.

Referenced by opt_map_metadata(), and transcode().

float mux_max_delay = 0.7
static

Definition at line 179 of file ffmpeg.c.

Referenced by opt_output_file().

float mux_preload = 0.5
static

Definition at line 178 of file ffmpeg.c.

Referenced by opt_output_file(), and opt_target().

int nb_chapter_maps
static

Definition at line 125 of file ffmpeg.c.

Referenced by opt_map_chapters(), and transcode().

int nb_frames_drop = 0
static

Definition at line 219 of file ffmpeg.c.

Referenced by do_video_out(), and print_report().

int nb_frames_dup = 0
static

Definition at line 218 of file ffmpeg.c.

Referenced by do_video_out(), and print_report().

int nb_input_files = 0
static

Definition at line 331 of file ffmpeg.c.

Referenced by check_inputs(), exit_program(), main(), opt_input_file(), opt_target(), and transcode().

int nb_input_streams = 0
static

Definition at line 329 of file ffmpeg.c.

Referenced by exit_program(), and transcode().

int nb_meta_data_maps
static

Definition at line 119 of file ffmpeg.c.

Referenced by opt_map_metadata(), and transcode().

int nb_output_files = 0
static

Definition at line 112 of file ffmpeg.c.

Referenced by exit_program(), read_avserver_streams(), and transcode().

int nb_output_streams_for_file[MAX_FILES] = { 0 }
static

Definition at line 298 of file ffmpeg.c.

Referenced by new_output_stream().

int nb_stream_maps
static

Definition at line 115 of file ffmpeg.c.

Referenced by main(), opt_map(), and transcode().

int nb_streamid_map = 0
static

Definition at line 129 of file ffmpeg.c.

Referenced by new_output_stream(), and opt_streamid().

int nb_ts_scale
static

Definition at line 108 of file ffmpeg.c.

Referenced by opt_input_file(), and opt_input_ts_scale().

int opt_programid = 0
static

Definition at line 204 of file ffmpeg.c.

Referenced by opt_input_file(), and transcode().

int opt_shortest = 0
static

Definition at line 201 of file ffmpeg.c.

Referenced by transcode().

static const OptionDef options
static

Definition at line 102 of file ffmpeg.c.

AVFormatContext* output_files[MAX_FILES]
static

Definition at line 110 of file ffmpeg.c.

AVDictionary* output_opts[MAX_FILES]
static

Definition at line 111 of file ffmpeg.c.

OutputStream** output_streams_for_file[MAX_FILES] = { NULL }
static

Definition at line 297 of file ffmpeg.c.

char* pass_logfilename_prefix = NULL
static

Definition at line 191 of file ffmpeg.c.

Referenced by transcode().

const int program_birth_year = 2000

program birth year, defined by the program for show_banner()

Definition at line 78 of file ffmpeg.c.

const char program_name[] = "ffmpeg"

program name, defined by the program for show_version().

Definition at line 77 of file ffmpeg.c.

int qp_hist = 0
static

Definition at line 154 of file ffmpeg.c.

Referenced by print_report().

int rate_emu = 0
static

Definition at line 207 of file ffmpeg.c.

Referenced by output_packet(), and transcode().

volatile int received_nb_signals = 0
static

Definition at line 425 of file ffmpeg.c.

Referenced by decode_interrupt_cb(), and sigterm_handler().

volatile int received_sigterm = 0
static

Definition at line 424 of file ffmpeg.c.

Referenced by exit_program(), sigterm_handler(), and transcode().

int64_t recording_time = INT64_MAX
static

Definition at line 181 of file ffmpeg.c.

Referenced by copy_chapters(), opt_recording_time(), and transcode().

int same_quality = 0
static

Definition at line 147 of file ffmpeg.c.

Referenced by new_video_stream(), and output_packet().

int64_t start_time = 0
static
StreamMap* stream_maps = NULL
static

Definition at line 114 of file ffmpeg.c.

int* streamid_map = NULL
static

Definition at line 128 of file ffmpeg.c.

Referenced by exit_program(), new_output_stream(), and opt_streamid().

AVBitStreamFilterContext* subtitle_bitstream_filters = NULL
static

Definition at line 237 of file ffmpeg.c.

Referenced by new_subtitle_stream(), and opt_bsf().

char* subtitle_codec_name = NULL
static
unsigned int subtitle_codec_tag = 0
static

Definition at line 172 of file ffmpeg.c.

Referenced by new_subtitle_stream(), and opt_codec_tag().

int subtitle_disable = 0
static

Definition at line 169 of file ffmpeg.c.

Referenced by new_subtitle_stream(), opt_input_file(), and opt_output_file().

char* subtitle_language = NULL
static

Definition at line 171 of file ffmpeg.c.

Referenced by new_subtitle_stream().

int subtitle_stream_copy = 0
static

Definition at line 194 of file ffmpeg.c.

Referenced by new_subtitle_stream(), opt_output_file(), and opt_subtitle_codec().

int64_t timer_start
static

Definition at line 227 of file ffmpeg.c.

Referenced by print_report(), and transcode().

int top_field_first = -1
static
double* ts_scale
static

Definition at line 107 of file ffmpeg.c.

Referenced by add_input_streams(), opt_input_file(), and opt_input_ts_scale().

int using_stdin = 0
static

Definition at line 212 of file ffmpeg.c.

Referenced by opt_input_file(), and opt_output_file().

AVBitStreamFilterContext* video_bitstream_filters = NULL
static

Definition at line 235 of file ffmpeg.c.

Referenced by new_video_stream().

char* video_codec_name = NULL
static
unsigned int video_codec_tag = 0
static

Definition at line 145 of file ffmpeg.c.

Referenced by new_video_stream(), and opt_codec_tag().

int video_disable = 0
static

Definition at line 142 of file ffmpeg.c.

Referenced by new_video_stream(), opt_input_file(), and opt_output_file().

int video_discard = 0
static

Definition at line 143 of file ffmpeg.c.

Referenced by opt_input_file().

char* video_language = NULL
static

Definition at line 146 of file ffmpeg.c.

Referenced by new_video_stream().

float video_qscale = 0
static

Definition at line 138 of file ffmpeg.c.

Referenced by new_video_stream(), and opt_qscale().

const char* video_rc_override_string = NULL
static

Definition at line 141 of file ffmpeg.c.

Referenced by new_video_stream(), and opt_video_rc_override_string().

int64_t video_size = 0
static

Definition at line 215 of file ffmpeg.c.

Referenced by do_video_out(), do_video_stats(), output_packet(), and print_report().

int video_stream_copy = 0
static
int video_sync_method = -1
static

Definition at line 196 of file ffmpeg.c.

Referenced by do_video_out().

FILE* vstats_file
static

Definition at line 203 of file ffmpeg.c.

Referenced by do_video_stats(), and exit_program().

char* vstats_filename
static

Definition at line 202 of file ffmpeg.c.

Referenced by do_video_stats(), exit_program(), opt_vstats_file(), and output_packet().