Program: 47249
Project: 47249
Buggy source:
@Override public ProcessWrapper launchTranscode(DLNAResource dlna,DLNAMediaInfo media,OutputParams params) throws IOException {
  final String filename=dlna.getSystemName();
  setAudioAndSubs(filename,media,params);
  PipeIPCProcess ffVideoPipe;
  ProcessWrapperImpl ffVideo;
  PipeIPCProcess ffAudioPipe[]=null;
  ProcessWrapperImpl ffAudio[]=null;
  String fps=media.getValidFps(false);
  int width=media.getWidth();
  int height=media.getHeight();
  if (width < 320 || height < 240) {
    width=-1;
    height=-1;
  }
  String videoType="String_Node_Str";
  if (media.getCodecV() != null && media.getCodecV().startsWith("String_Node_Str")) {
    videoType="String_Node_Str";
  }
  if (this instanceof TsMuxeRAudio && media.getFirstAudioTrack() != null) {
    ffVideoPipe=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
    String timeEndValue1="String_Node_Str";
    String timeEndValue2="String_Node_Str" + params.timeend;
    if (params.timeend < 1) {
      timeEndValue1="String_Node_Str";
      timeEndValue2="String_Node_Str";
    }
    String[] ffmpegLPCMextract=new String[]{configuration.getFfmpegPath(),timeEndValue1,timeEndValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ffVideoPipe.getInputPipe()};
    videoType="String_Node_Str";
    OutputParams ffparams=new OutputParams(configuration);
    ffparams.maxBufferSize=1;
    ffVideo=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
    if (filename.toLowerCase().endsWith("String_Node_Str") && media.getFirstAudioTrack().getBitsperSample() >= 24 && media.getFirstAudioTrack().getSampleRate() % 48000 == 0) {
      ffAudioPipe=new PipeIPCProcess[1];
      ffAudioPipe[0]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
      String[] flacCmd=new String[]{configuration.getFlacPath(),"String_Node_Str" + ffAudioPipe[0].getInputPipe(),"String_Node_Str","String_Node_Str","String_Node_Str",filename};
      ffparams=new OutputParams(configuration);
      ffparams.maxBufferSize=1;
      ffAudio=new ProcessWrapperImpl[1];
      ffAudio[0]=new ProcessWrapperImpl(flacCmd,ffparams);
    }
 else {
      ffAudioPipe=new PipeIPCProcess[1];
      ffAudioPipe[0]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
      String depth="String_Node_Str";
      String rate="String_Node_Str";
      if (media.getFirstAudioTrack().getBitsperSample() >= 24) {
        depth="String_Node_Str";
      }
      if (media.getFirstAudioTrack().getSampleRate() > 48000) {
        rate="String_Node_Str" + media.getFirstAudioTrack().getSampleRate();
      }
      String[] flacCmd=new String[]{configuration.getFfmpegPath(),"String_Node_Str",filename,"String_Node_Str",rate,"String_Node_Str","String_Node_Str","String_Node_Str",depth,"String_Node_Str",ffAudioPipe[0].getInputPipe()};
      ffparams=new OutputParams(configuration);
      ffparams.maxBufferSize=1;
      ffAudio=new ProcessWrapperImpl[1];
      ffAudio[0]=new ProcessWrapperImpl(flacCmd,ffparams);
    }
  }
 else {
    params.waitbeforestart=5000;
    params.manageFastStart();
    String mencoderPath=configuration.getMencoderPath();
    ffVideoPipe=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
    String evoValue1="String_Node_Str";
    String evoValue2="String_Node_Str";
    if (filename.toLowerCase().endsWith("String_Node_Str")) {
      evoValue1="String_Node_Str";
      evoValue2="String_Node_Str";
    }
    String[] ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ffVideoPipe.getInputPipe()};
    InputFile newInput=new InputFile();
    newInput.setFilename(filename);
    newInput.setPush(params.stdin);
    if (!media.isVideoWithinH264LevelLimits(newInput,params.mediaRenderer) && params.mediaRenderer.isH264Level41Limited()) {
      LOGGER.info("String_Node_Str");
    }
    if (media.getH264AnnexB() != null && media.getH264AnnexB().length > 0) {
      StreamModifier sm=new StreamModifier();
      sm.setHeader(media.getH264AnnexB());
      sm.setH264AnnexB(true);
      ffVideoPipe.setModifier(sm);
    }
    OutputParams ffparams=new OutputParams(configuration);
    ffparams.maxBufferSize=1;
    ffparams.stdin=params.stdin;
    ffVideo=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
    int numAudioTracks=1;
    if (media.getAudioTracksList() != null && media.getAudioTracksList().size() > 1 && configuration.isMuxAllAudioTracks()) {
      numAudioTracks=media.getAudioTracksList().size();
    }
    boolean singleMediaAudio=media.getAudioTracksList().size() <= 1;
    if (params.aid != null) {
      boolean ac3Remux;
      boolean dtsRemux;
      boolean encodedAudioPassthrough;
      boolean pcm;
      boolean mp4_with_non_h264=(media.getContainer().equals("String_Node_Str") && !media.getCodecV().equals("String_Node_Str"));
      if (numAudioTracks <= 1) {
        ffAudioPipe=new PipeIPCProcess[numAudioTracks];
        ffAudioPipe[0]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
        encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
        ac3Remux=params.aid.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
        dtsRemux=configuration.isAudioEmbedDtsInPcm() && params.aid.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
        pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (params.aid.isLossless() || (params.aid.isDTS() && params.aid.getAudioProperties().getNumberOfChannels() <= 6) || params.aid.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (params.aid.isAC3() || params.aid.isMP3() || params.aid.isAAC()|| params.aid.isVorbis()|| params.aid.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
        int channels;
        if (ac3Remux) {
          channels=params.aid.getAudioProperties().getNumberOfChannels();
        }
 else         if (dtsRemux || encodedAudioPassthrough) {
          channels=2;
        }
 else         if (pcm) {
          channels=params.aid.getAudioProperties().getNumberOfChannels();
        }
 else {
          channels=configuration.getAudioChannelCount();
        }
        if (!ac3Remux && (dtsRemux || pcm || encodedAudioPassthrough)) {
          StreamModifier sm=new StreamModifier();
          sm.setPcm(pcm);
          sm.setDtsEmbed(dtsRemux);
          sm.setEncodedAudioPassthrough(encodedAudioPassthrough);
          sm.setNbChannels(channels);
          sm.setSampleFrequency(params.aid.getSampleRate() < 48000 ? 48000 : params.aid.getSampleRate());
          sm.setBitsPerSample(16);
          String mixer=null;
          if (pcm && !dtsRemux && !encodedAudioPassthrough) {
            mixer=getLPCMChannelMappingForMencoder(params.aid);
          }
          ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + sm.getNbChannels(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? mixer : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + params.aid.getId()),"String_Node_Str","String_Node_Str","String_Node_Str",ffAudioPipe[0].getInputPipe()};
          if (!params.mediaRenderer.isMuxDTSToMpeg()) {
            ffAudioPipe[0].setModifier(sm);
          }
        }
 else {
          ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + channels,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",(ac3Remux) ? "String_Node_Str" : "String_Node_Str",params.aid.isAC3() ? "String_Node_Str" : "String_Node_Str",params.aid.isAC3() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str" + (configuration.isMencoderAc3Fixed() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ CodecUtil.getAC3Bitrate(configuration,params.aid),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + params.aid.getId()),"String_Node_Str",ffAudioPipe[0].getInputPipe()};
        }
        ffparams=new OutputParams(configuration);
        ffparams.maxBufferSize=1;
        ffparams.stdin=params.stdin;
        ffAudio=new ProcessWrapperImpl[numAudioTracks];
        ffAudio[0]=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
      }
 else {
        ffAudioPipe=new PipeIPCProcess[numAudioTracks];
        ffAudio=new ProcessWrapperImpl[numAudioTracks];
        for (int i=0; i < media.getAudioTracksList().size(); i++) {
          DLNAMediaAudio audio=media.getAudioTracksList().get(i);
          ffAudioPipe[i]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str" + i,System.currentTimeMillis() + "String_Node_Str" + i,false,true);
          encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
          ac3Remux=audio.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
          dtsRemux=configuration.isAudioEmbedDtsInPcm() && audio.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
          pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (audio.isLossless() || (audio.isDTS() && audio.getAudioProperties().getNumberOfChannels() <= 6) || audio.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (audio.isAC3() || audio.isMP3() || audio.isAAC()|| audio.isVorbis()|| audio.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
          int channels;
          if (ac3Remux) {
            channels=audio.getAudioProperties().getNumberOfChannels();
          }
 else           if (dtsRemux || encodedAudioPassthrough) {
            channels=2;
          }
 else           if (pcm) {
            channels=audio.getAudioProperties().getNumberOfChannels();
          }
 else {
            channels=configuration.getAudioChannelCount();
          }
          if (!ac3Remux && (dtsRemux || pcm || encodedAudioPassthrough)) {
            StreamModifier sm=new StreamModifier();
            sm.setPcm(pcm);
            sm.setDtsEmbed(dtsRemux);
            sm.setEncodedAudioPassthrough(encodedAudioPassthrough);
            sm.setNbChannels(channels);
            sm.setSampleFrequency(audio.getSampleRate() < 48000 ? 48000 : audio.getSampleRate());
            sm.setBitsPerSample(16);
            if (!params.mediaRenderer.isMuxDTSToMpeg()) {
              ffAudioPipe[i].setModifier(sm);
            }
            String mixer=null;
            if (pcm && !dtsRemux && !encodedAudioPassthrough) {
              mixer=getLPCMChannelMappingForMencoder(audio);
            }
            ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + sm.getNbChannels(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? mixer : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + audio.getId()),"String_Node_Str","String_Node_Str","String_Node_Str",ffAudioPipe[i].getInputPipe()};
          }
 else {
            ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + channels,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",(ac3Remux) ? "String_Node_Str" : "String_Node_Str",audio.isAC3() ? "String_Node_Str" : "String_Node_Str",audio.isAC3() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str" + (configuration.isMencoderAc3Fixed() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ CodecUtil.getAC3Bitrate(configuration,audio),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + audio.getId()),"String_Node_Str",ffAudioPipe[i].getInputPipe()};
          }
          ffparams=new OutputParams(configuration);
          ffparams.maxBufferSize=1;
          ffparams.stdin=params.stdin;
          ffAudio[i]=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
        }
      }
    }
  }
  File f=new File(configuration.getTempFolder(),"String_Node_Str");
  params.log=false;
  try (PrintWriter pw=new PrintWriter(f)){
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.println("String_Node_Str");
    String videoparams="String_Node_Str";
    if (this instanceof TsMuxeRAudio) {
      videoparams="String_Node_Str";
    }
    if (configuration.isFix25FPSAvMismatch()) {
      fps="String_Node_Str";
    }
    pw.println(videoType + "String_Node_Str" + ffVideoPipe.getOutputPipe()+ "String_Node_Str"+ (fps != null ? ("String_Node_Str" + fps + "String_Node_Str") : "String_Node_Str")+ (width != -1 ? ("String_Node_Str" + width + "String_Node_Str") : "String_Node_Str")+ (height != -1 ? ("String_Node_Str" + height + "String_Node_Str") : "String_Node_Str")+ videoparams);
    boolean mp4_with_non_h264=(media.getContainer().equals("String_Node_Str") && !media.getCodecV().equals("String_Node_Str"));
    if (ffAudioPipe != null && ffAudioPipe.length == 1) {
      String timeshift="String_Node_Str";
      boolean ac3Remux;
      boolean dtsRemux;
      boolean encodedAudioPassthrough;
      boolean pcm;
      encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
      ac3Remux=params.aid.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
      dtsRemux=configuration.isAudioEmbedDtsInPcm() && params.aid.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
      pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (params.aid.isLossless() || (params.aid.isDTS() && params.aid.getAudioProperties().getNumberOfChannels() <= 6) || params.aid.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (params.aid.isAC3() || params.aid.isMP3() || params.aid.isAAC()|| params.aid.isVorbis()|| params.aid.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
      String type="String_Node_Str";
      if (ac3Remux) {
        type="String_Node_Str";
      }
 else {
        if (pcm || this instanceof TsMuxeRAudio) {
          type="String_Node_Str";
        }
        if (encodedAudioPassthrough || this instanceof TsMuxeRAudio) {
          type="String_Node_Str";
        }
        if (dtsRemux || this instanceof TsMuxeRAudio) {
          type="String_Node_Str";
          if (params.mediaRenderer.isMuxDTSToMpeg()) {
            type="String_Node_Str";
          }
        }
      }
      if (params.aid != null && params.aid.getAudioProperties().getAudioDelay() != 0 && params.timeseek == 0) {
        timeshift="String_Node_Str" + params.aid.getAudioProperties().getAudioDelay() + "String_Node_Str";
      }
      pw.println(type + "String_Node_Str" + ffAudioPipe[0].getOutputPipe()+ "String_Node_Str"+ timeshift+ "String_Node_Str");
    }
 else     if (ffAudioPipe != null) {
      for (int i=0; i < media.getAudioTracksList().size(); i++) {
        DLNAMediaAudio lang=media.getAudioTracksList().get(i);
        String timeshift="String_Node_Str";
        boolean ac3Remux;
        boolean dtsRemux;
        boolean encodedAudioPassthrough;
        boolean pcm;
        encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
        ac3Remux=lang.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
        dtsRemux=configuration.isAudioEmbedDtsInPcm() && lang.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
        pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (lang.isLossless() || (lang.isDTS() && lang.getAudioProperties().getNumberOfChannels() <= 6) || lang.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (params.aid.isAC3() || params.aid.isMP3() || params.aid.isAAC()|| params.aid.isVorbis()|| params.aid.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
        String type="String_Node_Str";
        if (ac3Remux) {
          type="String_Node_Str";
        }
 else {
          if (pcm) {
            type="String_Node_Str";
          }
          if (encodedAudioPassthrough) {
            type="String_Node_Str";
          }
          if (dtsRemux) {
            type="String_Node_Str";
            if (params.mediaRenderer.isMuxDTSToMpeg()) {
              type="String_Node_Str";
            }
          }
        }
        if (lang.getAudioProperties().getAudioDelay() != 0 && params.timeseek == 0) {
          timeshift="String_Node_Str" + lang.getAudioProperties().getAudioDelay() + "String_Node_Str";
        }
        pw.println(type + "String_Node_Str" + ffAudioPipe[i].getOutputPipe()+ "String_Node_Str"+ timeshift+ "String_Node_Str"+ (2 + i));
      }
    }
  }
   PipeProcess tsPipe=new PipeProcess(System.currentTimeMillis() + "String_Node_Str");
  String executable=executable();
  if (params.mediaRenderer.isPS3()) {
    executable=configuration.getTsmuxerNewPath();
  }
  String[] cmdArray=new String[]{executable,f.getAbsolutePath(),tsPipe.getInputPipe()};
  cmdArray=finalizeTranscoderArgs(filename,dlna,media,params,cmdArray);
  ProcessWrapperImpl p=new ProcessWrapperImpl(cmdArray,params);
  params.maxBufferSize=100;
  params.input_pipes[0]=tsPipe;
  params.stdin=null;
  ProcessWrapper pipe_process=tsPipe.getPipeProcess();
  p.attachProcess(pipe_process);
  pipe_process.runInNewThread();
  try {
    Thread.sleep(50);
  }
 catch (  InterruptedException e) {
  }
  tsPipe.deleteLater();
  ProcessWrapper ff_pipe_process=ffVideoPipe.getPipeProcess();
  p.attachProcess(ff_pipe_process);
  ff_pipe_process.runInNewThread();
  try {
    Thread.sleep(50);
  }
 catch (  InterruptedException e) {
  }
  ffVideoPipe.deleteLater();
  p.attachProcess(ffVideo);
  ffVideo.runInNewThread();
  try {
    Thread.sleep(50);
  }
 catch (  InterruptedException e) {
  }
  if (ffAudioPipe != null && params.aid != null) {
    for (int i=0; i < ffAudioPipe.length; i++) {
      ff_pipe_process=ffAudioPipe[i].getPipeProcess();
      p.attachProcess(ff_pipe_process);
      ff_pipe_process.runInNewThread();
      try {
        Thread.sleep(50);
      }
 catch (      InterruptedException e) {
      }
      ffAudioPipe[i].deleteLater();
      p.attachProcess(ffAudio[i]);
      ffAudio[i].runInNewThread();
    }
  }
  try {
    Thread.sleep(100);
  }
 catch (  InterruptedException e) {
  }
  p.runInNewThread();
  return p;
}

Fixed version (ground truth):
@Override public ProcessWrapper launchTranscode(DLNAResource dlna,DLNAMediaInfo media,OutputParams params) throws IOException {
  final String filename=dlna.getSystemName();
  setAudioAndSubs(filename,media,params);
  PipeIPCProcess ffVideoPipe;
  ProcessWrapperImpl ffVideo;
  PipeIPCProcess ffAudioPipe[]=null;
  ProcessWrapperImpl ffAudio[]=null;
  String fps=media.getValidFps(false);
  int width=media.getWidth();
  int height=media.getHeight();
  if (width < 320 || height < 240) {
    width=-1;
    height=-1;
  }
  String videoType="String_Node_Str";
  if (media.getCodecV() != null && media.getCodecV().startsWith("String_Node_Str")) {
    videoType="String_Node_Str";
  }
  if (this instanceof TsMuxeRAudio && media.getFirstAudioTrack() != null) {
    ffVideoPipe=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
    String timeEndValue1="String_Node_Str";
    String timeEndValue2="String_Node_Str" + params.timeend;
    if (params.timeend < 1) {
      timeEndValue1="String_Node_Str";
      timeEndValue2="String_Node_Str";
    }
    String[] ffmpegLPCMextract=new String[]{configuration.getFfmpegPath(),timeEndValue1,timeEndValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ffVideoPipe.getInputPipe()};
    videoType="String_Node_Str";
    OutputParams ffparams=new OutputParams(configuration);
    ffparams.maxBufferSize=1;
    ffVideo=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
    if (filename.toLowerCase().endsWith("String_Node_Str") && media.getFirstAudioTrack().getBitsperSample() >= 24 && media.getFirstAudioTrack().getSampleRate() % 48000 == 0) {
      ffAudioPipe=new PipeIPCProcess[1];
      ffAudioPipe[0]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
      String[] flacCmd=new String[]{configuration.getFlacPath(),"String_Node_Str" + ffAudioPipe[0].getInputPipe(),"String_Node_Str","String_Node_Str","String_Node_Str",filename};
      ffparams=new OutputParams(configuration);
      ffparams.maxBufferSize=1;
      ffAudio=new ProcessWrapperImpl[1];
      ffAudio[0]=new ProcessWrapperImpl(flacCmd,ffparams);
    }
 else {
      ffAudioPipe=new PipeIPCProcess[1];
      ffAudioPipe[0]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
      String depth="String_Node_Str";
      String rate="String_Node_Str";
      if (media.getFirstAudioTrack().getBitsperSample() >= 24) {
        depth="String_Node_Str";
      }
      if (media.getFirstAudioTrack().getSampleRate() > 48000) {
        rate="String_Node_Str" + media.getFirstAudioTrack().getSampleRate();
      }
      String[] flacCmd=new String[]{configuration.getFfmpegPath(),"String_Node_Str",filename,"String_Node_Str",rate,"String_Node_Str","String_Node_Str","String_Node_Str",depth,"String_Node_Str",ffAudioPipe[0].getInputPipe()};
      ffparams=new OutputParams(configuration);
      ffparams.maxBufferSize=1;
      ffAudio=new ProcessWrapperImpl[1];
      ffAudio[0]=new ProcessWrapperImpl(flacCmd,ffparams);
    }
  }
 else {
    params.waitbeforestart=5000;
    params.manageFastStart();
    String mencoderPath=configuration.getMencoderPath();
    ffVideoPipe=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
    String evoValue1="String_Node_Str";
    String evoValue2="String_Node_Str";
    if (filename.toLowerCase().endsWith("String_Node_Str")) {
      evoValue1="String_Node_Str";
      evoValue2="String_Node_Str";
    }
    String[] ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",ffVideoPipe.getInputPipe()};
    InputFile newInput=new InputFile();
    newInput.setFilename(filename);
    newInput.setPush(params.stdin);
    if (!media.isVideoWithinH264LevelLimits(newInput,params.mediaRenderer) && params.mediaRenderer.isH264Level41Limited()) {
      LOGGER.info("String_Node_Str");
    }
    if (media.getH264AnnexB() != null && media.getH264AnnexB().length > 0) {
      StreamModifier sm=new StreamModifier();
      sm.setHeader(media.getH264AnnexB());
      sm.setH264AnnexB(true);
      ffVideoPipe.setModifier(sm);
    }
    OutputParams ffparams=new OutputParams(configuration);
    ffparams.maxBufferSize=1;
    ffparams.stdin=params.stdin;
    ffVideo=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
    int numAudioTracks=1;
    if (media.getAudioTracksList() != null && media.getAudioTracksList().size() > 1 && configuration.isMuxAllAudioTracks()) {
      numAudioTracks=media.getAudioTracksList().size();
    }
    boolean singleMediaAudio=media.getAudioTracksList().size() <= 1;
    if (params.aid != null) {
      boolean ac3Remux;
      boolean dtsRemux;
      boolean encodedAudioPassthrough;
      boolean pcm;
      boolean mp4_with_non_h264=(media.getContainer().equals("String_Node_Str") && !media.isH264());
      if (numAudioTracks <= 1) {
        ffAudioPipe=new PipeIPCProcess[numAudioTracks];
        ffAudioPipe[0]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str",System.currentTimeMillis() + "String_Node_Str",false,true);
        encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
        ac3Remux=params.aid.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
        dtsRemux=configuration.isAudioEmbedDtsInPcm() && params.aid.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
        pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (params.aid.isLossless() || (params.aid.isDTS() && params.aid.getAudioProperties().getNumberOfChannels() <= 6) || params.aid.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (params.aid.isAC3() || params.aid.isMP3() || params.aid.isAAC()|| params.aid.isVorbis()|| params.aid.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
        int channels;
        if (ac3Remux) {
          channels=params.aid.getAudioProperties().getNumberOfChannels();
        }
 else         if (dtsRemux || encodedAudioPassthrough) {
          channels=2;
        }
 else         if (pcm) {
          channels=params.aid.getAudioProperties().getNumberOfChannels();
        }
 else {
          channels=configuration.getAudioChannelCount();
        }
        if (!ac3Remux && (dtsRemux || pcm || encodedAudioPassthrough)) {
          StreamModifier sm=new StreamModifier();
          sm.setPcm(pcm);
          sm.setDtsEmbed(dtsRemux);
          sm.setEncodedAudioPassthrough(encodedAudioPassthrough);
          sm.setNbChannels(channels);
          sm.setSampleFrequency(params.aid.getSampleRate() < 48000 ? 48000 : params.aid.getSampleRate());
          sm.setBitsPerSample(16);
          String mixer=null;
          if (pcm && !dtsRemux && !encodedAudioPassthrough) {
            mixer=getLPCMChannelMappingForMencoder(params.aid);
          }
          ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + sm.getNbChannels(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? mixer : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + params.aid.getId()),"String_Node_Str","String_Node_Str","String_Node_Str",ffAudioPipe[0].getInputPipe()};
          if (!params.mediaRenderer.isMuxDTSToMpeg()) {
            ffAudioPipe[0].setModifier(sm);
          }
        }
 else {
          ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + channels,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",(ac3Remux) ? "String_Node_Str" : "String_Node_Str",params.aid.isAC3() ? "String_Node_Str" : "String_Node_Str",params.aid.isAC3() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str" + (configuration.isMencoderAc3Fixed() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ CodecUtil.getAC3Bitrate(configuration,params.aid),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + params.aid.getId()),"String_Node_Str",ffAudioPipe[0].getInputPipe()};
        }
        ffparams=new OutputParams(configuration);
        ffparams.maxBufferSize=1;
        ffparams.stdin=params.stdin;
        ffAudio=new ProcessWrapperImpl[numAudioTracks];
        ffAudio[0]=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
      }
 else {
        ffAudioPipe=new PipeIPCProcess[numAudioTracks];
        ffAudio=new ProcessWrapperImpl[numAudioTracks];
        for (int i=0; i < media.getAudioTracksList().size(); i++) {
          DLNAMediaAudio audio=media.getAudioTracksList().get(i);
          ffAudioPipe[i]=new PipeIPCProcess(System.currentTimeMillis() + "String_Node_Str" + i,System.currentTimeMillis() + "String_Node_Str" + i,false,true);
          encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
          ac3Remux=audio.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
          dtsRemux=configuration.isAudioEmbedDtsInPcm() && audio.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
          pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (audio.isLossless() || (audio.isDTS() && audio.getAudioProperties().getNumberOfChannels() <= 6) || audio.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (audio.isAC3() || audio.isMP3() || audio.isAAC()|| audio.isVorbis()|| audio.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
          int channels;
          if (ac3Remux) {
            channels=audio.getAudioProperties().getNumberOfChannels();
          }
 else           if (dtsRemux || encodedAudioPassthrough) {
            channels=2;
          }
 else           if (pcm) {
            channels=audio.getAudioProperties().getNumberOfChannels();
          }
 else {
            channels=configuration.getAudioChannelCount();
          }
          if (!ac3Remux && (dtsRemux || pcm || encodedAudioPassthrough)) {
            StreamModifier sm=new StreamModifier();
            sm.setPcm(pcm);
            sm.setDtsEmbed(dtsRemux);
            sm.setEncodedAudioPassthrough(encodedAudioPassthrough);
            sm.setNbChannels(channels);
            sm.setSampleFrequency(audio.getSampleRate() < 48000 ? 48000 : audio.getSampleRate());
            sm.setBitsPerSample(16);
            if (!params.mediaRenderer.isMuxDTSToMpeg()) {
              ffAudioPipe[i].setModifier(sm);
            }
            String mixer=null;
            if (pcm && !dtsRemux && !encodedAudioPassthrough) {
              mixer=getLPCMChannelMappingForMencoder(audio);
            }
            ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + sm.getNbChannels(),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str",sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? "String_Node_Str" : "String_Node_Str",isNotBlank(mixer) ? mixer : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + audio.getId()),"String_Node_Str","String_Node_Str","String_Node_Str",ffAudioPipe[i].getInputPipe()};
          }
 else {
            ffmpegLPCMextract=new String[]{mencoderPath,"String_Node_Str",params.timeseek > 0 ? "String_Node_Str" + params.timeseek : "String_Node_Str",params.stdin != null ? "String_Node_Str" : filename,evoValue1,evoValue2,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str" + channels,"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",(ac3Remux) ? "String_Node_Str" : "String_Node_Str",audio.isAC3() ? "String_Node_Str" : "String_Node_Str",audio.isAC3() ? "String_Node_Str" : "String_Node_Str","String_Node_Str","String_Node_Str" + (configuration.isMencoderAc3Fixed() ? "String_Node_Str" : "String_Node_Str") + "String_Node_Str"+ CodecUtil.getAC3Bitrate(configuration,audio),"String_Node_Str","String_Node_Str","String_Node_Str","String_Node_Str",singleMediaAudio ? "String_Node_Str" : "String_Node_Str",singleMediaAudio ? "String_Node_Str" : ("String_Node_Str" + audio.getId()),"String_Node_Str",ffAudioPipe[i].getInputPipe()};
          }
          ffparams=new OutputParams(configuration);
          ffparams.maxBufferSize=1;
          ffparams.stdin=params.stdin;
          ffAudio[i]=new ProcessWrapperImpl(ffmpegLPCMextract,ffparams);
        }
      }
    }
  }
  File f=new File(configuration.getTempFolder(),"String_Node_Str");
  params.log=false;
  try (PrintWriter pw=new PrintWriter(f)){
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.print("String_Node_Str");
    pw.println("String_Node_Str");
    String videoparams="String_Node_Str";
    if (this instanceof TsMuxeRAudio) {
      videoparams="String_Node_Str";
    }
    if (configuration.isFix25FPSAvMismatch()) {
      fps="String_Node_Str";
    }
    pw.println(videoType + "String_Node_Str" + ffVideoPipe.getOutputPipe()+ "String_Node_Str"+ (fps != null ? ("String_Node_Str" + fps + "String_Node_Str") : "String_Node_Str")+ (width != -1 ? ("String_Node_Str" + width + "String_Node_Str") : "String_Node_Str")+ (height != -1 ? ("String_Node_Str" + height + "String_Node_Str") : "String_Node_Str")+ videoparams);
    boolean mp4_with_non_h264=(media.getContainer().equals("String_Node_Str") && !media.isH264());
    if (ffAudioPipe != null && ffAudioPipe.length == 1) {
      String timeshift="String_Node_Str";
      boolean ac3Remux;
      boolean dtsRemux;
      boolean encodedAudioPassthrough;
      boolean pcm;
      encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
      ac3Remux=params.aid.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
      dtsRemux=configuration.isAudioEmbedDtsInPcm() && params.aid.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
      pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (params.aid.isLossless() || (params.aid.isDTS() && params.aid.getAudioProperties().getNumberOfChannels() <= 6) || params.aid.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (params.aid.isAC3() || params.aid.isMP3() || params.aid.isAAC()|| params.aid.isVorbis()|| params.aid.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
      String type="String_Node_Str";
      if (ac3Remux) {
        type="String_Node_Str";
      }
 else {
        if (pcm || this instanceof TsMuxeRAudio) {
          type="String_Node_Str";
        }
        if (encodedAudioPassthrough || this instanceof TsMuxeRAudio) {
          type="String_Node_Str";
        }
        if (dtsRemux || this instanceof TsMuxeRAudio) {
          type="String_Node_Str";
          if (params.mediaRenderer.isMuxDTSToMpeg()) {
            type="String_Node_Str";
          }
        }
      }
      if (params.aid != null && params.aid.getAudioProperties().getAudioDelay() != 0 && params.timeseek == 0) {
        timeshift="String_Node_Str" + params.aid.getAudioProperties().getAudioDelay() + "String_Node_Str";
      }
      pw.println(type + "String_Node_Str" + ffAudioPipe[0].getOutputPipe()+ "String_Node_Str"+ timeshift+ "String_Node_Str");
    }
 else     if (ffAudioPipe != null) {
      for (int i=0; i < media.getAudioTracksList().size(); i++) {
        DLNAMediaAudio lang=media.getAudioTracksList().get(i);
        String timeshift="String_Node_Str";
        boolean ac3Remux;
        boolean dtsRemux;
        boolean encodedAudioPassthrough;
        boolean pcm;
        encodedAudioPassthrough=configuration.isEncodedAudioPassthrough() && params.aid.isNonPCMEncodedAudio() && params.mediaRenderer.isWrapEncodedAudioIntoPCM();
        ac3Remux=lang.isAC3() && configuration.isAudioRemuxAC3() && !encodedAudioPassthrough;
        dtsRemux=configuration.isAudioEmbedDtsInPcm() && lang.isDTS() && params.mediaRenderer.isDTSPlayable()&& !encodedAudioPassthrough;
        pcm=configuration.isAudioUsePCM() && !mp4_with_non_h264 && (lang.isLossless() || (lang.isDTS() && lang.getAudioProperties().getNumberOfChannels() <= 6) || lang.isTrueHD()|| (!configuration.isMencoderUsePcmForHQAudioOnly() && (params.aid.isAC3() || params.aid.isMP3() || params.aid.isAAC()|| params.aid.isVorbis()|| params.aid.isMpegAudio())))&& params.mediaRenderer.isLPCMPlayable();
        String type="String_Node_Str";
        if (ac3Remux) {
          type="String_Node_Str";
        }
 else {
          if (pcm) {
            type="String_Node_Str";
          }
          if (encodedAudioPassthrough) {
            type="String_Node_Str";
          }
          if (dtsRemux) {
            type="String_Node_Str";
            if (params.mediaRenderer.isMuxDTSToMpeg()) {
              type="String_Node_Str";
            }
          }
        }
        if (lang.getAudioProperties().getAudioDelay() != 0 && params.timeseek == 0) {
          timeshift="String_Node_Str" + lang.getAudioProperties().getAudioDelay() + "String_Node_Str";
        }
        pw.println(type + "String_Node_Str" + ffAudioPipe[i].getOutputPipe()+ "String_Node_Str"+ timeshift+ "String_Node_Str"+ (2 + i));
      }
    }
  }
   PipeProcess tsPipe=new PipeProcess(System.currentTimeMillis() + "String_Node_Str");
  String executable=executable();
  if (params.mediaRenderer.isPS3()) {
    executable=configuration.getTsmuxerNewPath();
  }
  String[] cmdArray=new String[]{executable,f.getAbsolutePath(),tsPipe.getInputPipe()};
  cmdArray=finalizeTranscoderArgs(filename,dlna,media,params,cmdArray);
  ProcessWrapperImpl p=new ProcessWrapperImpl(cmdArray,params);
  params.maxBufferSize=100;
  params.input_pipes[0]=tsPipe;
  params.stdin=null;
  ProcessWrapper pipe_process=tsPipe.getPipeProcess();
  p.attachProcess(pipe_process);
  pipe_process.runInNewThread();
  try {
    Thread.sleep(50);
  }
 catch (  InterruptedException e) {
  }
  tsPipe.deleteLater();
  ProcessWrapper ff_pipe_process=ffVideoPipe.getPipeProcess();
  p.attachProcess(ff_pipe_process);
  ff_pipe_process.runInNewThread();
  try {
    Thread.sleep(50);
  }
 catch (  InterruptedException e) {
  }
  ffVideoPipe.deleteLater();
  p.attachProcess(ffVideo);
  ffVideo.runInNewThread();
  try {
    Thread.sleep(50);
  }
 catch (  InterruptedException e) {
  }
  if (ffAudioPipe != null && params.aid != null) {
    for (int i=0; i < ffAudioPipe.length; i++) {
      ff_pipe_process=ffAudioPipe[i].getPipeProcess();
      p.attachProcess(ff_pipe_process);
      ff_pipe_process.runInNewThread();
      try {
        Thread.sleep(50);
      }
 catch (      InterruptedException e) {
      }
      ffAudioPipe[i].deleteLater();
      p.attachProcess(ffAudio[i]);
      ffAudio[i].runInNewThread();
    }
  }
  try {
    Thread.sleep(100);
  }
 catch (  InterruptedException e) {
  }
  p.runInNewThread();
  return p;
}