public static int wavFileToCsvFile(string rFile, string wFile, string stdoutFile) { int hz; if (File.Exists(rFile) == false) { throw new FileNotFoundException(rFile); } using (WorkingDir wd = new WorkingDir()) { string wHzFile = wd.makePath(); runCTools("/W2C " + rFile + " " + wFile + " " + wHzFile + " > " + stdoutFile); if (File.Exists(wFile) == false) { throw new FileNotFoundException(wFile); } hz = int.Parse(File.ReadAllText(wHzFile, Encoding.ASCII)); } if (IntTools.isRange(hz, 1, IntTools.IMAX) == false) { throw new Exception(".wav ファイルのサンプリングレートを認識出来ません。" + hz); } return(hz); }
private void refreshUI_main() { int quality = this.barQuality.Value; if (quality == _lastQuality) { return; } if (quality <= 100) { using (WorkingDir wd = new WorkingDir()) { string imgFile = wd.makePath() + ".jpg"; { EncoderParameters eps = new EncoderParameters(1); eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)quality); _imgSample.Save(imgFile, Utils.getImageCodecInfo(ImageFormat.Jpeg), eps); } this.pbSample.Image = Bitmap.FromStream(new MemoryStream(File.ReadAllBytes(imgFile))); } } else { this.pbSample.Image = _imgSample; } this.lblQuality.Text = "画質 = " + quality; _lastQuality = quality; GC.Collect(); }
public FFmpegBin(string dir) { _dir = _wd.makePath(); _binDir = Path.Combine(_dir, "bin"); FileTools.copyDir(dir, _binDir); }
private void doTest() { using (WorkingDir wd = new WorkingDir()) { string mwFile = wd.makePath("muon.wav"); string seFile = wd.makePath("muon_stderr.txt"); File.Copy(getMuonWavFile(), mwFile); ProcessTools.runOnBatch("ffprobe.exe " + mwFile + " 2> " + seFile, binDir); if (hasAudioStream(seFile) == false) { throw new FaultOperation("ffmpeg を正しく実行出来ません。"); } } }
public static void doTest() { using (WorkingDir wd = new WorkingDir()) { string mwFile = wd.makePath("muon.wav"); string redirFile = wd.makePath(); File.Copy(muonWavFile, mwFile); ProcessTools.runOnBatch( "ffprobe.exe " + mwFile + " 2> " + redirFile, FFmpegBin.i.getBinDir() ); if (hasAudioStream(redirFile) == false) { throw new Exception("ffmpeg test error"); } } }
private void startProc() { // Kill Zombie { Utils.startConsole(getCrypTunnelFile(), _recvPortNo + " a 1 /S").WaitForExit(); // HACK -- crypTunnel.exe の停止を待っていない。 } string prmFile = _wd.makePath(); string keyFile = _wd.makePath(); string passphrase; if (_key != null) { File.WriteAllText(keyFile, _key.raw, Encoding.ASCII); passphrase = keyFile; } else { passphrase = "*" + _passphrase; } File.WriteAllLines( prmFile, new string[] { "" + _recvPortNo, "localhost", "" + _forwardPortNo, "/R", // サーバーなのでリバースモード passphrase, } ); _proc = Utils.startConsole(getCrypTunnelFile(), "//R " + prmFile); // 読まれるタイミングと同期出来ないので、削除しない。 //File.Delete(prmFile); //File.Delete(keyFile); }
private void startProc() { // Kill Zombie { Utils.startConsole(getCrypTunnelFile(), _recvPortNo + " a 1 /S").WaitForExit(); } string prmFile = _wd.makePath(); string keyFile = _wd.makePath(); string passphrase; if (_key != null) { File.WriteAllText(keyFile, _key.raw, Encoding.ASCII); passphrase = keyFile; } else { passphrase = "*" + _passphrase; } File.WriteAllLines( prmFile, new string[] { "" + _recvPortNo, "" + _serverHost, "" + _serverPortNo, passphrase, } ); _proc = Utils.startConsole(getCrypTunnelFile(), "//R " + prmFile); // 読まれるタイミングと同期出来ないので、削除しない。 //File.Delete(prmFile); //File.Delete(keyFile); }
private void convTh_main() { using (WorkingDir wd = new WorkingDir()) { string rExt = Path.GetExtension(_rFile); if (Gnd.i.audioVideoExtensions.contains(rExt) == false) { throw new Exception("再生可能なファイルではありません。(不明な拡張子)"); } string midFile = wd.makePath() + rExt; try { using (critSect.parallel()) { File.Copy(_rFile, midFile); } if (File.Exists(midFile) == false) { throw null; } } catch { throw new Exception("ファイルにアクセス出来ません。"); } string redirFile = wd.makePath(); ProcessTools.runOnBatch("ffprobe.exe " + _rFile + " 2> " + redirFile, FFmpeg.getBDir(), critSect); foreach (string line in FileTools.readAllLines(redirFile, Encoding.ASCII)) { if (line.Contains("Duration:")) { _duration = new Duration(); List <string> tokens = StringTools.tokenize(line, " :.,", false, true); if (tokens[1] == "N/A") { throw new Exception("再生可能なファイルではありません。(Duration)"); } int h = int.Parse(tokens[1]); int m = int.Parse(tokens[2]); int s = int.Parse(tokens[3]); int sec = h * 3600 + m * 60 + s; if (sec < 1) { throw new Exception("映像又は曲の長さが短すぎます。"); } if (IntTools.IMAX < sec) { throw new Exception("映像又は曲の長さが長すぎます。"); } _duration.secLength = sec; } else if (_audioStream == null && line.Contains("Stream") && line.Contains("Audio:")) { _audioStream = new AudioStream(); List <string> tokens = StringTools.tokenize(line, StringTools.DIGIT, true, true); _audioStream.mapIndex = int.Parse(tokens[1]); } else if (_videoStream == null && line.Contains("Stream") && line.Contains("Video:")) { _videoStream = new VideoStream(); { List <string> tokens = StringTools.tokenize(line, StringTools.DIGIT, true, true); _videoStream.mapIndex = int.Parse(tokens[1]); } { List <string> tokens = StringTools.tokenize(line, " ,"); foreach (string fToken in tokens) { string token = fToken; if (StringTools.toFormat(token, true) == "9x9") { List <string> whTokens = StringTools.tokenize(token, "x"); _videoStream.w = int.Parse(whTokens[0]); _videoStream.h = int.Parse(whTokens[1]); } } } if (_videoStream.w < Consts.VIDEO_W_MIN) { throw new Exception("映像の幅が小さすぎます。"); } if (_videoStream.h < Consts.VIDEO_H_MIN) { throw new Exception("映像の高さが小さすぎます。"); } if (IntTools.IMAX < _videoStream.w) { throw new Exception("映像の幅が大きすぎます。"); } if (IntTools.IMAX < _videoStream.h) { throw new Exception("映像の高さが大きすぎます。"); } } } if (_duration == null) { throw null; } if (_audioStream == null) { throw new Exception("再生可能なファイルではありません。(音声ストリームがありません)"); } if (_videoStream == null) { _type = Consts.MediaType_e.AUDIO; } else { _type = Consts.MediaType_e.MOVIE; } string wFile = Utils.getOgxFile(_wIndex, _type); if (Gnd.i.convWavMastering) { string wavFile = wd.makePath() + ".wav"; ProcessTools.runOnBatch( "ffmpeg.exe -i " + _rFile + " -map 0:" + _audioStream.mapIndex + " -ac 2 " + wavFile, FFmpeg.getBDir(), critSect ); if (File.Exists(wavFile) == false) { throw new Exception("音声ストリームの抽出に失敗しました。"); } string wmDir = wd.makePath(); string wmFile = Path.Combine(wmDir, "Master.exe"); string wavFileNew = wd.makePath() + ".wav"; Directory.CreateDirectory(wmDir); File.Copy(wavMasteringFile, wmFile); ProcessTools.runOnBatch( "Master.exe " + wavFile + " " + wavFileNew + " 0001.txt", wmDir, critSect ); if (File.Exists(wavFileNew) == false) { throw new Exception("wavFileNew does not exist"); } if (_type == Consts.MediaType_e.AUDIO) { ProcessTools.runOnBatch( "ffmpeg.exe -i " + wavFileNew + " -map 0:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptAudio + " " + wFile, FFmpeg.getBDir(), critSect ); } else { ProcessTools.runOnBatch( "ffmpeg.exe -i " + _rFile + " -i " + wavFileNew + " -map 0:" + _videoStream.mapIndex + " -map 1:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptVideo + " " + Gnd.i.ffmpegOptAudio + " " + wFile, FFmpeg.getBDir(), critSect ); } } else { if (_type == Consts.MediaType_e.AUDIO) { ProcessTools.runOnBatch( "ffmpeg.exe -i " + _rFile + " -map 0:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptAudio + " " + wFile, FFmpeg.getBDir(), critSect ); } else { ProcessTools.runOnBatch( "ffmpeg.exe -i " + _rFile + " -map 0:" + _videoStream.mapIndex + " -map 0:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptVideo + " " + Gnd.i.ffmpegOptAudio + " " + wFile, FFmpeg.getBDir(), critSect ); } } if (File.Exists(wFile) == false) { throw new Exception("wFile does not exist"); } _wFile = wFile; } }
private void doConv() { addOperation(delegate { rExt = Path.GetExtension(_rFile); if (Gnd.i.audioVideoExtensions.contains(rExt) == false) { throw new Exception("再生可能なファイルではありません。(不明な拡張子)"); } midRFile = _wd.makePath() + rExt; { long rFileSize = -1; try { rFileSize = new FileInfo(_rFile).Length; } catch { } if (Gnd.i.rFileSizeMax_MB * 1000000L < rFileSize) { throw new Exception("ファイルが大きすぎます。"); } } { long diskFree = new DriveInfo(FileTools.getTMP().Substring(0, 1)).AvailableFreeSpace; if (diskFree < Gnd.i.keepDiskFree_MB * 1000000L) { throw new Exception("ディスクの空き領域が不足しています。"); } } runCopyFile(_rFile, midRFile, "ファイルにアクセス出来ません。"); }); addOperation(delegate { redirFile = _wd.makePath(); runCommand("ffprobe.exe " + midRFile + " 2> " + redirFile, Gnd.i.ffmpeg.binDir); }); addOperation(delegate { foreach (string line in FileTools.readAllLines(redirFile, Encoding.ASCII)) { if (line.Contains("Duration:")) { _duration = new Duration(); List <string> tokens = StringTools.tokenize(line, " :.,", false, true); if (tokens[1] == "N/A") { throw new Exception("再生可能なファイルではありません。(Duration)"); } int h = int.Parse(tokens[1]); int m = int.Parse(tokens[2]); int s = int.Parse(tokens[3]); int sec = h * 3600 + m * 60 + s; if (sec < 1) { throw new Exception("映像又は曲の長さが短すぎます。"); } if (IntTools.IMAX < sec) { throw new Exception("映像又は曲の長さが長すぎます。"); } _duration.secLength = sec; } else if (_audioStream == null && line.Contains("Stream") && line.Contains("Audio:")) { _audioStream = new AudioStream(); List <string> tokens = StringTools.tokenize(line, StringTools.DIGIT, true, true); _audioStream.mapIndex = int.Parse(tokens[1]); } else if (_videoStream == null && line.Contains("Stream") && line.Contains("Video:")) { _videoStream = new VideoStream(); { List <string> tokens = StringTools.tokenize(line, StringTools.DIGIT, true, true); _videoStream.mapIndex = int.Parse(tokens[1]); } { List <string> tokens = StringTools.tokenize(line, " ,"); foreach (string token in tokens) { if (StringTools.toDigitFormat(token, true) == "9x9") { List <string> whTokens = StringTools.tokenize(token, "x"); _videoStream.w = int.Parse(whTokens[0]); _videoStream.h = int.Parse(whTokens[1]); } } } if (_videoStream.w < Consts.VIDEO_W_MIN) { throw new Exception("映像の幅が小さすぎます。"); } if (_videoStream.h < Consts.VIDEO_H_MIN) { throw new Exception("映像の高さが小さすぎます。"); } if (IntTools.IMAX < _videoStream.w) { throw new Exception("映像の幅が大きすぎます。"); } if (IntTools.IMAX < _videoStream.h) { throw new Exception("映像の高さが大きすぎます。"); } } } if (_duration == null) { throw new Exception("fatal: ffprobe _duration null"); } if (_audioStream == null) { throw new Exception("再生可能なファイルではありません。(音声ストリームがありません)"); } if (_duration.secLength < 3) { throw new Exception("再生時間が短すぎます。"); } if (_videoStream == null) { _type = Consts.MediaType_e.AUDIO; } else { _type = Consts.MediaType_e.MOVIE; } wFile = _wFileNoExt + (_type == Consts.MediaType_e.AUDIO ? ".ogg" : ".ogv"); if (StringTools.equalsIgnoreCase(rExt, Path.GetExtension(wFile))) { doConvMode = false; midWFile = midRFile; } else { doConvMode = true; midWFile = _wd.makePath() + Path.GetExtension(wFile); } }); if (Gnd.i.convWavMastering) { addOperation(delegate { if (doConvMode) { wavFile = _wd.makePath() + ".wav"; runCommand( "ffmpeg.exe -i " + midRFile + " -map 0:" + _audioStream.mapIndex + " -ac 2 " + wavFile, Gnd.i.ffmpeg.binDir ); } }); addOperation(delegate { if (doConvMode) { if (File.Exists(wavFile) == false) { throw new Exception("音声ストリームの抽出に失敗しました。"); } wavFileNew = _wd.makePath() + ".wav"; runCommand( "Master.exe " + wavFile + " " + wavFileNew + " 0001.txt > " + redirFile, Gnd.i.wavMaster.binDir ); } }); addOperation(delegate { if (doConvMode) { reportToLog(redirFile, StringTools.ENCODING_SJIS); if (File.Exists(wavFileNew) == false) // ? 音量の均一化 不要だった。 { Gnd.i.logger.writeLine("wavFileNew <- wavFile"); wavFileNew = wavFile; } if (_type == Consts.MediaType_e.AUDIO) { runCommand( "ffmpeg.exe -i " + wavFileNew + " -map 0:0 " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpeg.binDir ); } else { runCommand( "ffmpeg.exe -i " + midRFile + " -i " + wavFileNew + " -map 0:" + _videoStream.mapIndex + " -map 1:0 " + Gnd.i.ffmpegOptVideo + " " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpeg.binDir ); } } }); } else { addOperation(delegate { if (doConvMode) { if (_type == Consts.MediaType_e.AUDIO) { runCommand( "ffmpeg.exe -i " + midRFile + " -map 0:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpeg.binDir ); } else { runCommand( "ffmpeg.exe -i " + midRFile + " -map 0:" + _videoStream.mapIndex + " -map 0:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptVideo + " " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpeg.binDir ); } } }); } addOperation(delegate { if (doConvMode) { reportToLog(redirFile, Encoding.ASCII); } }); addOperation(delegate { try { string dir = Path.GetDirectoryName(wFile); Gnd.i.logger.writeLine("dir: " + dir); if (Directory.Exists(dir) == false) { Directory.CreateDirectory(dir); } } catch { throw new Exception("ファイルを出力できません。(フォルダ作成失敗)"); } runCopyFile(midWFile, wFile, "ファイルを出力できません。"); }); }
public void perform() { using (WorkingDir wd = new WorkingDir()) { string rExt = Path.GetExtension(Gnd.i.rFile); if (Gnd.i.audioVideoExtensions.contains(rExt) == false) { throw new Exception("再生可能なファイルではありません。(不明な拡張子)"); } string midRFile = wd.makePath() + rExt; try { File.Copy(Gnd.i.rFile, midRFile); if (File.Exists(midRFile) == false) { throw null; } } catch { throw new Exception("ファイルにアクセス出来ません。"); } string redirFile = wd.makePath(); ProcessTools.runOnBatch("ffprobe.exe " + midRFile + " 2> " + redirFile, Gnd.i.ffmpegBinDir); foreach (string line in FileTools.readAllLines(redirFile, Encoding.ASCII)) { if (line.Contains("Duration:")) { _duration = new Duration(); List <string> tokens = StringTools.tokenize(line, " :.,", false, true); if (tokens[1] == "N/A") { throw new Exception("再生可能なファイルではありません。(Duration)"); } int h = int.Parse(tokens[1]); int m = int.Parse(tokens[2]); int s = int.Parse(tokens[3]); int sec = h * 3600 + m * 60 + s; if (sec < 1) { throw new Exception("映像又は曲の長さが短すぎます。"); } if (IntTools.IMAX < sec) { throw new Exception("映像又は曲の長さが長すぎます。"); } _duration.secLength = sec; } else if (_audioStream == null && line.Contains("Stream") && line.Contains("Audio:")) { _audioStream = new AudioStream(); List <string> tokens = StringTools.tokenize(line, StringTools.DIGIT, true, true); _audioStream.mapIndex = int.Parse(tokens[1]); } else if (_videoStream == null && line.Contains("Stream") && line.Contains("Video:")) { _videoStream = new VideoStream(); { List <string> tokens = StringTools.tokenize(line, StringTools.DIGIT, true, true); _videoStream.mapIndex = int.Parse(tokens[1]); } { List <string> tokens = StringTools.tokenize(line, " ,"); foreach (string token in tokens) { if (StringTools.toDigitFormat(token, true) == "9x9") { List <string> whTokens = StringTools.tokenize(token, "x"); _videoStream.w = int.Parse(whTokens[0]); _videoStream.h = int.Parse(whTokens[1]); } } } if (_videoStream.w < Consts.VIDEO_W_MIN) { throw new Exception("映像の幅が小さすぎます。"); } if (_videoStream.h < Consts.VIDEO_H_MIN) { throw new Exception("映像の高さが小さすぎます。"); } if (IntTools.IMAX < _videoStream.w) { throw new Exception("映像の幅が大きすぎます。"); } if (IntTools.IMAX < _videoStream.h) { throw new Exception("映像の高さが大きすぎます。"); } } } if (_duration == null) { throw null; } if (_audioStream == null) { throw new Exception("再生可能なファイルではありません。(音声ストリームがありません)"); } if (_videoStream == null) { _type = Consts.MediaType_e.AUDIO; } else { _type = Consts.MediaType_e.MOVIE; } string wFile = Utils.getFile(Gnd.i.wFileNoExt, _type); if (Utils.equalsExt(midRFile, wFile)) { try { File.Copy(midRFile, wFile, true); if (File.Exists(wFile) == false) { throw null; } } catch { throw new Exception("ファイルの出力に失敗しました。(単にコピー)"); } } else { string midWFile = wd.makePath() + Utils.getExt(_type); if (Gnd.i.convWavMastering) { string wavFile = wd.makePath() + ".wav"; ProcessTools.runOnBatch( "ffmpeg.exe -i " + midRFile + " -map 0:" + _audioStream.mapIndex + " -ac 2 " + wavFile, Gnd.i.ffmpegBinDir ); if (File.Exists(wavFile) == false) { throw new Exception("音声ストリームの抽出に失敗しました。"); } string wavFileNew = wd.makePath() + ".wav"; ProcessTools.runOnBatch( "Master.exe " + wavFile + " " + wavFileNew + " " + wd.makePath() + "_DMY_REP.tmp > " + redirFile, Gnd.i.wavMasterBinDir ); Utils.textFileToLog(redirFile, StringTools.ENCODING_SJIS); if (File.Exists(wavFileNew) == false) { throw new Exception("wavFileNew does not exist"); } if (_type == Consts.MediaType_e.AUDIO) { ProcessTools.runOnBatch( "ffmpeg.exe -i " + wavFileNew + " -map 0:0 " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpegBinDir ); } else { ProcessTools.runOnBatch( "ffmpeg.exe -i " + midRFile + " -i " + wavFileNew + " -map 0:" + _videoStream.mapIndex + " -map 1:0 " + Gnd.i.ffmpegOptVideo + " " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpegBinDir ); } } else { if (_type == Consts.MediaType_e.AUDIO) { ProcessTools.runOnBatch( "ffmpeg.exe -i " + midRFile + " -map 0:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpegBinDir ); } else { ProcessTools.runOnBatch( "ffmpeg.exe -i " + midRFile + " -map 0:" + _videoStream.mapIndex + " -map 0:" + _audioStream.mapIndex + " " + Gnd.i.ffmpegOptVideo + " " + Gnd.i.ffmpegOptAudio + " " + midWFile + " 2> " + redirFile, Gnd.i.ffmpegBinDir ); } } Utils.textFileToLog(redirFile, Encoding.ASCII); if (File.Exists(midWFile) == false) { throw new Exception("midWFile does not exist"); } try { File.Copy(midWFile, wFile, true); if (File.Exists(wFile) == false) { throw null; } } catch { throw new Exception("ファイルの出力に失敗しました。(変換した)"); } } Gnd.i.convReturn.wFile = wFile; } if (_videoStream != null) { Gnd.i.convReturn.w = _videoStream.w; Gnd.i.convReturn.h = _videoStream.h; } }
private string getFile(long index) { return(_wd.makePath(index + ".bin")); }
public MediaData(string file) { try { _origFile = file; _ext = Path.GetExtension(file); if (Gnd.i.movieExtensions.contains(_ext) == false) { throw new FailedOperation("指定されたファイルは動画ファイルではありません。"); } // サイズ・チェック { long fileSize = new FileInfo(file).Length; if (Gnd.i.rFileSizeWarning_MB * 1000000L < fileSize) { if (BusyDlg.self == null) { throw null; // never } Gnd.i.mediaDataSync.waitForMillis(0); // clear Gnd.i.mediaDataCancelled = false; BusyDlg.self.BeginInvoke((MethodInvoker) delegate { if (MessageBox.Show( "指定されたファイルは、けっこうデカいようです。\n" + "このソフトは数分~数十分程度の短い動画の編集を想定しています。\n" + "デカすぎる動画ファイルを読み込むと作業ファイルがディスクの空き領域を使い果たしてしまうかもしれません。\n" + "あと、多分もの凄く時間が掛かります。\n" + "続行しますか?", Program.APP_TITLE + " / 警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning ) != DialogResult.OK ) { Gnd.i.mediaDataCancelled = true; } Gnd.i.mediaDataSync.set(); }); Gnd.i.mediaDataSync.waitForMillis(-1); if (Gnd.i.mediaDataCancelled) { throw new Cancelled(); } } } _duplFile = _wd.makePath() + _ext; _imgDir = _wd.makePath(); _wavFile = _wd.makePath() + ".wav"; _wavCsvFile = _wd.makePath() + ".csv"; Directory.CreateDirectory(_imgDir); loadFile(); Gnd.i.lastOpenedFile = file; } catch (Exception e) { _wd.Dispose(); _wd = null; throw new ExceptionCarrier(e); } }
private void doSave(string file) { string extNew = Path.GetExtension(file); if (Gnd.i.movieExtensions.contains(extNew) == false) { throw new FailedOperation("保存先ファイル名は不明な拡張子です。"); } using (WorkingDir wd = new WorkingDir()) { string wavFile = wd.makePath("1.wav"); string midFile = wd.makePath("2") + extNew; Gnd.i.progressMessage.post("音声ファイルを生成しています..."); CTools.csvFileToWavFile(md.getWavCsvFile(), wavFile, md.getWavHz(), wd.makePath("wr_wav_stdout.txt")); Gnd.i.progressMessage.post("映像ファイルを生成しています..."); string imgDir = md.getImageDir(); string vImgExt = Consts.V_IMG_EXT; if (Gnd.i._映像をJPEGで保存する) { string imgDirNew = wd.makePath(); Directory.CreateDirectory(imgDirNew); foreach (string vImgFile in Directory.GetFiles(imgDir)) { string wFile = Path.Combine(imgDirNew, Path.GetFileNameWithoutExtension(vImgFile)) + Consts.V_IMG_JPEG_EXT; using (Image bmp = Bitmap.FromFile(vImgFile)) using (EncoderParameters eps = new EncoderParameters(1)) using (EncoderParameter ep = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)Gnd.i._映像をJPEGで保存する時の画質)) { eps.Param[0] = ep; ImageCodecInfo ici = GetICI(ImageFormat.Jpeg); bmp.Save(wFile, ici, eps); } } imgDir = imgDirNew; vImgExt = Consts.V_IMG_JPEG_EXT; } Gnd.i.progressMessage.post("動画ファイルを生成しています..."); ProcessTools.runOnBatch( "ffmpeg.exe -r " + md.getTargetVideoStream().fps + " -i " + imgDir + "\\%%010d" + vImgExt + " -i " + wavFile + " -map 0:0 -map 1:0 " + Gnd.i.extensionsOptions.getOption(extNew) + " " + midFile + " 2> " + wd.makePath("wr_movie_stderr.txt"), FFmpegBin.i.getBinDir() ); if (File.Exists(midFile) == false) { throw new FailedOperation("動画ファイルの生成に失敗しました。"); } File.Copy(midFile, file, true); Gnd.i.progressMessage.post(""); // 完了 } }