FFmpeg
Data Structures | Macros | Functions | Variables
ffmpeg.c File Reference
#include "config.h"
#include <errno.h>
#include <limits.h>
#include <stdatomic.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/dict.h"
#include "libavutil/display.h"
#include "libavutil/fifo.h"
#include "libavutil/hwcontext.h"
#include "libavutil/imgutils.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/libm.h"
#include "libavutil/mathematics.h"
#include "libavutil/opt.h"
#include "libavutil/parseutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/samplefmt.h"
#include "libavutil/thread.h"
#include "libavutil/threadmessage.h"
#include "libavutil/timestamp.h"
#include "libavcodec/version.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswresample/swresample.h"
#include "cmdutils.h"
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.h"
#include "sync_queue.h"

Go to the source code of this file.

Data Structures

struct  BenchmarkTimeStamps
 

Macros

#define SIGNAL(sig, func)   signal(sig, func)
 

Functions

static BenchmarkTimeStamps get_benchmark_time_stamps (void)
 
static int64_t getmaxrss (void)
 
static void term_exit_sigsafe (void)
 
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)
 
static void ffmpeg_cleanup (int ret)
 
OutputStreamost_iter (OutputStream *prev)
 
InputStreamist_iter (InputStream *prev)
 
static void frame_data_free (void *opaque, uint8_t *data)
 
static int frame_data_ensure (AVBufferRef **dst, int writable)
 
FrameDataframe_data (AVFrame *frame)
 Get our axiliary frame data attached to the frame, allocating it if needed. More...
 
const FrameDataframe_data_c (AVFrame *frame)
 
FrameDatapacket_data (AVPacket *pkt)
 
const FrameDatapacket_data_c (AVPacket *pkt)
 
void remove_avoptions (AVDictionary **a, AVDictionary *b)
 
int check_avoptions (AVDictionary *m)
 
void update_benchmark (const char *fmt,...)
 
static void print_report (int is_last_report, int64_t timer_start, int64_t cur_time, int64_t pts)
 
static void print_stream_maps (void)
 
static void set_tty_echo (int on)
 
static int check_keyboard_interaction (int64_t cur_time)
 
static int transcode (Scheduler *sch)
 
int main (int argc, char **argv)
 

Variables

const char program_name [] = "ffmpeg"
 program name, defined by the program for show_version(). More...
 
const int program_birth_year = 2000
 program birth year, defined by the program for show_banner() More...
 
FILE * vstats_file
 
atomic_uint nb_output_dumped = 0
 
static BenchmarkTimeStamps current_time
 
AVIOContextprogress_avio = NULL
 
InputFile ** input_files = NULL
 
int nb_input_files = 0
 
OutputFile ** output_files = NULL
 
int nb_output_files = 0
 
FilterGraph ** filtergraphs
 
int nb_filtergraphs
 
Decoder ** decoders
 
int nb_decoders
 
static volatile int received_sigterm = 0
 
static volatile int received_nb_signals = 0
 
static atomic_int transcode_init_done = ATOMIC_VAR_INIT(0)
 
static volatile int ffmpeg_exited = 0
 
static int64_t copy_ts_first_pts = AV_NOPTS_VALUE
 
const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL }
 

Detailed Description

multimedia converter based on the FFmpeg libraries

Definition in file ffmpeg.c.

Macro Definition Documentation

◆ SIGNAL

#define SIGNAL (   sig,
  func 
)    signal(sig, func)

Definition at line 218 of file ffmpeg.c.

Function Documentation

◆ get_benchmark_time_stamps()

static BenchmarkTimeStamps get_benchmark_time_stamps ( void  )
static

Definition at line 885 of file ffmpeg.c.

Referenced by main(), and update_benchmark().

◆ getmaxrss()

static int64_t getmaxrss ( void  )
static

Definition at line 911 of file ffmpeg.c.

Referenced by ffmpeg_cleanup().

◆ term_exit_sigsafe()

static void term_exit_sigsafe ( void  )
static

Definition at line 144 of file ffmpeg.c.

Referenced by sigterm_handler(), and term_exit().

◆ term_exit()

void term_exit ( void  )

Definition at line 152 of file ffmpeg.c.

Referenced by assert_file_overwrite(), ffmpeg_cleanup(), and transcode().

◆ sigterm_handler()

static void sigterm_handler ( int  sig)
static

Definition at line 165 of file ffmpeg.c.

Referenced by term_init().

◆ term_init()

void term_init ( void  )

Definition at line 222 of file ffmpeg.c.

Referenced by assert_file_overwrite().

◆ read_key()

static int read_key ( void  )
static

Definition at line 271 of file ffmpeg.c.

Referenced by check_keyboard_interaction().

◆ decode_interrupt_cb()

static int decode_interrupt_cb ( void *  ctx)
static

Definition at line 322 of file ffmpeg.c.

◆ ffmpeg_cleanup()

static void ffmpeg_cleanup ( int  ret)
static

Definition at line 329 of file ffmpeg.c.

Referenced by main().

◆ ost_iter()

OutputStream* ost_iter ( OutputStream prev)

Definition at line 380 of file ffmpeg.c.

Referenced by print_report(), and print_stream_maps().

◆ ist_iter()

InputStream* ist_iter ( InputStream prev)

Definition at line 396 of file ffmpeg.c.

Referenced by ist_find_unused(), map_auto_data(), map_auto_subtitle(), and print_stream_maps().

