import saccubus.conv.ConvertToVideoHook;
import java.net.URLEncoder;
import java.util.Properties;
+import saccubus.util.Cws2Fws;
/**
* <p>\83^\83C\83g\83\8b: \82³\82«\82ã\82Î\82·</p>
private static final int CODE_CONVERTING_ABORTED = 100;
private int converting_video(String vhook_path) {
+ File fwsFile = Cws2Fws.createFws(VideoFile);
+
StringBuffer sb = new StringBuffer();
sb.append("\"");
sb.append(Setting.getFFmpegPath().replace("\\", "\\\\"));
sb.append(" ");
sb.append(InOption);
sb.append(" -i ");
- sb.append("\"");
- sb.append(VideoFile.getPath().replace("\\", "\\\\"));
- sb.append("\"");
+ if (fwsFile == null) {
+ sb.append("\"");
+ sb.append(VideoFile.getPath().replace("\\", "\\\\"));
+ sb.append("\"");
+ } else {
+ sb.append(fwsFile.getPath().replace("\\", "\\\\"));
+ }
sb.append(" ");
sb.append(OutOption);
sb.append(" \"");
} catch (IOException ex) {
ex.printStackTrace();
return -1;
+ } finally {
+ if (fwsFile != null) {
+ fwsFile.delete();
+ }
}
}
--- /dev/null
+package saccubus.util;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.zip.InflaterInputStream;
+
+/**
+ *
+ * @author yuki
+ */
+public class Cws2Fws {
+
+ private static final String CWS = "CWS";
+ private static final String FWS = "FWS";
+
+ /**
+ * \88³\8fkSWF\82©\82Ç\82¤\82©\94»\92è\82·\82é.
+ * @param file \94»\92è\91Î\8fÛ.
+ * @return \88³\8fkSWF\82Å\82 \82ê\82Îtrue.
+ */
+ public static boolean isCws(File file) {
+ BufferedInputStream bis = null;
+ try {
+ bis = new BufferedInputStream(new FileInputStream(file));
+ byte header[] = new byte[CWS.length()];
+ bis.read(header, 0, header.length);
+ if (CWS.equals(new String(header))) {
+ return true;
+ }
+ } catch (IOException ex) {
+ Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ if (bis != null) {
+ try {
+ bis.close();
+ } catch (IOException ex) {
+ Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * \88³\8fkSWF\82ð\93W\8aJ\82·\82é.
+ * @param in \93W\8aJ\91Î\8fÛ.
+ * @return \93W\8aJ\8cã\82Ì\83t\83@\83C\83\8b. \91Î\8fÛ\82ª\88³\8fkSWF\82Å\82È\82¯\82ê\82Înull.
+ */
+ public static File createFws(File in) {
+ if (!isCws(in)) {
+ return null;
+ }
+ File out = new File("fws_tmp.swf");
+ BufferedInputStream bis = null;
+ BufferedOutputStream bos = null;
+ try {
+ byte buffer[] = new byte[1024];
+ bis = new BufferedInputStream(new FileInputStream(in));
+ bis.read(buffer, 0, CWS.length()); // CWS
+ bis.read(buffer, 0, 5); // \82»\82Ì\91¼\83w\83b\83_
+
+ bos = new BufferedOutputStream(new FileOutputStream(out));
+ bos.write(FWS.getBytes());
+ bos.write(buffer);
+
+ InflaterInputStream iis = new InflaterInputStream(bis);
+ while (true) {
+ int res = iis.read(buffer);
+ if (res < 0) {
+ break;
+ }
+ bos.write(buffer, 0, res);
+ }
+ return out;
+ } catch (IOException ex) {
+ Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ if (bis != null) {
+ try {
+ bis.close();
+ } catch (IOException ex) {
+ Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ if (bos != null) {
+ try {
+ bos.close();
+ } catch (IOException ex) {
+ Logger.getLogger(Cws2Fws.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+ return null;
+ }
+}