Go to the documentation of this file.
11 #include <sys/types.h>
17 #include <QCoreApplication>
19 #include <QApplication>
33 #include "libmythbase/mythversion.h"
43 #define LOC QString("MythPreviewGen: ")
44 #define LOC_WARN QString("MythPreviewGen, Warning: ")
45 #define LOC_ERR QString("MythPreviewGen, Error: ")
55 long long previewFrameNumber, std::chrono::seconds previewSeconds,
56 const QSize previewSize,
57 const QString &infile,
const QString &outfile)
61 LOG(VB_GENERAL, LOG_ERR,
"Setting priority failed." +
ENO);
63 if (!QFileInfo(infile).isReadable() && ((chanid == 0U) || !starttime.isValid()))
67 if (chanid && starttime.isValid())
72 LOG(VB_GENERAL, LOG_ERR,
73 QString(
"Cannot locate recording made on '%1' at '%2'")
80 else if (!infile.isEmpty())
82 if (!QFileInfo(infile).isReadable())
84 LOG(VB_GENERAL, LOG_ERR,
85 QString(
"Cannot read this file '%1'").arg(infile));
89 infile,
"",
"",
"",
"",
91 "", 120min, 1895,
"");
95 LOG(VB_GENERAL, LOG_ERR,
"Cannot locate recording to preview");
102 if (previewFrameNumber >= 0)
103 previewgen->SetPreviewTimeAsFrameNumber(previewFrameNumber);
105 if (previewSeconds >= 0s)
106 previewgen->SetPreviewTimeAsSeconds(previewSeconds);
108 previewgen->SetOutputSize(previewSize);
109 previewgen->SetOutputFilename(outfile);
110 bool ok = previewgen->RunReal();
111 previewgen->deleteLater();
118 int main(
int argc,
char **argv)
143 for (
long i =
UNUSED_FILENO; i < sysconf(_SC_OPEN_MAX) - 1; ++i)
146 QCoreApplication a(argc, argv);
150 QApplication a(argc, argv);
161 std::cerr <<
"--generate-preview must be accompanied by either " <<std::endl
162 <<
"\nboth --chanid and --starttime parameters, " << std::endl
163 <<
"\nor the --infile parameter." << std::endl;
172 if (signal(
SIGPIPE, SIG_IGN) == SIG_ERR)
173 LOG(VB_GENERAL, LOG_WARNING,
LOC +
"Unable to ignore SIGPIPE");
176 if (!context.Init(
false))
178 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_)
virtual bool Parse(int argc, const char *const *argv)
Loop through argv and populate arguments with values.
void SetPathname(const QString &pn)
@ GENERIC_EXIT_INVALID_CMDLINE
Command line parse error.
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)
@ GENERIC_EXIT_OK
Exited with no error.
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.
static constexpr const char * MYTH_APPNAME_MYTHPREVIEWGEN
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.
@ GENERIC_EXIT_NOT_OK
Exited with error.
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.
QDateTime toDateTime(const QString &key) const
Returns stored QVariant as a QDateTime, falling to default if not provided.
@ GENERIC_EXIT_NO_MYTHCONTEXT
No MythContext available.
static bool QueryKeyFromPathname(const QString &pathname, uint &chanid, QDateTime &recstartts)