◆ frame_data_free()

static void frame_data_free ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 412 of file ffmpeg.c.

Referenced by frame_data_ensure().

◆ frame_data_ensure()

static int frame_data_ensure ( AVBufferRef **  dst,
int  writable 
)
static

Definition at line 421 of file ffmpeg.c.

Referenced by frame_data(), frame_data_c(), packet_data(), and packet_data_c().

◆ frame_data()

FrameData* frame_data ( AVFrame frame)

Get our axiliary frame data attached to the frame, allocating it if needed.

Definition at line 473 of file ffmpeg.c.

Referenced by close_output(), dwt_plane(), encode_frame(), fg_output_step(), generate_raw_frame(), nvenc_retrieve_frame_data(), nvenc_store_frame_data(), packet_decode(), and send_frame().

◆ frame_data_c()

const FrameData* frame_data_c ( AVFrame frame)

Definition at line 479 of file ffmpeg.c.

Referenced by choose_out_timebase().

◆ packet_data()

FrameData* packet_data ( AVPacket pkt)

Definition at line 485 of file ffmpeg.c.

Referenced by encode_frame(), input_packet_process(), and packet_decode().

◆ packet_data_c()

const FrameData* packet_data_c ( AVPacket pkt)

Definition at line 491 of file ffmpeg.c.

◆ remove_avoptions()

void remove_avoptions ( AVDictionary **  a,
AVDictionary b 
)

Definition at line 497 of file ffmpeg.c.

Referenced by ifile_open().

◆ check_avoptions()

int check_avoptions ( AVDictionary m)

Definition at line 506 of file ffmpeg.c.

Referenced by dec_open(), enc_open(), and ifile_open().

◆ update_benchmark()

void update_benchmark ( const char *  fmt,
  ... 
)

Definition at line 517 of file ffmpeg.c.

Referenced by encode_frame(), and packet_decode().

◆ print_report()

static void print_report ( int  is_last_report,
int64_t  timer_start,
int64_t  cur_time,
int64_t  pts 
)
static

Definition at line 538 of file ffmpeg.c.

Referenced by transcode().

◆ print_stream_maps()

static void print_stream_maps ( void  )
static

Definition at line 688 of file ffmpeg.c.

Referenced by transcode().

◆ set_tty_echo()

static void set_tty_echo ( int  on)
static

Definition at line 764 of file ffmpeg.c.

Referenced by check_keyboard_interaction().

◆ check_keyboard_interaction()

static int check_keyboard_interaction ( int64_t  cur_time)
static

Definition at line 776 of file ffmpeg.c.

Referenced by transcode().

◆ transcode()

static int transcode ( Scheduler sch)
static

Definition at line 838 of file ffmpeg.c.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 929 of file ffmpeg.c.

Variable Documentation

◆ program_name

const char program_name[] = "ffmpeg"

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

Definition at line 106 of file ffmpeg.c.

Referenced by main().

◆ program_birth_year

const int program_birth_year = 2000

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

Definition at line 107 of file ffmpeg.c.

◆ vstats_file

FILE* vstats_file

Definition at line 109 of file ffmpeg.c.

Referenced by ffmpeg_cleanup(), and update_video_stats().

◆ nb_output_dumped

atomic_uint nb_output_dumped = 0

Definition at line 120 of file ffmpeg.c.

Referenced by mux_check_init(), and print_report().

◆ current_time

BenchmarkTimeStamps current_time
static

Definition at line 122 of file ffmpeg.c.

Referenced by main(), and update_benchmark().

◆ progress_avio

AVIOContext* progress_avio = NULL

Definition at line 123 of file ffmpeg.c.

Referenced by print_report().

◆ input_files

InputFile** input_files = NULL

◆ nb_input_files

int nb_input_files = 0

◆ output_files

OutputFile** output_files = NULL

◆ nb_output_files

int nb_output_files = 0

◆ filtergraphs

FilterGraph** filtergraphs

◆ nb_filtergraphs

int nb_filtergraphs

◆ decoders

Decoder** decoders

Definition at line 134 of file ffmpeg.c.

Referenced by dec_create(), ffmpeg_cleanup(), and fg_complex_bind_input().

◆ nb_decoders

int nb_decoders

Definition at line 135 of file ffmpeg.c.

Referenced by dec_create(), ffmpeg_cleanup(), and fg_complex_bind_input().

◆ received_sigterm

volatile int received_sigterm = 0
static

Definition at line 158 of file ffmpeg.c.

Referenced by ffmpeg_cleanup(), and sigterm_handler().

◆ received_nb_signals

volatile int received_nb_signals = 0
static

Definition at line 159 of file ffmpeg.c.

Referenced by check_keyboard_interaction(), decode_interrupt_cb(), main(), and sigterm_handler().

◆ transcode_init_done

atomic_int transcode_init_done = ATOMIC_VAR_INIT(0)
static

Definition at line 160 of file ffmpeg.c.

Referenced by decode_interrupt_cb(), ffmpeg_cleanup(), and transcode().

◆ ffmpeg_exited

volatile int ffmpeg_exited = 0
static

Definition at line 161 of file ffmpeg.c.

Referenced by ffmpeg_cleanup().

◆ copy_ts_first_pts

int64_t copy_ts_first_pts = AV_NOPTS_VALUE
static

Definition at line 162 of file ffmpeg.c.

Referenced by print_report().

◆ int_cb