15#if QT_VERSION >= QT_VERSION_CHECK(6,5,0)
16#include <QtSystemDetection>
19#include <QCoreApplication>
21#include <QApplication>
30#include "libmythbase/mythconfig.h"
36#include "libmythbase/mythversion.h"
46#define LOC QString("MythPreviewGen: ")
56 long long previewFrameNumber, std::chrono::seconds previewSeconds,
57 const QSize previewSize,
58 const QString &infile,
const QString &outfile)
60 if (!QFileInfo(infile).isReadable() && ((chanid == 0U) || !starttime.isValid()))
64 if (chanid && starttime.isValid())
69 LOG(VB_GENERAL, LOG_ERR,
70 QString(
"Cannot locate recording made on '%1' at '%2'")
77 else if (!infile.isEmpty())
79 if (!QFileInfo(infile).isReadable())
81 LOG(VB_GENERAL, LOG_ERR,
82 QString(
"Cannot read this file '%1'").arg(infile));
86 infile,
"",
"",
"",
"",
88 "", 120min, 1895,
"");
92 LOG(VB_GENERAL, LOG_ERR,
"Cannot locate recording to preview");
99 if (previewFrameNumber >= 0)
100 previewgen->SetPreviewTimeAsFrameNumber(previewFrameNumber);
102 if (previewSeconds >= 0s)
103 previewgen->SetPreviewTimeAsSeconds(previewSeconds);
105 previewgen->SetOutputSize(previewSize);
106 previewgen->SetOutputFilename(outfile);
107 bool ok = previewgen->RunReal();
108 previewgen->deleteLater();
140 for (
long i =
UNUSED_FILENO; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
143 QCoreApplication a(argc, argv);
147 QApplication a(argc, argv);
158 std::cerr <<
"--generate-preview must be accompanied by either\n"
159 <<
"\nboth --chanid and --starttime parameters,\n"
160 <<
"\nor the --infile parameter.\n";
169 if (signal(
SIGPIPE, SIG_IGN) == SIG_ERR)
170 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Unable to ignore SIGPIPE");
173 if (!context.Init(
false))
175 LOG(VB_GENERAL, LOG_ERR,
"Failed to init MythContext.");
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
QSize toSize(const QString &key) const
Returns stored QVariant as a QSize value, falling to default if not provided.
int ConfigureLogging(const QString &mask="general", bool progress=false)
Read in logging options and initialize the logging interface.
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
long long toLongLong(const QString &key) const
Returns stored QVariant as a long integer, falling to default if not provided.
static void PrintVersion(void)
Print application version information.
QDateTime toDateTime(const QString &key) const
Returns stored QVariant as a QDateTime, falling to default if not provided.
uint toUInt(const QString &key) const
Returns stored QVariant as an unsigned integer, falling to default if not provided.
void PrintHelp(void) const
Print command line option help.
Startup context for MythTV.
This class creates a preview image of a recording.
Holds information on recordings and videos.
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
static bool QueryKeyFromPathname(const QString &pathname, uint &chanid, QDateTime &recstartts)
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
void SetPathname(const QString &pn)
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
@ GENERIC_EXIT_OK
Exited with no error.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
@ GENERIC_EXIT_NOT_OK
Exited with error.
static constexpr const char * MYTH_APPNAME_MYTHPREVIEWGEN
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
int main(int argc, char **argv)
int preview_helper(uint chanid, QDateTime starttime, long long previewFrameNumber, std::chrono::seconds previewSeconds, const QSize previewSize, const QString &infile, const QString &outfile)
static constexpr long UNUSED_FILENO
MythCommFlagCommandLineParser cmdline