FFmpegfs Fuse Multi Media Filesystem 2.19
Loading...
Searching...
No Matches
ffmpeg_base.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017-2026 Norbert Schlia (nschlia@oblivion-software.de)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 * On Debian systems, the complete text of the GNU General Public License
19 * Version 3 can be found in `/usr/share/common-licenses/GPL-3'.
20 */
21
32#ifndef FFMPEG_BASE_H
33#define FFMPEG_BASE_H
34
35#pragma once
36
37#include "ffmpeg_utils.h"
38
39struct VIRTUALFILE;
40struct AVCodecContext;
41
46{
47public:
51 explicit FFmpeg_Base();
55 virtual ~FFmpeg_Base() = default;
56
57protected:
66 void video_stream_setup(AVCodecContext *output_codec_ctx, AVStream* output_stream, AVCodecContext *input_codec_ctx, AVRational framerate, AVPixelFormat enc_hw_pix_fmt) const;
77 int dict_set_with_check(AVDictionary **pm, const char *key, const char *value, int flags, const char *filename = nullptr, bool nodelete = false) const;
88 int dict_set_with_check(AVDictionary **pm, const char *key, int64_t value, int flags, const char *filename = nullptr, bool nodelete = false) const;
98 int opt_set_with_check(void *obj, const char *key, const char *value, int flags, const char *filename = nullptr) const;
105 void video_info(bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const;
112 void audio_info(bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const;
119 void subtitle_info(bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const;
125 static std::string get_pix_fmt_name(AVPixelFormat pix_fmt);
131 static std::string get_sample_fmt_name(AVSampleFormat sample_fmt);
132#if LAVU_DEP_OLD_CHANNEL_LAYOUT
138 static std::string get_channel_layout_name(const AVChannelLayout * ch_layout);
139#else // !LAVU_DEP_OLD_CHANNEL_LAYOUT
146 static std::string get_channel_layout_name(int nb_channels, uint64_t channel_layout);
147#endif // !LAVU_DEP_OLD_CHANNEL_LAYOUT
148
153 virtual const char *filename() const = 0;
158 virtual const char *destname() const = 0;
163 virtual const char *virtname() const = 0;
170 uint32_t pts_to_frame(AVStream* stream, int64_t pts) const;
177 int64_t frame_to_pts(AVStream* stream, uint32_t frame_no) const;
183 int get_channels(const AVCodecParameters *codecpar) const;
189 void set_channels(AVCodecParameters *codecpar_out, const AVCodecParameters *codecpar_in) const;
195 int get_channels(const AVCodecContext *codec_ctx) const;
201 void set_channels(AVCodecContext *codec_ctx_out, const AVCodecContext *codec_ctx_in) const;
207 void set_channels(AVCodecContext *codec_ctx_out, int channels) const;
208
209#define ASS_DEFAULT_PLAYRESX 384
210#define ASS_DEFAULT_PLAYRESY 288
211#define ASS_DEFAULT_FONT "Arial"
212#define ASS_DEFAULT_FONT_SIZE 16
223#define ASS_DEFAULT_COLOUR 0xffffff
224#define ASS_DEFAULT_BACK_COLOUR 0
225#define ASS_DEFAULT_BOLD 0
226#define ASS_DEFAULT_ITALIC 0
227#define ASS_DEFAULT_UNDERLINE 0
243#define ASS_DEFAULT_ALIGNMENT 2
249#define ASS_DEFAULT_BORDERSTYLE 1
250
270 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;
271
272protected:
274};
275
276#endif // FFMPEG_BASE_H
277
The FFmpeg_Base class.
Definition ffmpeg_base.h:46
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.
int get_channels(const AVCodecParameters *codecpar) const
Get the number of channels from AVCodecParameters.
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.
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 funct...
void audio_info(bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const
Print data from the audio stream to log.
int64_t frame_to_pts(AVStream *stream, uint32_t frame_no) const
Convert frame number to PTS value.
uint32_t pts_to_frame(AVStream *stream, int64_t pts) const
Convert PTS value to frame number.
virtual const char * virtname() const =0
Return virtual filename. Must be implemented in child class.
virtual ~FFmpeg_Base()=default
Destruct FFmpeg_Base object.
void video_info(bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const
Print data from the video stream to a log.
virtual const char * destname() const =0
Return destination filename. Must be implemented in child class.
void subtitle_info(bool out_file, const AVFormatContext *format_ctx, const AVStream *stream) const
Print data from the subtitle stream to log.
VIRTUALFILE * m_virtualfile
Underlying virtual file object.
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.
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.
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.
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.
void set_channels(AVCodecParameters *codecpar_out, const AVCodecParameters *codecpar_in) const
Set the number of channels from AVCodecParameters.
FFmpeg_Base()
Construct FFmpeg_Base object.
virtual const char * filename() const =0
Return source filename. Must be implemented in child class.
Various FFmpegfs utility functions.
Virtual file definition.
Definition fileio.h:123