Commits

Ivan Andrianov committed 853f37a

Destination codecs intersection for all input files.

Comments (0)

Files changed (1)

fftranscoder/gui.py

             indexes = self.__view.selectionModel().selectedRows()
 
     def __transcode(self):
-        sourceCodec = getCodecByFileName(self.__model.getFileName(0))
-        sourceBitRate = self.__model.getBitRate(0)
-        (destinationCodecs, destinationBitRates) = getDestinationCodecsAndBitRates(sourceCodec, sourceBitRate)
-        #TODO: make it work not only for the first track (intersect destination codecs and bitrates)
+        multiCodecs = []
+        multiBitRates = []
+        for i in range(self.__model.rowCount()):
+            codec = getCodecByFileName(self.__model.getFileName(i))
+            bitRate = self.__model.getBitRate(i)
+            (codecs, bitRates) = getDestinationCodecsAndBitRates(codec, bitRate)
+            multiCodecs.append(codecs)
+            multiBitRates.append(bitRates)
+
+        destinationCodecs = multiCodecs[0]
+        destinationBitRates = multiBitRates[0]
+        for i in range(1, self.__model.rowCount()):
+            destinationCodecs = filter(lambda codec: codec in multiCodecs[i], destinationCodecs)
+            destinationBitRates = filter(lambda bitRate: bitRate in multiBitRates[i], destinationBitRates)
 
         transcodeDialog = TranscodeDialog(destinationCodecs, destinationBitRates, self)
         if transcodeDialog.exec_() == QDialog.Accepted: