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/bprint.h"
#include "libavutil/dict.h"
#include "libavutil/mem.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "cmdutils.h"
#include "ffmpeg.h"
#include "ffmpeg_sched.h"
#include "ffmpeg_utils.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)
 
int check_avoptions_used (const AVDictionary *opts, const AVDictionary *opts_used, void *logctx, int decode)
 
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 = 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 197 of file ffmpeg.c.

Function Documentation

◆ get_benchmark_time_stamps()

static BenchmarkTimeStamps get_benchmark_time_stamps ( void  )
static

Definition at line 902 of file ffmpeg.c.

Referenced by main(), and update_benchmark().

◆ getmaxrss()

static int64_t getmaxrss ( void  )
static

Definition at line 928 of file ffmpeg.c.

Referenced by ffmpeg_cleanup().

◆ term_exit_sigsafe()

static void term_exit_sigsafe ( void  )
static

Definition at line 123 of file ffmpeg.c.

Referenced by sigterm_handler(), and term_exit().

◆ term_exit()

void term_exit ( void  )

Definition at line 131 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 144 of file ffmpeg.c.

Referenced by term_init().

◆ term_init()

void term_init ( void  )

Definition at line 201 of file ffmpeg.c.

Referenced by assert_file_overwrite().

◆ read_key()

static int read_key ( void  )
static

Definition at line 250 of file ffmpeg.c.

Referenced by check_keyboard_interaction().

◆ decode_interrupt_cb()

static int decode_interrupt_cb ( void *  ctx)
static

Definition at line 302 of file ffmpeg.c.

◆ ffmpeg_cleanup()

static void ffmpeg_cleanup ( int  ret)
static

Definition at line 309 of file ffmpeg.c.

Referenced by main().

◆ ost_iter()

OutputStream* ost_iter ( OutputStream prev)

Definition at line 360 of file ffmpeg.c.

Referenced by check_keyboard_interaction(), print_report(), and print_stream_maps().

◆ ist_iter()

InputStream* ist_iter ( InputStream prev)

Definition at line 376 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 392 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 401 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 453 of file ffmpeg.c.

Referenced by close_output(), dwt_plane(), encode_frame(), fg_output_step(), generate_raw_frame(), mc(), 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 459 of file ffmpeg.c.

Referenced by choose_out_timebase().

◆ packet_data()

FrameData* packet_data ( AVPacket pkt)

Definition at line 465 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 471 of file ffmpeg.c.

◆ check_avoptions_used()

int check_avoptions_used ( const AVDictionary opts,
const AVDictionary opts_used,
void *  logctx,
int  decode 
)

Definition at line 477 of file ffmpeg.c.

Referenced by ifile_open(), and of_open().

◆ update_benchmark()

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

Definition at line 527 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 548 of file ffmpeg.c.

Referenced by transcode().

◆ print_stream_maps()

static void print_stream_maps ( void  )
static

Definition at line 700 of file ffmpeg.c.

Referenced by transcode().

◆ set_tty_echo()

static void set_tty_echo ( int  on)
static

Definition at line 776 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 788 of file ffmpeg.c.

Referenced by transcode().

◆ transcode()

static int transcode ( Scheduler sch)
static

Definition at line 855 of file ffmpeg.c.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 946 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 85 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 86 of file ffmpeg.c.

◆ vstats_file

FILE* vstats_file

Definition at line 88 of file ffmpeg.c.

Referenced by ffmpeg_cleanup(), and update_video_stats().

◆ nb_output_dumped

atomic_uint nb_output_dumped = 0

Definition at line 99 of file ffmpeg.c.

Referenced by mux_check_init(), and print_report().

◆ current_time

BenchmarkTimeStamps current_time
static

Definition at line 101 of file ffmpeg.c.

Referenced by main(), and update_benchmark().

◆ progress_avio

AVIOContext* progress_avio = NULL

Definition at line 102 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 113 of file ffmpeg.c.

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

◆ nb_decoders

int nb_decoders

Definition at line 114 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 137 of file ffmpeg.c.

Referenced by ffmpeg_cleanup(), and sigterm_handler().

◆ received_nb_signals

volatile int received_nb_signals = 0
static

Definition at line 138 of file ffmpeg.c.

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

◆ transcode_init_done

atomic_int transcode_init_done = 0
static

Definition at line 139 of file ffmpeg.c.

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

◆ ffmpeg_exited

volatile int ffmpeg_exited = 0
static

Definition at line 140 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 141 of file ffmpeg.c.

Referenced by print_report().

◆ int_cb