--- /dev/null
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package jtssplitter;
+
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author yukikaze
+ */
+public class Chlist {
+ public void writeCHList(String tspath,String listpath){
+ FileWriter fw = null;
+ try {
+ Tsfile tsf = new Tsfile();
+ Integer[] programnum = tsf.getProgramNum_byte(tspath);
+ String str = "";
+ for (int i = 0; i < programnum.length; i++) {
+ str = str + programnum[i].toString() + "\n";
+ }
+ fw = new FileWriter(listpath);
+ fw.write(str);
+ fw.close();
+ } catch (IOException ex) {
+ Logger.getLogger(Chlist.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ try {
+ fw.close();
+ } catch (IOException ex) {
+ Logger.getLogger(Chlist.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+}
if (args.length > 2) {
ch = Integer.parseInt(args[2].trim(), 10);
}
+ if (args[0].toUpperCase().equals("-CH")){
+ Chlist chl=new Chlist();
+ chl.writeCHList(args[1], args[3]);
+ System.exit(0);
+ }
}
Tsfile t1 = new Tsfile();
File f=new File(inf);
if (f.length()>1000*1000){
t1.splitTS_byte(inf, outf, ch);
}
+ System.exit(0);
}
}
}
return pids;
}
+ public Integer[] getProgramNum_byte(String fpath){
+ /**
+ * PIDを取得し、これと思われる必要なPIDを抜き出す。
+ * @return プログラム番号(return[0])とPIDのリスト(return[1-])
+ */
+ FileInputStream in = null;
+ ArrayList<Integer> retti = new ArrayList<Integer>();
+ byte[] tb = new byte[188];
+ ArrayList<PATData> pat = new ArrayList<PATData>();
+ try {
+ in = new FileInputStream(fpath);
+ int imax = 1000;
+ for (int i = 0; i < imax; i++) {
+ if (in.read(tb) == -1) {
+ in.close();
+ System.out.println("Program Table not found.");
+ System.exit(1);
+ }
+ String last8;
+ Mpeg2TSPacket m2tp;
+ m2tp = new Mpeg2TSPacket();
+ m2tp.setPAT(pat);
+ m2tp.readTS_byte(tb);
+ pat = m2tp.getPAT();
+ for (int i2 = 0; i2 < pat.size(); i2++) {
+ PATData patdd = pat.get(i2);
+ if (!(retti.contains(patdd.Program_TABLE))){
+ retti.add(patdd.Program_TABLE);
+ }
+ }
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(Tsfile.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ Integer[] rt=retti.toArray(new Integer[retti.size()]);
+ return rt;
+ }
private int getFirstP_Table_byte(String fpath){
/**
* PIDを取得し、これと思われる必要なPIDを抜き出す。