Beispiel #1
0
  /**
   * Create VobSub IDX file
   *
   * @param fname file name
   * @param pic a SubPicture object used to read screen width and height
   * @param offsets array of offsets (one for each caption)
   * @param timestamps array of PTS time stamps (one for each caption)
   * @param palette 16 color main Palette
   * @throws bdsup2sub.core.CoreException
   */
  public static void writeIdx(
      String fname, SubPicture pic, int[] offsets, int[] timestamps, Palette palette)
      throws CoreException {
    BufferedWriter out = null;
    try {
      out = new BufferedWriter(new FileWriter(fname));

      out.write("# VobSub index file, v7 (do not modify this line!)");
      out.newLine();
      out.write("# Created by " + Constants.APP_NAME + " " + Constants.APP_VERSION);
      out.newLine();
      out.newLine();
      out.write("# Frame size");
      out.newLine();
      out.write(
          "size: " + pic.getWidth() + "x" + (pic.getHeight() - 2 * configuration.getCropOffsetY()));
      out.newLine();
      out.newLine();
      out.write("# Origin - upper-left corner");
      out.newLine();
      out.write("org: 0, 0");
      out.newLine();
      out.newLine();
      out.write("# Scaling");
      out.newLine();
      out.write("scale: 100%, 100%");
      out.newLine();
      out.newLine();
      out.write("# Alpha blending");
      out.newLine();
      out.write("alpha: 100%");
      out.newLine();
      out.newLine();
      out.write("# Smoothing");
      out.newLine();
      out.write("smooth: OFF");
      out.newLine();
      out.newLine();
      out.write("# Fade in/out in milliseconds");
      out.newLine();
      out.write("fadein/out: 0, 0");
      out.newLine();
      out.newLine();
      out.write("# Force subtitle placement relative to (org.x, org.y)");
      out.newLine();
      out.write("align: OFF at LEFT TOP");
      out.newLine();
      out.newLine();
      out.write("# For correcting non-progressive desync. (in millisecs or hh:mm:ss:ms)");
      out.newLine();
      out.write("time offset: 0");
      out.newLine();
      out.newLine();
      out.write("# ON: displays only forced subtitles, OFF: shows everything");
      out.newLine();
      out.write("forced subs: OFF");
      out.newLine();
      out.newLine();
      out.write("# The palette of the generated file");
      out.newLine();
      out.write("palette: ");
      // Palette pal = Core.getCurrentDVDPalette();
      for (int i = 0; i < palette.getSize(); i++) {
        int rbg[] = palette.getRGB(i);
        int val = (rbg[0] << 16) | (rbg[1] << 8) | rbg[2];
        out.write(ToolBox.toHexLeftZeroPadded(val, 6).substring(2));
        if (i != palette.getSize() - 1) {
          out.write(", ");
        }
      }
      out.newLine();
      out.newLine();
      out.write("# Custom colors (transp idxs and the four colors)");
      out.newLine();
      out.write("custom colors: OFF, tridx: 1000, colors: 000000, 444444, 888888, cccccc");
      out.newLine();
      out.newLine();
      out.write("# Language index in use");
      out.newLine();
      out.write("langidx: 0");
      out.newLine();
      out.newLine();
      out.write("# " + LANGUAGES[configuration.getLanguageIdx()][0]);
      out.newLine();
      out.write("id: " + LANGUAGES[configuration.getLanguageIdx()][1] + ", index: 0");
      out.newLine();
      out.write(
          "# Decomment next line to activate alternative name in DirectVobSub / Windows Media Player 6.x");
      out.newLine();
      out.write("# alt: " + LANGUAGES[configuration.getLanguageIdx()][0]);
      out.newLine();
      out.write("# Vob/Cell ID: 1, 1 (PTS: 0)");
      out.newLine();
      for (int i = 0; i < timestamps.length; i++) {
        out.write("timestamp: " + ptsToTimeStrIdx(timestamps[i]));
        out.write(", filepos: " + ToolBox.toHexLeftZeroPadded(offsets[i], 9).substring(2));
        out.newLine();
      }
    } catch (IOException ex) {
      throw new CoreException(ex.getMessage());
    } finally {
      try {
        if (out != null) {
          out.close();
        }
      } catch (IOException ex) {
      }
    }
  }