Package net.pms.dlna

Examples of net.pms.dlna.DLNAMediaAudio


    // Construct regular two channel MP3 information
    DLNAMediaInfo info = new DLNAMediaInfo();
    info.setContainer("mp3");
    info.setMimeType(HTTPResource.AUDIO_MP3_TYPEMIME);
    DLNAMediaAudio audio = new DLNAMediaAudio();
    audio.getAudioProperties().setNumberOfChannels(2);
    List<DLNAMediaAudio> audioCodes = new ArrayList<>();
    audioCodes.add(audio);
    info.setAudioTracksList(audioCodes);
    Format format = new MP3();
    format.match("test.mp3");
    assertEquals("PS3 is compatible with MP3", true,
        conf.isCompatible(info, format));

    // Construct five channel MP3 that the PS3 does not support natively
    audio.getAudioProperties().setNumberOfChannels(5);
    assertEquals("PS3 is incompatible with five channel MP3", false,
        conf.isCompatible(info, format));
  }
View Full Code Here


    assertNotNull("Renderer named \"Playstation 3\" found.", conf);

    // Construct regular two channel MPG information
    DLNAMediaInfo info = new DLNAMediaInfo();
    info.setContainer("avi");
    DLNAMediaAudio audio = new DLNAMediaAudio();
    audio.setCodecA("ac3");
    audio.getAudioProperties().setNumberOfChannels(5);
    List<DLNAMediaAudio> audioCodes = new ArrayList<>();
    audioCodes.add(audio);
    info.setAudioTracksList(audioCodes);
    info.setCodecV("mp4");
    Format format = new MPG();
View Full Code Here

    assertNotNull("Renderer named \"Playstation 3\" found.", conf);

    // Construct MKV information
    DLNAMediaInfo info = new DLNAMediaInfo();
    info.setContainer("mkv");
    DLNAMediaAudio audio = new DLNAMediaAudio();
    audio.setCodecA("ac3");
    audio.getAudioProperties().setNumberOfChannels(5);
    List<DLNAMediaAudio> audioCodes = new ArrayList<>();
    audioCodes.add(audio);
    info.setAudioTracksList(audioCodes);
    info.setCodecV("mp4");
    Format format = new MPG();
