コード例 #1
0
 private void extractPidsFromFfmpeg(TranscodeRequest request, String command)
     throws ProcessorException {
   log.info("Executing '" + command + "'");
   ExternalJobRunner runner;
   try {
     runner = new ExternalJobRunner(new String[] {"bash", "-c", command});
     log.debug("Command '" + command + "' returned with output '" + runner.getError());
   } catch (IOException e) {
     throw new ProcessorException(e);
   } catch (InterruptedException e) {
     throw new ProcessorException(e);
   } catch (ExternalProcessTimedOutException e) {
     throw new ProcessorException(e);
   }
   Pattern thisProgramPattern =
       Pattern.compile(".*Program\\s" + request.getClips().get(0).getProgramId() + ".*");
   Pattern programPattern = Pattern.compile(".*Program.*");
   Pattern dvbsubPattern = Pattern.compile(".*Stream.*\\[(0x[0-9a-f]*)\\].*dvb.*sub.*");
   Pattern videoPattern =
       Pattern.compile(".*Stream.*\\[(0x[0-9a-f]*)\\].*Video.*DAR\\s(([0-9]*):([0-9]*)).*");
   Pattern audioPattern1 = Pattern.compile(".*Stream.*\\[(0x[0-9a-f]*)\\].*Audio.*");
   Pattern audioPattern2 = Pattern.compile(".*Stream.*\\[(0x[0-9a-f]*)\\].*0x0011.*");
   String[] commandOutput = runner.getError().split("\\n");
   boolean foundProgram = false;
   for (String line : commandOutput) {
     log.debug("Checking line '" + line + "'");
     if (foundProgram && programPattern.matcher(line).matches()) {
       log.debug("Found next program section, returning");
       return;
     }
     if (thisProgramPattern.matcher(line).matches()) {
       log.debug("Found requested program");
       foundProgram = true;
     }
     if (foundProgram) {
       Matcher dvbsubMatcher = dvbsubPattern.matcher(line);
       if (dvbsubMatcher.matches()) {
         request.setDvbsubPid(dvbsubMatcher.group(1));
         log.info("Setting pid for dvbsub '" + dvbsubMatcher.group(1) + "'");
       }
       Matcher videoMatcher = videoPattern.matcher(line);
       if (videoMatcher.matches()) {
         request.setVideoPid(videoMatcher.group(1));
         log.info("Setting pid for video '" + videoMatcher.group(1) + "'");
         if (line.contains("mpeg2video")) {
           request.setVideoFcc("mpgv");
         } else if (line.contains("h264")) {
           request.setVideoFcc("h264");
         }
         log.debug(
             "Identified video fourcc for " + request.getPid() + ": " + request.getVideoFcc());
         request.setDisplayAspectRatioString(videoMatcher.group(2));
         log.debug("Identified aspect ratio '" + request.getDisplayAspectRatioString() + "'");
       }
       Matcher audioMatcher = audioPattern1.matcher(line);
       if (audioMatcher.matches()) {
         request.addAudioPid(audioMatcher.group(1));
         log.info("Setting pid for audio '" + audioMatcher.group(1) + "'");
         if (line.contains("aac_latm")) {
           request.setAudioFcc("mp4a");
         } else if (line.contains("mp2")) {
           request.setAudioFcc("mpga");
         }
         log.debug(
             "Identified audio fourcc for " + request.getPid() + ": " + request.getAudioFcc());
       }
       audioMatcher = audioPattern2.matcher(line);
       if (audioMatcher.matches()) {
         request.addAudioPid(audioMatcher.group(1));
         log.info("Setting pid for audio '" + audioMatcher.group(1) + "'");
         request.setAudioFcc("mp4a");
         log.debug(
             "Identified audio fourcc for " + request.getPid() + ": " + request.getAudioFcc());
       }
     }
   }
 }
コード例 #2
0
 private void extractPidsFromVlc(TranscodeRequest request, String command)
     throws ProcessorException {
   log.info("Executing '" + command + "'");
   ExternalJobRunner runner;
   try {
     runner = new ExternalJobRunner(new String[] {"bash", "-c", command});
     log.debug("Command '" + command + "' returned with output '" + runner.getError());
   } catch (IOException e) {
     throw new ProcessorException(e);
   } catch (InterruptedException e) {
     throw new ProcessorException(e);
   } catch (ExternalProcessTimedOutException e) {
     throw new ProcessorException(e);
   }
   Pattern thisProgramPattern =
       Pattern.compile(".*program number=" + request.getClips().get(0).getProgramId() + ".*");
   Pattern programPattern = Pattern.compile(".*program number=.*");
   Pattern dvbsubPattern = Pattern.compile(".*pid=([0-9]*).*fcc=dvbs.*");
   Pattern videoPattern = Pattern.compile(".*pid=([0-9]*).*((fcc=mpgv)|(fcc=h264)).*");
   Pattern audioPattern1 = Pattern.compile(".*pid=([0-9]*).*((fcc=mp4a)|(fcc=mpga)).*");
   String[] commandOutput = runner.getError().split("\\n");
   boolean foundProgram = false;
   for (String line : commandOutput) {
     log.debug("Checking line '" + line + "'");
     if (foundProgram && programPattern.matcher(line).matches()) {
       log.debug("Found next program section, returning");
       return;
     }
     if (thisProgramPattern.matcher(line).matches()) {
       log.debug("Found requested program");
       foundProgram = true;
     }
     if (foundProgram) {
       Matcher dvbsubMatcher = dvbsubPattern.matcher(line);
       if (dvbsubMatcher.matches()) {
         request.setDvbsubPid(dvbsubMatcher.group(1));
         log.info("Setting pid for dvbsub '" + dvbsubMatcher.group(1) + "'");
       }
       Matcher videoMatcher = videoPattern.matcher(line);
       if (videoMatcher.matches()) {
         request.setVideoPid(videoMatcher.group(1));
         log.info("Setting pid for video '" + videoMatcher.group(1) + "'");
         if (line.contains("mpgv")) {
           request.setVideoFcc("mpgv");
         } else if (line.contains("h264")) {
           request.setVideoFcc("h264");
         }
         log.debug(
             "Identified video fourcc for " + request.getPid() + ": " + request.getVideoFcc());
       }
       Matcher audioMatcher = audioPattern1.matcher(line);
       if (audioMatcher.matches()) {
         request.addAudioPid(audioMatcher.group(1));
         log.info("Setting pid for audio '" + audioMatcher.group(1) + "'");
         if (line.contains("mp4a")) {
           request.setAudioFcc("mp4a");
         } else if (line.contains("mpga")) {
           request.setAudioFcc("mpga");
         }
         log.debug(
             "Identified audio fourcc for " + request.getPid() + ": " + request.getAudioFcc());
       }
     }
   }
 }