FFmpegfs Fuse Multi Media Filesystem 2.19
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Enumerations | Functions | Variables
ffmpegfs.cc File Reference

FFmpeg main function and utilities implementation. More...

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/avfilter.h>
#include "ffmpegfs.h"
#include "logging.h"
#include "ffmpegfshelp.h"
#include <sys/sysinfo.h>
#include <sqlite3.h>
#include <unistd.h>
#include <fnmatch.h>
#include <iostream>
#include <libbluray/bluray-version.h>
Include dependency graph for ffmpegfs.cc:

Go to the source code of this file.

Classes

struct  HWACCEL
 Hardware acceleration device and type. More...
 

Macros

#define AV_PROFILE_UNKNOWN   FF_PROFILE_UNKNOWN
 Compatibility alias for older FFmpeg versions that only define FF_PROFILE_UNKNOWN.
 
#define FFMPEGFS_OPT(templ, param, value)   { templ, offsetof(FFMPEGFS_PARAMS, param), value }
 

Typedefs

typedef std::map< const std::string, const AUTOCOPY, compAUTOCOPY_MAP
 Map command line option to AUTOCOPY enum.
 
typedef std::map< const std::string, const PROFILE, compPROFILE_MAP
 Map command line option to PROFILE enum.
 
typedef std::map< const std::string, const PRORESLEVEL, compLEVEL_MAP
 Map command line option to LEVEL enum.
 
typedef std::map< const std::string, const RECODESAME, compRECODESAME_MAP
 Map command line option to RECODESAME enum.
 
typedef struct HWACCEL HWACCEL
 Hardware acceleration device and type.
 
typedef std::map< const std::string, HWACCEL, compHWACCEL_MAP
 Map command line option to HWACCEL struct.
 
typedef std::map< const std::string, const AVCodecID, compCODEC_MAP
 Map command line option to AVCodecID.
 
typedef std::map< const std::string, const SAMPLE_FMT, compSAMPLE_FMT_MAP
 Map command line option to SAMPLE_FMT.
 
typedef std::map< const std::string, const AVCodecID, compAUDIOCODEC_MAP
 Map command line option to audio AVCodecID.
 
typedef std::map< const std::string, const AVCodecID, compVIDEOCODEC_MAP
 Map command line option to video AVCodecID.
 

Enumerations

enum  {
  KEY_HELP , KEY_VERSION , KEY_FFMPEG_CAPS , KEY_KEEP_OPT ,
  KEY_DESTTYPE , KEY_AUDIOCODEC , KEY_VIDEOCODEC , KEY_AUDIO_BITRATE ,
  KEY_AUDIO_SAMPLERATE , KEY_AUDIO_CHANNELS , KEY_AUDIO_SAMPLE_FMT , KEY_VIDEO_BITRATE ,
  KEY_SEGMENT_DURATION , KEY_MIN_SEEK_TIME_DIFF , KEY_SCRIPTFILE , KEY_SCRIPTSOURCE ,
  KEY_EXPIRY_TIME , KEY_MAX_INACTIVE_SUSPEND_TIME , KEY_MAX_INACTIVE_ABORT_TIME , KEY_PREBUFFER_TIME ,
  KEY_PREBUFFER_SIZE , KEY_MAX_CACHE_SIZE , KEY_MIN_DISKSPACE_SIZE , KEY_CACHEPATH ,
  KEY_CACHE_MAINTENANCE , KEY_AUTOCOPY , KEY_RECODESAME , KEY_PROFILE ,
  KEY_LEVEL , KEY_LOG_MAXLEVEL , KEY_LOGFILE , KEY_HWACCEL_ENCODER_API ,
  KEY_HWACCEL_ENCODER_DEVICE , KEY_HWACCEL_DECODER_API , KEY_HWACCEL_DECODER_DEVICE , KEY_HWACCEL_DECODER_BLOCKED ,
  KEY_INCLUDE_EXTENSIONS , KEY_HIDE_EXTENSIONS
}
 

Functions

static int get_bitrate (const std::string &arg, BITRATE *bitrate)
 Get formatted bitrate.
 
static int get_samplerate (const std::string &arg, int *samplerate)
 Get formatted sample rate.
 
static int get_sampleformat (const std::string &arg, SAMPLE_FMT *sample_fmt)
 Get sample format.
 
static int get_time (const std::string &arg, time_t *time)
 Get formatted time,.
 
static int get_size (const std::string &arg, size_t *size)
 Read size:
.
 
static int get_desttype (const std::string &arg, FFMPEGFS_FORMAT_ARR &format)
 Get destination type.
 
static int get_audiocodec (const std::string &arg, AVCodecID *audio_codec)
 Get the audio codec.
 
static int get_videocodec (const std::string &arg, AVCodecID *video_codec)
 Get the video codec.
 
static int get_autocopy (const std::string &arg, AUTOCOPY *autocopy)
 Get autocopy option.
 
static int get_recodesame (const std::string &arg, RECODESAME *recode)
 Get recode option.
 
static int get_profile (const std::string &arg, PROFILE *profile)
 Get profile option.
 
static int get_level (const std::string &arg, PRORESLEVEL *level)
 Get ProRes level.
 
static int get_segment_duration (const std::string &arg, int64_t *value)
 Get HLS segment duration. Input value must be in seconds.
 
static int get_seek_time_diff (const std::string &arg, int64_t *value)
 Get seek time diff. Input value must be in seconds.
 
static int get_hwaccel (const std::string &arg, HWACCELAPI *hwaccel_API, AVHWDeviceType *hwaccel_device_type)
 Get type of hardware acceleration. To keep it simple, currently all values are accepted.
 
static int get_codec (const std::string &codec, AVCodecID *codec_id)
 Get AVCodecID for codec string.
 