View Full Code Here

      boolean keep = res.getName().toLowerCase().contains(searchCriteria);
      final DLNAMediaInfo media = res.getMedia();

      if (!keep && media != null && media.getAudioTracksList() != null) {
        for (int j = 0; j < media.getAudioTracksList().size(); j++) {
          DLNAMediaAudio audio = media.getAudioTracksList().get(j);
          if (audio.getAlbum() != null) {
            keep |= audio.getAlbum().toLowerCase().contains(searchCriteria);
          }
          if (audio.getArtist() != null) {
            keep |= audio.getArtist().toLowerCase().contains(searchCriteria);
          }
          if (audio.getSongname() != null) {
            keep |= audio.getSongname().toLowerCase().contains(searchCriteria);
          }
        }
      }

      if (!keep) { // dump it
View Full Code Here

          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() + "ffmpeg" + i, System.currentTimeMillis() + "audioout" + i, false, true);

            /**
             * Disable AC3 remux for stereo tracks with 384 kbits bitrate and PS3 renderer (PS3 FW bug?)
             *
             * Commented out until we can find a way to detect when a video has an audio track that switches from 2 to 6 channels
             * because MEncoder can't handle those files, which are very common these days.
            boolean ps3_and_stereo_and_384_kbits = params.aid != null &&
              (params.mediaRenderer.isPS3() && params.aid.getAudioProperties().getNumberOfChannels() == 2) &&
              (params.aid.getBitRate() > 370000 && params.aid.getBitRate() < 400000);
             */

            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() &&
              media.isValidForLPCMTranscoding() &&
              (
                audio.isLossless() ||
                (audio.isDTS() && audio.getAudioProperties().getNumberOfChannels() <= 6) ||
                audio.isTrueHD() ||
                (
                  !configuration.isMencoderUsePcmForHQAudioOnly() &&
                  (
                    audio.isAC3() ||
                    audio.isMP3() ||
                    audio.isAAC() ||
                    audio.isVorbis() ||
                    // audio.isWMA() ||
                    audio.isMpegAudio()
                  )
                )
              ) && params.mediaRenderer.isLPCMPlayable();

            int channels;
            if (ac3Remux) {
              channels = audio.getAudioProperties().getNumberOfChannels(); // AC-3 remux
            } else if (dtsRemux || encodedAudioPassthrough) {
              channels = 2;
            } else if (pcm) {
              channels = audio.getAudioProperties().getNumberOfChannels();
            } else {
              channels = configuration.getAudioChannelCount(); // 5.1 max for AC-3 encoding
            }

            if (!ac3Remux && (dtsRemux || pcm || encodedAudioPassthrough)) {
              // DTS remux or LPCM
              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,
                "-ss", params.timeseek > 0 ? "" + params.timeseek : "0",
                params.stdin != null ? "-" : filename,
                evoValue1, evoValue2,
                "-really-quiet",
                "-msglevel", "statusline=2",
                "-channels", "" + sm.getNbChannels(),
                "-ovc", "copy",
                "-of", "rawaudio",
                "-mc", sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "0.1" : "0",
                "-noskip",
                "-oac", sm.isDtsEmbed() || sm.isEncodedAudioPassthrough() ? "copy" : "pcm",
                isNotBlank(mixer) ? "-af" : "-quiet", isNotBlank(mixer) ? mixer : "-quiet",
                singleMediaAudio ? "-quiet" : "-aid", singleMediaAudio ? "-quiet" : ("" + audio.getId()),
                "-srate", "48000",
                "-o", ffAudioPipe[i].getInputPipe()
              };
            } else {
              // AC-3 remux or encoding
              ffmpegLPCMextract = new String[]{
                mencoderPath,
                "-ss", params.timeseek > 0 ? "" + params.timeseek : "0",
                params.stdin != null ? "-" : filename,
                evoValue1, evoValue2,
                "-really-quiet",
                "-msglevel", "statusline=2",
                "-channels", "" + channels,
                "-ovc", "copy",
                "-of", "rawaudio",
                "-mc", "0",
                "-noskip",
                "-oac", (ac3Remux) ? "copy" : "lavc",
                audio.isAC3() ? "-fafmttag" : "-quiet", audio.isAC3() ? "0x2000" : "-quiet",
                "-lavcopts", "acodec=" + (configuration.isMencoderAc3Fixed() ? "ac3_fixed" : "ac3") + ":abitrate=" + CodecUtil.getAC3Bitrate(configuration, audio),
                "-af", "lavcresample=48000",
                "-srate", "48000",
                singleMediaAudio ? "-quiet" : "-aid", singleMediaAudio ? "-quiet" : ("" + audio.getId()),
                "-o", 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(), "pms-tsmuxer.meta");
    params.log = false;
    try (PrintWriter pw = new PrintWriter(f)) {
      pw.print("MUXOPT --no-pcr-on-video-pid");
      pw.print(" --new-audio-pes");
      pw.print(" --no-asyncio");
      pw.print(" --vbr");
      pw.println(" --vbv-len=500");

      String videoparams = "level=4.1, insertSEI, contSPS, track=1";
      if (this instanceof TsMuxeRAudio) {
        videoparams = "track=224";
      }
      if (configuration.isFix25FPSAvMismatch()) {
        fps = "25";
      }
      pw.println(videoType + ", \"" + ffVideoPipe.getOutputPipe() + "\", " + (fps != null ? ("fps=" + fps + ", ") : "") + (width != -1 ? ("video-width=" + width + ", ") : "") + (height != -1 ? ("video-height=" + height + ", ") : "") + videoparams);

      if (ffAudioPipe != null && ffAudioPipe.length == 1) {
        String timeshift = "";
        boolean ac3Remux;
        boolean dtsRemux;
        boolean encodedAudioPassthrough;
        boolean pcm;

        /**
         * Disable AC3 remux for stereo tracks with 384 kbits bitrate and PS3 renderer (PS3 FW bug?)
         *
         * Commented out until we can find a way to detect when a video has an audio track that switches from 2 to 6 channels
         * because MEncoder can't handle those files, which are very common these days.
        boolean ps3_and_stereo_and_384_kbits = params.aid != null &&
          (params.mediaRenderer.isPS3() && params.aid.getAudioProperties().getNumberOfChannels() == 2) &&
          (params.aid.getBitRate() > 370000 && params.aid.getBitRate() < 400000);
         */

        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() &&
          media.isValidForLPCMTranscoding() &&
          (
            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.isWMA() ||
                params.aid.isMpegAudio()
              )
            )
          ) && params.mediaRenderer.isLPCMPlayable();
        String type = "A_AC3";
        if (ac3Remux) {
          // AC-3 remux takes priority
          type = "A_AC3";
        } else {
          if (pcm || this instanceof TsMuxeRAudio) {
            type = "A_LPCM";
          }
          if (encodedAudioPassthrough || this instanceof TsMuxeRAudio) {
            type = "A_LPCM";
          }
          if (dtsRemux || this instanceof TsMuxeRAudio) {
            type = "A_LPCM";
            if (params.mediaRenderer.isMuxDTSToMpeg()) {
              type = "A_DTS";
            }
          }
        }
        if (params.aid != null && params.aid.getAudioProperties().getAudioDelay() != 0 && params.timeseek == 0) {
          timeshift = "timeshift=" + params.aid.getAudioProperties().getAudioDelay() + "ms, ";
        }
        pw.println(type + ", \"" + ffAudioPipe[0].getOutputPipe() + "\", " + timeshift + "track=2");
      } else if (ffAudioPipe != null) {
        for (int i = 0; i < media.getAudioTracksList().size(); i++) {
          DLNAMediaAudio lang = media.getAudioTracksList().get(i);
          String timeshift = "";
          boolean ac3Remux;
          boolean dtsRemux;
          boolean encodedAudioPassthrough;
          boolean pcm;

          /**
           * Disable AC3 remux for stereo tracks with 384 kbits bitrate and PS3 renderer (PS3 FW bug?)
           *
           * Commented out until we can find a way to detect when a video has an audio track that switches from 2 to 6 channels
           * because MEncoder can't handle those files, which are very common these days.
          boolean ps3_and_stereo_and_384_kbits = params.aid != null &&
            (params.mediaRenderer.isPS3() && params.aid.getAudioProperties().getNumberOfChannels() == 2) &&
            (params.aid.getBitRate() > 370000 && params.aid.getBitRate() < 400000);
           */

          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() &&
            media.isValidForLPCMTranscoding() &&
            (
              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.isWMA() ||
                  params.aid.isMpegAudio()
                )
              )
            ) && params.mediaRenderer.isLPCMPlayable();
          String type = "A_AC3";
          if (ac3Remux) {
            // AC-3 remux takes priority
            type = "A_AC3";
          } else {
            if (pcm) {
              type = "A_LPCM";
            }
            if (encodedAudioPassthrough) {
              type = "A_LPCM";
            }
            if (dtsRemux) {
              type = "A_LPCM";
              if (params.mediaRenderer.isMuxDTSToMpeg()) {
                type = "A_DTS";
              }
            }
          }
          if (lang.getAudioProperties().getAudioDelay() != 0 && params.timeseek == 0) {
            timeshift = "timeshift=" + lang.getAudioProperties().getAudioDelay() + "ms, ";
          }
          pw.println(type + ", \"" + ffAudioPipe[i].getOutputPipe() + "\", " + timeshift + "track=" + (2 + i));
        }
      }
    }
