Ticket #1607: mtd_cleanup.patch
File mtd_cleanup.patch, 10.1 KB (added by , 18 years ago) |
---|
-
mythplugins/mythdvd/mtd/jobthread.cpp
818 818 ac3_flag = do_ac3; 819 819 working_directory = NULL; 820 820 tc_process = NULL; 821 two_pass = false;822 821 audio_track = which_audio; 823 822 length_in_seconds = numb_seconds; 824 823 if(length_in_seconds == 0) … … 837 836 838 837 nice(nice_level); 839 838 839 if(keepGoing()) 840 { 841 if(!getTranscodeParams()) 842 { 843 problem("Couldn't fetch transcode settings from the database"); 844 return; 845 } 846 } 847 840 848 // 841 849 // Make working directory 842 850 // … … 849 857 } 850 858 } 851 859 852 //853 // Build the transcode command line. We do this early854 // (before ripping) so we can figure out if this is855 // a two pass job or not (for the progress display)856 //857 860 858 861 if(keepGoing()) 859 862 { 860 if(!buildTranscodeCommandLine(1))861 {862 cleanUp();863 return;864 }865 863 if(two_pass) 866 864 { 867 865 setJobName(QString(QObject::tr("Transcode of %1")).arg(rip_name)); … … 947 945 cleanUp(); 948 946 } 949 947 950 bool DVDTranscodeThread:: makeWorkingDirectory()948 bool DVDTranscodeThread::getTranscodeParams() 951 949 { 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 {986 950 // 987 // If our destination file already exists, bail out988 //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 //1011 951 // Now *that* is a query string ! 1012 952 // 1013 953 … … 1054 994 } 1055 995 1056 996 // 1057 // Convert query results to useful variables997 // Assign query results 1058 998 // 1059 999 1060 intsync_mode = a_query.value(0).toInt();1061 booluse_yv12 = a_query.value(1).toBool();1062 intcliptop = a_query.value(2).toInt();1063 intclipbottom = a_query.value(3).toInt();1064 intclipleft = a_query.value(4).toInt();1065 intclipright = a_query.value(5).toInt();1066 intf_resize_h = a_query.value(6).toInt();1067 intf_resize_w = a_query.value(7).toInt();1068 inthq_resize_h = a_query.value(8).toInt();1069 inthq_resize_w = a_query.value(9).toInt();1070 intgrow_h = a_query.value(10).toInt();1071 intgrow_w = a_query.value(11).toInt();1072 intclipttop = a_query.value(12).toInt();1073 intcliptbottom = a_query.value(13).toInt();1074 intcliptleft = a_query.value(14).toInt();1075 intcliptright = a_query.value(15).toInt();1076 QStringcodec = a_query.value(16).toString();1077 QStringcodec_param = a_query.value(17).toString();1078 intbitrate = a_query.value(18).toInt();1079 inta_sample_r = a_query.value(19).toInt();1080 inta_bitrate = a_query.value(20).toInt();1081 in t input_setting = a_query.value(21).toInt();1082 QStringname = a_query.value(22).toString();1083 1084 QStringtc_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(); 1085 1025 1086 1026 // 1087 1027 // And now, another query to get frame rate code and … … 1101 1041 return false; 1102 1042 } 1103 1043 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 1051 bool 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 } 1107 1059 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 1085 bool DVDTranscodeThread::buildTranscodeCommandLine(int which_run) 1086 { 1108 1087 // 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 // 1109 1111 // Check if we are doing subtitles 1110 1112 // 1111 1113 … … 1228 1230 } 1229 1231 1230 1232 1231 if(ac3_flag && ! name.contains("VCD", false))1233 if(ac3_flag && !qual_name.contains("VCD", false)) 1232 1234 { 1233 1235 tc_arguments.append("-A"); 1234 1236 tc_arguments.append("-N"); … … 1295 1297 double percent_transcoded = 0.0; 1296 1298 QTime job_time; 1297 1299 bool finally = true; 1298 1299 if(which_run > 1)1300 {1301 //1302 // Second pass1303 //1304 1300 1305 1306 1307 1308 1309 1301 if(tc_process) 1302 { 1303 delete tc_process; 1304 tc_process = NULL; 1305 } 1310 1306 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; 1316 1311 } 1317 1312 1318 1313 // Debugging -
mythplugins/mythdvd/mtd/jobthread.h
194 194 virtual void run(); 195 195 bool transcodeSlotUsed(){return used_transcode_slot;} 196 196 197 bool getTranscodeParams(); 197 198 bool makeWorkingDirectory(); 198 199 bool buildTranscodeCommandLine(int which_run); 199 200 bool runTranscode(int run); … … 207 208 QDir *working_directory; 208 209 QStringList tc_arguments; 209 210 class QProcess *tc_process; 210 bool two_pass;211 211 int audio_track; 212 212 int length_in_seconds; 213 213 bool ac3_flag; 214 214 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 215 246 }; 216 247 217 248