static int get_hwaccel_dec_blocked (const std::string &arg, HWACCEL_BLOCKED_MAP **hwaccel_dec_blocked)
 Get list of codecs and optional profiles blocked for hardware accelerated decoding.
 
static int get_value (const std::string &arg, int *value)
 Get value from command line string. Finds whatever is after the "=" sign.
 
static int get_value (const std::string &arg, std::string *value)
 Get value from command line string. Finds whatever is after the "=" sign.
 
static int get_value (const std::string &arg, MATCHVEC *value)
 Get comma separated values from command line string. Finds whatever is after the "=" sign.
 
static int get_value (const std::string &arg, double *value)
 Get value from command line string. Finds whatever is after the "=" sign.
 
static int ffmpegfs_opt_proc (__attribute__((unused)) void *data, const char *arg, int key, struct fuse_args *outargs)
 FUSE option parsing function.
 
static bool set_defaults ()
 Set default values.
 
static void build_device_type_list ()
 Build list of available device types. Builds a list of device types supported by the current FFmpeg libary.
 
static void print_params ()
 Print currently selected parameters.
 
static void usage ()
 Print program usage info.
 
static void ffmpeg_log (void *ptr, int level, const char *fmt, va_list vl)
 Custom FFmpeg log function. Used with av_log_set_callback().
 
static bool init_logging (const std::string &logfile, const std::string &max_level, bool to_stderr, bool to_syslog)
 Inititalise logging facility.
 
template<typename T >
static void list_options (const char *info, const T &map)
 Iterate through all elements in map print all keys.
 
std::string get_sampleformat_text (SAMPLE_FMT sample_fmt)
 Convert SAMPLE_FMT enum to human readable text.
 
std::string get_audio_codec_text (AVCodecID audio_codec)
 Convert AVCodecID enum for audio codec to human readable text.
 
std::string get_video_codec_text (AVCodecID video_codec)
 Convert AVCodecID enum for video codec to human readable text.
 
std::string get_autocopy_text (AUTOCOPY autocopy)
 Convert AUTOCOPY enum to human readable text.
 
std::string get_recodesame_text (RECODESAME recode)
 Convert RECODESAME enum to human readable text.
 
std::string get_profile_text (PROFILE profile)
 Convert PROFILE enum to human readable text.
 
std::string get_level_text (PRORESLEVEL level)
 Convert PRORESLEVEL enum to human readable text.
 
bool check_hwaccel_dec_blocked (AVCodecID codec_id, int profile)
 Check if codec_id and the optional profile are in the block list.
 
std::string get_hwaccel_API_text (HWACCELAPI hwaccel_API)
 Get the selected hardware acceleration as text.
 
const char * value_or_none (const char *value)
 Return a printable parameter value.
 
int main (int argc, char *argv[])
 Main program entry point.
 

Variables

FFMPEGFS_FORMAT_ARR ffmpeg_format
 Two FFmpegfs_Format infos, 0: video file, 1: audio file.
 
FFMPEGFS_PARAMS params
 FFmpegfs command line parameters.
 
static struct fuse_opt ffmpegfs_opts []
 
static const AUDIOCODEC_MAP audiocodec_map
 List of audio codecs.
 
static const VIDEOCODEC_MAP videocodec_map
 List of video codecs.
 
static const AUTOCOPY_MAP autocopy_map
 
static const PROFILE_MAP profile_map
 
static const LEVEL_MAP prores_level_map
 
static const RECODESAME_MAP recode_map
 
static HWACCEL_MAP hwaccel_map
 
static const CODEC_MAP hwaccel_codec_map
 
static const SAMPLE_FMT_MAP sample_fmt_map
 

Detailed Description

FFmpeg main function and utilities implementation.

Author
Norbert Schlia (nschl.nosp@m.ia@o.nosp@m.blivi.nosp@m.on-s.nosp@m.oftwa.nosp@m.re.d.nosp@m.e)

Definition in file ffmpegfs.cc.

Macro Definition Documentation

◆ AV_PROFILE_UNKNOWN

#define AV_PROFILE_UNKNOWN   FF_PROFILE_UNKNOWN

Compatibility alias for older FFmpeg versions that only define FF_PROFILE_UNKNOWN.

Definition at line 77 of file ffmpegfs.cc.

◆ FFMPEGFS_OPT

#define FFMPEGFS_OPT (   templ,
  param,
  value 
)    { templ, offsetof(FFMPEGFS_PARAMS, param), value }

Map FFmpegfs options to FUSE parameters

Definition at line 297 of file ffmpegfs.cc.

Typedef Documentation

◆ AUDIOCODEC_MAP

typedef std::map<const std::string, const AVCodecID, comp> AUDIOCODEC_MAP

Map command line option to audio AVCodecID.

Definition at line 454 of file ffmpegfs.cc.

◆ AUTOCOPY_MAP

typedef std::map<const std::string, const AUTOCOPY, comp> AUTOCOPY_MAP

Map command line option to AUTOCOPY enum.

Definition at line 438 of file ffmpegfs.cc.

◆ CODEC_MAP

typedef std::map<const std::string, const AVCodecID, comp> CODEC_MAP

Map command line option to AVCodecID.

Definition at line 451 of file ffmpegfs.cc.

◆ HWACCEL

typedef struct HWACCEL HWACCEL

Hardware acceleration device and type.

<

◆ HWACCEL_MAP

typedef std::map<const std::string, HWACCEL, comp> HWACCEL_MAP

Map command line option to HWACCEL struct.

Definition at line 450 of file ffmpegfs.cc.

◆ LEVEL_MAP

typedef std::map<const std::string, const PRORESLEVEL, comp> LEVEL_MAP

Map command line option to LEVEL enum.

Definition at line 440 of file ffmpegfs.cc.