View Full Code Here

   * The parameters to populate.
   */
  public static void setAudioOutputParameters(DLNAMediaInfo media, OutputParams params) {
    if (params.aid == null && media != null && media.getFirstAudioTrack() != null) {
      // check for preferred audio
      DLNAMediaAudio dtsTrack = null;
      StringTokenizer st = new StringTokenizer(configuration.getAudioLanguages(), ",");
      while (st.hasMoreTokens()) {
        String lang = st.nextToken().trim();
        LOGGER.trace("Looking for an audio track with lang: " + lang);
        for (DLNAMediaAudio audio : media.getAudioTracksList()) {
View Full Code Here

        while (JOptionPane.showOptionDialog(SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()),
          codecPanel, Messages.getString("MEncoderVideo.34"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, null, null) == JOptionPane.OK_OPTION) {
          String newCodecparam = textArea.getText();
          DLNAMediaInfo fakemedia = new DLNAMediaInfo();
          DLNAMediaAudio audio = new DLNAMediaAudio();
          audio.setCodecA("ac3");
          fakemedia.setCodecV("mpeg4");
          fakemedia.setContainer("matroska");
          fakemedia.setDuration(45d*60);
          audio.getAudioProperties().setNumberOfChannels(2);
          fakemedia.setWidth(1280);
          fakemedia.setHeight(720);
          audio.setSampleFrequency("48000");
          fakemedia.setFrameRate("23.976");
          fakemedia.getAudioTracksList().add(audio);
          String result[] = getSpecificCodecOptions(newCodecparam, fakemedia, new OutputParams(configuration), "dummy.mpg", "dummy.srt", false, true);

          if (result.length > 0 && result[0].startsWith("@@")) {
View Full Code Here

    // Construct regular two channel MP3 information
    DLNAMediaInfo info = new DLNAMediaInfo();
    info.setContainer("mp3");
    info.setMimeType(HTTPResource.AUDIO_MP3_TYPEMIME);
    DLNAMediaAudio audio = new DLNAMediaAudio();
    audio.getAudioProperties().setNumberOfChannels(2);
    List<DLNAMediaAudio> audioCodes = new ArrayList<DLNAMediaAudio>();
    audioCodes.add(audio);
    info.setAudioTracksList(audioCodes);
    Format format = new MP3();
    format.match("test.mp3");
    assertEquals("PS3 is compatible with MP3", true,
        conf.isCompatible(info, format));

    // Construct five channel MP3 that the PS3 does not support natively
    audio.getAudioProperties().setNumberOfChannels(5);
    assertEquals("PS3 is incompatible with five channel MP3", false,
        conf.isCompatible(info, format));
  }
View Full Code Here

    assertNotNull("Renderer named \"Playstation 3\" found.", conf);

    // Construct regular two channel MPG information
    DLNAMediaInfo info = new DLNAMediaInfo();
    info.setContainer("avi");
    DLNAMediaAudio audio = new DLNAMediaAudio();
    audio.setCodecA("ac3");
    audio.getAudioProperties().setNumberOfChannels(5);
    List<DLNAMediaAudio> audioCodes = new ArrayList<DLNAMediaAudio>();
    audioCodes.add(audio);
    info.setAudioTracksList(audioCodes);
    info.setCodecV("mp4");
    Format format = new MPG();
View Full Code Here

    assertNotNull("Renderer named \"Playstation 3\" found.", conf);

    // Construct MKV information
    DLNAMediaInfo info = new DLNAMediaInfo();
    info.setContainer("mkv");
    DLNAMediaAudio audio = new DLNAMediaAudio();
    audio.setCodecA("ac3");
    audio.getAudioProperties().setNumberOfChannels(5);
    List<DLNAMediaAudio> audioCodes = new ArrayList<DLNAMediaAudio>();
    audioCodes.add(audio);
    info.setAudioTracksList(audioCodes);
    info.setCodecV("mp4");
    Format format = new MPG();
View Full Code Here

TOP

Related Classes of net.pms.dlna.DLNAMediaAudio

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.