Ticket #9409: transcode.diff

File transcode.diff, 3.8 KB (added by Doug Haber <doug@…>, 10 years ago)
  • mythtv/programs/mythtranscode/main.cpp

    diff --git a/mythtv/programs/mythtranscode/main.cpp b/mythtv/programs/mythtranscode/main.cpp
    index 305271d..5dcbd89 100644
    a b static void usage(char *progname) 
    6666    cerr << "\t                or -ro: Pass a comma-separated list of\n";
    6767    cerr << "\t                        recordingprofile options to override\n";
    6868    cerr << "\t                        values in the database.\n";
     69    cerr << "\t--queue          or -q: Insert transcode job into the JobQueue rather than\n";
     70    cerr << "\t                        running transcoding in the foreground\n";
    6971    cerr << "\t--verbose level  or -v: Use '-v help' for level info\n";
    7072    cerr << "\t--help           or -h: Prints this help statement.\n";
    7173}
    static void UpdateJobQueue(float percent_done) 
    123125                               .arg(percent_done, 0, 'f', 1));
    124126}
    125127
     128static int QueueTranscodeJob(ProgramInfo *pginfo)
     129{
     130    bool result = JobQueue::QueueJob(
     131        JOB_TRANSCODE, pginfo->GetChanID(), pginfo->GetRecordingStartTime(),
     132        "", "Job Queued By MythTranscoder");
     133
     134    if (result)
     135    {
     136        VERBOSE(VB_IMPORTANT,
     137          QString("Queued transcode job for chanid %1 @ %2")
     138                   .arg(pginfo->GetChanID()).arg(pginfo->GetRecordingStartTime().toString("yyyyMMddhhmmss")));
     139
     140        return TRANSCODE_EXIT_OK;
     141    }
     142    QString tmp = QString("Error queueing job for chanid %1 @ %2")
     143        .arg(pginfo->GetChanID()).arg(pginfo->GetRecordingStartTime().toString("yyyyMMddhhmmss"));
     144    cerr << tmp.toLocal8Bit().constData() << endl;
     145    return TRANSCODE_EXIT_DB_ERROR;
     146}
     147
    126148static int CheckJobQueue()
    127149{
    128150    if (JobQueue::GetJobCmd(glbl_jobID) == JOB_STOP)
    int main(int argc, char *argv[]) 
    143165    QDateTime startts;
    144166    int jobType = JOB_NONE;
    145167    int otype = REPLEX_MPEG2;
    146     bool useCutlist = false, keyframesonly = false;
     168    bool useCutlist = false, keyframesonly = false, queueJobInstead = false, foundProfileName = false;
    147169    bool build_index = false, fifosync = false, showprogress = false, mpeg2 = false;
    148170    QMap<QString, QString> settingsOverride;
    149171    frm_dir_map_t deleteMap;
    int main(int argc, char *argv[]) 
    284306            if (a.argc()-1 > argpos && a.argv()[argpos+1][0] != '-')
    285307            {
    286308                profilename = a.argv()[argpos + 1];
     309                foundProfileName = true;
    287310                ++argpos;
    288311            }
    289312            else
    int main(int argc, char *argv[]) 
    474497
    475498            ++argpos;
    476499        }
     500        else if (!strcmp(a.argv()[argpos],"-q") ||
     501                 !strcmp(a.argv()[argpos],"--queue"))
     502        {
     503            queueJobInstead = true;
     504        }
    477505        else if (!strcmp(a.argv()[argpos],"-h") ||
    478506                 !strcmp(a.argv()[argpos],"--help"))
    479507        {
    int main(int argc, char *argv[]) 
    562590         cerr << "Must specify --fifodir to use --fifosync\n";
    563591         return TRANSCODE_EXIT_INVALID_CMDLINE;
    564592    }
     593    if (queueJobInstead && 
     594         (found_infile || build_index ||  jobID >= 0 || !outfile.isEmpty() ||
     595          !fifodir.isEmpty() || fifosync || showprogress || useCutlist || mpeg2 ||
     596          isVideo || keyframesonly || !recorderOptions.isEmpty() || foundProfileName ))
     597    {
     598         cerr << "--queue can only be used with --chanid and --starttime \n";
     599         return TRANSCODE_EXIT_INVALID_CMDLINE;
     600    }
    565601
    566602    VERBOSE(VB_IMPORTANT, QString("Enabled verbose msgs: %1").arg(verboseString));
    567603
    int main(int argc, char *argv[]) 
    593629            return TRANSCODE_EXIT_NO_RECORDING_DATA;
    594630        }
    595631
     632        if (queueJobInstead)
     633        {
     634            return QueueTranscodeJob(pginfo);
     635        }
     636
    596637        infile = pginfo->GetPlaybackURL(false, true);
    597638    }
    598639    else