◆ PROFILE_MAP

typedef std::map<const std::string, const PROFILE, comp> PROFILE_MAP

Map command line option to PROFILE enum.

Definition at line 439 of file ffmpegfs.cc.

◆ RECODESAME_MAP

typedef std::map<const std::string, const RECODESAME, comp> RECODESAME_MAP

Map command line option to RECODESAME enum.

Definition at line 441 of file ffmpegfs.cc.

◆ SAMPLE_FMT_MAP

typedef std::map<const std::string, const SAMPLE_FMT, comp> SAMPLE_FMT_MAP

Map command line option to SAMPLE_FMT.

Definition at line 452 of file ffmpegfs.cc.

◆ VIDEOCODEC_MAP

typedef std::map<const std::string, const AVCodecID, comp> VIDEOCODEC_MAP

Map command line option to video AVCodecID.

Definition at line 455 of file ffmpegfs.cc.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Definition at line 251 of file ffmpegfs.cc.

Function Documentation

◆ build_device_type_list()

static void build_device_type_list ( )
static

Build list of available device types. Builds a list of device types supported by the current FFmpeg libary.

Definition at line 2039 of file ffmpegfs.cc.

References hwaccel_map.

Referenced by main().

◆ check_hwaccel_dec_blocked()

bool check_hwaccel_dec_blocked ( AVCodecID  codec_id,
int  profile 
)

Check if codec_id and the optional profile are in the block list.

Parameters
[in]codec_id- Codec ID to check
[in]profile- Profile to check. Set to FF_PROFILE_UNKOWN to ignore.
Returns
Returns true if codec is in block list, false if not.

Definition at line 1596 of file ffmpegfs.cc.

References AV_PROFILE_UNKNOWN, FFMPEGFS_PARAMS::m_hwaccel_dec_blocked, and params.

Referenced by FFmpeg_Transcoder::open_decoder().

◆ ffmpeg_log()

static void ffmpeg_log ( void *  ptr,
int  level,
const char *  fmt,
va_list  vl 
)
static

Custom FFmpeg log function. Used with av_log_set_callback().

Parameters
[in]ptr- See av_log_set_callback() in FFmpeg API.
[in]level- See av_log_set_callback() in FFmpeg API.
[in]fmt- See av_log_set_callback() in FFmpeg API.
[in]vl- See av_log_set_callback() in FFmpeg API.

Definition at line 2183 of file ffmpegfs.cc.

References Logging::log_with_level(), LOGDEBUG, LOGERROR, LOGTRACE, LOGWARN, Logging::show(), and strsprintf().

Referenced by main().

◆ ffmpegfs_opt_proc()

static int ffmpegfs_opt_proc ( __attribute__((unused)) void *  data,
const char *  arg,
int  key,
struct fuse_args *  outargs 
)
static

FUSE option parsing function.

Parameters
[in]data- is the user data passed to the fuse_opt_parse() function
[in]arg- is the whole argument or option
[in]key- determines why the processing function was called
[in]outargs- the current output argument list
Returns
-1 on error, 0 if arg is to be discarded, 1 if arg should be kept

Definition at line 1768 of file ffmpegfs.cc.

References append_sep(), docker_client, expand_path(), FFMPEFS_VERSION, ffmpeg_format, ffmpeg_libinfo(), ffmpegfs_ops, get_audiocodec(), get_autocopy(), get_bitrate(), get_desttype(), get_hwaccel(), get_hwaccel_dec_blocked(), get_level(), get_profile(), get_recodesame(), get_sampleformat(), get_samplerate(), get_seek_time_diff(), get_segment_duration(), get_size(), get_time(), get_value(), get_videocodec(), is_mount(), FFMPEGFS_PARAMS::m_audio_codec, FFMPEGFS_PARAMS::m_audiobitrate, FFMPEGFS_PARAMS::m_audiochannels, FFMPEGFS_PARAMS::m_audiosamplerate, FFMPEGFS_PARAMS::m_autocopy, FFMPEGFS_PARAMS::m_basepath, FFMPEGFS_PARAMS::m_cache_maintenance, FFMPEGFS_PARAMS::m_cachepath, FFMPEGFS_PARAMS::m_expiry_time, FFMPEGFS_PARAMS::m_hide_extensions, FFMPEGFS_PARAMS::m_hwaccel_dec_API, FFMPEGFS_PARAMS::m_hwaccel_dec_blocked, FFMPEGFS_PARAMS::m_hwaccel_dec_device, FFMPEGFS_PARAMS::m_hwaccel_dec_device_type, FFMPEGFS_PARAMS::m_hwaccel_enc_API, FFMPEGFS_PARAMS::m_hwaccel_enc_device, FFMPEGFS_PARAMS::m_hwaccel_enc_device_type, FFMPEGFS_PARAMS::m_include_extensions, FFMPEGFS_PARAMS::m_level, FFMPEGFS_PARAMS::m_log_maxlevel, FFMPEGFS_PARAMS::m_logfile, FFMPEGFS_PARAMS::m_max_cache_size, FFMPEGFS_PARAMS::m_max_inactive_abort, FFMPEGFS_PARAMS::m_max_inactive_suspend, FFMPEGFS_PARAMS::m_min_diskspace, FFMPEGFS_PARAMS::m_min_seek_time_diff, FFMPEGFS_PARAMS::m_mountpath, FFMPEGFS_PARAMS::m_prebuffer_size, FFMPEGFS_PARAMS::m_prebuffer_time, FFMPEGFS_PARAMS::m_profile, FFMPEGFS_PARAMS::m_recodesame, FFMPEGFS_PARAMS::m_sample_fmt, FFMPEGFS_PARAMS::m_scriptfile, FFMPEGFS_PARAMS::m_scriptsource, FFMPEGFS_PARAMS::m_segment_duration, FFMPEGFS_PARAMS::m_video_codec, FFMPEGFS_PARAMS::m_videobitrate, params, sanitise_filepath(), show_caps(), and usage().

