Ticket #1607: mtd_cleanup.patch

File mtd_cleanup.patch, 10.1 KB (added by mcheely@…, 18 years ago)
  • mythplugins/mythdvd/mtd/jobthread.cpp

     
    818818    ac3_flag = do_ac3;
    819819    working_directory = NULL;
    820820    tc_process = NULL;
    821     two_pass = false;
    822821    audio_track = which_audio;
    823822    length_in_seconds = numb_seconds;
    824823    if(length_in_seconds == 0)
     
    837836   
    838837    nice(nice_level);
    839838
     839    if(keepGoing())
     840    {
     841        if(!getTranscodeParams())
     842        {
     843            problem("Couldn't fetch transcode settings from the database");
     844            return;
     845        }
     846    }
     847   
    840848    //
    841849    //  Make working directory
    842850    //
     
    849857        }   
    850858    }
    851859
    852     //
    853     //  Build the transcode command line. We do this early
    854     //  (before ripping) so we can figure out if this is
    855     //  a two pass job or not (for the progress display)
    856     //
    857860
    858861    if(keepGoing())
    859862    {
    860         if(!buildTranscodeCommandLine(1))
    861         {
    862             cleanUp();
    863             return;
    864         }
    865863        if(two_pass)
    866864        {
    867865            setJobName(QString(QObject::tr("Transcode of %1")).arg(rip_name));
     
    947945    cleanUp();
    948946}
    949947
    950 bool DVDTranscodeThread::makeWorkingDirectory()
     948bool DVDTranscodeThread::getTranscodeParams()
    951949{
    952     QString dir_name = gContext->GetSetting("DVDRipLocation");
    953     if( dir_name.length() < 1)
    954     {
    955         problem("could not find rip directory in settings");
    956         return false;
    957     }
    958    
    959     working_directory = new QDir (dir_name);
    960     if(!working_directory->exists())
    961     {
    962         problem("rip directory does not seem to exist");
    963         return false;
    964     }
    965     if(!working_directory->mkdir(rip_name))
    966     {
    967         problem(QString("could not create directory called \"%1\" in rip directory").arg(rip_name));
    968         return false;
    969     }
    970     if(!working_directory->cd(rip_name))
    971     {
    972         problem(QString("could not cd into \"%1\"").arg(rip_name));
    973         return false;
    974     }
    975     if(!working_directory->mkdir("vob"))
    976     {
    977         problem("could not create a vob subdirectory in the working directory");
    978         return false;
    979     }
    980    
    981     return true;
    982 }
    983 
    984 bool DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
    985 {
    986950    //
    987     //  If our destination file already exists, bail out
    988     //
    989    
    990     QFile a_file(QString("%1.avi").arg(destination_file_string));
    991     if(a_file.exists())
    992     {
    993         problem("transcode cannot run, destination file already exists");
    994         return false;
    995     }
    996    
    997    
    998    
    999     QString tc_command = gContext->GetSetting("TranscodeCommand");
    1000     if(tc_command.length() < 1)
    1001     {
    1002         problem("there is no TranscodeCommand setting for this system");
    1003         return false;
    1004     }
    1005    
    1006     tc_arguments.clear();
    1007     tc_arguments.append(tc_command);
    1008    
    1009    
    1010     //
    1011951    //  Now *that* is a query string !
    1012952    //
    1013953   
     
    1054994    }       
    1055995   
    1056996    //
    1057     //  Convert query results to useful variables
     997    //  Assign query results
    1058998    //                           
    1059999   
    1060     int       sync_mode = a_query.value(0).toInt();
    1061     bool       use_yv12 = a_query.value(1).toBool();
    1062     int         cliptop = a_query.value(2).toInt();
    1063     int      clipbottom = a_query.value(3).toInt();
    1064     int        clipleft = a_query.value(4).toInt();
    1065     int       clipright = a_query.value(5).toInt();
    1066     int      f_resize_h = a_query.value(6).toInt();
    1067     int      f_resize_w = a_query.value(7).toInt();
    1068     int     hq_resize_h = a_query.value(8).toInt();
    1069     int     hq_resize_w = a_query.value(9).toInt();
    1070     int          grow_h = a_query.value(10).toInt();
    1071     int          grow_w = a_query.value(11).toInt();
    1072     int        clipttop = a_query.value(12).toInt();
    1073     int     cliptbottom = a_query.value(13).toInt();
    1074     int       cliptleft = a_query.value(14).toInt();
    1075     int      cliptright = a_query.value(15).toInt();
    1076     QString       codec = a_query.value(16).toString();
    1077     QString codec_param = a_query.value(17).toString();
    1078     int         bitrate = a_query.value(18).toInt();
    1079     int      a_sample_r = a_query.value(19).toInt();
    1080     int       a_bitrate = a_query.value(20).toInt();
    1081     int   input_setting = a_query.value(21).toInt();
    1082     QString        name = a_query.value(22).toString();
    1083                two_pass = a_query.value(23).toBool();
    1084     QString    tc_param = a_query.value(24).toString();
     1000    sync_mode = a_query.value(0).toInt();
     1001    use_yv12 = a_query.value(1).toBool();
     1002    cliptop = a_query.value(2).toInt();
     1003    clipbottom = a_query.value(3).toInt();
     1004    clipleft = a_query.value(4).toInt();
     1005    clipright = a_query.value(5).toInt();
     1006    f_resize_h = a_query.value(6).toInt();
     1007    f_resize_w = a_query.value(7).toInt();
     1008    hq_resize_h = a_query.value(8).toInt();
     1009    hq_resize_w = a_query.value(9).toInt();
     1010    grow_h = a_query.value(10).toInt();
     1011    grow_w = a_query.value(11).toInt();
     1012    clipttop = a_query.value(12).toInt();
     1013    cliptbottom = a_query.value(13).toInt();
     1014    cliptleft = a_query.value(14).toInt();
     1015    cliptright = a_query.value(15).toInt();
     1016    codec = a_query.value(16).toString();
     1017    codec_param = a_query.value(17).toString();
     1018    bitrate = a_query.value(18).toInt();
     1019    a_sample_r = a_query.value(19).toInt();
     1020    a_bitrate = a_query.value(20).toInt();
     1021    input_setting = a_query.value(21).toInt();
     1022    qual_name = a_query.value(22).toString();
     1023    two_pass = a_query.value(23).toBool();
     1024    tc_param = a_query.value(24).toString();
    10851025   
    10861026    //
    10871027    //  And now, another query to get frame rate code and
     
    11011041        return false;
    11021042    }
    11031043
    1104     int input_hsize = a_query.value(0).toInt();
    1105     int input_vsize = a_query.value(1).toInt();
    1106     int fr_code = a_query.value(2).toInt();
     1044    input_hsize = a_query.value(0).toInt();
     1045    input_vsize = a_query.value(1).toInt();
     1046    fr_code = a_query.value(2).toInt();
     1047
     1048    return true;
     1049}
     1050
     1051bool DVDTranscodeThread::makeWorkingDirectory()
     1052{
     1053    QString dir_name = gContext->GetSetting("DVDRipLocation");
     1054    if( dir_name.length() < 1)
     1055    {
     1056        problem("could not find rip directory in settings");
     1057        return false;
     1058    }
    11071059   
     1060    working_directory = new QDir (dir_name);
     1061    if(!working_directory->exists())
     1062    {
     1063        problem("rip directory does not seem to exist");
     1064        return false;
     1065    }
     1066    if(!working_directory->mkdir(rip_name))
     1067    {
     1068        problem(QString("could not create directory called \"%1\" in rip directory").arg(rip_name));
     1069        return false;
     1070    }
     1071    if(!working_directory->cd(rip_name))
     1072    {
     1073        problem(QString("could not cd into \"%1\"").arg(rip_name));
     1074        return false;
     1075    }
     1076    if(!working_directory->mkdir("vob"))
     1077    {
     1078        problem("could not create a vob subdirectory in the working directory");
     1079        return false;
     1080    }
     1081   
     1082    return true;
     1083}
     1084
     1085bool DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
     1086{
    11081087    //
     1088    //  If our destination file already exists, bail out
     1089    //
     1090   
     1091    QFile a_file(QString("%1.avi").arg(destination_file_string));
     1092    if(a_file.exists())
     1093    {
     1094        problem("transcode cannot run, destination file already exists");
     1095        return false;
     1096    }
     1097   
     1098   
     1099   
     1100    QString tc_command = gContext->GetSetting("TranscodeCommand");
     1101    if(tc_command.length() < 1)
     1102    {
     1103        problem("there is no TranscodeCommand setting for this system");
     1104        return false;
     1105    }
     1106   
     1107    tc_arguments.clear();
     1108    tc_arguments.append(tc_command);
     1109   
     1110    //
    11091111    //  Check if we are doing subtitles
    11101112    //
    11111113   
     
    12281230    }
    12291231   
    12301232   
    1231     if(ac3_flag && !name.contains("VCD", false))
     1233    if(ac3_flag && !qual_name.contains("VCD", false))
    12321234    {
    12331235        tc_arguments.append("-A");
    12341236        tc_arguments.append("-N");
     
    12951297    double percent_transcoded = 0.0;
    12961298    QTime job_time;
    12971299    bool finally = true;
    1298    
    1299     if(which_run > 1)
    1300     {
    1301         //
    1302         //  Second pass
    1303         //
    13041300       
    1305         if(tc_process)
    1306         {
    1307             delete tc_process;
    1308             tc_process = NULL;
    1309         }
     1301    if(tc_process)
     1302    {
     1303        delete tc_process;
     1304        tc_process = NULL;
     1305    }
    13101306
    1311         if (!buildTranscodeCommandLine(which_run))       
    1312         {
    1313             problem( "Problem building second pass command line." );
    1314             return false;
    1315         }
     1307    if (!buildTranscodeCommandLine(which_run))       
     1308    {
     1309        problem( "Problem building transcode command line." );
     1310        return false;
    13161311    }
    13171312
    13181313    //  Debugging
  • mythplugins/mythdvd/mtd/jobthread.h

     
    194194    virtual void run();
    195195    bool transcodeSlotUsed(){return used_transcode_slot;}
    196196   
     197    bool    getTranscodeParams();
    197198    bool    makeWorkingDirectory();
    198199    bool    buildTranscodeCommandLine(int which_run);
    199200    bool    runTranscode(int run);
     
    207208    QDir         *working_directory;
    208209    QStringList  tc_arguments;
    209210    class QProcess     *tc_process;
    210     bool         two_pass;
    211211    int          audio_track;
    212212    int          length_in_seconds;
    213213    bool         ac3_flag;
    214214    int          subtitle_track;
     215
     216    int     sync_mode;
     217    bool    use_yv12;
     218    int     cliptop;
     219    int     clipbottom;
     220    int     clipleft;
     221    int     clipright;
     222    int     f_resize_h;
     223    int     f_resize_w;
     224    int     hq_resize_h;
     225    int     hq_resize_w;
     226    int     grow_h;
     227    int     grow_w;
     228    int     clipttop;
     229    int     cliptbottom;
     230    int     cliptleft;
     231    int     cliptright;
     232    QString codec;
     233    QString codec_param;
     234    int     bitrate;
     235    int     a_sample_r;
     236    int     a_bitrate;
     237    int     input_setting;
     238    QString qual_name;
     239    bool    two_pass;
     240    QString tc_param;
     241   
     242    int     input_hsize;
     243    int     input_vsize;
     244    int     fr_code;
     245                                                                                                               
    215246};
    216247
    217248