Index: mythplugins/mythdvd/mtd/jobthread.cpp
===================================================================
--- mythplugins/mythdvd/mtd/jobthread.cpp	(revision 9584)
+++ mythplugins/mythdvd/mtd/jobthread.cpp	(working copy)
@@ -818,7 +818,6 @@
     ac3_flag = do_ac3;
     working_directory = NULL;
     tc_process = NULL;
-    two_pass = false;
     audio_track = which_audio;
     length_in_seconds = numb_seconds;
     if(length_in_seconds == 0)
@@ -837,6 +836,15 @@
     
     nice(nice_level);
 
+    if(keepGoing())
+    {
+        if(!getTranscodeParams())
+        {
+            problem("Couldn't fetch transcode settings from the database");
+            return;
+        }
+    }
+    
     //
     //  Make working directory
     //
@@ -849,19 +857,9 @@
         }    
     }
 
-    //
-    //  Build the transcode command line. We do this early
-    //  (before ripping) so we can figure out if this is
-    //  a two pass job or not (for the progress display)
-    //
 
     if(keepGoing())
     {
-        if(!buildTranscodeCommandLine(1))
-        {
-            cleanUp();
-            return;
-        }
         if(two_pass)
         {
             setJobName(QString(QObject::tr("Transcode of %1")).arg(rip_name));
@@ -947,67 +945,9 @@
     cleanUp();
 }
 
-bool DVDTranscodeThread::makeWorkingDirectory()
+bool DVDTranscodeThread::getTranscodeParams()
 {
-    QString dir_name = gContext->GetSetting("DVDRipLocation");
-    if( dir_name.length() < 1)
-    {
-        problem("could not find rip directory in settings");
-        return false;
-    }
-    
-    working_directory = new QDir (dir_name);
-    if(!working_directory->exists())
-    {
-        problem("rip directory does not seem to exist");
-        return false;
-    }
-    if(!working_directory->mkdir(rip_name))
-    {
-        problem(QString("could not create directory called \"%1\" in rip directory").arg(rip_name));
-        return false;
-    }
-    if(!working_directory->cd(rip_name))
-    {
-        problem(QString("could not cd into \"%1\"").arg(rip_name));
-        return false;
-    }
-    if(!working_directory->mkdir("vob"))
-    {
-        problem("could not create a vob subdirectory in the working directory");
-        return false;
-    }
-    
-    return true;
-}
-
-bool DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
-{
     //
-    //  If our destination file already exists, bail out
-    //
-    
-    QFile a_file(QString("%1.avi").arg(destination_file_string));
-    if(a_file.exists())
-    {
-        problem("transcode cannot run, destination file already exists");
-        return false;
-    }
-    
-    
-    
-    QString tc_command = gContext->GetSetting("TranscodeCommand");
-    if(tc_command.length() < 1)
-    {
-        problem("there is no TranscodeCommand setting for this system");
-        return false;
-    }
-    
-    tc_arguments.clear();
-    tc_arguments.append(tc_command);
-    
-    
-    //
     //  Now *that* is a query string !
     //
     
@@ -1054,34 +994,34 @@
     }       
     
     //
-    //  Convert query results to useful variables
+    //  Assign query results
     //                           
     
-    int       sync_mode = a_query.value(0).toInt();
-    bool       use_yv12 = a_query.value(1).toBool();
-    int         cliptop = a_query.value(2).toInt();
-    int      clipbottom = a_query.value(3).toInt();
-    int        clipleft = a_query.value(4).toInt();
-    int       clipright = a_query.value(5).toInt();
-    int      f_resize_h = a_query.value(6).toInt();
-    int      f_resize_w = a_query.value(7).toInt();
-    int     hq_resize_h = a_query.value(8).toInt();
-    int     hq_resize_w = a_query.value(9).toInt();
-    int          grow_h = a_query.value(10).toInt();
-    int          grow_w = a_query.value(11).toInt();
-    int        clipttop = a_query.value(12).toInt();
-    int     cliptbottom = a_query.value(13).toInt();
-    int       cliptleft = a_query.value(14).toInt();
-    int      cliptright = a_query.value(15).toInt();
-    QString       codec = a_query.value(16).toString();
-    QString codec_param = a_query.value(17).toString();
-    int         bitrate = a_query.value(18).toInt();
-    int      a_sample_r = a_query.value(19).toInt();
-    int       a_bitrate = a_query.value(20).toInt();
-    int   input_setting = a_query.value(21).toInt();
-    QString        name = a_query.value(22).toString();
-               two_pass = a_query.value(23).toBool();
-    QString    tc_param = a_query.value(24).toString();
+    sync_mode = a_query.value(0).toInt();
+    use_yv12 = a_query.value(1).toBool();
+    cliptop = a_query.value(2).toInt();
+    clipbottom = a_query.value(3).toInt();
+    clipleft = a_query.value(4).toInt();
+    clipright = a_query.value(5).toInt();
+    f_resize_h = a_query.value(6).toInt();
+    f_resize_w = a_query.value(7).toInt();
+    hq_resize_h = a_query.value(8).toInt();
+    hq_resize_w = a_query.value(9).toInt();
+    grow_h = a_query.value(10).toInt();
+    grow_w = a_query.value(11).toInt();
+    clipttop = a_query.value(12).toInt();
+    cliptbottom = a_query.value(13).toInt();
+    cliptleft = a_query.value(14).toInt();
+    cliptright = a_query.value(15).toInt();
+    codec = a_query.value(16).toString();
+    codec_param = a_query.value(17).toString();
+    bitrate = a_query.value(18).toInt();
+    a_sample_r = a_query.value(19).toInt();
+    a_bitrate = a_query.value(20).toInt();
+    input_setting = a_query.value(21).toInt();
+    qual_name = a_query.value(22).toString();
+    two_pass = a_query.value(23).toBool();
+    tc_param = a_query.value(24).toString();
     
     //
     //  And now, another query to get frame rate code and
@@ -1101,11 +1041,73 @@
         return false;
     }
 
