FFmpeg
|
#include "config.h"
#include <stdatomic.h>
#include <stdint.h>
#include <stdio.h>
#include <signal.h>
#include "cmdutils.h"
#include "ffmpeg_sched.h"
#include "sync_queue.h"
#include "libavformat/avformat.h"
#include "libavformat/avio.h"
#include "libavcodec/avcodec.h"
#include "libavcodec/bsf.h"
#include "libavfilter/avfilter.h"
#include "libavutil/avutil.h"
#include "libavutil/dict.h"
#include "libavutil/eval.h"
#include "libavutil/fifo.h"
#include "libavutil/hwcontext.h"
#include "libavutil/pixfmt.h"
#include "libavutil/rational.h"
#include "libavutil/thread.h"
#include "libavutil/threadmessage.h"
#include "libswresample/swresample.h"
Go to the source code of this file.
Data Structures | |
struct | HWDevice |
struct | StreamMap |
struct | OptionsContext |
struct | InputFilterOptions |
struct | OutputFilterOptions |
struct | InputFilter |
struct | OutputFilter |
struct | FilterGraph |
struct | DecoderOpts |
struct | Decoder |
struct | InputStream |
struct | InputFile |
struct | EncStatsComponent |
struct | EncStats |
struct | KeyframeForceCtx |
struct | OutputStream |
struct | OutputFile |
struct | FrameData |
Macros | |
#define | FFMPEG_OPT_QPHIST 1 |
#define | FFMPEG_OPT_ADRIFT_THRESHOLD 1 |
#define | FFMPEG_OPT_ENC_TIME_BASE_NUM 1 |
#define | FFMPEG_OPT_TOP 1 |
#define | FFMPEG_OPT_FORCE_KF_SOURCE_NO_DROP 1 |
#define | FFMPEG_OPT_VSYNC_DROP 1 |
#define | FFMPEG_OPT_VSYNC 1 |
#define | FFMPEG_OPT_FILTER_SCRIPT 1 |
#define | FFMPEG_ERROR_RATE_EXCEEDED FFERRTAG('E', 'R', 'E', 'D') |
#define | ABORT_ON_FLAG_EMPTY_OUTPUT (1 << 0) |
#define | ABORT_ON_FLAG_EMPTY_OUTPUT_STREAM (1 << 1) |
Variables | |
const char *const | forced_keyframes_const_names [] |
InputFile ** | input_files |
int | nb_input_files |
OutputFile ** | output_files |
int | nb_output_files |
FilterGraph ** | filtergraphs |
int | nb_filtergraphs |
Decoder ** | decoders |
int | nb_decoders |
char * | vstats_filename |
float | dts_delta_threshold |
float | dts_error_threshold |
enum VideoSyncMethod | video_sync_method |
float | frame_drop_threshold |
int | do_benchmark |
int | do_benchmark_all |
int | do_hex_dump |
int | do_pkt_dump |
int | copy_ts |
int | start_at_zero |
int | copy_tb |
int | debug_ts |
int | exit_on_error |
int | abort_on_flags |
int | print_stats |
int64_t | stats_period |
int | stdin_interaction |
AVIOContext * | progress_avio |
float | max_error_rate |
char * | filter_nbthreads |
int | filter_complex_nbthreads |
int | vstats_version |
int | auto_conversion_filters |
const AVIOInterruptCB | int_cb |
const OptionDef | options [] |
HWDevice * | filter_hw_device |
atomic_uint | nb_output_dumped |
int | ignore_unknown_streams |
int | copy_unknown_streams |
int | recast_media |
FILE * | vstats_file |
enum VideoSyncMethod |
enum EncTimeBase |
enum HWAccelID |
enum FrameOpaque |
enum PacketOpaque |
enum LatencyProbe |
enum IFilterFlags |
enum OFilterFlags |
enum DecoderFlags |
enum EncStatsType |
enum OSTFinished |
anonymous enum |
enum CroppingType |
void term_init | ( | void | ) |
Definition at line 201 of file ffmpeg.c.
Referenced by assert_file_overwrite().
void term_exit | ( | void | ) |
Definition at line 131 of file ffmpeg.c.
Referenced by assert_file_overwrite(), ffmpeg_cleanup(), and transcode().
void show_usage | ( | void | ) |
Definition at line 1231 of file ffmpeg_opt.c.
Referenced by main(), and show_help_default().
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().
int assert_file_overwrite | ( | const char * | filename | ) |
Definition at line 673 of file ffmpeg_opt.c.
Referenced by dump_attachment(), and of_open().
int find_codec | ( | void * | logctx, |
const char * | name, | ||
enum AVMediaType | type, | ||
int | encoder, | ||
const AVCodec ** | codec | ||
) |
Definition at line 640 of file ffmpeg_opt.c.
Referenced by choose_decoder(), choose_encoder(), and ifile_open().
int parse_and_set_vsync | ( | const char * | arg, |
int * | vsync_var, | ||
int | file_idx, | ||
int | st_idx, | ||
int | is_global | ||
) |
Definition at line 231 of file ffmpeg_opt.c.
Referenced by new_stream_video(), and opt_vsync().
int filtergraph_is_simple | ( | const FilterGraph * | fg | ) |
Definition at line 2030 of file ffmpeg_filter.c.
Referenced by configure_filtergraph(), fg_thread_set_name(), ifilter_bind_ist(), and print_stream_maps().
int init_simple_filtergraph | ( | InputStream * | ist, |
OutputStream * | ost, | ||
char * | graph_desc, | ||
Scheduler * | sch, | ||
unsigned | sch_idx_enc, | ||
const OutputFilterOptions * | opts | ||
) |
Definition at line 1181 of file ffmpeg_filter.c.
Referenced by ost_bind_filter().
int fg_finalise_bindings | ( | void | ) |
Definition at line 1365 of file ffmpeg_filter.c.
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(), nvenc_retrieve_frame_data(), nvenc_store_frame_data(), packet_decode(), and send_frame().
Definition at line 459 of file ffmpeg.c.
Referenced by choose_out_timebase().
Definition at line 465 of file ffmpeg.c.
Referenced by encode_frame(), input_packet_process(), and packet_decode().
int ofilter_bind_ost | ( | OutputFilter * | ofilter, |
OutputStream * | ost, | ||
unsigned | sched_idx_enc, | ||
const OutputFilterOptions * | opts | ||
) |
Definition at line 783 of file ffmpeg_filter.c.
Referenced by init_simple_filtergraph(), and ost_bind_filter().
int fg_create | ( | FilterGraph ** | pfg, |
char * | graph_desc, | ||
Scheduler * | sch | ||
) |
Create a new filtergraph in the global filtergraph list.
graph_desc | Graph description; an av_malloc()ed string, filtergraph takes ownership of it. |
Definition at line 1049 of file ffmpeg_filter.c.
Referenced by init_simple_filtergraph(), opt_filter_complex(), and opt_filter_complex_script().
void fg_free | ( | FilterGraph ** | pfg | ) |
Definition at line 979 of file ffmpeg_filter.c.
Referenced by ffmpeg_cleanup(), and ost_free().
void fg_send_command | ( | FilterGraph * | fg, |
double | time, | ||
const char * | target, | ||
const char * | command, | ||
const char * | arg, | ||
int | all_filters | ||
) |
Definition at line 3036 of file ffmpeg_filter.c.
Referenced by check_keyboard_interaction().
void enc_stats_write | ( | OutputStream * | ost, |
EncStats * | es, | ||
const AVFrame * | frame, | ||
const AVPacket * | pkt, | ||
uint64_t | frame_num | ||
) |
Definition at line 455 of file ffmpeg_enc.c.
Referenced by encode_frame(), and write_packet().
HWDevice* hw_device_get_by_name | ( | const char * | name | ) |
Definition at line 42 of file ffmpeg_hw.c.
Referenced by hw_device_default_name(), hw_device_init_from_string(), hw_device_setup_for_decode(), and opt_filter_hw_device().
HWDevice* hw_device_get_by_type | ( | enum AVHWDeviceType | type | ) |
Definition at line 28 of file ffmpeg_hw.c.
Referenced by hw_device_match_by_codec(), hw_device_setup_for_decode(), and hw_device_setup_for_encode().
int hw_device_init_from_string | ( | const char * | arg, |
HWDevice ** | dev | ||
) |
Definition at line 92 of file ffmpeg_hw.c.
Referenced by opt_init_hw_device().
int hw_device_init_from_type | ( | enum AVHWDeviceType | type, |
const char * | device, | ||
HWDevice ** | dev_out | ||
) |
Definition at line 243 of file ffmpeg_hw.c.
Referenced by hw_device_setup_for_decode().
void hw_device_free_all | ( | void | ) |
Definition at line 286 of file ffmpeg_hw.c.
Referenced by ffmpeg_cleanup().
AVBufferRef* hw_device_for_filter | ( | void | ) |
Get a hardware device to be used with this filtergraph.
The returned reference is owned by the callee, the caller must ref it explicitly for long-term use.
Definition at line 298 of file ffmpeg_hw.c.
Referenced by configure_filtergraph().
int dec_create | ( | const OptionsContext * | o, |
const char * | arg, | ||
Scheduler * | sch | ||
) |
Create a standalone decoder.
Definition at line 1306 of file ffmpeg_dec.c.
int dec_init | ( | Decoder ** | pdec, |
Scheduler * | sch, | ||
AVDictionary ** | dec_opts, | ||
const DecoderOpts * | o, | ||
AVFrame * | param_out | ||
) |
dec_opts | Dictionary filled with decoder options. Its ownership is transferred to the decoder. |
param_out | If non-NULL, media properties after opening the decoder are written here. |
>=0 | non-negative scheduler index on success |
<0 | an error code on failure |
Definition at line 1281 of file ffmpeg_dec.c.
Referenced by ist_use().
void dec_free | ( | Decoder ** | pdec | ) |
Definition at line 97 of file ffmpeg_dec.c.
Referenced by dec_alloc(), dec_create(), dec_init(), ffmpeg_cleanup(), and ist_free().
int dec_filter_add | ( | Decoder * | dec, |
InputFilter * | ifilter, | ||
InputFilterOptions * | opts | ||
) |
Definition at line 1378 of file ffmpeg_dec.c.
Referenced by ifilter_bind_dec().
Definition at line 71 of file ffmpeg_enc.c.
Referenced by ost_add().
void enc_free | ( | Encoder ** | penc | ) |
Definition at line 61 of file ffmpeg_enc.c.
Referenced by ost_free().
int enc_open | ( | void * | opaque, |
const AVFrame * | frame | ||
) |
Definition at line 165 of file ffmpeg_enc.c.
Referenced by encoder_thread(), and ost_add().
int enc_loopback | ( | Encoder * | enc | ) |
Definition at line 922 of file ffmpeg_enc.c.
Referenced by dec_create().
int of_stream_init | ( | OutputFile * | of, |
OutputStream * | ost | ||
) |
Definition at line 611 of file ffmpeg_mux.c.
Referenced by enc_open(), and of_open().
int of_write_trailer | ( | OutputFile * | of | ) |
Definition at line 740 of file ffmpeg_mux.c.
Referenced by transcode().
int of_open | ( | const OptionsContext * | o, |
const char * | filename, | ||
Scheduler * | sch | ||
) |
Definition at line 3214 of file ffmpeg_mux_init.c.
void of_free | ( | OutputFile ** | pof | ) |
Definition at line 848 of file ffmpeg_mux.c.
Referenced by ffmpeg_cleanup().
void of_enc_stats_close | ( | void | ) |
Definition at line 196 of file ffmpeg_mux_init.c.
Referenced by ffmpeg_cleanup().
int64_t of_filesize | ( | OutputFile * | of | ) |
Definition at line 875 of file ffmpeg_mux.c.
Referenced by mux_final_stats(), and print_report().
int ifile_open | ( | const OptionsContext * | o, |
const char * | filename, | ||
Scheduler * | sch | ||
) |
Definition at line 1594 of file ffmpeg_demux.c.
void ifile_close | ( | InputFile ** | f | ) |
Definition at line 855 of file ffmpeg_demux.c.
Referenced by ffmpeg_cleanup().
int ist_output_add | ( | InputStream * | ist, |
OutputStream * | ost | ||
) |
Definition at line 967 of file ffmpeg_demux.c.
Referenced by ost_add().
int ist_filter_add | ( | InputStream * | ist, |
InputFilter * | ifilter, | ||
int | is_simple, | ||
InputFilterOptions * | opts | ||
) |
Definition at line 985 of file ffmpeg_demux.c.
Referenced by ifilter_bind_ist().
InputStream* ist_find_unused | ( | enum AVMediaType | type | ) |
Find an unused input stream of given type.
Definition at line 157 of file ffmpeg_demux.c.
Referenced by fg_complex_bind_input().
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().
OutputStream* ost_iter | ( | OutputStream * | prev | ) |
Definition at line 360 of file ffmpeg.c.
Referenced by check_keyboard_interaction(), print_report(), and print_stream_maps().
void update_benchmark | ( | const char * | fmt, |
... | |||
) |
Definition at line 527 of file ffmpeg.c.
Referenced by encode_frame(), and packet_decode().
const char* opt_match_per_type_str | ( | const SpecifierOptList * | sol, |
char | mediatype | ||
) |
Definition at line 154 of file ffmpeg_opt.c.
Referenced by ifile_open(), map_auto_subtitle(), and opt_preset().
void opt_match_per_stream_str | ( | void * | logctx, |
const SpecifierOptList * | sol, | ||
AVFormatContext * | fc, | ||
AVStream * | st, | ||
const char ** | out | ||
) |
void opt_match_per_stream_int | ( | void * | logctx, |
const SpecifierOptList * | sol, | ||
AVFormatContext * | fc, | ||
AVStream * | st, | ||
int * | out | ||
) |
Referenced by add_display_matrix_to_stream(), ist_add(), new_stream_audio(), new_stream_video(), and ost_add().
void opt_match_per_stream_int64 | ( | void * | logctx, |
const SpecifierOptList * | sol, | ||
AVFormatContext * | fc, | ||
AVStream * | st, | ||
int64_t * | out | ||
) |
Referenced by ost_add().
void opt_match_per_stream_dbl | ( | void * | logctx, |
const SpecifierOptList * | sol, | ||
AVFormatContext * | fc, | ||
AVStream * | st, | ||
double * | out | ||
) |
Referenced by add_display_matrix_to_stream(), ist_add(), and ost_add().
int muxer_thread | ( | void * | arg | ) |
Definition at line 407 of file ffmpeg_mux.c.
Referenced by of_open().
int encoder_thread | ( | void * | arg | ) |
Definition at line 841 of file ffmpeg_enc.c.
Referenced by ost_add().
const char* const forced_keyframes_const_names[] |
Definition at line 3047 of file ffmpeg_mux_init.c.
Referenced by process_forced_keyframes().
InputFile** input_files |
Definition at line 104 of file ffmpeg.c.
Referenced by apply_sync_offsets(), assert_file_overwrite(), copy_meta(), correct_input_start_times(), demux_alloc(), ffmpeg_cleanup(), fg_complex_bind_input(), ist_iter(), map_auto_audio(), map_auto_video(), map_manual(), of_map_group(), opt_map(), and opt_target().
int nb_input_files |
Definition at line 105 of file ffmpeg.c.
Referenced by apply_sync_offsets(), assert_file_overwrite(), copy_meta(), correct_input_start_times(), demux_alloc(), ffmpeg_cleanup(), fg_complex_bind_input(), ist_iter(), main(), map_auto_audio(), map_auto_video(), of_map_group(), opt_map(), and opt_target().
OutputFile** output_files |
Definition at line 107 of file ffmpeg.c.
Referenced by dec_create(), ffmpeg_cleanup(), mux_alloc(), new_stream_video(), ost_iter(), print_report(), print_sdp(), and transcode().
int nb_output_files |
Definition at line 108 of file ffmpeg.c.
Referenced by create_streams(), dec_create(), ffmpeg_cleanup(), main(), mux_alloc(), ost_iter(), print_report(), print_sdp(), and transcode().
FilterGraph** filtergraphs |
Definition at line 110 of file ffmpeg.c.
Referenced by check_keyboard_interaction(), create_streams(), ffmpeg_cleanup(), fg_complex_bind_input(), fg_create(), fg_finalise_bindings(), and map_manual().
int nb_filtergraphs |
Definition at line 111 of file ffmpeg.c.
Referenced by check_keyboard_interaction(), create_streams(), ffmpeg_cleanup(), fg_complex_bind_input(), fg_create(), fg_finalise_bindings(), map_manual(), and print_stream_maps().
Decoder** decoders |
Definition at line 113 of file ffmpeg.c.
Referenced by dec_create(), ffmpeg_cleanup(), and fg_complex_bind_input().
int nb_decoders |
Definition at line 114 of file ffmpeg.c.
Referenced by dec_create(), ffmpeg_cleanup(), and fg_complex_bind_input().
char* vstats_filename |
Definition at line 52 of file ffmpeg_opt.c.
Referenced by encode_frame(), ffmpeg_cleanup(), opt_vstats_file(), and update_video_stats().
float dts_delta_threshold |
Definition at line 55 of file ffmpeg_opt.c.
Referenced by ts_discontinuity_detect().
float dts_error_threshold |
Definition at line 56 of file ffmpeg_opt.c.
Referenced by ts_discontinuity_detect(), and video_sync_process().
enum VideoSyncMethod video_sync_method |
Definition at line 59 of file ffmpeg_opt.c.
Referenced by new_stream_video(), opt_vsync(), and parse_and_set_vsync().
float frame_drop_threshold |
Definition at line 61 of file ffmpeg_opt.c.
Referenced by video_sync_process().
int do_benchmark |
Definition at line 62 of file ffmpeg_opt.c.
Referenced by ffmpeg_cleanup(), and main().
int do_benchmark_all |
Definition at line 63 of file ffmpeg_opt.c.
Referenced by update_benchmark().
int do_hex_dump |
Definition at line 64 of file ffmpeg_opt.c.
Referenced by input_thread().
int do_pkt_dump |
Definition at line 65 of file ffmpeg_opt.c.
Referenced by input_thread().
int copy_ts |
Definition at line 66 of file ffmpeg_opt.c.
Referenced by apply_sync_offsets(), correct_input_start_times(), ifile_open(), input_packet_process(), ist_filter_add(), new_stream_video(), print_report(), readrate_sleep(), streamcopy_init(), and ts_discontinuity_detect().
int start_at_zero |
Definition at line 67 of file ffmpeg_opt.c.
Referenced by apply_sync_offsets(), correct_input_start_times(), ifile_open(), input_packet_process(), ist_filter_add(), and readrate_sleep().
int copy_tb |
Definition at line 68 of file ffmpeg_opt.c.
int debug_ts |
Definition at line 69 of file ffmpeg_opt.c.
Referenced by adjust_frame_pts_to_encoder_tb(), encode_frame(), fg_output_step(), input_packet_process(), mux_fixup_ts(), and video_frame_process().
int exit_on_error |
Definition at line 70 of file ffmpeg_opt.c.
Referenced by do_subtitle_out(), input_thread(), mux_fixup_ts(), mux_packet_filter(), packet_decode(), and transcode_subtitles().
int abort_on_flags |
Definition at line 71 of file ffmpeg_opt.c.
Referenced by check_written(), and opt_abort_on().
int print_stats |
Definition at line 72 of file ffmpeg_opt.c.
Referenced by print_report().
int64_t stats_period |
Definition at line 79 of file ffmpeg_opt.c.
Referenced by opt_stats_period(), print_report(), and transcode().
int stdin_interaction |
Definition at line 73 of file ffmpeg_opt.c.
Referenced by assert_file_overwrite(), ifile_open(), term_init(), and transcode().
AVIOContext* progress_avio |
Definition at line 102 of file ffmpeg.c.
Referenced by print_report().
float max_error_rate |
Definition at line 74 of file ffmpeg_opt.c.
Referenced by decoder_thread().
char* filter_nbthreads |
Definition at line 75 of file ffmpeg_opt.c.
Referenced by configure_filtergraph(), ffmpeg_cleanup(), and opt_filter_threads().
int filter_complex_nbthreads |
Definition at line 76 of file ffmpeg_opt.c.
Referenced by configure_filtergraph().
int vstats_version |
Definition at line 77 of file ffmpeg_opt.c.
Referenced by update_video_stats().
int auto_conversion_filters |
Definition at line 78 of file ffmpeg_opt.c.
Referenced by fg_create().
const AVIOInterruptCB int_cb |
Definition at line 307 of file ffmpeg.c.
Referenced by avio_open2(), dump_attachment(), enc_stats_get_file(), ff_network_sleep_interruptible(), ff_network_wait_fd_timeout(), ffio_open_whitelist(), ffurl_alloc(), ffurl_open_whitelist(), get_preset_file_2(), ifile_open(), libsrt_network_wait_fd_timeout(), of_add_attachments(), of_open(), print_sdp(), read_binary(), url_alloc_for_protocol(), and zmq_proto_wait_timeout().
const OptionDef options[] |
Referenced by av_bsf_list_append2(), av_hwdevice_ctx_create_derived_opts(), av_opt_set_dict(), av_opt_set_dict2(), avcodec_open2(), avfilter_init_dict(), avfilter_init_str(), avformat_find_stream_info(), avformat_init_output(), avformat_open_input(), avformat_stream_group_create(), avformat_write_header(), bsf_list_append_internal(), crypto_open2(), ff_filter_opt_parse(), ff_format_output_open(), ff_opus_psy_init(), ff_tee_parse_slave_options(), ff_tls_open_underlying(), hls_read_header(), hw_device_init_from_string(), init(), init_input(), init_muxer(), io_open_default(), list_devices_for_context(), locate_option(), main(), open_url_keepalive(), opt_audio_codec(), opt_audio_filters(), opt_audio_frames(), opt_audio_qscale(), opt_data_codec(), opt_data_frames(), opt_old2new(), opt_qscale(), opt_recording_timestamp(), opt_subtitle_codec(), opt_target(), opt_timecode(), opt_video_codec(), opt_video_filters(), opt_video_frames(), parse_loglevel(), parse_option(), parse_options(), pcm_read_header(), pp_get_mode_by_name_and_quality(), set_string_dict(), show_banner(), show_help_default(), show_help_options(), split_commandline(), subfile_open(), tee_open(), try_decode_frame(), uninit_options(), wrap(), and write_packet().
HWDevice* filter_hw_device |
Definition at line 50 of file ffmpeg_opt.c.
Referenced by hw_device_for_filter(), and opt_filter_hw_device().
atomic_uint nb_output_dumped |
Definition at line 99 of file ffmpeg.c.
Referenced by mux_check_init(), and print_report().
int ignore_unknown_streams |
Definition at line 84 of file ffmpeg_opt.c.
Referenced by map_manual().
int copy_unknown_streams |
Definition at line 85 of file ffmpeg_opt.c.
Referenced by map_manual().
int recast_media |
Definition at line 86 of file ffmpeg_opt.c.
Referenced by choose_decoder(), and find_codec().
FILE* vstats_file |
Definition at line 88 of file ffmpeg.c.
Referenced by ffmpeg_cleanup(), and update_video_stats().