diff --git a/main.py b/main.py index 0e8658b..5042dbc 100644 --- a/main.py +++ b/main.py @@ -7,22 +7,30 @@ ffmpeg = 'ffmpeg' config = os.path.dirname(os.path.abspath(sys.argv[0])) + '/config.txt' -output = '' +output = '' +def make_manifest(manifest_dir, relative_manifest_path, manifest_textfile): + os.chdir(manifest_dir) + if os.path.isfile(manifest_destination): + print 'Destination manifest already exists' + manifest_generator = subprocess.check_output(['md5deep', '-ler', relative_manifest_path]) + manifest_list = manifest_generator.splitlines() + files_in_manifest = len(manifest_list) + # http://stackoverflow.com/a/31306961/2188572 + manifest_list = sorted(manifest_list, key=lambda x:(x[34:])) + with open(manifest_textfile,"wb") as fo: + for i in manifest_list: + fo.write(i + '\n') + return files_in_manifest class ExampleApp(QtGui.QMainWindow, design.Ui_MainWindow): def __init__(self): global ffmpeg super(self.__class__, self).__init__() self.setupUi(self) # This is defined in design.py file automatically if os.path.isfile(config): - print os.path.isfile(config) with open(config,"r") as fo: ffmpeg = fo.readline() - print ffmpeg - - - print 'i used %s as exe' % ffmpeg + try: - print ffmpeg, 'fsuioduiouwriou' subprocess.call([ffmpeg, '-v','0']) except OSError: print 'ffmpeg is not installed - please set ffmpeg path in settings!' @@ -61,7 +69,6 @@ def override_output(self): def on_combo_activated(self): global container container = self.container_selection.currentText() - print container def encode(self): ''' @@ -74,9 +81,18 @@ def encode(self): if output == '': output = str(directory) + container source_framemd5 = directory + '.framemd5' - print source_framemd5 output_framemd5 = output + '.framemd5' - cmd = [str(ffmpeg),'-i', str(directory), '-c:v', 'ffv1', '-level', '3',str(output)] + cmd = [str(ffmpeg), + '-i', str(directory), + '-c:v', 'ffv1', + '-g','1', # Use intra-frame only aka ALL-I aka GOP=1 + '-level','3', # Use Version 3 of FFv1 + '-c:a','copy', # Copy and paste audio bitsream with no transcoding + '-map','0', + '-dn', + '-report', + '-slicecrc', '1', + '-slices', '16',str(output)] if not self.checkBox.isChecked(): cmd += ['-f','framemd5','-an',str(source_framemd5)] print cmd @@ -96,14 +112,27 @@ def encode(self): else: msgBox = QtGui.QMessageBox() msgBox.setText('Your transcode was not lossless') - ret = msgBox.exec_() + ret = msgBox.exec_() + global output_parent_dir + global normpath + global relative_path + global dirname + global manifest_destination + output_parent_dir = os.path.dirname(str(output)) + normpath = os.path.normpath(str(output)) + relative_path = normpath.split(os.sep)[-1] + dirname = os.path.split(os.path.basename(str(output)))[1] + manifest_destination = output_parent_dir + '/%s_manifest.md5' % dirname + if self.checkBox_2.isChecked(): + make_manifest( output_parent_dir, relative_path, manifest_destination ) + print 'Encode process completed' def update_dir(self): self.filename_text.setText(directory) def update_output(self): self.lineEdit_2.setText(output) - + def main(): app = QtGui.QApplication(sys.argv) # A new instance of QApplication