Referenced by main().

◆ get_audio_codec_text()

std::string get_audio_codec_text ( AVCodecID  audio_codec)

Convert AVCodecID enum for audio codec to human readable text.

Parameters
[in]audio_codec- AVCodecID enum value to convert.
Returns
AVCodecID as text or "INVALID" if not known.

Definition at line 1247 of file ffmpegfs.cc.

References audiocodec_map, and search_by_value().

Referenced by Format_Options::audio_codec_list(), and main().

◆ get_audiocodec()

static int get_audiocodec ( const std::string &  arg,
AVCodecID *  audio_codec 
)
static

Get the audio codec.

Parameters
[in]arg- One of the possible audio codecs.
[out]audio_codec- Upon return contains selected AVCodecID enum.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1141 of file ffmpegfs.cc.

References audiocodec_map, and list_options().

Referenced by ffmpegfs_opt_proc().

◆ get_autocopy()

static int get_autocopy ( const std::string &  arg,
AUTOCOPY autocopy 
)
static

Get autocopy option.

Parameters
[in]arg- One of the auto copy options.
[out]autocopy- Upon return contains selected AUTOCOPY enum.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1217 of file ffmpegfs.cc.

References autocopy_map, and list_options().

Referenced by ffmpegfs_opt_proc().

◆ get_autocopy_text()

std::string get_autocopy_text ( AUTOCOPY  autocopy)

Convert AUTOCOPY enum to human readable text.

Parameters
[in]autocopy- AUTOCOPY enum value to convert.
Returns
AUTOCOPY enum as text or "INVALID" if not known.

Definition at line 1267 of file ffmpegfs.cc.

References autocopy_map, and search_by_value().

Referenced by print_params().

◆ get_bitrate()

static int get_bitrate ( const std::string &  arg,
BITRATE bitrate 
)
static

Get formatted bitrate.

Supported formats:
In bit/s:  #  or #bps
In kbit/s: #M or #Mbps
In Mbit/s: #M or #Mbps
Parameters
[in]arg- Bitrate as string.
[in]bitrate- On return, contains parsed bitrate.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 718 of file ffmpegfs.cc.

References BITRATE, and reg_compare().

Referenced by ffmpegfs_opt_proc().

◆ get_codec()

static int get_codec ( const std::string &  codec,
AVCodecID *  codec_id 
)
static

Get AVCodecID for codec string.

Parameters
[in]codec- Codec string
[out]codec_id- AVCodecID of codec string
Returns
Returns 0 if found; if not found returns -1 and codec_id set to AV_CODEC_ID_NONE.

Definition at line 1520 of file ffmpegfs.cc.

References hwaccel_codec_map, and list_options().

Referenced by get_hwaccel_dec_blocked().

◆ get_desttype()

static int get_desttype ( const std::string &  arg,
FFMPEGFS_FORMAT_ARR format 
)
static

Get destination type.

Parameters
[in]arg- Format as string (MP4, OGG etc.).
[out]format- Index 0: Selected video format.
Index 1: Selected audio format.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1087 of file ffmpegfs.cc.

References split().

Referenced by ffmpegfs_opt_proc().

◆ get_hwaccel()

static int get_hwaccel ( const std::string &  arg,
HWACCELAPI hwaccel_API,
AVHWDeviceType *  hwaccel_device_type 
)
static

Get type of hardware acceleration. To keep it simple, currently all values are accepted.

Parameters
[in]arg- One of the hardware acceleration types, e.g. VAAPI.
[out]hwaccel_API- Upon return contains the hardware acceleration API.
[out]hwaccel_device_type- Upon return contains the hardware acceleration device type.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1476 of file ffmpegfs.cc.

References hwaccel_map, list_options(), HWACCEL::m_hwaccel_API, HWACCEL::m_hwaccel_device_type, and HWACCEL::m_supported.

Referenced by ffmpegfs_opt_proc().

◆ get_hwaccel_API_text()

std::string get_hwaccel_API_text ( HWACCELAPI  hwaccel_API)

Get the selected hardware acceleration as text.

Parameters
[in]hwaccel_API- Hardware acceleration buffering API.
Returns
Hardware acceleration API as string.

Definition at line 1614 of file ffmpegfs.cc.

References hwaccel_map.

Referenced by FFmpeg_Transcoder::add_stream(), FFmpeg_Transcoder::open_bestmatch_video(), FFmpeg_Transcoder::open_decoder(), and print_params().

◆ get_hwaccel_dec_blocked()

static int get_hwaccel_dec_blocked ( const std::string &  arg,
HWACCEL_BLOCKED_MAP **  hwaccel_dec_blocked 
)
static

Get list of codecs and optional profiles blocked for hardware accelerated decoding.

Parameters
[in]arg- Parameter with codec string and optional profile
[out]hwaccel_dec_blocked- Map with blocked codecs and profiles. Will be allocated if necessary.
Returns
Returns 0 on success; on error returns -1.

Definition at line 1545 of file ffmpegfs.cc.

References AV_PROFILE_UNKNOWN, and get_codec().

Referenced by ffmpegfs_opt_proc().

◆ get_level()

static int get_level ( const std::string &  arg,
PRORESLEVEL level 
)
static

Get ProRes level.

Parameters
[in]arg- One of the ProRes levels.
[out]level- Upon return contains selected PRORESLEVEL enum.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1376 of file ffmpegfs.cc.

References list_options(), and prores_level_map.

Referenced by ffmpegfs_opt_proc().

◆ get_level_text()

std::string get_level_text ( PRORESLEVEL  level)

