39#pragma GCC diagnostic push
40#pragma GCC diagnostic ignored "-Wconversion"
41#pragma GCC diagnostic ignored "-Wsign-conversion"
42#include <libavcodec/avcodec.h>
43#include <libavformat/avformat.h>
44#include <libavfilter/avfilter.h>
45#pragma GCC diagnostic pop
56#include "ffmpegfshelp.h"
58#include <sys/sysinfo.h>
65#include <libbluray/bluray-version.h>
70#pragma GCC diagnostic ignored "-Wimplicit-int-conversion"
76FFMPEGFS_PARAMS::FFMPEGFS_PARAMS()
80 , m_audio_codec(AV_CODEC_ID_NONE)
81 , m_video_codec(AV_CODEC_ID_NONE)
90 , m_audiobitrate(128*1024)
91 , m_audiosamplerate(44100)
96 , m_videobitrate(2*1024*1024)
100 , m_segment_duration(10 * AV_TIME_BASE)
101 , m_min_seek_time_diff(30 * AV_TIME_BASE)
104 , m_hwaccel_enc_device_type(AV_HWDEVICE_TYPE_NONE)
106 , m_hwaccel_dec_device_type(AV_HWDEVICE_TYPE_NONE)
107 , m_hwaccel_dec_blocked(nullptr)
116 , m_scriptfile(
"index.php")
117 , m_scriptsource(
"scripts/videotag.php")
120 , m_log_maxlevel(
"INFO")
125 , m_expiry_time((60*60*24 ) * 7)
126 , m_max_inactive_suspend(15)
127 , m_max_inactive_abort(30)
128 , m_prebuffer_time(0)
129 , m_prebuffer_size(100 * 1024)
130 , m_max_cache_size(0)
134 , m_cache_maintenance((60*60))
138 , m_decoding_errors(0)
139 , m_min_dvd_chapter_duration(1)
141 , m_include_extensions(new (std::nothrow)
MATCHVEC)
142 , m_hide_extensions(new (std::nothrow)
MATCHVEC)
152FFMPEGFS_PARAMS::~FFMPEGFS_PARAMS()
162 m_mountpath = other.m_mountpath;
164 m_audio_codec = other.m_audio_codec;
165 m_video_codec = other.m_video_codec;
167 m_autocopy = other.m_autocopy;
168 m_recodesame = other.m_recodesame;
169 m_profile = other.m_profile;
170 m_level = other.m_level;
172 m_audiobitrate = other.m_audiobitrate;
173 m_audiosamplerate = other.m_audiosamplerate;
174 m_audiochannels = other.m_audiochannels;
175 m_sample_fmt = other.m_sample_fmt;
177 m_videobitrate = other.m_videobitrate;
178 m_videowidth = other.m_videowidth;
179 m_videoheight = other.m_videoheight;
180 m_deinterlace = other.m_deinterlace;
181 m_segment_duration = other.m_segment_duration;
182 m_min_seek_time_diff = other.m_min_seek_time_diff;
184 m_hwaccel_enc_API = other.m_hwaccel_enc_API;
185 m_hwaccel_enc_device_type = other.m_hwaccel_enc_device_type;
186 m_hwaccel_enc_device = other.m_hwaccel_enc_device;
187 m_hwaccel_dec_API = other.m_hwaccel_dec_API;
188 m_hwaccel_dec_device_type = other.m_hwaccel_dec_device_type;
189 m_hwaccel_dec_device = other.m_hwaccel_dec_device;
190 m_hwaccel_dec_blocked = other.m_hwaccel_dec_blocked;
192 m_no_subtitles = other.m_no_subtitles;
194 m_noalbumarts = other.m_noalbumarts;
196 m_enablescript = other.m_enablescript;
197 m_scriptfile = other.m_scriptfile;
198 m_scriptsource = other.m_scriptsource;
200 m_debug = other.m_debug;
201 m_log_maxlevel = other.m_log_maxlevel;
202 m_log_stderr = other.m_log_stderr;
203 m_log_syslog = other.m_log_syslog;
204 m_logfile = other.m_logfile;
206 m_expiry_time = other.m_expiry_time;
207 m_max_inactive_suspend = other.m_max_inactive_suspend;
208 m_max_inactive_abort = other.m_max_inactive_abort;
209 m_prebuffer_time = other.m_prebuffer_time;
210 m_prebuffer_size = other.m_prebuffer_size;
211 m_max_cache_size = other.m_max_cache_size;
212 m_min_diskspace = other.m_min_diskspace;
213 m_cachepath = other.m_cachepath;
214 m_disable_cache = other.m_disable_cache;
215 m_cache_maintenance = other.m_cache_maintenance;
216 m_prune_cache = other.m_prune_cache;
217 m_clear_cache = other.m_clear_cache;
218 m_max_threads = other.m_max_threads;
219 m_decoding_errors = other.m_decoding_errors;
220 m_min_dvd_chapter_duration = other.m_min_dvd_chapter_duration;
221 m_oldnamescheme = other.m_oldnamescheme;
222 *m_include_extensions = *other.m_include_extensions;
223 *m_hide_extensions = *other.m_hide_extensions;
224 m_win_smb_fix = other.m_win_smb_fix;
237 if (virtualfile ==
nullptr || virtualfile->m_format_idx > 1)
255 KEY_AUDIO_SAMPLERATE,
257 KEY_AUDIO_SAMPLE_FMT,
259 KEY_SEGMENT_DURATION,
260 KEY_MIN_SEEK_TIME_DIFF,
264 KEY_MAX_INACTIVE_SUSPEND_TIME,
265 KEY_MAX_INACTIVE_ABORT_TIME,
269 KEY_MIN_DISKSPACE_SIZE,
271 KEY_CACHE_MAINTENANCE,
278 KEY_HWACCEL_ENCODER_API,
279 KEY_HWACCEL_ENCODER_DEVICE,
280 KEY_HWACCEL_DECODER_API,
281 KEY_HWACCEL_DECODER_DEVICE,
282 KEY_HWACCEL_DECODER_BLOCKED,
283 KEY_INCLUDE_EXTENSIONS,
290#define FFMPEGFS_OPT(templ, param, value) { templ, offsetof(FFMPEGFS_PARAMS, param), value }
297#pragma GCC diagnostic push
298#pragma GCC diagnostic ignored "-Wnarrowing"
299#pragma GCC diagnostic ignored "-Wsign-conversion"
303 FUSE_OPT_KEY(
"--desttype=%s", KEY_DESTTYPE),
304 FUSE_OPT_KEY(
"desttype=%s", KEY_DESTTYPE),
305 FUSE_OPT_KEY(
"--audiocodec=%s", KEY_AUDIOCODEC),
306 FUSE_OPT_KEY(
"audiocodec=%s", KEY_AUDIOCODEC),
307 FUSE_OPT_KEY(
"--videocodec=%s", KEY_VIDEOCODEC),
308 FUSE_OPT_KEY(
"videocodec=%s", KEY_VIDEOCODEC),
309 FUSE_OPT_KEY(
"--profile=%s", KEY_PROFILE),
310 FUSE_OPT_KEY(
"profile=%s", KEY_PROFILE),
311 FUSE_OPT_KEY(
"--autocopy=%s", KEY_AUTOCOPY),
312 FUSE_OPT_KEY(
"autocopy=%s", KEY_AUTOCOPY),
313 FUSE_OPT_KEY(
"--recodesame=%s", KEY_RECODESAME),
314 FUSE_OPT_KEY(
"recodesame=%s", KEY_RECODESAME),
315 FUSE_OPT_KEY(
"--level=%s", KEY_LEVEL),
316 FUSE_OPT_KEY(
"level=%s", KEY_LEVEL),
319 FUSE_OPT_KEY(
"--audiobitrate=%s", KEY_AUDIO_BITRATE),
320 FUSE_OPT_KEY(
"audiobitrate=%s", KEY_AUDIO_BITRATE),
321 FUSE_OPT_KEY(
"--audiosamplerate=%s", KEY_AUDIO_SAMPLERATE),
322 FUSE_OPT_KEY(
"audiosamplerate=%s", KEY_AUDIO_SAMPLERATE),
323 FUSE_OPT_KEY(
"--audiochannels=%s", KEY_AUDIO_CHANNELS),
324 FUSE_OPT_KEY(
"audiochannels=%s", KEY_AUDIO_CHANNELS),
325 FUSE_OPT_KEY(
"--audiosamplefmt=%s", KEY_AUDIO_SAMPLE_FMT),
326 FUSE_OPT_KEY(
"audiosamplefmt=%s", KEY_AUDIO_SAMPLE_FMT),
328 FUSE_OPT_KEY(
"--videobitrate=%s", KEY_VIDEO_BITRATE),
329 FUSE_OPT_KEY(
"videobitrate=%s", KEY_VIDEO_BITRATE),
337 FUSE_OPT_KEY(
"--segment_duration=%s", KEY_SEGMENT_DURATION),
338 FUSE_OPT_KEY(
"segment_duration=%s", KEY_SEGMENT_DURATION),
339 FUSE_OPT_KEY(
"--min_seek_time_diff=%s", KEY_MIN_SEEK_TIME_DIFF),
340 FUSE_OPT_KEY(
"min_seek_time_diff=%s", KEY_MIN_SEEK_TIME_DIFF),
342 FUSE_OPT_KEY(
"--hwaccel_enc=%s", KEY_HWACCEL_ENCODER_API),
343 FUSE_OPT_KEY(
"hwaccel_enc=%s", KEY_HWACCEL_ENCODER_API),
344 FUSE_OPT_KEY(
"--hwaccel_enc_device=%s", KEY_HWACCEL_ENCODER_DEVICE),
345 FUSE_OPT_KEY(
"hwaccel_enc_device=%s", KEY_HWACCEL_ENCODER_DEVICE),
346 FUSE_OPT_KEY(
"--hwaccel_dec=%s", KEY_HWACCEL_DECODER_API),
347 FUSE_OPT_KEY(
"hwaccel_dec=%s", KEY_HWACCEL_DECODER_API),
348 FUSE_OPT_KEY(
"--hwaccel_dec_device=%s", KEY_HWACCEL_DECODER_DEVICE),
349 FUSE_OPT_KEY(
"hwaccel_dec_device=%s", KEY_HWACCEL_DECODER_DEVICE),
350 FUSE_OPT_KEY(
"--hwaccel_dec_blocked=%s", KEY_HWACCEL_DECODER_BLOCKED),
351 FUSE_OPT_KEY(
"hwaccel_dec_blocked=%s", KEY_HWACCEL_DECODER_BLOCKED),
361 FUSE_OPT_KEY(
"--scriptfile=%s", KEY_SCRIPTFILE),
362 FUSE_OPT_KEY(
"scriptfile=%s", KEY_SCRIPTFILE),
363 FUSE_OPT_KEY(
"--scriptsource=%s", KEY_SCRIPTSOURCE),
364 FUSE_OPT_KEY(
"scriptsource=%s", KEY_SCRIPTSOURCE),
367 FUSE_OPT_KEY(
"--expiry_time=%s", KEY_EXPIRY_TIME),
368 FUSE_OPT_KEY(
"expiry_time=%s", KEY_EXPIRY_TIME),
369 FUSE_OPT_KEY(
"--max_inactive_suspend=%s", KEY_MAX_INACTIVE_SUSPEND_TIME),
370 FUSE_OPT_KEY(
"max_inactive_suspend=%s", KEY_MAX_INACTIVE_SUSPEND_TIME),
371 FUSE_OPT_KEY(
"--max_inactive_abort=%s", KEY_MAX_INACTIVE_ABORT_TIME),
372 FUSE_OPT_KEY(
"max_inactive_abort=%s", KEY_MAX_INACTIVE_ABORT_TIME),
373 FUSE_OPT_KEY(
"--prebuffer_time=%s", KEY_PREBUFFER_TIME),
374 FUSE_OPT_KEY(
"prebuffer_time=%s", KEY_PREBUFFER_TIME),
375 FUSE_OPT_KEY(
"--prebuffer_size=%s", KEY_PREBUFFER_SIZE),
376 FUSE_OPT_KEY(
"prebuffer_size=%s", KEY_PREBUFFER_SIZE),
377 FUSE_OPT_KEY(
"--max_cache_size=%s", KEY_MAX_CACHE_SIZE),
378 FUSE_OPT_KEY(
"max_cache_size=%s", KEY_MAX_CACHE_SIZE),
379 FUSE_OPT_KEY(
"--min_diskspace=%s", KEY_MIN_DISKSPACE_SIZE),
380 FUSE_OPT_KEY(
"min_diskspace=%s", KEY_MIN_DISKSPACE_SIZE),
381 FUSE_OPT_KEY(
"--cachepath=%s", KEY_CACHEPATH),
382 FUSE_OPT_KEY(
"cachepath=%s", KEY_CACHEPATH),
385 FUSE_OPT_KEY(
"--cache_maintenance=%s", KEY_CACHE_MAINTENANCE),
386 FUSE_OPT_KEY(
"cache_maintenance=%s", KEY_CACHE_MAINTENANCE),
394 FFMPEGFS_OPT(
"--decoding_errors=%u", m_decoding_errors, 0),
395 FFMPEGFS_OPT(
"decoding_errors=%u", m_decoding_errors, 0),
396 FFMPEGFS_OPT(
"--min_dvd_chapter_duration=%u", m_min_dvd_chapter_duration, 0),
397 FFMPEGFS_OPT(
"min_dvd_chapter_duration=%u", m_min_dvd_chapter_duration, 0),
400 FUSE_OPT_KEY(
"--include_extensions=%s", KEY_INCLUDE_EXTENSIONS),
401 FUSE_OPT_KEY(
"include_extensions=%s", KEY_INCLUDE_EXTENSIONS),
402 FUSE_OPT_KEY(
"--hide_extensions=%u", KEY_HIDE_EXTENSIONS),
403 FUSE_OPT_KEY(
"hide_extensions=%u", KEY_HIDE_EXTENSIONS),
410 FUSE_OPT_KEY(
"--log_maxlevel=%s", KEY_LOG_MAXLEVEL),
411 FUSE_OPT_KEY(
"log_maxlevel=%s", KEY_LOG_MAXLEVEL),
416 FUSE_OPT_KEY(
"--logfile=%s", KEY_LOGFILE),
417 FUSE_OPT_KEY(
"logfile=%s", KEY_LOGFILE),
419 FUSE_OPT_KEY(
"-h", KEY_HELP),
420 FUSE_OPT_KEY(
"--help", KEY_HELP),
421 FUSE_OPT_KEY(
"-V", KEY_VERSION),
422 FUSE_OPT_KEY(
"--version", KEY_VERSION),
423 FUSE_OPT_KEY(
"-c", KEY_FFMPEG_CAPS),
424 FUSE_OPT_KEY(
"--capabilities", KEY_FFMPEG_CAPS),
425 FUSE_OPT_KEY(
"-d", KEY_KEEP_OPT),
426 FUSE_OPT_KEY(
"debug", KEY_KEEP_OPT),
429#pragma GCC diagnostic pop
432typedef std::map<const std::string, const PROFILE, comp>
PROFILE_MAP;
433typedef std::map<const std::string, const PRORESLEVEL, comp>
LEVEL_MAP;
444typedef std::map<const std::string, const AVCodecID, comp>
CODEC_MAP;
455 {
"AAC", AV_CODEC_ID_AAC },
456 {
"AC3", AV_CODEC_ID_AC3 },
457 {
"MP3", AV_CODEC_ID_MP3 },
458 {
"OPUS", AV_CODEC_ID_OPUS },
460 {
"VORBIS", AV_CODEC_ID_VORBIS },
461 {
"DTS", AV_CODEC_ID_DTS },
462 {
"PCM16", AV_CODEC_ID_PCM_S16LE },
463 {
"PCM24", AV_CODEC_ID_PCM_S24LE },
464 {
"PCM32", AV_CODEC_ID_PCM_S32LE },
472 {
"MPEG1", AV_CODEC_ID_MPEG1VIDEO },
473 {
"MPEG2", AV_CODEC_ID_MPEG2VIDEO },
474 {
"H264", AV_CODEC_ID_H264 },
475 {
"H265", AV_CODEC_ID_H265 },
476 {
"VP8", AV_CODEC_ID_VP8 },
477 {
"VP9", AV_CODEC_ID_VP9 },
546 {
"NONE", {
true, HWACCELAPI::NONE, AV_HWDEVICE_TYPE_NONE } },
559 {
"CUDA", {
false, HWACCELAPI::CUDA, AV_HWDEVICE_TYPE_NONE } },
560 {
"V4L2M2M", {
false, HWACCELAPI::V4L2M2M, AV_HWDEVICE_TYPE_NONE } },
561 {
"VDPAU", {
false, HWACCELAPI::VDPAU, AV_HWDEVICE_TYPE_NONE } },
562 {
"QSV", {
false, HWACCELAPI::QSV, AV_HWDEVICE_TYPE_NONE } },
563 {
"OPENCL", {
false, HWACCELAPI::OPENCL, AV_HWDEVICE_TYPE_NONE } },
564 #if HAVE_VULKAN_HWACCEL
565 {
"VULKAN", {
false, HWACCELAPI::VULKAN, AV_HWDEVICE_TYPE_NONE } },
569 {
"VIDEOTOOLBOX", {
false, HWACCELAPI::VIDEOTOOLBOX, AV_HWDEVICE_TYPE_NONE } },
573 {
"MEDIACODEC", {
false, HWACCELAPI::MEDIACODEC, AV_HWDEVICE_TYPE_NONE } },
579 {
"DRM", {
false, HWACCELAPI::DRM, AV_HWDEVICE_TYPE_NONE } },
582 {
"DXVA2", {
false, HWACCELAPI::DXVA2, AV_HWDEVICE_TYPE_NONE } },
583 {
"D3D11VA", {
false, HWACCELAPI::D3D11VA, AV_HWDEVICE_TYPE_NONE } },
593 {
"H263", AV_CODEC_ID_H263 },
594 {
"H264", AV_CODEC_ID_H264 },
595 {
"HEVC", AV_CODEC_ID_HEVC },
596 {
"MPEG2", AV_CODEC_ID_MPEG2VIDEO },
597 {
"MPEG4", AV_CODEC_ID_MPEG4 },
598 {
"VC1", AV_CODEC_ID_VC1 },
599 {
"VP8", AV_CODEC_ID_VP8 },
600 {
"VP9", AV_CODEC_ID_VP9 },
601 {
"WMV3", AV_CODEC_ID_WMV3 },
622static int get_samplerate(
const std::string & arg,
int * samplerate);
624static int get_time(
const std::string & arg, time_t *time);
625static int get_size(
const std::string & arg,
size_t *size);
627static int get_audiocodec(
const std::string & arg, AVCodecID *audio_codec);
628static int get_videocodec(
const std::string & arg, AVCodecID *video_codec);
635static int get_hwaccel(
const std::string & arg,
HWACCELAPI *hwaccel_API, AVHWDeviceType *hwaccel_device_type);
636static int get_codec(
const std::string & codec, AVCodecID *codec_id);
638static int get_value(
const std::string & arg,
int *value);
639static int get_value(
const std::string & arg, std::string *value);
642static int get_value(
const std::string & arg,
double *value);
644static int ffmpegfs_opt_proc(__attribute__((unused))
void* data,
const char* arg,
int key,
struct fuse_args *outargs);
649static void ffmpeg_log(
void *ptr,
int level,
const char *fmt, va_list vl);
650static bool init_logging(
const std::string &logfile,
const std::string & max_level,
bool to_stderr,
bool to_syslog);
660 help.assign(
reinterpret_cast<const char*
>(ffmpegfshelp), ffmpegfshelp_len);
661 pos = help.find(
"OPTIONS\n");
663 std::cout << help.substr(pos +
sizeof(
"OPTIONS\n"));
675 for (
typename T::const_iterator it = map.cbegin(); it != map.cend();)
677 buffer += it->first.c_str();
679 if (++it != map.cend())
687 std::fprintf(stderr,
"%s: %s\n", info, buffer.c_str());
691 std::fprintf(stderr,
"%s\n", buffer.c_str());
709 size_t pos = arg.find(
'=');
711 if (pos != std::string::npos)
713 std::string param(arg.substr(0, pos));
714 std::string data(arg.substr(pos + 1));
718 reti =
reg_compare(data,
"^([1-9][0-9]*|0)?(bps)?$", std::regex::icase);
726 *bitrate =
static_cast<BITRATE>(std::stol(data));
731 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?K(bps)?$", std::regex::icase);
739 *bitrate =
static_cast<BITRATE>(std::stof(data) * 1000);
744 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?M(bps)?$", std::regex::icase);
752 *bitrate =
static_cast<BITRATE>(std::stof(data) * 1000000);
756 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid bit rate '%s'\n", param.c_str(), data.c_str());
759 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
777 size_t pos = arg.find(
'=');
779 if (pos != std::string::npos)
781 std::string param(arg.substr(0, pos));
782 std::string data(arg.substr(pos + 1));
786 reti =
reg_compare(data,
"^([1-9][0-9]*|0)(Hz)?$", std::regex::icase);
794 *samplerate = std::stoi(data);
799 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?K(Hz)?$", std::regex::icase);
807 *samplerate =
static_cast<int>(std::stof(data) * 1000);
811 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid sample rate '%s'\n", param.c_str(), data.c_str());
815 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
829 size_t pos = arg.find(
'=');
833 if (pos != std::string::npos)
835 std::string param(arg.substr(0, pos));
836 std::string data(arg.substr(pos + 1));
842 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid sample format option: %s\n", param.c_str(), data.c_str());
850 *sample_fmt = it->second;
855 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
885static int get_time(
const std::string & arg, time_t *time)
887 size_t pos = arg.find(
'=');
889 if (pos != std::string::npos)
891 std::string param(arg.substr(0, pos));
892 std::string data(arg.substr(pos + 1));
896 reti =
reg_compare(data,
"^([1-9][0-9]*|0)?s?$", std::regex::icase);
904 *time =
static_cast<time_t
>(std::stol(data));
909 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?m$", std::regex::icase);
917 *time =
static_cast<time_t
>(std::stof(data) * 60);
922 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?h$", std::regex::icase);
930 *time =
static_cast<time_t
>(std::stof(data) * 60 * 60);
935 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?d$", std::regex::icase);
943 *time =
static_cast<time_t
>(std::stof(data) * 60 * 60 * 24);
948 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?w$", std::regex::icase);
956 *time =
static_cast<time_t
>(std::stof(data) * 60 * 60 * 24 * 7);
960 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid time format '%s'\n", param.c_str(), data.c_str());
964 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid time format\n", arg.c_str());
984static int get_size(
const std::string & arg,
size_t *size)
986 size_t pos = arg.find(
'=');
988 if (pos != std::string::npos)
990 std::string param(arg.substr(0, pos));
991 std::string data(arg.substr(pos + 1));
995 reti =
reg_compare(data,
"^([1-9][0-9]*|0)?B?$", std::regex::icase);
1003 *size =
static_cast<size_t>(std::stol(data));
1008 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?KB?$", std::regex::icase);
1016 *size =
static_cast<size_t>(std::stof(data) * 1024);
1021 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?MB?$", std::regex::icase);
1029 *size =
static_cast<size_t>(std::stof(data) * 1024 * 1024);
1034 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?GB?$", std::regex::icase);
1042 *size =
static_cast<size_t>(std::stof(data) * 1024 * 1024 * 1024);
1047 reti =
reg_compare(data,
"^[1-9][0-9]*(\\.[0-9]+)?TB?$", std::regex::icase);
1055 *size =
static_cast<size_t>(std::stof(data) * 1024 * 1024 * 1024 * 1024);
1059 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid size '%s'\n", param.c_str(), data.c_str());
1063 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid size\n", arg.c_str());
1078 size_t pos = arg.find(
'=');
1080 if (pos != std::string::npos)
1082 std::string param(arg.substr(0, pos));
1083 std::vector<std::string> results =
split(arg.substr(pos + 1),
"\\+");
1085 if (results.size() > 0 && results.size() < 3)
1088 if (!format[0].init(results[0]))
1090 std::fprintf(stderr,
"INVALID PARAMETER (%s): No codecs available for desttype: %s\n", param.c_str(), results[0].c_str());
1094 if (results.size() == 2)
1096 if (format[0].video_codec() == AV_CODEC_ID_NONE)
1098 std::fprintf(stderr,
"INVALID PARAMETER (%s): First format %s does not support video\n", param.c_str(), results[0].c_str());
1102 if (!format[1].init(results[1]))
1104 std::fprintf(stderr,
"INVALID PARAMETER (%s): No codecs available for desttype: %s\n", param.c_str(), results[1].c_str());
1108 if (format[1].video_codec() != AV_CODEC_ID_NONE)
1110 std::fprintf(stderr,
"INVALID PARAMETER (%s): Second format %s should be audio only\n", param.c_str(), results[1].c_str());
1119 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1132 *audio_codec = AV_CODEC_ID_NONE;
1134 size_t pos = arg.find(
'=');
1136 if (pos != std::string::npos)
1138 std::string param(arg.substr(0, pos));
1139 std::string data(arg.substr(pos + 1));
1145 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid videocodec option: %s\n", param.c_str(), data.c_str());
1152 *audio_codec = it->second;
1157 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1170 *video_codec = AV_CODEC_ID_NONE;
1172 size_t pos = arg.find(
'=');
1174 if (pos != std::string::npos)
1176 std::string param(arg.substr(0, pos));
1177 std::string data(arg.substr(pos + 1));
1183 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid videocodec option: %s\n", param.c_str(), data.c_str());
1190 *video_codec = it->second;
1195 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1208 size_t pos = arg.find(
'=');
1210 if (pos != std::string::npos)
1212 std::string param(arg.substr(0, pos));
1213 std::string data(arg.substr(pos + 1));
1215 AUTOCOPY_MAP::const_iterator it =
autocopy_map.find(data);
1219 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid autocopy option: %s\n", param.c_str(), data.c_str());
1226 *autocopy = it->second;
1231 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1274 size_t pos = arg.find(
'=');
1276 if (pos != std::string::npos)
1278 std::string param(arg.substr(0, pos));
1279 std::string data(arg.substr(pos + 1));
1281 RECODESAME_MAP::const_iterator it =
recode_map.find(data);
1285 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid recode option: %s\n", param.c_str(), data.c_str());
1292 *recode = it->second;
1297 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1320 size_t pos = arg.find(
'=');
1322 if (pos != std::string::npos)
1324 std::string param(arg.substr(0, pos));
1325 std::string data(arg.substr(pos + 1));
1327 PROFILE_MAP::const_iterator it =
profile_map.find(data);
1331 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid profile: %s\n", param.c_str(), data.c_str());
1338 *profile = it->second;
1343 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1367 size_t pos = arg.find(
'=');
1369 if (pos != std::string::npos)
1371 std::string param(arg.substr(0, pos));
1372 std::string data(arg.substr(pos + 1));
1378 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid level: %s\n", param.c_str(), data.c_str());
1385 *level = it->second;
1390 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1422 std::fprintf(stderr,
"INVALID PARAMETER: segment_duration %.1f is out of range. For obvious reasons this must be greater than zero.\n", duration);
1426 *value =
static_cast<int>(duration * AV_TIME_BASE);
1447 std::fprintf(stderr,
"INVALID PARAMETER: seek time %.1f is out of range. For obvious reasons this must be greater than or equal zero.\n", duration);
1451 *value =
static_cast<int>(duration * AV_TIME_BASE);
1467 size_t pos = arg.find(
'=');
1469 if (pos != std::string::npos)
1471 std::string param(arg.substr(0, pos));
1472 std::string data(arg.substr(pos + 1));
1474 HWACCEL_MAP::const_iterator it =
hwaccel_map.find(data);
1478 std::fprintf(stderr,
"INVALID PARAMETER (%s): Invalid hardware acceleration API: %s\n", param.c_str(), data.c_str());
1485 const HWACCEL & hwaccel = it->second;
1489 std::fprintf(stderr,
"INVALID PARAMETER (%s): Unsupported hardware acceleration API: %s\n", param.c_str(), data.c_str());
1498 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1509static int get_codec(
const std::string & codec, AVCodecID *codec_id)
1515 std::fprintf(stderr,
"INVALID PARAMETER: Unknown codec '%s'.\n", codec.c_str());
1519 *codec_id = AV_CODEC_ID_NONE;
1523 *codec_id = it->second;
1536 size_t pos = arg.find(
'=');
1538 if (pos != std::string::npos)
1540 std::string param(arg.substr(0, pos));
1541 std::stringstream data(arg.substr(pos + 1));
1544 if (*hwaccel_dec_blocked ==
nullptr)
1549 if (!std::getline(data, codec,
':'))
1551 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", param.c_str());
1559 std::fprintf(stderr,
"INVALID PARAMETER (%s): Unknown codec '%s'\n", param.c_str(), codec.c_str());
1563 int nProfilesFound = 0;
1564 for (std::string profile; std::getline(data, profile,
':');)
1568 (*hwaccel_dec_blocked)->insert(std::pair<AVCodecID, int>(codec_id, std::stoi(profile)));
1571 if (!nProfilesFound)
1574 (*hwaccel_dec_blocked)->insert(std::pair<AVCodecID, int>(codec_id, FF_PROFILE_UNKNOWN));
1580 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1594 if (it->first == codec_id && (it->second == profile || it->second == FF_PROFILE_UNKNOWN))
1605 HWACCEL_MAP::const_iterator it =
hwaccel_map.cbegin();
1608 if (it->second.m_hwaccel_API == hwaccel_API)
1627 size_t pos = arg.find(
'=');
1629 if (pos != std::string::npos)
1631 *value = std::stoi(arg.substr(pos + 1));
1636 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1648static int get_value(
const std::string & arg, std::string *value)
1650 size_t pos = arg.find(
'=');
1652 if (pos != std::string::npos)
1654 *value = arg.substr(pos + 1);
1659 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1673 size_t pos = arg.find(
'=');
1675 if (pos != std::string::npos)
1677 std::vector<std::string> v =
split(arg.substr(pos + 1),
",");
1679 for (
const std::string & str : v)
1681 int res = fnmatch(str.c_str(),
"", 0);
1683 if (res != 0 && res != FNM_NOMATCH)
1685 std::fprintf(stderr,
"INVALID PARAMETER (%s): Error in wildcard pattern\n", str.c_str());
1691 value->insert(value->end(), v.begin(), v.end());
1696 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1709static int get_value(
const std::string & arg, std::optional<std::string> *value)
1711 size_t pos = arg.find(
'=');
1713 if (pos != std::string::npos)
1715 *value = arg.substr(pos + 1);
1720 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1735 size_t pos = arg.find(
'=');
1737 if (pos != std::string::npos)
1739 *value = std::stof(arg.substr(pos + 1));
1744 std::fprintf(stderr,
"INVALID PARAMETER (%s): Missing argument\n", arg.c_str());
1757static int ffmpegfs_opt_proc(__attribute__((unused))
void* data,
const char* arg,
int key,
struct fuse_args *outargs)
1761 case FUSE_OPT_KEY_NONOPT:
1805 fuse_opt_add_arg(outargs,
"-ho");
1806 fuse_main(outargs->argc, outargs->argv, &
ffmpegfs_ops,
nullptr);
1811 std::printf(
"-------------------------------------------------------------------------------------------\n");
1814#ifndef __clang_version__
1815 std::printf(
"%-20s: %s (%s)\n",
"Built with",
"gcc " __VERSION__, HOST_OS);
1817 std::printf(
"%-20s: %s (%s)\n",
"Built with",
"clang " __clang_version__, HOST_OS);
1820 std::printf(
"%-20s: %s\n\n",
"configuration", CONFIGURE_ARGS);
1827 std::printf(
"%-20s: %s\n",
"Video CD Library",
"enabled");
1830 std::printf(
"%-20s: %s\n",
"DVD Library",
"enabled");
1833 std::printf(
"%-20s: %s\n",
"Blu-ray Library", BLURAY_VERSION_STRING);
1836 fuse_opt_add_arg(outargs,
"--version");
1837 fuse_main(outargs->argc, outargs->argv, &
ffmpegfs_ops,
nullptr);
1841 case KEY_FFMPEG_CAPS:
1843 std::printf(
"-------------------------------------------------------------------------------------------\n\n");
1848 std::printf(
"\nFFMpeg Capabilities\n\n");
1858 case KEY_AUDIOCODEC:
1862 case KEY_VIDEOCODEC:
1870 case KEY_RECODESAME:
1882 case KEY_AUDIO_BITRATE:
1886 case KEY_AUDIO_SAMPLERATE:
1890 case KEY_AUDIO_CHANNELS:
1894 case KEY_AUDIO_SAMPLE_FMT:
1898 case KEY_SCRIPTFILE:
1902 case KEY_SCRIPTSOURCE:
1906 case KEY_VIDEO_BITRATE:
1910 case KEY_SEGMENT_DURATION:
1914 case KEY_MIN_SEEK_TIME_DIFF:
1918 case KEY_HWACCEL_ENCODER_API:
1922 case KEY_HWACCEL_ENCODER_DEVICE:
1926 case KEY_HWACCEL_DECODER_API:
1930 case KEY_HWACCEL_DECODER_DEVICE:
1934 case KEY_HWACCEL_DECODER_BLOCKED:
1938 case KEY_EXPIRY_TIME:
1942 case KEY_MAX_INACTIVE_SUSPEND_TIME:
1946 case KEY_MAX_INACTIVE_ABORT_TIME:
1950 case KEY_PREBUFFER_TIME:
1954 case KEY_PREBUFFER_SIZE:
1958 case KEY_MAX_CACHE_SIZE:
1962 case KEY_MIN_DISKSPACE_SIZE:
1970 case KEY_CACHE_MAINTENANCE:
1974 case KEY_LOG_MAXLEVEL:
1980 std::string logfile;
1993 case KEY_INCLUDE_EXTENSIONS:
1997 case KEY_HIDE_EXTENSIONS:
2030 for (AVHWDeviceType device_type = AV_HWDEVICE_TYPE_NONE; (device_type = av_hwdevice_iterate_types(device_type)) != AV_HWDEVICE_TYPE_NONE;)
2032 HWACCEL_MAP::iterator it =
hwaccel_map.find(av_hwdevice_get_type_name(device_type));
2039 it->second.m_hwaccel_device_type = device_type;
2048 std::string cachepath;
2052 Logging::trace(
nullptr,
"********* " PACKAGE_NAME
" Options *********");
2147 Logging::trace(
nullptr,
"--------- Experimental Options ---------");
2158static void ffmpeg_log(
void *ptr,
int level,
const char *fmt, va_list vl)
2166 if (level <= AV_LOG_ERROR)
2171 else if (level <= AV_LOG_WARNING)
2183 else if (level < AV_LOG_DEBUG)
2196 ffmpegfs_level = DEBUG;
2206 static int print_prefix = 1;
2208#if (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(55, 23, 0))
2211 std::string category;
2215 AVClass* avc = *(AVClass **)ptr;
2217 switch (avc->category)
2219 case AV_CLASS_CATEGORY_NA:
2223 case AV_CLASS_CATEGORY_INPUT:
2225 category =
"INPUT ";
2228 case AV_CLASS_CATEGORY_OUTPUT:
2230 category =
"OUTPUT ";
2233 case AV_CLASS_CATEGORY_MUXER:
2235 category =
"MUXER ";
2238 case AV_CLASS_CATEGORY_DEMUXER:
2240 category =
"DEMUXER ";
2243 case AV_CLASS_CATEGORY_ENCODER:
2245 category =
"ENCODER ";
2248 case AV_CLASS_CATEGORY_DECODER:
2250 category =
"DECODER ";
2253 case AV_CLASS_CATEGORY_FILTER:
2255 category =
"FILTER ";
2258 case AV_CLASS_CATEGORY_BITSTREAM_FILTER:
2260 category =
"BITFILT ";
2263 case AV_CLASS_CATEGORY_SWSCALER:
2265 category =
"SWSCALE ";
2268 case AV_CLASS_CATEGORY_SWRESAMPLER:
2270 category =
"SWRESAM ";
2275 strsprintf(&category,
"CAT %3i ",
static_cast<int>(avc->category));
2282 av_log_default_callback(ptr, level, fmt, vl);
2283 line_size = av_log_format_line2(ptr, level, fmt, vl2,
nullptr, 0, &print_prefix);
2289 line =
static_cast<char *
>(av_malloc(
static_cast<size_t>(line_size)));
2290 if (line ==
nullptr)
2294 av_log_format_line2(ptr, level, fmt, vl2, line, line_size, &print_prefix);
2300 av_log_default_callback(ptr, level, fmt, vl);
2301 av_log_format_line(ptr, level, fmt, vl2, line,
sizeof(line), &print_prefix);
2307#if (LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(55, 23, 0))
2320static bool init_logging(
const std::string &logfile,
const std::string & max_level,
bool to_stderr,
bool to_syslog)
2322 static const std::map<const std::string, const Logging::LOGLEVEL, comp> log_level_map =
2331 std::map<const std::string, const Logging::LOGLEVEL, comp>::const_iterator it = log_level_map.find(max_level);
2333 if (it == log_level_map.cend())
2335 std::fprintf(stderr,
"Invalid logging level string: %s\n", max_level.c_str());
2353 struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
2356 if (getppid() == getpgid(0))
2359 std::printf(
"Copyright (C) 2017-2024 Norbert Schlia (nschlia@oblivion-software.de)\n"
2360 "David Collett (2006-2008) and K. Henriksson (2008-2012)\n\n");
2379 std::fprintf(stderr,
"\nError parsing command line options.\n\n");
2396 av_log_set_level(AV_LOG_INFO);
2400 av_log_set_level(AV_LOG_QUIET);
2405 std::fprintf(stderr,
"ERROR: Failed to initialise logging module.\n");
2406 std::fprintf(stderr,
"Maybe log file couldn't be opened for writing?\n\n");
2414 std::fprintf(stderr,
"INVALID PARAMETER: Invalid additional parameters for --prune_cache:\n");
2415 for (
int n = 1; n < args.argc; n++)
2417 std::fprintf(stderr,
"Invalid: '%s'\n", args.argv[n]);
2433 std::fprintf(stderr,
"INVALID PARAMETER: No valid basepath specified.\n\n");
2439 std::fprintf(stderr,
"INVALID PARAMETER: basepath must be an absolute path.\n\n");
2444 if (stat(
params.
m_basepath.c_str(), &stbuf) != 0 || !S_ISDIR(stbuf.st_mode))
2446 std::fprintf(stderr,
"INVALID PARAMETER: basepath is not a valid directory: %s\n\n",
params.
m_basepath.c_str());
2452 std::fprintf(stderr,
"INVALID PARAMETER: No valid mountpath specified.\n\n");
2458 std::fprintf(stderr,
"INVALID PARAMETER: mountpath must be an absolute path.\n\n");
2464 std::fprintf(stderr,
"INVALID PARAMETER: mountpath is not a valid directory: %s\n\n",
params.
m_mountpath.c_str());
2471 if (fmt.filetype() != FILETYPE::UNKNOWN && !fmt.is_sample_fmt_supported())
2474 std::fprintf(stderr,
"Supported formats: %s\n\n", fmt.sample_fmt_list().c_str());
2482 if (fmt.filetype() != FILETYPE::UNKNOWN)
2487 std::fprintf(stderr,
"Supported formats: %s\n\n", fmt.audio_codec_list().c_str());
2494 std::fprintf(stderr,
"Supported formats: %s\n\n", fmt.video_codec_list().c_str());
2522 ret = fuse_main(args.argc, args.argv, &
ffmpegfs_ops,
nullptr);
2524 fuse_opt_free_args(&args);
@ NONE
No result code available.
static void log_with_level(LOGLEVEL loglevel, const char *filename, const std::string &message)
Write log entry.
static bool init_logging(const std::string &logfile, LOGLEVEL max_level, bool to_stderr, bool to_syslog)
Initialise the logging facility.
static void trace(const T filename, const std::string &format_string, Args &&...args)
Write trace level log entry.
static bool show(LOGLEVEL loglevel)
Check if log entry should be displayed at the current log level.
LOGLEVEL
Logging level types enum.
const char * get_codec_name(AVCodecID codec_id, bool long_name)
Safe way to get the codec name. Function never fails, will return "unknown" on error.
std::string format_duration(int64_t value, uint32_t fracs)
Format a time in format HH:MM:SS.fract.
int is_mount(const std::string &path)
Check if path is a mount.
std::string sanitise_filepath(std::string *filepath)
Sanitise file name. Calls realpath() to remove duplicate // or resolve ../.. etc. Changes the path in...
int reg_compare(const std::string &value, const std::string &pattern, std::regex::flag_type flag)
Compare value with pattern.
int show_caps(int device_only)
Lists all supported codecs and devices.
std::string format_time(time_t value)
Format a time in format "w d m s".
std::string format_samplerate(int value)
Format a samplerate.
std::string format_bitrate(BITRATE value)
Format a bit rate.
bool detect_docker()
Detect if we are running under Docker.
static std::string ffmpeg_libinfo(bool lib_exists, __attribute__((unused)) unsigned int version, __attribute__((unused)) const char *cfg, int version_minor, int version_major, int version_micro, const char *libname)
Get FFmpeg library info.
const std::string & append_sep(std::string *path)
Add / to the path if required.
const std::string & expand_path(std::string *tgt, const std::string &src)
Expand path, e.g., expand ~/ to home directory.
std::string format_size(uint64_t value)
Format size.
std::vector< std::string > split(const std::string &input, const std::string ®ex)
Split string into an array delimited by a regular expression.
std::string format_number(int64_t value)
Format numeric value.
@ PRORES_STANDARD
Prores Level: STANDARD.
@ PRORES_PROXY
Prores Level: PROXY.
@ PRORES_HQ
Prores Level: HQ.
@ PRORES_LT
Prores Level: LT.
std::array< FFmpegfs_Format, 2 > FFMPEGFS_FORMAT_ARR
Array of FFmpegfs formats. There are two, for audio and video.
@ YES
Always recode to same format.
@ NO
Never recode to same format.
#define BITRATE
For FFmpeg bit rate is an int.
std::string implode(const T &s)
Combine array of strings into comma separated list.
@ MP4_CHROME
Google Chrome.
@ MP4_IE
MS Internet Explorer.
@ DEFAULT
No specific profile/Don't care.
@ MP4_SAFARI
Apple Safari.
#define FFMPEFS_VERSION
FFmpegfs version number.
std::map< conststd::string, constT, comp >::const_iterator search_by_value(const std::map< const std::string, const T, comp > &mapOfWords, T value)
Iterate through all elements in map and search for the passed element.
@ 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.
const std::string & strsprintf(std::string *str, const std::string &format, Args ... args)
Format a std::string sprintf-like.
@ VIDEO
FFmpegfs_Format info, 0: video file.
@ AUDIO
FFmpegfs_Format info, 1: audio file.
std::vector< std::string > MATCHVEC
Array of strings, sorted/search case insensitive.
@ FMT_F16
16 bit floating point
@ FMT_F32
32 bit floating point
@ FMT_F24
24 bit floating point
@ FMT_DONTCARE
Don't care, leave to FFmpegfs to choose.
@ FMT_F64
64 bit floating point
static const AUDIOCODEC_MAP audiocodec_map
List of audio codecs.
static int get_value(const std::string &arg, int *value)
Get value from command line string. Finds whatever is after the "=" sign.
int main(int argc, char *argv[])
Main program entry point.
static const VIDEOCODEC_MAP videocodec_map
List of video codecs.
static int get_size(const std::string &arg, size_t *size)
Read size: .
std::map< const std::string, HWACCEL, comp > HWACCEL_MAP
Map command line option to HWACCEL struct.
std::string get_recodesame_text(RECODESAME recode)
Convert RECODESAME enum to human readable text.
std::map< const std::string, const AVCodecID, comp > VIDEOCODEC_MAP
Map command line option to video AVCodecID.
static HWACCEL_MAP hwaccel_map
#define FFMPEGFS_OPT(templ, param, value)
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 const SAMPLE_FMT_MAP sample_fmt_map
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_seek_time_diff(const std::string &arg, int64_t *value)
Get seek time diff. Input value must be in seconds.
static int get_audiocodec(const std::string &arg, AVCodecID *audio_codec)
Get the audio codec.
FFMPEGFS_PARAMS params
FFmpegfs command line parameters.
static bool init_logging(const std::string &logfile, const std::string &max_level, bool to_stderr, bool to_syslog)
Inititalise logging facility.
std::map< const std::string, const AUTOCOPY, comp > AUTOCOPY_MAP
Map command line option to AUTOCOPY enum.
std::map< const std::string, const AVCodecID, comp > CODEC_MAP
Map command line option to AVCodecID.
static int get_bitrate(const std::string &arg, BITRATE *bitrate)
Get formatted bitrate.
std::map< const std::string, const SAMPLE_FMT, comp > SAMPLE_FMT_MAP
Map command line option to SAMPLE_FMT.
std::map< const std::string, const AVCodecID, comp > AUDIOCODEC_MAP
Map command line option to audio AVCodecID.
static void usage()
Print program usage info.
static const LEVEL_MAP prores_level_map
static const AUTOCOPY_MAP autocopy_map
std::map< const std::string, const PRORESLEVEL, comp > LEVEL_MAP
Map command line option to LEVEL enum.
static int get_videocodec(const std::string &arg, AVCodecID *video_codec)
Get the video codec.
static struct fuse_opt ffmpegfs_opts[]
static const PROFILE_MAP profile_map
static int get_profile(const std::string &arg, PROFILE *profile)
Get profile option.
static int get_desttype(const std::string &arg, FFMPEGFS_FORMAT_ARR &format)
Get destination type.
static int get_level(const std::string &arg, PRORESLEVEL *level)
Get ProRes level.
std::string get_profile_text(PROFILE profile)
Convert PROFILE enum to human readable text.
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 void print_params()
Print currently selected parameters.
static const CODEC_MAP hwaccel_codec_map
std::string get_level_text(PRORESLEVEL level)
Convert PRORESLEVEL enum to human readable text.
std::string get_sampleformat_text(SAMPLE_FMT sample_fmt)
Convert SAMPLE_FMT enum to human readable text.
static int get_sampleformat(const std::string &arg, SAMPLE_FMT *sample_fmt)
Get sample format.
static int ffmpegfs_opt_proc(__attribute__((unused)) void *data, const char *arg, int key, struct fuse_args *outargs)
FUSE option parsing function.
static int get_segment_duration(const std::string &arg, int64_t *value)
Get HLS segment duration. Input value must be in seconds.
static void build_device_type_list()
Build list of available device types. Builds a list of device types supported by the current FFmpeg l...
static int get_time(const std::string &arg, time_t *time)
Get formatted time,.
std::string get_video_codec_text(AVCodecID video_codec)
Convert AVCodecID enum for video codec to human readable text.
std::map< const std::string, const PROFILE, comp > PROFILE_MAP
Map command line option to PROFILE enum.
static int get_recodesame(const std::string &arg, RECODESAME *recode)
Get recode option.
static void list_options(const char *info, const T &map)
Iterate through all elements in map print all keys.
static const RECODESAME_MAP recode_map
FFMPEGFS_FORMAT_ARR ffmpeg_format
Two FFmpegfs_Format infos, 0: video file, 1: audio file.
std::map< const std::string, const RECODESAME, comp > RECODESAME_MAP
Map command line option to RECODESAME enum.
static int get_samplerate(const std::string &arg, int *samplerate)
Get formatted sample rate.
std::string get_autocopy_text(AUTOCOPY autocopy)
Convert AUTOCOPY enum to human readable text.
std::string get_audio_codec_text(AVCodecID audio_codec)
Convert AVCodecID enum for audio codec to human readable text.
static int get_codec(const std::string &codec, AVCodecID *codec_id)
Get AVCodecID for codec string.
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.
struct HWACCEL HWACCEL
Hardware acceleration device and type.
static int get_autocopy(const std::string &arg, AUTOCOPY *autocopy)
Get autocopy option.
static bool set_defaults()
Set default values.
Main include for FFmpegfs project.
fuse_operations ffmpegfs_ops
Fuse operations struct.
void transcoder_cache_path(std::string *path)
Get transcoder cache path.
bool docker_client
True if running inside a Docker container.
HWACCELAPI
Hardware acceleration types.
bool transcoder_init()
Initialise transcoder, create cache.
std::multimap< AVCodecID, int > HWACCEL_BLOCKED_MAP
Map command line option to AVCodecID.
bool transcoder_cache_clear()
Clear transcoder cache.
bool transcoder_cache_maintenance()
Run cache maintenance.
void init_fuse_ops()
Initialise FUSE operation structure.
VIRTUALFILE const * LPCVIRTUALFILE
Pointer to const version of VIRTUALFILE.
Provide various log facilities to stderr, disk or syslog.
constexpr Logging::LOGLEVEL LOGDEBUG
Shorthand for log level DEBUG.
constexpr Logging::LOGLEVEL LOGTRACE
Shorthand for log level TRACE.
constexpr Logging::LOGLEVEL LOGWARN
Shorthand for log level WARNING.
constexpr Logging::LOGLEVEL LOGERROR
Shorthand for log level ERROR.
constexpr Logging::LOGLEVEL LOGINFO
Shorthand for log level INFO.
Global program parameters.
std::string m_scriptsource
Source script.
std::string m_hwaccel_enc_device
Encoder device. May be AUTO to auto detect or empty.
int m_log_stderr
Log output to standard error.
time_t m_cache_maintenance
Prune timer interval.
bool smart_transcode() const
Check for smart transcode mode.
AVHWDeviceType m_hwaccel_dec_device_type
Enable hardware acceleration buffering for decoder.
time_t m_max_inactive_suspend
Time (seconds) that must elapse without access until transcoding is suspended.
int m_deinterlace
1: deinterlace video, 0: no deinterlace
int m_decoding_errors
Break transcoding on decoding error.
int m_oldnamescheme
Use old output name scheme, can create duplicate filenames.
AVHWDeviceType m_hwaccel_enc_device_type
Enable hardware acceleration buffering for encoder.
time_t m_expiry_time
Time (seconds) after which an cache entry is deleted.
int m_no_subtitles
0: allow subtitles, 1: do no transcode subtitles
FFMPEGFS_PARAMS & operator=(const FFMPEGFS_PARAMS &other) noexcept
Make copy from other FFMPEGFS_PARAMS object.
int m_clear_cache
Clear cache on start up.
std::string m_hwaccel_dec_device
Decoder device. May be AUTO to auto detect or empty.
const FFmpegfs_Format * current_format(LPCVIRTUALFILE virtualfile) const
Get FFmpegfs_Format for a virtual file.
int m_audiochannels
Max. number of audio channels.
int64_t m_min_seek_time_diff
Minimum time diff from current to next requested segment to perform a seek, in AV_TIME_BASE fractiona...
int m_videowidth
Output video width.
BITRATE m_videobitrate
Output video bit rate (bits per second)
HWACCELAPI m_hwaccel_dec_API
Decoder API.
size_t m_prebuffer_size
Number of bytes that will be decoded before the output can be accessed.
int m_videoheight
Output video height.
time_t m_prebuffer_time
Playing time that will be decoded before the output can be accessed.
int64_t m_segment_duration
Duration of one HLS segment file, in AV_TIME_BASE fractional seconds.
BITRATE m_audiobitrate
Output audio bit rate (bits per second)
std::string m_cachepath
Disk cache path, defaults to $XDG_CACHE_HOME.
int m_prune_cache
Prune cache immediately.
RECODESAME m_recodesame
Recode to same format options.
SAMPLE_FMT m_sample_fmt
Sample format.
PROFILE m_profile
Target profile: Firefox, MS Edge/IE or other.
int m_audiosamplerate
Output audio sample rate (in Hz)
size_t m_max_cache_size
Max. cache size in MB. When exceeded, oldest entries will be pruned.
AVCodecID m_video_codec
Either AV_CODEC_ID_NONE for default, or a user selected codec.
unsigned int m_max_threads
Max. number of recoder threads.
int m_disable_cache
Disable cache.
std::unique_ptr< MATCHVEC > m_hide_extensions
Set of extensions to block/hide. Must be a pointer as the fuse API cannot handle advanced c++ objects...
time_t m_max_inactive_abort
Time (seconds) that must elapse without access until transcoding is aborted.
int m_min_dvd_chapter_duration
Min. DVD chapter duration. Shorter chapters will be ignored.
std::string m_logfile
Output filename if logging to file.
std::string m_log_maxlevel
Max. log level.
std::string m_mountpath
Mount path: Files from m_mountpath will be mapped to this directory.
AVCodecID m_audio_codec
Either AV_CODEC_ID_NONE for default, or a user selected codec.
PRORESLEVEL m_level
Level, currently proxy/hq/lt/HQ (ProRes only)
size_t m_min_diskspace
Min. diskspace required for cache.
int m_noalbumarts
Skip album arts.
int m_enablescript
Enable virtual script.
std::unique_ptr< MATCHVEC > m_include_extensions
Set of extensions to include. If empty, include all. Must be a pointer as the fuse API cannot handle ...
HWACCEL_BLOCKED_MAP * m_hwaccel_dec_blocked
List of blocked decoders and optional profiles.
int m_debug
Debug mode (stay in foreground.
std::string m_scriptfile
Script name.
int m_win_smb_fix
Experimental Windows fix for access to EOF at file open.
int m_log_syslog
Log output to system log.
std::string m_basepath
Base path: Files from this directory (including all sub directories) will be mapped to m_mountpath.
HWACCELAPI m_hwaccel_enc_API
Encoder API.
AUTOCOPY m_autocopy
Copy streams if codec matches.
Hardware acceleration device and type.
HWACCELAPI m_hwaccel_API
Acceleration API, e.g VAAPI, MMAL or OMX.
AVHWDeviceType m_hwaccel_device_type
Hardware buffering type, NONE if not used.
bool m_supported
true if API supported, false if not