Package net.pms.io

Examples of net.pms.io.ProcessWrapperImpl


      dlna,
      media,
      params,
      cmdArray);

    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.attachProcess(pipe_process);

    try {
      Thread.sleep(150);
    } catch (InterruptedException e) {
    }

    pw.runInNewThread();
    return pw;
  }
View Full Code Here


      params,
      cmdArray
    );

    // Now launch FFmpeg
    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    parseMediaInfo(filename, dlna, pw); // Better late than never
    pw.attachProcess(mkfifo_process); // Clean up the mkfifo process when the transcode ends

    // Give the mkfifo process a little time
    try {
      Thread.sleep(300);
    } catch (InterruptedException e) {
      LOGGER.error("Thread interrupted while waiting for named pipe to be created", e);
    }

    // Launch the transcode command...
    pw.runInNewThread();
    // ...and wait briefly to allow it to start
    try {
      Thread.sleep(200);
    } catch (InterruptedException e) {
      LOGGER.error("Thread interrupted while waiting for transcode to start", e);
View Full Code Here

    // Pass to process wrapper
    String[] cmdArray = new String[cmdList.size()];
    cmdList.toArray(cmdArray);
    cmdArray = finalizeTranscoderArgs(filename, dlna, media, params, cmdArray);
    LOGGER.trace("Finalized args: " + StringUtils.join(cmdArray, " "));
    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.attachProcess(pipe_process);

    // TODO: Why is this here?
    try {
      Thread.sleep(150);
    } catch (InterruptedException e) {
    }

    pw.runInNewThread();
    return pw;
  }
View Full Code Here

      media,
      params,
      cmdArray
    );

    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);

    setOutputParsing(dlna, pw, false);

    if (dtsRemux) {
      PipeProcess pipe;
      pipe = new PipeProcess(System.currentTimeMillis() + "tsmuxerout.ts");

      TsMuxeRVideo ts = new TsMuxeRVideo();
      File f = new File(configuration.getTempFolder(), "pms-tsmuxer.meta");
      String cmd[] = new String[]{ ts.executable(), f.getAbsolutePath(), pipe.getInputPipe() };
      pw = new ProcessWrapperImpl(cmd, params);

      PipeIPCProcess ffVideoPipe = new PipeIPCProcess(System.currentTimeMillis() + "ffmpegvideo", System.currentTimeMillis() + "videoout", false, true);

      cmdList.add(ffVideoPipe.getInputPipe());

      OutputParams ffparams = new OutputParams(configuration);
      ffparams.maxBufferSize = 1;
      ffparams.stdin = params.stdin;

      String[] cmdArrayDts = new String[cmdList.size()];
      cmdList.toArray(cmdArrayDts);

      cmdArrayDts = finalizeTranscoderArgs(
        filename,
        dlna,
        media,
        params,
        cmdArrayDts
      );

      ProcessWrapperImpl ffVideo = new ProcessWrapperImpl(cmdArrayDts, ffparams);

      ProcessWrapper ff_video_pipe_process = ffVideoPipe.getPipeProcess();
      pw.attachProcess(ff_video_pipe_process);
      ff_video_pipe_process.runInNewThread();
      ffVideoPipe.deleteLater();

      pw.attachProcess(ffVideo);
      ffVideo.runInNewThread();

      PipeIPCProcess ffAudioPipe = new PipeIPCProcess(System.currentTimeMillis() + "ffmpegaudio01", System.currentTimeMillis() + "audioout", false, true);
      StreamModifier sm = new StreamModifier();
      sm.setPcm(false);
      sm.setDtsEmbed(dtsRemux);
      sm.setSampleFrequency(48000);
      sm.setBitsPerSample(16);
      sm.setNbChannels(2);

      List<String> cmdListDTS = new ArrayList<>();
      cmdListDTS.add(executable());
      cmdListDTS.add("-y");
      cmdListDTS.add("-ss");

      if (params.timeseek > 0) {
        cmdListDTS.add(String.valueOf(params.timeseek));
      } else {
        cmdListDTS.add("0");
      }

      if (params.stdin == null) {
        cmdListDTS.add("-i");
      } else {
        cmdListDTS.add("-");
      }
      cmdListDTS.add(filename);

      if (params.timeseek > 0) {
        cmdListDTS.add("-copypriorss");
        cmdListDTS.add("0");
        cmdListDTS.add("-avoid_negative_ts");
        cmdListDTS.add("1");
      }

      cmdListDTS.add("-ac");
      cmdListDTS.add("2");

      cmdListDTS.add("-f");
      cmdListDTS.add("dts");

      cmdListDTS.add("-c:a");
      cmdListDTS.add("copy");

      cmdListDTS.add(ffAudioPipe.getInputPipe());

      String[] cmdArrayDTS = new String[cmdListDTS.size()];
      cmdListDTS.toArray(cmdArrayDTS);

      if (!params.mediaRenderer.isMuxDTSToMpeg()) { // No need to use the PCM trick when media renderer supports DTS
        ffAudioPipe.setModifier(sm);
      }

      OutputParams ffaudioparams = new OutputParams(configuration);
      ffaudioparams.maxBufferSize = 1;
      ffaudioparams.stdin = params.stdin;
      ProcessWrapperImpl ffAudio = new ProcessWrapperImpl(cmdArrayDTS, ffaudioparams);

      params.stdin = null;
      try (PrintWriter pwMux = new PrintWriter(f)) {
        pwMux.println("MUXOPT --no-pcr-on-video-pid --no-asyncio --new-audio-pes --vbr --vbv-len=500");
        String videoType = "V_MPEG-2";

        if (renderer.isTranscodeToH264()) {
          videoType = "V_MPEG4/ISO/AVC";
        }

        if (params.no_videoencode && params.forceType != null) {
          videoType = params.forceType;
        }

        StringBuilder fps = new StringBuilder();
        fps.append("");
        if (params.forceFps != null) {
          fps.append("fps=").append(params.forceFps).append(", ");
        }

        String audioType = "A_AC3";
        if (dtsRemux) {
          if (params.mediaRenderer.isMuxDTSToMpeg()) {
            // Renderer can play proper DTS track
            audioType = "A_DTS";
          } else {
            // DTS padded in LPCM trick
            audioType = "A_LPCM";
          }
        }

        pwMux.println(videoType + ", \"" + ffVideoPipe.getOutputPipe() + "\", " + fps + "level=4.1, insertSEI, contSPS, track=1");
        pwMux.println(audioType + ", \"" + ffAudioPipe.getOutputPipe() + "\", track=2");
      }

      ProcessWrapper pipe_process = pipe.getPipeProcess();
      pw.attachProcess(pipe_process);
      pipe_process.runInNewThread();

      try {
        wait(50);
      } catch (InterruptedException e) {
      }

      pipe.deleteLater();
      params.input_pipes[0] = pipe;

      ProcessWrapper ff_pipe_process = ffAudioPipe.getPipeProcess();
      pw.attachProcess(ff_pipe_process);
      ff_pipe_process.runInNewThread();

      try {
        wait(50);
      } catch (InterruptedException e) {
      }

      ffAudioPipe.deleteLater();
      pw.attachProcess(ffAudio);
      ffAudio.runInNewThread();
    }

    pw.runInNewThread();
    return pw;
  }
