コード例 #1
0
ファイル: DvdAnalyzer.java プロジェクト: thedarkman/feinrip
  /** Returns the number of the longest track. */
  public int getLongestTrack() {
    int maxTitle = 0;
    long maxLength = 0;

    for (int ix = 0; ix < info.getTitles().size(); ix++) {
      DvdTitle title = info.getTitle(ix);
      if (title.getTotalTimeMs() > maxLength) {
        maxTitle = ix;
        maxLength = title.getTotalTimeMs();
      }
    }

    return maxTitle + 1;
  }
コード例 #2
0
ファイル: DvdAnalyzer.java プロジェクト: thedarkman/feinrip
  /**
   * Gets all {@link Audio} streams of a track.
   *
   * @param trackNr Track number, starting from 1
   * @return List of {@link Audio} streams found
   */
  public List<Audio> getAudios(int trackNr) {
    if (trackNr <= 0) {
      return Collections.emptyList();
    }

    DvdTitle title = info.getTitle(trackNr - 1);
    DvdTitleSet vts = title.getTitleSet();

    List<Audio> result = new ArrayList<>();

    for (int ix = 0; ix < vts.getAudios().size(); ix++) {
      DvdAudio da = vts.getAudios().get(ix);
      if (da.getStreamId() == null) {
        continue;
      }

      Audio audio = new Audio();
      audio.setIx(ix + 1);
      audio.setFormat(da.getMode().toString().toLowerCase());
      audio.setChannels(da.getChannels());
      audio.setStreamId(da.getStreamId());
      audio.setType(AudioType.NOT_SPECIFIED);

      if (da.getType() != null) {
        try {
          audio.setType(AudioType.valueOf(da.getType().name()));
        } catch (IllegalArgumentException ex) {
          // ignore
        }
      }

      Language language = LanguageUtils.findLanguage(da.getLang());
      if (language != null) {
        audio.setLanguage(language);
        audio.setEnabled(true);
      } else {
        audio.setLanguage(LanguageUtils.getMissing());
        audio.setEnabled(false);
      }

      result.add(audio);
    }

    return result;
  }
コード例 #3
0
ファイル: DvdAnalyzer.java プロジェクト: thedarkman/feinrip
  /**
   * Gets all {@link Subtitle} of a track.
   *
   * @param trackNr Track number, starting from 1
   * @return List of {@link Subtitle} found
   */
  public List<Subtitle> getSubtitles(int trackNr) {
    if (trackNr <= 0) {
      return Collections.emptyList();
    }

    DvdTitle title = info.getTitle(trackNr - 1);
    DvdTitleSet vts = title.getTitleSet();

    List<Subtitle> result = new ArrayList<>();
    Set<Integer> seen = new HashSet<>(); // make sure streams appear only once

    int index = 1;
    for (DvdSubtitle ds : vts.getSubs()) {
      if (ds.getStream43Id() != null && !seen.contains(ds.getStream43Id())) {
        result.add(
            createSubtitle(
                index++, ds.getStream43Id(), title.getVtsn(), ds, SubtitleFormat.STANDARD));
        seen.add(ds.getStream43Id());
      }

      if (ds.getStreamWideId() != null && !seen.contains(ds.getStreamWideId())) {
        result.add(
            createSubtitle(
                index++, ds.getStreamWideId(), title.getVtsn(), ds, SubtitleFormat.WIDE));
        seen.add(ds.getStreamWideId());
      }

      if (ds.getStreamLetterboxId() != null && !seen.contains(ds.getStreamLetterboxId())) {
        result.add(
            createSubtitle(
                index++, ds.getStreamLetterboxId(), title.getVtsn(), ds, SubtitleFormat.LETTERBOX));
        seen.add(ds.getStreamLetterboxId());
      }

      if (ds.getStreamPanScanId() != null && !seen.contains(ds.getStreamPanScanId())) {
        result.add(
            createSubtitle(
                index++, ds.getStreamPanScanId(), title.getVtsn(), ds, SubtitleFormat.PANSCAN));
        seen.add(ds.getStreamPanScanId());
      }
    }

    return result;
  }
コード例 #4
0
ファイル: DvdAnalyzer.java プロジェクト: thedarkman/feinrip
  /**
   * Analyzes a DVD track and returns all chapters.
   *
   * @param trackNr Track number to be analyzed, starting from 1
   * @return List of {@link Chapter} entities
   */
  public List<Chapter> getChapters(int trackNr) {
    if (trackNr <= 0) {
      return Collections.emptyList();
    }

    DvdTitle title = info.getTitle(trackNr - 1);
    int chapters = title.getChapters();

    List<Chapter> result = new ArrayList<>();

    long ms = 0;
    int chapter = 1;
    for (long time : title.getChapterTimeMs()) {
      result.add(createChapter(chapter++, ms, chapters));
      ms += time;
    }
    result.add(createChapter(chapter, ms, chapters));

    return result;
  }
コード例 #5
0
ファイル: DvdAnalyzer.java プロジェクト: thedarkman/feinrip
  /** Gets a description of all {@link Track} of the DVD. */
  public Track[] getTracks() {
    Track[] result = new Track[info.getTitles().size()];

    for (int ix = 0; ix < result.length; ix++) {
      DvdTitle title = info.getTitle(ix);
      DvdTitleSet vts = title.getTitleSet();

      Track track = new Track();
      track.setTrack(title.getTitle());
      track.setAngles(title.getAngles());
      track.setChapters(title.getChapters());
      track.setDimension(new Dimension(vts.getWidth(), vts.getHeight()));

      long lengthSec = title.getTotalTimeMs() / 1000L;
      track.setLength(String.format("%d:%02d", (int) (lengthSec / 60), (int) (lengthSec % 60)));
      track.setAspect(AspectRatio.valueOf(vts.getAspect().name()));

      result[ix] = track;
    }

    return result;
  }
コード例 #6
0
ファイル: DvdAnalyzer.java プロジェクト: thedarkman/feinrip
 /**
  * Gets the subtitle palette of a track.
  *
  * @param trackNr Track number, starting from 1
  * @return {@link Palette}
  */
 public Palette getPalette(int trackNr) {
   DvdTitle title = info.getTitle(trackNr - 1);
   return new Palette(title.getColors());
 }