#include "config.h"
#include <ctype.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <errno.h>
#include <limits.h>
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libswresample/swresample.h"
#include "libavutil/opt.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 "libavutil/imgutils.h"
#include "libavutil/timestamp.h"
#include "libavutil/bprint.h"
#include "libavutil/time.h"
#include "libavformat/os_support.h"
#include "libavformat/ffm.h"
#include "libavfilter/avcodec.h"
#include "libavfilter/avfilter.h"
#include "libavfilter/avfiltergraph.h"
#include "libavfilter/buffersrc.h"
#include "libavfilter/buffersink.h"
#include "ffmpeg.h"
#include "cmdutils.h"
#include "libavutil/avassert.h"
Go to the source code of this file.
Defines | |
#define | DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" |
Functions | |
static void | do_video_stats (AVFormatContext *os, OutputStream *ost, int frame_size) |
static int64_t | getutime (void) |
static void | sub2video_copy_rect (uint8_t *dst, int dst_linesize, int w, int h, AVSubtitleRect *r) |
static void | sub2video_push_ref (InputStream *ist, int64_t pts) |
static void | sub2video_update (InputStream *ist, AVSubtitle *sub) |
static void | sub2video_heartbeat (InputStream *ist, int64_t pts) |
static void | sub2video_flush (InputStream *ist) |
void | term_exit (void) |
static void | sigterm_handler (int sig) |
void | term_init (void) |
static int | read_key (void) |
static int | decode_interrupt_cb (void *ctx) |
void av_noreturn | exit_program (int ret) |
Do all the necessary cleanup and abort. | |
void | assert_avoptions (AVDictionary *m) |
static void | assert_codec_experimental (AVCodecContext *c, int encoder) |
static void | update_benchmark (const char *fmt,...) |
static void | write_frame (AVFormatContext *s, AVPacket *pkt, OutputStream *ost) |
static void | close_output_stream (OutputStream *ost) |
static int | check_recording_time (OutputStream *ost) |
static void | do_audio_out (AVFormatContext *s, OutputStream *ost, AVFrame *frame) |
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) |
static void | do_video_out (AVFormatContext *s, OutputStream *ost, AVFrame *in_picture, float quality) |
static double | psnr (double d) |
static int | reap_filters (void) |
Get and encode new output from any of the filtergraphs, without causing activity. | |
static void | print_report (int is_last_report, int64_t timer_start, int64_t cur_time) |
static void | flush_encoders (void) |
static int | check_output_constraints (InputStream *ist, OutputStream *ost) |
static void | do_streamcopy (InputStream *ist, OutputStream *ost, const AVPacket *pkt) |
static void | rate_emu_sleep (InputStream *ist) |
int | guess_input_channel_layout (InputStream *ist) |
static int | decode_audio (InputStream *ist, AVPacket *pkt, int *got_output) |
static int | decode_video (InputStream *ist, AVPacket *pkt, int *got_output) |
static int | transcode_subtitles (InputStream *ist, AVPacket *pkt, int *got_output) |
static int | output_packet (InputStream *ist, const AVPacket *pkt) |
static void | print_sdp (void) |
static int | init_input_stream (int ist_index, char *error, int error_len) |
static InputStream * | get_input_stream (OutputStream *ost) |
static void | parse_forced_key_frames (char *kf, OutputStream *ost, AVCodecContext *avctx) |
static void | report_new_stream (int input_index, AVPacket *pkt) |
static int | transcode_init (void) |
static int | need_output (void) |
static OutputStream * | choose_output (void) |
Select the output stream to process. | |
static int | check_keyboard_interaction (int64_t cur_time) |
static int | get_input_packet (InputFile *f, AVPacket *pkt) |
static int | got_eagain (void) |
static void | reset_eagain (void) |
static int | process_input (int file_index) |
static int | transcode_from_filter (FilterGraph *graph, InputStream **best_ist) |
Perform a step of transcoding for the specified filter graph. | |
static int | transcode_step (void) |
Run a single step of transcoding. | |
static int | transcode (void) |
static int64_t | getmaxrss (void) |
static void | log_callback_null (void *ptr, int level, const char *fmt, va_list vl) |
static void | parse_cpuflags (int argc, char **argv, const OptionDef *options) |
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 FILE * | vstats_file |
static int | run_as_daemon = 0 |
static int64_t | video_size = 0 |
static int64_t | audio_size = 0 |
static int64_t | subtitle_size = 0 |
static int64_t | extra_size = 0 |
static int | nb_frames_dup = 0 |
static int | nb_frames_drop = 0 |
static int | current_time |
AVIOContext * | progress_avio = NULL |
static uint8_t * | subtitle_out |
InputStream ** | input_streams = NULL |
int | nb_input_streams = 0 |
InputFile ** | input_files = NULL |
int | nb_input_files = 0 |
OutputStream ** | output_streams = NULL |
int | nb_output_streams = 0 |
OutputFile ** | output_files = NULL |
int | nb_output_files = 0 |
FilterGraph ** | filtergraphs |
int | nb_filtergraphs |
static volatile int | received_sigterm = 0 |
static volatile int | received_nb_signals = 0 |
const AVIOInterruptCB | int_cb = { decode_interrupt_cb, NULL } |
Definition in file ffmpeg.c.
#define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass" |
void assert_avoptions | ( | AVDictionary * | m | ) |
Definition at line 463 of file ffmpeg.c.
Referenced by init_input_stream(), opt_input_file(), and transcode_init().
static void assert_codec_experimental | ( | AVCodecContext * | c, | |
int | encoder | |||
) | [static] |
static int check_keyboard_interaction | ( | int64_t | cur_time | ) | [static] |
static int check_output_constraints | ( | InputStream * | ist, | |
OutputStream * | ost | |||
) | [static] |
static int check_recording_time | ( | OutputStream * | ost | ) | [static] |
Definition at line 604 of file ffmpeg.c.
Referenced by do_audio_out(), do_subtitle_out(), and do_video_out().
static OutputStream* choose_output | ( | void | ) | [static] |
Select the output stream to process.
Definition at line 2452 of file ffmpeg.c.
Referenced by transcode_step().
static void close_output_stream | ( | OutputStream * | ost | ) | [static] |
Definition at line 592 of file ffmpeg.c.
Referenced by check_recording_time(), do_streamcopy(), need_output(), process_input(), and transcode_from_filter().
static int decode_audio | ( | InputStream * | ist, | |
AVPacket * | pkt, | |||
int * | got_output | |||
) | [static] |
static int decode_interrupt_cb | ( | void * | ctx | ) | [static] |
static int decode_video | ( | InputStream * | ist, | |
AVPacket * | pkt, | |||
int * | got_output | |||
) | [static] |
static void do_audio_out | ( | AVFormatContext * | s, | |
OutputStream * | ost, | |||
AVFrame * | frame | |||
) | [static] |
static void do_streamcopy | ( | InputStream * | ist, | |
OutputStream * | ost, | |||
const AVPacket * | pkt | |||
) | [static] |
static void do_subtitle_out | ( | AVFormatContext * | s, | |
OutputStream * | ost, | |||
InputStream * | ist, | |||
AVSubtitle * | sub | |||
) | [static] |
static void do_video_out | ( | AVFormatContext * | s, | |
OutputStream * | ost, | |||
AVFrame * | in_picture, | |||
float | quality | |||
) | [static] |
static void do_video_stats | ( | AVFormatContext * | os, | |
OutputStream * | ost, | |||
int | frame_size | |||
) | [static] |
void av_noreturn exit_program | ( | int | ret | ) |
static void flush_encoders | ( | void | ) | [static] |
static InputStream* get_input_stream | ( | OutputStream * | ost | ) | [static] |
static int64_t getmaxrss | ( | void | ) | [static] |
static int64_t getutime | ( | void | ) | [static] |
static int got_eagain | ( | void | ) | [static] |
int guess_input_channel_layout | ( | InputStream * | ist | ) |
static void log_callback_null | ( | void * | ptr, | |
int | level, | |||
const char * | fmt, | |||
va_list | vl | |||
) | [static] |
static int need_output | ( | void | ) | [static] |
Definition at line 2422 of file ffmpeg.c.
Referenced by transcode().
static int output_packet | ( | InputStream * | ist, | |
const AVPacket * | pkt | |||
) | [static] |
Definition at line 1719 of file ffmpeg.c.
Referenced by mpeg_mux_end(), mpeg_mux_write_packet(), process_input(), and transcode().
static void parse_forced_key_frames | ( | char * | kf, | |
OutputStream * | ost, | |||
AVCodecContext * | avctx | |||
) | [static] |
static void pre_process_video_frame | ( | InputStream * | ist, | |
AVPicture * | picture, | |||
void ** | bufp | |||
) | [static] |
static void print_report | ( | int | is_last_report, | |
int64_t | timer_start, | |||
int64_t | cur_time | |||
) | [static] |
static void print_sdp | ( | void | ) | [static] |
Definition at line 2707 of file ffmpeg.c.
Referenced by transcode_step().
static double psnr | ( | double | d | ) | [static] |
Definition at line 940 of file ffmpeg.c.
Referenced by do_video_stats(), main(), print_report(), and run_psnr().
static void rate_emu_sleep | ( | InputStream * | ist | ) | [static] |
Definition at line 1403 of file ffmpeg.c.
Referenced by decode_audio(), decode_video(), output_packet(), and transcode_subtitles().
static int read_key | ( | void | ) | [static] |
static int reap_filters | ( | void | ) | [static] |
Get and encode new output from any of the filtergraphs, without causing activity.
Definition at line 988 of file ffmpeg.c.
Referenced by transcode_from_filter(), and transcode_step().
static void reset_eagain | ( | void | ) | [static] |
static void sigterm_handler | ( | int | sig | ) | [static] |
static void sub2video_copy_rect | ( | uint8_t * | dst, | |
int | dst_linesize, | |||
int | w, | |||
int | h, | |||
AVSubtitleRect * | r | |||
) | [static] |
static void sub2video_flush | ( | InputStream * | ist | ) | [static] |
static void sub2video_heartbeat | ( | InputStream * | ist, | |
int64_t | pts | |||
) | [static] |
static void sub2video_push_ref | ( | InputStream * | ist, | |
int64_t | pts | |||
) | [static] |
Definition at line 191 of file ffmpeg.c.
Referenced by sub2video_heartbeat(), and sub2video_update().
static void sub2video_update | ( | InputStream * | ist, | |
AVSubtitle * | sub | |||
) | [static] |
void term_exit | ( | void | ) |
Definition at line 261 of file ffmpeg.c.
Referenced by assert_file_overwrite(), sigterm_handler(), term_init(), and transcode().
void term_init | ( | void | ) |
static int transcode | ( | void | ) | [static] |
static int transcode_from_filter | ( | FilterGraph * | graph, | |
InputStream ** | best_ist | |||
) | [static] |
Perform a step of transcoding for the specified filter graph.
[in] | graph | filter graph to consider |
[out] | best_ist | input stream where a frame would allow to continue |
Definition at line 2863 of file ffmpeg.c.
Referenced by transcode_step().
static int transcode_init | ( | void | ) | [static] |
static int transcode_step | ( | void | ) | [static] |
Run a single step of transcoding.
Definition at line 2909 of file ffmpeg.c.
Referenced by transcode().
static int transcode_subtitles | ( | InputStream * | ist, | |
AVPacket * | pkt, | |||
int * | got_output | |||
) | [static] |
static void update_benchmark | ( | const char * | fmt, | |
... | ||||
) | [static] |
Definition at line 489 of file ffmpeg.c.
Referenced by decode_audio(), decode_video(), do_audio_out(), do_video_out(), and flush_encoders().
static void write_frame | ( | AVFormatContext * | s, | |
AVPacket * | pkt, | |||
OutputStream * | ost | |||
) | [static] |
Definition at line 506 of file ffmpeg.c.
Referenced by alac_encode_frame(), do_audio_out(), do_streamcopy(), do_video_out(), flac_encode_frame(), and flush_encoders().
int64_t audio_size = 0 [static] |
Definition at line 116 of file ffmpeg.c.
Referenced by bfi_read_packet(), bmv_read_packet(), cdxl_read_packet(), do_audio_out(), do_streamcopy(), flush_encoders(), print_report(), read_packet(), rl2_read_header(), rpl_read_header(), and sdl_audio_callback().
int current_time [static] |
int64_t extra_size = 0 [static] |
Definition at line 118 of file ffmpeg.c.
Referenced by ape_read_packet(), asf_write_header1(), print_report(), and transcode_init().
Definition at line 144 of file ffmpeg.c.
Referenced by configure_complex_filters(), DEF_CHOOSE_FORMAT(), opt_filter_complex(), and opt_output_file().
InputFile** input_files = NULL |
Definition at line 136 of file ffmpeg.c.
Referenced by init_input_filter(), opt_input_file(), opt_map(), opt_map_channel(), opt_output_file(), opt_target(), and sub2video_prepare().
Definition at line 134 of file ffmpeg.c.
Referenced by add_input_streams(), init_input_filter(), new_audio_stream(), new_output_stream(), and opt_output_file().
const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL } |
Definition at line 379 of file ffmpeg.c.
Referenced by dump_attachment(), get_preset_file_2(), opt_input_file(), opt_output_file(), opt_progress(), and read_ffserver_streams().
Definition at line 145 of file ffmpeg.c.
Referenced by check_keyboard_interaction(), configure_complex_filters(), decode_audio(), decode_video(), DEF_CHOOSE_FORMAT(), exit_program(), opt_filter_complex(), opt_output_file(), and transcode_init().
int nb_frames_drop = 0 [static] |
int nb_frames_dup = 0 [static] |
int nb_input_files = 0 |
Definition at line 137 of file ffmpeg.c.
Referenced by add_input_streams(), dump_attachment(), exit_program(), init_input_filter(), opt_input_file(), opt_map(), opt_map_channel(), opt_output_file(), opt_target(), and transcode_init().
int nb_input_streams = 0 |
Definition at line 135 of file ffmpeg.c.
Referenced by add_input_streams(), check_keyboard_interaction(), exit_program(), init_input_filter(), opt_input_file(), opt_output_file(), transcode(), and transcode_init().
int nb_output_files = 0 |
Definition at line 142 of file ffmpeg.c.
Referenced by exit_program(), main(), new_output_stream(), opt_output_file(), print_sdp(), transcode(), and transcode_init().
int nb_output_streams = 0 |
Definition at line 140 of file ffmpeg.c.
Referenced by check_keyboard_interaction(), choose_output(), exit_program(), flush_encoders(), got_eagain(), need_output(), new_output_stream(), opt_output_file(), output_packet(), print_report(), process_input(), reap_filters(), reset_eagain(), transcode(), transcode_init(), and transcode_subtitles().
const int program_birth_year = 2000 |
program birth year, defined by the program for show_banner()
const char program_name[] = "ffmpeg" |
volatile int received_nb_signals = 0 [static] |
Definition at line 271 of file ffmpeg.c.
Referenced by check_keyboard_interaction(), decode_interrupt_cb(), and sigterm_handler().
volatile int received_sigterm = 0 [static] |
Definition at line 270 of file ffmpeg.c.
Referenced by exit_program(), sigterm_handler(), and transcode().
int run_as_daemon = 0 [static] |
Definition at line 114 of file ffmpeg.c.
Referenced by check_keyboard_interaction(), main(), and term_init().
uint8_t* subtitle_out [static] |
int64_t subtitle_size = 0 [static] |
int64_t video_size = 0 [static] |
Definition at line 115 of file ffmpeg.c.
Referenced by cdxl_read_packet(), decode_0(), decode_frame(), do_streamcopy(), do_video_out(), do_video_stats(), flush_encoders(), print_report(), and rpl_read_header().
FILE* vstats_file [static] |