View Full Code Here

      // let's get that speed
      OutputParams op = new OutputParams(null);
      op.log = true;
      op.maxBufferSize = 1;
      SystemUtils sysUtil = PMS.get().getRegistry();
      final ProcessWrapperImpl pw = new ProcessWrapperImpl(sysUtil.getPingCommand(addr.getHostAddress(), 3, size), op, true, false);
      Runnable r = new Runnable() {
        @Override
        public void run() {
          try {
            Thread.sleep(3000);
          } catch (InterruptedException e) {
          }
          pw.stopProcess();
        }
      };

      Thread failsafe = new Thread(r, "SpeedStats Failsafe");
      failsafe.start();
      pw.runInSameThread();
      List<String> ls = pw.getOtherResults();
      double time = 0;
      int c = 0;
      String timeString;

      for (String line : ls) {
View Full Code Here

      media,
      params,
      cmdArray
    );

    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.attachProcess(mkfifo_process);

    /**
     * It can take a long time for Windows to create a named pipe (and
     * mkfifo can be slow if /tmp isn't memory-mapped), so run this in
     * the current thread.
     */
    mkfifo_process.runInSameThread();

    pipe.deleteLater();

    pw.runInNewThread();

    // Not sure what good this 50ms wait will do for the calling method.
    try {
      Thread.sleep(50);
    } catch (InterruptedException e) {
View Full Code Here

    String cmdArray[] = new String[4];
    cmdArray[0] = configuration.getDCRawPath();
    cmdArray[1] = "-e";
    cmdArray[2] = "-c";
    cmdArray[3] = fileName;
    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.runInSameThread();
    ByteArrayOutputStream baos;
    try (InputStream is = pw.getInputStream(0)) {
      baos = new ByteArrayOutputStream();
      int n = -1;
      byte buffer[] = new byte[4096];
      while ((n = is.read(buffer)) > -1) {
        baos.write(buffer, 0, n);
View Full Code Here

      media,
      params,
      cmdArray
    );

    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.runInNewThread();

    return pw;
  }
View Full Code Here

      media,
      params,
      cmdArray
    );

    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.runInNewThread();

    return pw;
  }
View Full Code Here

      media,
      params,
      cmdArray
    );

    ProcessWrapperImpl pw = new ProcessWrapperImpl(cmdArray, params);
    pw.attachProcess(mkfifo_process);

    // It can take a long time for Windows to create a named pipe (and
    // mkfifo can be slow if /tmp isn't memory-mapped), so run this in the
    // current thread.
    mkfifo_process.runInSameThread();

    pipe.deleteLater();

    pw.runInNewThread();

    // Not sure what good this 50ms wait will do for the calling method.
    try {
      Thread.sleep(50);
    } catch (InterruptedException e) { }
View Full Code Here

TOP

Related Classes of net.pms.io.ProcessWrapperImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.