Go to the documentation of this file.
11 #include <sys/types.h>
17 #include <QCoreApplication>
19 #include <QApplication>
34 #include "libmythbase/mythversion.h"
45 #define LOC QString("MythPreviewGen: ")
46 #define LOC_WARN QString("MythPreviewGen, Warning: ")
47 #define LOC_ERR QString("MythPreviewGen, Error: ")
67 long long previewFrameNumber, std::chrono::seconds previewSeconds,
68 const QSize previewSize,
69 const QString &infile,
const QString &outfile)
73 LOG(VB_GENERAL, LOG_ERR,
"Setting priority failed." +
ENO);
75 if (!QFileInfo(infile).isReadable() && ((chanid == 0U) || !starttime.isValid()))
79 if (chanid && starttime.isValid())
84 LOG(VB_GENERAL, LOG_ERR,
85 QString(
"Cannot locate recording made on '%1' at '%2'")
92 else if (!infile.isEmpty())
94 if (!QFileInfo(infile).isReadable())
96 LOG(VB_GENERAL, LOG_ERR,
97 QString(
"Cannot read this file '%1'").arg(infile));
101 infile,
"",
"",
"",
"",
103 "", 120min, 1895,
"");
107 LOG(VB_GENERAL, LOG_ERR,
"Cannot locate recording to preview");
114 if (previewFrameNumber >= 0)
115 previewgen->SetPreviewTimeAsFrameNumber(previewFrameNumber);
117 if (previewSeconds >= 0s)
118 previewgen->SetPreviewTimeAsSeconds(previewSeconds);
120 previewgen->SetOutputSize(previewSize);
121 previewgen->SetOutputFilename(outfile);
122 bool ok = previewgen->RunReal();
123 previewgen->deleteLater();
130 int main(
int argc,
char **argv)
152 for (
long i =
UNUSED_FILENO; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
154 QCoreApplication a(argc, argv);
158 QApplication a(argc, argv);
169 std::cerr <<
"--generate-preview must be accompanied by either " <<std::endl
170 <<
"\nboth --chanid and --starttime parameters, " << std::endl
171 <<
"\nor the --infile parameter." << std::endl;
186 if (signal(
SIGPIPE, SIG_IGN) == SIG_ERR)
187 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Unable to ignore SIGPIPE");
193 LOG(VB_GENERAL, LOG_ERR,
"Failed to init MythContext.");
#define ENO
This can be appended to the LOG args with "+".
MythCommFlagCommandLineParser cmdline
static constexpr long UNUSED_FILENO
Startup context for MythTV.
This class creates a preview image of a recording.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
@ GENERIC_EXIT_OK
Exited with no error.
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
void SetPathname(const QString &pn)
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
int preview_helper(uint chanid, QDateTime starttime, long long previewFrameNumber, std::chrono::seconds previewSeconds, const QSize previewSize, const QString &infile, const QString &outfile)
int main(int argc, char **argv)
static void PrintVersion(void)
Print application version information.
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.
@ GENERIC_EXIT_NOT_OK
Exited with error.
static QString cleanup(const QString &str)
static void Init(QObject *parent=nullptr)
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Holds information on recordings and videos.
QString toString(const QString &key) const
Returns stored QVariant as a QString, falling to default if not provided.
bool toBool(const QString &key) const
Returns stored QVariant as a boolean.
long long toLongLong(const QString &key) const
Returns stored QVariant as a long integer, falling to default if not provided.
#define setpriority(x, y, z)
QString GetPlaybackURL(bool checkMaster=false, bool forceCheckLocal=false)
Returns filename or URL to be used to play back this recording.
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.
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
static constexpr const char * MYTH_APPNAME_MYTHPREVIEWGEN
QDateTime toDateTime(const QString &key) const
Returns stored QVariant as a QDateTime, falling to default if not provided.
MythContext * gContext
This global variable contains the MythContext instance for the application.
bool Init(bool gui=true, bool promptForBackend=false, bool disableAutoDiscovery=false, bool ignoreDB=false)
static bool QueryKeyFromPathname(const QString &pathname, uint &chanid, QDateTime &recstartts)