-    int input_hsize = a_query.value(0).toInt();
-    int input_vsize = a_query.value(1).toInt();
-    int fr_code = a_query.value(2).toInt();
+    input_hsize = a_query.value(0).toInt();
+    input_vsize = a_query.value(1).toInt();
+    fr_code = a_query.value(2).toInt();
+
+    return true;
+}
+
+bool DVDTranscodeThread::makeWorkingDirectory()
+{
+    QString dir_name = gContext->GetSetting("DVDRipLocation");
+    if( dir_name.length() < 1)
+    {
+        problem("could not find rip directory in settings");
+        return false;
+    }
     
+    working_directory = new QDir (dir_name);
+    if(!working_directory->exists())
+    {
+        problem("rip directory does not seem to exist");
+        return false;
+    }
+    if(!working_directory->mkdir(rip_name))
+    {
+        problem(QString("could not create directory called \"%1\" in rip directory").arg(rip_name));
+        return false;
+    }
+    if(!working_directory->cd(rip_name))
+    {
+        problem(QString("could not cd into \"%1\"").arg(rip_name));
+        return false;
+    }
+    if(!working_directory->mkdir("vob"))
+    {
+        problem("could not create a vob subdirectory in the working directory");
+        return false;
+    }
+    
+    return true;
+}
+
+bool DVDTranscodeThread::buildTranscodeCommandLine(int which_run)
+{
     //
+    //  If our destination file already exists, bail out
+    //
+    
+    QFile a_file(QString("%1.avi").arg(destination_file_string));
+    if(a_file.exists())
+    {
+        problem("transcode cannot run, destination file already exists");
+        return false;
+    }
+    
+    
+    
+    QString tc_command = gContext->GetSetting("TranscodeCommand");
+    if(tc_command.length() < 1)
+    {
+        problem("there is no TranscodeCommand setting for this system");
+        return false;
+    }
+    
+    tc_arguments.clear();
+    tc_arguments.append(tc_command);
+    
+    //
     //  Check if we are doing subtitles
     //
     
@@ -1228,7 +1230,7 @@
     }
     
     
-    if(ac3_flag && !name.contains("VCD", false))
+    if(ac3_flag && !qual_name.contains("VCD", false))
     {
         tc_arguments.append("-A");
         tc_arguments.append("-N");
@@ -1295,24 +1297,17 @@
     double percent_transcoded = 0.0;
     QTime job_time;
     bool finally = true;
-    
-    if(which_run > 1)
-    {
-        //
-        //  Second pass
-        //
         
-        if(tc_process)
-        {
-            delete tc_process;
-            tc_process = NULL;
-        }
+    if(tc_process)
+    {
+        delete tc_process;
+        tc_process = NULL;
+    }
 
-        if (!buildTranscodeCommandLine(which_run))        
-        {
-            problem( "Problem building second pass command line." );
-            return false;
-        }
+    if (!buildTranscodeCommandLine(which_run))        
+    {
+        problem( "Problem building transcode command line." );
+        return false;
     }
 
     //  Debugging
Index: mythplugins/mythdvd/mtd/jobthread.h
===================================================================
--- mythplugins/mythdvd/mtd/jobthread.h	(revision 9584)
+++ mythplugins/mythdvd/mtd/jobthread.h	(working copy)
@@ -194,6 +194,7 @@
     virtual void run();
     bool transcodeSlotUsed(){return used_transcode_slot;}
     
+    bool    getTranscodeParams();
     bool    makeWorkingDirectory();
     bool    buildTranscodeCommandLine(int which_run);
     bool    runTranscode(int run);
@@ -207,11 +208,41 @@
     QDir         *working_directory;
     QStringList  tc_arguments;
     class QProcess     *tc_process;
-    bool         two_pass;
     int          audio_track;
     int          length_in_seconds;
     bool         ac3_flag;
     int          subtitle_track;
+
+    int     sync_mode;
+    bool    use_yv12;
+    int     cliptop;
+    int     clipbottom;
+    int     clipleft;
+    int     clipright;
+    int     f_resize_h;
+    int     f_resize_w;
+    int     hq_resize_h;
+    int     hq_resize_w;
+    int     grow_h;
+    int     grow_w;
+    int     clipttop;
+    int     cliptbottom;
+    int     cliptleft;
+    int     cliptright;
+    QString codec;
+    QString codec_param;
+    int     bitrate;
+    int     a_sample_r;
+    int     a_bitrate;
+    int     input_setting;
+    QString qual_name;
+    bool    two_pass;
+    QString tc_param;
+    
+    int     input_hsize;
+    int     input_vsize;
+    int     fr_code;
+                                                                                                               
 };
 
 