Convert PRORESLEVEL enum to human readable text.

Parameters
[in]level- PRORESLEVEL enum value to convert.
Returns
PRORESLEVEL enum as text or "INVALID" if not known.

Definition at line 1407 of file ffmpegfs.cc.

References prores_level_map, and search_by_value().

Referenced by print_params().

◆ get_profile()

static int get_profile ( const std::string &  arg,
PROFILE profile 
)
static

Get profile option.

Parameters
[in]arg- One of the auto profile options.
[out]profile- Upon return contains selected PROFILE enum.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1329 of file ffmpegfs.cc.

References list_options(), and profile_map.

Referenced by ffmpegfs_opt_proc().

◆ get_profile_text()

std::string get_profile_text ( PROFILE  profile)

Convert PROFILE enum to human readable text.

Parameters
[in]profile- PROFILE enum value to convert.
Returns
PROFILE enum as text or "INVALID" if not known.

Definition at line 1359 of file ffmpegfs.cc.

References profile_map, and search_by_value().

Referenced by print_params().

◆ get_recodesame()

static int get_recodesame ( const std::string &  arg,
RECODESAME recode 
)
static

Get recode option.

Parameters
[in]arg- One of the recode options.
[out]recode- Upon return contains selected RECODESAME enum.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1283 of file ffmpegfs.cc.

References list_options(), and recode_map.

Referenced by ffmpegfs_opt_proc().

◆ get_recodesame_text()

std::string get_recodesame_text ( RECODESAME  recode)

Convert RECODESAME enum to human readable text.

Parameters
[in]recode- RECODESAME enum value to convert.
Returns
RECODESAME enum as text or "INVALID" if not known.

Definition at line 1313 of file ffmpegfs.cc.

References recode_map, and search_by_value().

Referenced by print_params().

◆ get_sampleformat()

static int get_sampleformat ( const std::string &  arg,
SAMPLE_FMT sample_fmt 
)
static

Get sample format.

Parameters
[in]arg- Sample format as string.
[in]sample_fmt- On return, contains parsed sample format.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 838 of file ffmpegfs.cc.

References FMT_DONTCARE, list_options(), and sample_fmt_map.

Referenced by ffmpegfs_opt_proc().

◆ get_sampleformat_text()

std::string get_sampleformat_text ( SAMPLE_FMT  sample_fmt)

Convert SAMPLE_FMT enum to human readable text.

Returns
SAMPLE_FMT enum as text or "INVALID" if not known.

Definition at line 872 of file ffmpegfs.cc.

References sample_fmt_map, and search_by_value().

Referenced by main(), print_params(), and Format_Options::sample_fmt_list().

◆ get_samplerate()

static int get_samplerate ( const std::string &  arg,
int *  samplerate 
)
static

Get formatted sample rate.

Supported formats:
In Hz:  #  or #Hz
In kHz: #K or #KHz
Parameters
[in]arg- Samplerate as string.
[in]samplerate- On return, contains parsed sample rate.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 786 of file ffmpegfs.cc.

References reg_compare().

Referenced by ffmpegfs_opt_proc().

◆ get_seek_time_diff()

static int get_seek_time_diff ( const std::string &  arg,
int64_t *  value 
)
static

Get seek time diff. Input value must be in seconds.

Parameters
[in]arg- Segment duration in seconds. Must be greater or equal 0.
[out]value- Upon return contains seek time diff in AV_TIME_BASE units.
Returns
Returns 0 if valid; if out of range returns -1.

Definition at line 1448 of file ffmpegfs.cc.

References get_value().

Referenced by ffmpegfs_opt_proc().

◆ get_segment_duration()

static int get_segment_duration ( const std::string &  arg,
int64_t *  value 
)
static

Get HLS segment duration. Input value must be in seconds.

Parameters
[in]arg- Segment duration in seconds. Must be greater than 0.
[out]value- Upon return contains segment duration in AV_TIME_BASE units.
Returns
Returns 0 if valid; if out of range returns -1.

Definition at line 1423 of file ffmpegfs.cc.

References get_value().

Referenced by ffmpegfs_opt_proc().

◆ get_size()

static int get_size ( const std::string &  arg,
size_t *  size 
)
static

Read size:
.

Supported formats:
In bytes:  # or #B @n
In KBytes: #K or #KB @n
In MBytes: #B or #MB @n
In GBytes: #G or #GB @n
In TBytes: #T or #TB
Parameters
[in]arg- Time as string.
[out]size- On return, contains parsed size.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 995 of file ffmpegfs.cc.

References reg_compare().

Referenced by ffmpegfs_opt_proc().

◆ get_time()

static int get_time ( const std::string &  arg,
time_t *  time 
)
static

Get formatted time,.

Supported formats:
Seconds: # @n
Minutes: #m @n
Hours:   #h @n
Days:    #d @n
Weeks:   #w
Parameters
[in]arg- Time as string.
[in]time- On return, contains parsed time.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 896 of file ffmpegfs.cc.

References reg_compare().

Referenced by ffmpegfs_opt_proc().

◆ get_value() [1/4]

static int get_value ( const std::string &  arg,
double *  value 
)
static

Get value from command line string. Finds whatever is after the "=" sign.

Parameters
[in]arg- Command line option.
[in]value- Upon return, contains the value after the "=" sign.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 1744 of file ffmpegfs.cc.

◆ get_value() [2/4]

static int get_value ( const std::string &  arg,
int *  value 
)
static

Get value from command line string. Finds whatever is after the "=" sign.

Parameters
[in]arg- Command line option.
[in]value- Upon return, contains the value after the "=" sign.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 1636 of file ffmpegfs.cc.

Referenced by ffmpegfs_opt_proc(), get_seek_time_diff(), and get_segment_duration().

