FFmpegfs Fuse Multi Media Filesystem 2.16
|
The FFmpeg_Base class. More...
#include <ffmpeg_base.h>
Public Member Functions | |
FFmpeg_Base () | |
Construct FFmpeg_Base object. More... | |
virtual | ~FFmpeg_Base ()=default |
Destruct FFmpeg_Base object. | |
Protected Member Functions | |
void | video_stream_setup (AVCodecContext *output_codec_ctx, AVStream *output_stream, AVCodecContext *input_codec_ctx, AVRational framerate, AVPixelFormat enc_hw_pix_fmt) const |
Set up a video stream. More... | |
int | dict_set_with_check (AVDictionary **pm, const char *key, const char *value, int flags, const char *filename=nullptr, bool nodelete=false) const |
Call av_dict_set and check the result code. It displays an error message if appropriate. More... | |
int | dict_set_with_check (AVDictionary **pm, const char *key, int64_t value, int flags, const char *filename=nullptr, bool nodelete=false) const |
Call av_dict_set and check the result code. It displays an error message if appropriate. More... | |
int | opt_set_with_check (void *obj, const char *key, const char *value, int flags, const char *filename=nullptr) const |
Call av_opt_set and check result code. Displays an error message if appropriate. More... | |
void | video_info (bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const |
Print data from the video stream to a log. More... | |
void | audio_info (bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const |
Print data from the audio stream to log. More... | |
void | subtitle_info (bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const |
Print data from the subtitle stream to log. More... | |
virtual const char * | filename () const =0 |
Return source filename. Must be implemented in child class. More... | |
virtual const char * | destname () const =0 |
Return destination filename. Must be implemented in child class. More... | |
virtual const char * | virtname () const =0 |
Return virtual filename. Must be implemented in child class. More... | |
uint32_t | pts_to_frame (AVStream *stream, int64_t pts) const |
Convert PTS value to frame number. More... | |
int64_t | frame_to_pts (AVStream *stream, uint32_t frame_no) const |
Convert frame number to PTS value. More... | |
int | get_channels (const AVCodecParameters *codecpar) const |
Get the number of channels from AVCodecParameters. More... | |
void | set_channels (AVCodecParameters *codecpar_out, const AVCodecParameters *codecpar_in) const |
Set the number of channels from AVCodecParameters. More... | |
int | get_channels (const AVCodecContext *codec_ctx) const |
Get the number of channels from AVCodecContext. More... | |
void | set_channels (AVCodecContext *codec_ctx_out, const AVCodecContext *codec_ctx_in) const |
Set the number of channels from AVCodecContext. More... | |
void | set_channels (AVCodecContext *codec_ctx_out, int channels) const |
Set the number of channels from AVCodecContext. More... | |
int | get_script_info (AVCodecContext *codec_ctx, int play_res_x, int play_res_y, const char *font, int font_size, int primary_color, int secondary_color, int outline_color, int back_color, int bold, int italic, int underline, int border_style, int alignment) const |
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS. Nicked from the FFmpeg API function ff_ass_subtitle_header_full(). :) More... | |
Static Protected Member Functions | |
static std::string | get_pix_fmt_name (AVPixelFormat pix_fmt) |
Calls av_get_pix_fmt_name and returns a std::string with the pix format name. More... | |
static std::string | get_sample_fmt_name (AVSampleFormat sample_fmt) |
Calls av_get_sample_fmt_name and returns a std::string with the format name. More... | |
static std::string | get_channel_layout_name (const AVChannelLayout *ch_layout) |
Calls av_channel_layout_describe and returns a std::string with the channel layout. More... | |
Protected Attributes | |
VIRTUALFILE * | m_virtualfile |
Underlying virtual file object. More... | |
The FFmpeg_Base class.
Definition at line 45 of file ffmpeg_base.h.
|
explicit |
Construct FFmpeg_Base object.
Definition at line 53 of file ffmpeg_base.cc.
|
protected |
Print data from the audio stream to log.
[in] | out_file | - True if the file is output. |
[in] | format_ctx | - AVFormatContext belonging to the stream. |
[in] | stream | - Stream to show data for. |
Definition at line 243 of file ffmpeg_base.cc.
References Logging::debug(), ffmpeg_rescale_q_rnd(), filename(), format_bitrate(), format_duration(), format_samplerate(), get_channels(), get_codec_name(), and virtname().
Referenced by FFmpeg_Transcoder::open_bestmatch_audio(), and FFmpeg_Transcoder::open_output().
|
protectedpure virtual |
Return destination filename. Must be implemented in child class.
Implemented in FFmpeg_Transcoder.
|
protected |
Call av_dict_set and check the result code. It displays an error message if appropriate.
[in] | pm | - Pointer to a pointer to a dictionary struct. |
[in] | key | - Entry key to add to *pm. |
[in] | value | - Entry value to add to *pm. |
[in] | flags | - AV_DICT_* flags. |
[in] | filename | - Filename this frame was created for. Only used for logging; may be nullptr. |
[in] | nodelete | - If true, the tag is not deleted if the value is 0. |
Definition at line 172 of file ffmpeg_base.cc.
References Logging::error(), ffmpeg_geterror(), and filename().
Referenced by FFmpeg_Transcoder::add_stream(), FFmpeg_Transcoder::add_subtitle_stream(), FFmpeg_Transcoder::copy_metadata(), FFmpeg_Transcoder::open_input_file(), FFmpeg_Transcoder::open_output_frame_set(), FFmpeg_Transcoder::process_metadata(), and FFmpeg_Transcoder::update_format().
|
protected |
Call av_dict_set and check the result code. It displays an error message if appropriate.
[in] | pm | - Pointer to a pointer to a dictionary struct. |
[in] | key | - Entry key to add to *pm. |
[in] | value | - Entry value to add to *pm. |
[in] | flags | - AV_DICT_* flags. |
[in] | filename | - Filename this frame was created for. Only used for logging; may be nullptr. |
[in] | nodelete | - If true, the tag is not deleted if the value is 0. |
Definition at line 189 of file ffmpeg_base.cc.
References Logging::error(), ffmpeg_geterror(), and filename().
|
protectedpure virtual |
Return source filename. Must be implemented in child class.
Implemented in FFmpeg_Transcoder.
Referenced by audio_info(), dict_set_with_check(), opt_set_with_check(), subtitle_info(), and video_info().
|
protected |
Convert frame number to PTS value.
[in] | stream | - Source video stream. |
[in] | frame_no | - Number of frame. |
Definition at line 324 of file ffmpeg_base.cc.
Referenced by FFmpeg_Transcoder::do_seek_frame(), and FFmpeg_Transcoder::encode_image_frame().
|
staticprotected |
Calls av_channel_layout_describe and returns a std::string with the channel layout.
[in] | ch_layout | - Channel layout |
Definition at line 298 of file ffmpeg_base.cc.
Referenced by FFmpeg_Transcoder::init_resampler().
|
protected |
Get the number of channels from AVCodecContext.
[in] | codec_ctx | - AVCodecContext to check. |
Definition at line 349 of file ffmpeg_base.cc.
|
protected |
Get the number of channels from AVCodecParameters.
[in] | codecpar | - AVCodecParameters to check. |
Definition at line 331 of file ffmpeg_base.cc.
Referenced by FFmpeg_Transcoder::add_stream(), audio_info(), FFmpeg_Transcoder::calculate_predicted_filesize(), FFmpeg_Transcoder::convert_samples(), FFmpeg_Transcoder::init_audio_fifo(), and FFmpeg_Transcoder::init_converted_samples().
|
staticprotected |
Calls av_get_pix_fmt_name and returns a std::string with the pix format name.
[in] | pix_fmt | - AVPixelFormat enum to convert. |
Definition at line 286 of file ffmpeg_base.cc.
Referenced by FFmpeg_Transcoder::get_format(), FFmpeg_Transcoder::init_rescaler(), and FFmpeg_Transcoder::open_output_frame_set().
|
staticprotected |
Calls av_get_sample_fmt_name and returns a std::string with the format name.
[in] | sample_fmt | - AVSampleFormat enum to convert. |
Definition at line 292 of file ffmpeg_base.cc.
Referenced by FFmpeg_Transcoder::init_resampler().
|
protected |
Generate a suitable AVCodecContext.subtitle_header for SUBTITLE_ASS. Nicked from the FFmpeg API function ff_ass_subtitle_header_full(). :)
[in] | codec_ctx | pointer to the AVCodecContext |
[in] | play_res_x | subtitle frame width |
[in] | play_res_y | subtitle frame height |
[in] | font | name of the default font face to use |
[in] | font_size | default font size to use |
[in] | primary_color | default text color to use (ABGR) |
[in] | secondary_color | default secondary text color to use (ABGR) |
[in] | outline_color | default outline color to use (ABGR) |
[in] | back_color | default background color to use (ABGR) |
[in] | bold | 1 for bold text, 0 for normal text |
[in] | italic | 1 for italic text, 0 for normal text |
[in] | underline | 1 for underline text, 0 for normal text |
[in] | border_style | 1 for outline, 3 for opaque box |
[in] | alignment | position of the text (left, center, top...), defined after the layout of the numpad (1-3 sub, 4-6 mid, 7-9 top) |
Definition at line 382 of file ffmpeg_base.cc.
References FFMPEFS_VERSION.
Referenced by FFmpeg_Transcoder::add_subtitle_stream().
|
protected |
Call av_opt_set and check result code. Displays an error message if appropriate.
[in] | obj | - A structure whose first element is a pointer to an AVClass. |
[in] | key | - The name of the field to be set. |
[in] | value | - The value to be set. |
[in] | flags | - Flags to be passed to av_opt_find2. |
[in] | filename | - Filename this frame was created for. Only used for logging; may be nullptr. |
Definition at line 206 of file ffmpeg_base.cc.
References Logging::error(), ffmpeg_geterror(), and filename().
Referenced by FFmpeg_Transcoder::update_codec().
|
protected |
Convert PTS value to frame number.
[in] | stream | - Source video stream. |
[in] | pts | - PTS of current frame in stream's time_base units. |
Definition at line 313 of file ffmpeg_base.cc.
Referenced by FFmpeg_Transcoder::encode_image_frame(), and FFmpeg_Transcoder::skip_decoded_frames().
|
protected |
Set the number of channels from AVCodecContext.
[in,out] | codec_ctx_out | - AVCodecContext to set channels for. |
[in] | codec_ctx_in | - AVCodecContext to copy channels from. |
Definition at line 358 of file ffmpeg_base.cc.
|
protected |
Set the number of channels from AVCodecContext.
[in,out] | codec_ctx_out | - AVCodecContext to set. |
[in] | channels | - Number of channels to set. |
Definition at line 367 of file ffmpeg_base.cc.
|
protected |
Set the number of channels from AVCodecParameters.
[in,out] | codecpar_out | - AVCodecParameters to set. |
[in] | codecpar_in | - AVCodecParameters to get channels from. |
Definition at line 340 of file ffmpeg_base.cc.
Referenced by FFmpeg_Transcoder::add_stream().
|
protected |
Print data from the subtitle stream to log.
[in] | out_file | - True if the file is output. |
[in] | format_ctx | - AVFormatContext belonging to the stream. |
[in] | stream | - Stream to show data for. |
Definition at line 270 of file ffmpeg_base.cc.
References Logging::debug(), filename(), get_codec_name(), and virtname().
Referenced by FFmpeg_Transcoder::open_output(), and FFmpeg_Transcoder::open_subtitles().
|
protected |
Print data from the video stream to a log.
[in] | out_file | - True if the file is output. |
[in] | format_ctx | - AVFormatContext belonging to the stream. |
[in] | stream | - Stream to show data for. |
Definition at line 218 of file ffmpeg_base.cc.
References Logging::debug(), ffmpeg_rescale_q_rnd(), filename(), format_bitrate(), format_duration(), get_codec_name(), and virtname().
Referenced by FFmpeg_Transcoder::open_bestmatch_video(), and FFmpeg_Transcoder::open_output().
|
protected |
Set up a video stream.
[in] | output_codec_ctx | - Output codec context. |
[in] | output_stream | - Output stream object. |
[in] | input_codec_ctx | - Input codec context. |
[in] | framerate | - Frame rate of input stream. |
[in] | enc_hw_pix_fmt | - Forcibly set the destination pixel format. Set it to AV_PIX_FMT_NONE for automatic selection. |
Definition at line 68 of file ffmpeg_base.cc.
References Logging::warning().
Referenced by FFmpeg_Transcoder::add_stream().
|
protectedpure virtual |
Return virtual filename. Must be implemented in child class.
Implemented in FFmpeg_Transcoder.
Referenced by audio_info(), subtitle_info(), and video_info().
|
protected |
Underlying virtual file object.
Definition at line 280 of file ffmpeg_base.h.
Referenced by FFmpeg_Transcoder::copy_metadata(), FFmpeg_Transcoder::decode_frame(), FFmpeg_Transcoder::destname(), FFmpeg_Transcoder::duration(), FFmpeg_Transcoder::encode_finish(), FFmpeg_Transcoder::filename(), FFmpeg_Transcoder::open_bestmatch_audio(), FFmpeg_Transcoder::open_bestmatch_video(), FFmpeg_Transcoder::open_input_file(), FFmpeg_Transcoder::open_output(), FFmpeg_Transcoder::open_output_file(), FFmpeg_Transcoder::predicted_filesize(), FFmpeg_Transcoder::process_metadata(), FFmpeg_Transcoder::purge(), FFmpeg_Transcoder::read_decode_convert_and_store(), FFmpeg_Transcoder::segment_count(), FFmpeg_Transcoder::skip_decoded_frames(), FFmpeg_Transcoder::start_new_segment(), FFmpeg_Transcoder::video_frame_count(), and FFmpeg_Transcoder::virtname().