Example #1
0
 /**
  * Calls avconv command to perform a specific audio task.
  *
  * <p>Can strip audio, replace or overlay audio on another selected input file.
  *
  * <p>Relays success or errors back to EDT to deal with.
  */
 @Override
 protected Void doInBackground() throws Exception {
   ProcessBuilder builder = null;
   errorState = false;
   switch (_cmd) {
     case "STRIP-audio":
       builder =
           new ProcessBuilder(
               "/bin/bash", "-c", "avconv -i " + _inputFile + " -vn " + _outputFile);
       fc = new FileChecker(_inputFile);
       if (!fc.checkAVFile("Audio")) {
         firePropertyChange("failure", null, _noAudioWarning);
         errorState = true;
         return null;
       }
       break;
     case "STRIP-video":
       builder =
           new ProcessBuilder(
               "/bin/bash", "-c", "avconv -i " + _inputFile + " -c copy -map 0:v " + _outputFile);
       fc = new FileChecker(_inputFile);
       if (!fc.checkAVFile("Audio")) {
         firePropertyChange("failure", null, _noAudioWarning);
         errorState = true;
         return null;
       }
       break;
     case "MERGE":
       builder =
           new ProcessBuilder(
               "/bin/bash",
               "-c",
               "avconv -i "
                   + _inputFile
                   + " -i "
                   + _replaceOrMergeFile
                   + " -filter_complex amix=duration=shortest -vcodec copy -shortest -y -strict experimental "
                   + _outputFile);
       break;
     case "REPLACE":
       builder =
           new ProcessBuilder(
               "/bin/bash",
               "-c",
               "avconv -i "
                   + _inputFile
                   + " -i "
                   + _replaceOrMergeFile
                   + " -c copy -map 0:v -map 1:a "
                   + _outputFile);
       break;
   }
   bashProcess(builder);
   return null;
 }