◆ get_value() [3/4]

static int get_value ( const std::string &  arg,
MATCHVEC value 
)
static

Get comma separated values from command line string. Finds whatever is after the "=" sign.

Parameters
[in]arg- Command line option.
[in]value- Upon return, contains a set of the values after the "=" sign.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 1682 of file ffmpegfs.cc.

References split().

◆ get_value() [4/4]

static int get_value ( const std::string &  arg,
std::string *  value 
)
static

Get value from command line string. Finds whatever is after the "=" sign.

Parameters
[in]arg- Command line option.
[in]value- Upon return, contains the value after the "=" sign.
Returns
Returns 0 if valid; if invalid returns -1.

Definition at line 1659 of file ffmpegfs.cc.

◆ get_video_codec_text()

std::string get_video_codec_text ( AVCodecID  video_codec)

Convert AVCodecID enum for video codec to human readable text.

Parameters
[in]video_codec- AVCodecID enum value to convert.
Returns
AVCodecID as text or "INVALID" if not known.

Definition at line 1257 of file ffmpegfs.cc.

References search_by_value(), and videocodec_map.

Referenced by main(), and Format_Options::video_codec_list().

◆ get_videocodec()

static int get_videocodec ( const std::string &  arg,
AVCodecID *  video_codec 
)
static

Get the video codec.

Parameters
[in]arg- One of the possible video codecs.
[out]video_codec- Upon return contains selected AVCodecID enum.
Returns
Returns 0 if found; if not found returns -1.

Definition at line 1179 of file ffmpegfs.cc.

References list_options(), and videocodec_map.

Referenced by ffmpegfs_opt_proc().

◆ init_logging()

static bool init_logging ( const std::string &  logfile,
const std::string &  max_level,
bool  to_stderr,
bool  to_syslog 
)
static

Inititalise logging facility.

Parameters
[in]logfile- Name of log file if file writing is selected.
[in]max_level- Maximum level to log.
[in]to_stderr- If true, log to stderr.
[in]to_syslog- If true, log to syslog.
Returns
Returns true on success; false on error.

Definition at line 2345 of file ffmpegfs.cc.

References Logging::init_logging(), LOGDEBUG, LOGERROR, LOGINFO, LOGTRACE, and LOGWARN.

Referenced by main().

◆ list_options()

template<typename T >
static void list_options ( const char *  info,
const T &  map 
)
static

Iterate through all elements in map print all keys.

Parameters
[in]info- Informative text, will be printed before the list. May be nullptr.
[in]map- Map to go through.

Definition at line 683 of file ffmpegfs.cc.

Referenced by get_audiocodec(), get_autocopy(), get_codec(), get_hwaccel(), get_level(), get_profile(), get_recodesame(), get_sampleformat(), and get_videocodec().

◆ main()

int main ( int  argc,
char *  argv[] 
)

◆ print_params()

static void print_params ( )
static

Print currently selected parameters.

Definition at line 2071 of file ffmpegfs.cc.

References ffmpeg_format, FMT_DONTCARE, format_bitrate(), format_duration(), format_number(), format_samplerate(), format_size(), format_time(), get_autocopy_text(), get_codec_name(), get_hwaccel_API_text(), get_level_text(), get_profile_text(), get_recodesame_text(), get_sampleformat_text(), implode(), FFMPEGFS_PARAMS::m_audiobitrate, FFMPEGFS_PARAMS::m_audiochannels, FFMPEGFS_PARAMS::m_audiosamplerate, FFMPEGFS_PARAMS::m_autocopy, FFMPEGFS_PARAMS::m_basepath, FFMPEGFS_PARAMS::m_cache_maintenance, FFMPEGFS_PARAMS::m_clear_cache, FFMPEGFS_PARAMS::m_decoding_errors, FFMPEGFS_PARAMS::m_deinterlace, FFMPEGFS_PARAMS::m_disable_cache, FFMPEGFS_PARAMS::m_enablescript, FFMPEGFS_PARAMS::m_expiry_time, FFMPEGFS_PARAMS::m_hide_extensions, FFMPEGFS_PARAMS::m_hwaccel_dec_API, FFMPEGFS_PARAMS::m_hwaccel_dec_device, FFMPEGFS_PARAMS::m_hwaccel_dec_device_type, FFMPEGFS_PARAMS::m_hwaccel_enc_API, FFMPEGFS_PARAMS::m_hwaccel_enc_device, FFMPEGFS_PARAMS::m_hwaccel_enc_device_type, FFMPEGFS_PARAMS::m_include_extensions, FFMPEGFS_PARAMS::m_level, FFMPEGFS_PARAMS::m_log_maxlevel, FFMPEGFS_PARAMS::m_log_stderr, FFMPEGFS_PARAMS::m_log_syslog, FFMPEGFS_PARAMS::m_logfile, FFMPEGFS_PARAMS::m_max_cache_size, FFMPEGFS_PARAMS::m_max_inactive_abort, FFMPEGFS_PARAMS::m_max_inactive_suspend, FFMPEGFS_PARAMS::m_max_threads, FFMPEGFS_PARAMS::m_min_diskspace, FFMPEGFS_PARAMS::m_min_dvd_chapter_duration, FFMPEGFS_PARAMS::m_min_seek_time_diff, FFMPEGFS_PARAMS::m_mountpath, FFMPEGFS_PARAMS::m_no_subtitles, FFMPEGFS_PARAMS::m_noalbumarts, FFMPEGFS_PARAMS::m_oldnamescheme, FFMPEGFS_PARAMS::m_prebuffer_size, FFMPEGFS_PARAMS::m_prebuffer_time, FFMPEGFS_PARAMS::m_profile, FFMPEGFS_PARAMS::m_recodesame, FFMPEGFS_PARAMS::m_sample_fmt, FFMPEGFS_PARAMS::m_scriptfile, FFMPEGFS_PARAMS::m_scriptsource, FFMPEGFS_PARAMS::m_segment_duration, FFMPEGFS_PARAMS::m_videobitrate, FFMPEGFS_PARAMS::m_videoheight, FFMPEGFS_PARAMS::m_videowidth, FFMPEGFS_PARAMS::m_win_smb_fix, params, FFMPEGFS_PARAMS::smart_transcode(), Logging::trace(), transcoder_cache_path(), and value_or_none().

Referenced by main().

◆ set_defaults()

static bool set_defaults ( )
static

Set default values.

Returns
Returns true if options are OK, false if option combination is invalid.

Definition at line 2021 of file ffmpegfs.cc.

References ffmpeg_format, FFMPEGFS_PARAMS::m_level, NONE, params, and PRORES_HQ.

Referenced by main().

◆ usage()

static void usage ( )
static

Print program usage info.

Definition at line 666 of file ffmpegfs.cc.

Referenced by ffmpegfs_opt_proc().

◆ value_or_none()

const char * value_or_none ( const char *  value)

Return a printable parameter value.

Converts nullable C strings used by optional command-line parameters into a stable text representation for diagnostic output.

Parameters
[in]valueString value to print, or nullptr if the value is unset.
Returns
value if it is not nullptr, otherwise the literal string "NONE".

Definition at line 2063 of file ffmpegfs.cc.

Referenced by print_params().

Variable Documentation

◆ audiocodec_map

const AUDIOCODEC_MAP audiocodec_map
static
Initial value:
{
{ "AAC", AV_CODEC_ID_AAC },
{ "AC3", AV_CODEC_ID_AC3 },
{ "MP3", AV_CODEC_ID_MP3 },
{ "OPUS", AV_CODEC_ID_OPUS },
{ "VORBIS", AV_CODEC_ID_VORBIS },
{ "DTS", AV_CODEC_ID_DTS },
{ "PCM16", AV_CODEC_ID_PCM_S16LE },
{ "PCM24", AV_CODEC_ID_PCM_S24LE },
{ "PCM32", AV_CODEC_ID_PCM_S32LE },
}

List of audio codecs.

Definition at line 460 of file ffmpegfs.cc.

Referenced by get_audio_codec_text(), and get_audiocodec().

◆ autocopy_map

const AUTOCOPY_MAP autocopy_map
static
Initial value:
{
{ "OFF", AUTOCOPY::OFF },
{ "MATCH", AUTOCOPY::MATCH },
{ "MATCHLIMIT", AUTOCOPY::MATCHLIMIT },
{ "STRICT", AUTOCOPY::STRICT },
{ "STRICTLIMIT", AUTOCOPY::STRICTLIMIT },
}
@ STRICT
Copy stream if codec matches desired target, transcode otherwise.
@ MATCH
Copy stream if target supports codec.
@ MATCHLIMIT
Same as MATCH, only copy if target not larger transcode otherwise.
@ OFF
Never copy streams, transcode always.
@ STRICTLIMIT
Same as STRICT, only copy if target not larger, transcode otherwise.

List of AUTOCOPY options

Definition at line 492 of file ffmpegfs.cc.

Referenced by get_autocopy(), and get_autocopy_text().

◆ ffmpeg_format

FFMPEGFS_FORMAT_ARR ffmpeg_format

◆ ffmpegfs_opts

struct fuse_opt ffmpegfs_opts[]
static

FUSE option descriptions

Need to ignore annoying warnings caused by fuse.h

Definition at line 307 of file ffmpegfs.cc.

Referenced by main().

◆ hwaccel_codec_map

const CODEC_MAP hwaccel_codec_map
static
Initial value:
{
{ "H263", AV_CODEC_ID_H263 },
{ "H264", AV_CODEC_ID_H264 },
{ "HEVC", AV_CODEC_ID_HEVC },
{ "MPEG2", AV_CODEC_ID_MPEG2VIDEO },
{ "MPEG4", AV_CODEC_ID_MPEG4 },
{ "VC1", AV_CODEC_ID_VC1 },
{ "VP8", AV_CODEC_ID_VP8 },
{ "VP9", AV_CODEC_ID_VP9 },
{ "WMV3", AV_CODEC_ID_WMV3 },
}

List of AUTOCOPY options

Definition at line 602 of file ffmpegfs.cc.

Referenced by get_codec().

◆ hwaccel_map

HWACCEL_MAP hwaccel_map
static

List if hardware acceleration options. See https://trac.ffmpeg.org/wiki/HWAccelIntro

AV_HWDEVICE_TYPE_NONE will be set to the appropriate device type in build_device_type_list() by asking the FFmpeg API for the proper type.

Definition at line 555 of file ffmpegfs.cc.

Referenced by build_device_type_list(), get_hwaccel(), and get_hwaccel_API_text().

◆ params

FFmpegfs command line parameters.

Definition at line 81 of file ffmpegfs.cc.

Referenced by FFmpeg_Transcoder::add_stream(), Format_Options::audio_codec(), Format_Options::audio_codec_list(), FFmpeg_Transcoder::audio_size(), Cache_Entry::Cache_Entry(), FFmpeg_Transcoder::calculate_predicted_filesize(), FFmpeg_Transcoder::can_copy_stream(), check_hwaccel_dec_blocked(), Cache_Entry::clear(), create_dvd_virtualfile(), FFmpeg_Transcoder::decode_frame(), Cache_Entry::decode_timeout(), FFmpeg_Transcoder::encode_finish(), Cache_Entry::expired(), FFmpeg_Transcoder::FFmpeg_Transcoder(), ffmpegfs_getattr(), ffmpegfs_init(), ffmpegfs_opt_proc(), ffmpegfs_readdir(), find_original(), FFmpeg_Transcoder::get_format(), get_format(), FFmpeg_Transcoder::get_hw_decoder_name(), FFmpeg_Transcoder::get_hw_encoder_name(), FFmpeg_Transcoder::get_next_segment(), FFmpeg_Transcoder::get_pix_formats(), VIRTUALFILE::get_segment_count(), FFmpeg_Transcoder::get_video_size(), guess_format_idx(), FFmpeg_Transcoder::hwframe_ctx_set(), Buffer::init(), insert_file(), invalidate_stale_cache_file(), Format_Options::is_audio_codec_supported(), Format_Options::is_sample_fmt_supported(), Format_Options::is_video_codec_supported(), load_path(), log_transcoding_result(), main(), Buffer::make_cachefile_name(), make_hls_fileset(), FFmpeg_Transcoder::open_albumarts(), FFmpeg_Transcoder::open_bestmatch_video(), FFmpeg_Transcoder::open_decoder(), FFmpeg_Transcoder::open_input_file(), FFmpeg_Transcoder::open_output(), FFmpeg_Transcoder::open_output_filestreams(), FFmpeg_Transcoder::open_output_frame_set(), Cache_Entry::outdated(), FFmpeg_Transcoder::prepare_codec(), FFmpeg_Transcoder::prepare_format(), prepare_script(), print_params(), FFmpeg_Transcoder::process_single_fr(), Format_Options::sample_format(), set_defaults(), FFmpeg_Transcoder::start_new_segment(), start_transcoder_thread(), Format_Options::subtitle_codec(), Cache_Entry::suspend_timeout(), transcode(), transcoder_cache_path(), transcoder_new(), transcoder_read(), transcoder_set_filesize(), Format_Options::video_codec(), Format_Options::video_codec_list(), FFmpeg_Transcoder::video_size(), virtual_name(), and Logging::Logger::~Logger().

◆ profile_map

const PROFILE_MAP profile_map
static
Initial value:
{
{ "NONE", PROFILE::DEFAULT },
{ "FF", PROFILE::MP4_FF },
{ "EDGE", PROFILE::MP4_EDGE },
{ "IE", PROFILE::MP4_IE },
{ "CHROME", PROFILE::MP4_CHROME },
{ "SAFARI", PROFILE::MP4_SAFARI },
{ "OPERA", PROFILE::MP4_OPERA },
{ "MAXTHON", PROFILE::MP4_MAXTHON },
{ "ITUNES", PROFILE::ALAC_ITUNES },
}
@ MP4_MAXTHON
Maxthon.
@ MP4_CHROME
Google Chrome.
@ MP4_OPERA
Opera.
@ MP4_EDGE
MS Edge.
@ MP4_IE
MS Internet Explorer.
@ ALAC_ITUNES
Optimised for iTunes.
@ DEFAULT
No specific profile/Don't care.
@ MP4_SAFARI
Apple Safari.
@ MP4_FF
Firefox.

List if MP4 profiles

Definition at line 504 of file ffmpegfs.cc.

Referenced by get_profile(), and get_profile_text().

◆ prores_level_map

const LEVEL_MAP prores_level_map
static
Initial value:
{
}
@ PRORES_STANDARD
Prores Level: STANDARD.
@ PRORES_PROXY
Prores Level: PROXY.
@ PRORES_HQ
Prores Level: HQ.
@ PRORES_LT
Prores Level: LT.

List if ProRes levels.

Definition at line 528 of file ffmpegfs.cc.

Referenced by get_level(), and get_level_text().

◆ recode_map

const RECODESAME_MAP recode_map
static
Initial value:
{
{ "NO", RECODESAME::NO },
{ "YES", RECODESAME::YES },
}
@ YES
Always recode to same format.
@ NO
Never recode to same format.

List if recode options.

Definition at line 540 of file ffmpegfs.cc.

Referenced by get_recodesame(), and get_recodesame_text().

◆ sample_fmt_map

const SAMPLE_FMT_MAP sample_fmt_map
static
Initial value:
{
{ "16", SAMPLE_FMT::FMT_16 },
{ "24", SAMPLE_FMT::FMT_24 },
{ "32", SAMPLE_FMT::FMT_32 },
{ "64", SAMPLE_FMT::FMT_64 },
{ "F16", SAMPLE_FMT::FMT_F16 },
{ "F24", SAMPLE_FMT::FMT_F24 },
{ "F32", SAMPLE_FMT::FMT_F32 },
{ "F64", SAMPLE_FMT::FMT_F64 },
}
@ FMT_F16
16 bit floating point
@ FMT_F32
32 bit floating point
@ FMT_F24
24 bit floating point
@ FMT_8
8 bit integer
@ FMT_32
32 bit integer
@ FMT_16
16 bit integer
@ FMT_DONTCARE
Don't care, leave to FFmpegfs to choose.
@ FMT_F64
64 bit floating point
@ FMT_24
24 bit integer
@ FMT_64
64 bit integer

List of sample formats.

Definition at line 618 of file ffmpegfs.cc.

Referenced by get_sampleformat(), and get_sampleformat_text().

◆ videocodec_map

const VIDEOCODEC_MAP videocodec_map
static
Initial value:
{
{ "MPEG1", AV_CODEC_ID_MPEG1VIDEO },
{ "MPEG2", AV_CODEC_ID_MPEG2VIDEO },
{ "H264", AV_CODEC_ID_H264 },
{ "H265", AV_CODEC_ID_H265 },
{ "VP8", AV_CODEC_ID_VP8 },
{ "VP9", AV_CODEC_ID_VP9 },
}

List of video codecs.

Definition at line 477 of file ffmpegfs.cc.

Referenced by get_video_codec_text(), and get_videocodec().