1
// ------------------------------------------------------------------
2 // Copyright (C) 2011-2015 Maruko Toolbox Project
4 // Authors: komaruchan <sandy_0308@hotmail.com>
5 // LunarShaddow <aflyhorse@hotmail.com>
6 // LYF <lyfjxymf@sina.com>
8 // Licensed under the Apache License, Version 2.0 (the "License");
9 // you may not use this file except in compliance with the License.
10 // You may obtain a copy of the License at
12 // http://www.apache.org/licenses/LICENSE-2.0
14 // Unless required by applicable law or agreed to in writing, software
15 // distributed under the License is distributed on an "AS IS" BASIS,
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
17 // express or implied.
18 // See the License for the specific language governing permissions
19 // and limitations under the License.
20 // -------------------------------------------------------------------
26 using System
.Collections
.Generic
;
27 using System
.ComponentModel
;
28 using System
.Configuration
;
29 using System
.Diagnostics
;
31 using System
.Drawing
.Imaging
;
35 using System
.Reflection
;
36 using System
.Runtime
.InteropServices
;
37 using System
.Runtime
.Remoting
.Messaging
;
39 using System
.Text
.RegularExpressions
;
40 using System
.Threading
;
41 using System
.Windows
.Forms
;
42 using System
.Xml
.Linq
;
46 public partial class MainForm
: FormBase
48 public string workPath
= "!undefined";
49 public bool shutdownState
= false;
50 public bool trayMode
= false;
52 #region Private Members Declaration
54 private StringBuilder avsBuilder
= new StringBuilder(1000);
55 private string syspath
= Environment
.GetFolderPath(Environment
.SpecialFolder
.System
).Remove(1);
56 private int indexofsource
;
57 private int indexoftarget
;
58 private byte mode
= 1;
59 private string clip
= "";
60 private string MIvideo
= "";
61 private string namevideo
= "";
62 private string namevideo2
= "";
64 //string namevideo3 = "";
65 private string namevideo4
= "";
67 private string namevideo5
= "";
68 private string namevideo6
= "";
69 private string nameaudio
= "";
70 private string nameaudio2
= "";
71 private string nameaudio3
= "";
72 private string namevideo8
= "";
73 private string namevideo9
= "video";
74 private string nameout
;
75 private string nameout2
;
76 private string nameout3
;
79 private string nameout5
;
81 private string nameout6
;
82 private string nameout9
;
83 private string namesub
;
84 private string namesub2
= "";
85 private string namesub9
= "subtitle";
86 private string MItext
= "把视频文件拖到这里";
87 private string mkvextract
;
88 private string mkvmerge
;
91 private string ffmpeg
;
93 private string aextract
;
94 private string batpath
;
96 private string startpath
;
97 private string avs
= "";
98 private string tempavspath
= "";
99 private string tempPic
= "";
100 private string logFileName
, logPath
;
101 private DateTime ReleaseDate
= DateTime
.Parse("2015-4-2 8:0:0");
103 #endregion Private Members Declaration
105 #region CPU Porocessors Number
107 [StructLayout(LayoutKind
.Sequential
)]
108 public struct SYSTEM_INFO
111 public uint dwPageSize
;
112 public uint lpMinimumApplicationAddress
;
113 public uint lpMaximumApplicationAddress
;
114 public uint dwActiveProcessorMask
;
115 public uint dwNumberOfProcessors
;
116 public uint dwProcessorType
;
117 public uint dwAllocationGranularity
;
118 public uint dwProcessorLevel
;
119 public uint dwProcessorRevision
;
122 [DllImport("kernel32")]
123 private static extern void GetSystemInfo(ref SYSTEM_INFO pSI
);
125 #endregion CPU Porocessors Number
129 logPath
= Application
.StartupPath
+ "\\logs";
130 logFileName
= logPath
+ "\\LogFile-" + DateTime
.Now
.ToString("yyyy'-'MM'-'dd'_'HH'-'mm'-'ss") + ".log";
131 InitializeComponent();
134 public string MediaInfo(string VideoName
)
136 string info
= "无视频信息";
137 if (File
.Exists(VideoName
))
139 MediaInfo MI
= new MediaInfo();
142 string container
= MI
.Get(StreamKind
.General
, 0, "Format");
143 string bitrate
= MI
.Get(StreamKind
.General
, 0, "BitRate/String");
144 string duration
= MI
.Get(StreamKind
.General
, 0, "Duration/String1");
145 string fileSize
= MI
.Get(StreamKind
.General
, 0, "FileSize/String");
147 string vid
= MI
.Get(StreamKind
.Video
, 0, "ID");
148 string video
= MI
.Get(StreamKind
.Video
, 0, "Format");
149 string vBitRate
= MI
.Get(StreamKind
.Video
, 0, "BitRate/String");
150 string vSize
= MI
.Get(StreamKind
.Video
, 0, "StreamSize/String");
151 string width
= MI
.Get(StreamKind
.Video
, 0, "Width");
152 string height
= MI
.Get(StreamKind
.Video
, 0, "Height");
153 string risplayAspectRatio
= MI
.Get(StreamKind
.Video
, 0, "DisplayAspectRatio/String");
154 string risplayAspectRatio2
= MI
.Get(StreamKind
.Video
, 0, "DisplayAspectRatio");
155 string frameRate
= MI
.Get(StreamKind
.Video
, 0, "FrameRate/String");
156 string bitDepth
= MI
.Get(StreamKind
.Video
, 0, "BitDepth/String");
157 string pixelAspectRatio
= MI
.Get(StreamKind
.Video
, 0, "PixelAspectRatio");
158 string encodedLibrary
= MI
.Get(StreamKind
.Video
, 0, "Encoded_Library");
159 string encodeTime
= MI
.Get(StreamKind
.Video
, 0, "Encoded_Date");
160 string codecProfile
= MI
.Get(StreamKind
.Video
, 0, "Codec_Profile");
161 string frameCount
= MI
.Get(StreamKind
.Video
, 0, "FrameCount");
164 string aid
= MI
.Get(StreamKind
.Audio
, 0, "ID");
165 string audio
= MI
.Get(StreamKind
.Audio
, 0, "Format");
166 string aBitRate
= MI
.Get(StreamKind
.Audio
, 0, "BitRate/String");
167 string samplingRate
= MI
.Get(StreamKind
.Audio
, 0, "SamplingRate/String");
168 string channel
= MI
.Get(StreamKind
.Audio
, 0, "Channel(s)");
169 string aSize
= MI
.Get(StreamKind
.Audio
, 0, "StreamSize/String");
171 string audioInfo
= MI
.Get(StreamKind
.Audio
, 0, "Inform") + MI
.Get(StreamKind
.Audio
, 1, "Inform") + MI
.Get(StreamKind
.Audio
, 2, "Inform") + MI
.Get(StreamKind
.Audio
, 3, "Inform");
172 string videoInfo
= MI
.Get(StreamKind
.Video
, 0, "Inform");
174 info
= Path
.GetFileName(VideoName
) + "\r\n" +
175 "容器:" + container
+ "\r\n" +
176 "总码率:" + bitrate
+ "\r\n" +
177 "大小:" + fileSize
+ "\r\n" +
178 "时长:" + duration
+ "\r\n" +
180 "视频(" + vid
+ "):" + video
+ "\r\n" +
181 "码率:" + vBitRate
+ "\r\n" +
182 "大小:" + vSize
+ "\r\n" +
183 "分辨率:" + width
+ "x" + height
+ "\r\n" +
184 "宽高比:" + risplayAspectRatio
+ "(" + risplayAspectRatio2
+ ")" + "\r\n" +
185 "帧率:" + frameRate
+ "\r\n" +
186 "位深度:" + bitDepth
+ "\r\n" +
187 "像素宽高比:" + pixelAspectRatio
+ "\r\n" +
188 "编码库:" + encodedLibrary
+ "\r\n" +
189 "Profile:" + codecProfile
+ "\r\n" +
190 "编码时间:" + encodeTime
+ "\r\n" +
191 "总帧数:" + frameCount
+ "\r\n" +
194 "音频(" + aid
+ "):" + audio
+ "\r\n" +
195 "大小:" + aSize
+ "\r\n" +
196 "码率:" + aBitRate
+ "\r\n" +
197 "采样率:" + samplingRate
+ "\r\n" +
198 "声道数:" + channel
+ "\r\n" +
199 "\r\n====详细信息====\r\n" +
208 public string ffmuxbat(string input1
, string input2
, string output
)
210 return "\"" + workPath
+ "\\ffmpeg.exe\" -i \"" + input1
+ "\" -i \"" + input2
+ "\" -sn -c copy -y \"" + output
+ "\"\r\n";
213 public string boxmuxbat(string input1
, string input2
, string output
)
215 return "\"" + workPath
+ "\\mp4box.exe\" -add \"" + input1
+ "#trackID=1:name=\" -add \"" + input2
+ "#trackID=1:name=\" -new \"" + output
+ "\"\r\n";
218 public string x264bat(string input
, string output
, int pass
= 1, string sub
= "")
221 MediaInfo MI
= new MediaInfo();
223 string frameRate
= MI
.Get(StreamKind
.Video
, 0, "FrameRate");
225 string keyint
= "-1";
226 if (double.TryParse(frameRate
, out fps
))
228 fps
= Math
.Round(fps
);
229 keyint
= (fps
* 10).ToString();
232 StringBuilder sb
= new StringBuilder();
233 if (Path
.GetExtension(input
) == ".avs")
234 sb
.Append("\"" + workPath
+ "\\avs4x26x.exe\"" + " -L ");
235 sb
.Append("\"" + Path
.Combine(workPath
, x264ExeComboBox
.SelectedItem
.ToString()) + "\"");
240 sb
.Append(" " + x264CustomParameterTextBox
.Text
);
243 sb
.Append(" --crf " + x264CRFNum
.Value
);
246 sb
.Append(" --pass " + pass
+ " --bitrate " + x264BitrateNum
.Value
);
251 sb
.Append(" --demuxer " + x264DemuxerComboBox
.Text
+ " --threads " + x264ThreadsComboBox
.SelectedItem
.ToString());
252 if (x264extraLine
.Text
!= "")
253 sb
.Append(" " + x264extraLine
.Text
);
255 sb
.Append(" --preset 8 " + " -I " + keyint
+ " -r 4 -b 3 --me umh -i 1 --scenecut 60 -f 1:1 --qcomp 0.5 --psy-rd 0.3:0 --aq-mode 2 --aq-strength 0.8");
256 if (x264HeightNum
.Value
!= 0 && x264WidthNum
.Value
!= 0 && !MaintainResolutionCheckBox
.Checked
)
257 sb
.Append(" --vf resize:" + x264WidthNum
.Value
+ "," + x264HeightNum
.Value
+ ",,,,lanczos");
259 if (!string.IsNullOrEmpty(sub
))
261 string x264tmpline
= sb
.ToString();
262 if (x264tmpline
.IndexOf("--vf") == -1)
263 sb
.Append(" --vf subtitles --sub \"" + sub
+ "\"");
266 Regex r
= new Regex("--vf\\s\\S*");
267 Match m
= r
.Match(x264tmpline
);
268 sb
.Insert(m
.Index
+ 5, "subtitles/").Append(" --sub \"" + sub
+ "\"");
271 if (x264SeekNumericUpDown
.Value
!= 0)
272 sb
.Append(" --seek " + x264SeekNumericUpDown
.Value
.ToString());
273 if (x264FramesNumericUpDown
.Value
!= 0)
274 sb
.Append(" --frames " + x264FramesNumericUpDown
.Value
.ToString());
275 if (mode
== 2 && pass
== 1)
276 sb
.Append(" -o NUL");
277 else if (!string.IsNullOrEmpty(output
))
278 sb
.Append(" -o " + "\"" + output
+ "\"");
279 if (!string.IsNullOrEmpty(input
))
280 sb
.Append(" \"" + input
+ "\"");
281 return sb
.ToString();
284 public string x265bat(string input
, string output
, int pass
= 1)
286 StringBuilder sb
= new StringBuilder();
287 sb
.Append("\"" + workPath
+ "\\ffmpeg.exe\"" + " -i \"" + input
+ "\"");
288 if (x264HeightNum
.Value
!= 0 && x264WidthNum
.Value
!= 0 && !MaintainResolutionCheckBox
.Checked
)
289 sb
.Append(" -s " + x264WidthNum
.Value
+ "x" + x264HeightNum
.Value
);
290 sb
.Append(" -f yuv4mpegpipe -an -v 0 - | ");
291 sb
.Append(Util
.FormatPath(Path
.Combine(workPath
, x264ExeComboBox
.SelectedItem
.ToString())) + " --y4m");
296 sb
.Append(" " + x264CustomParameterTextBox
.Text
);
299 sb
.Append(" --crf " + x264CRFNum
.Value
);
302 sb
.Append(" --pass " + pass
+ " --bitrate " + x264BitrateNum
.Value
);
307 if (x264extraLine
.Text
!= "")
308 sb
.Append(" " + x264extraLine
.Text
);
310 sb
.Append(""); // 小丸工具箱除界面设置外的内置参数
312 if (x264SeekNumericUpDown
.Value
!= 0)
313 sb
.Append(" --seek " + x264SeekNumericUpDown
.Value
.ToString());
314 if (x264FramesNumericUpDown
.Value
!= 0)
315 sb
.Append(" --frames " + x264FramesNumericUpDown
.Value
.ToString());
316 if (mode
== 2 && pass
== 1)
317 sb
.Append(" -o NUL");
318 else if (!string.IsNullOrEmpty(output
))
319 sb
.Append(" -o " + "\"" + output
+ "\"");
320 if (!string.IsNullOrEmpty(input
))
322 return sb
.ToString();
325 public static bool stringCheck(string str
, string info
= "")
327 if (String
.IsNullOrEmpty(str
))
329 MessageBox
.Show("发现空或者无效的字符串 " + info
);
331 return String
.IsNullOrEmpty(str
);
334 public string timeminus(int h1
, int m1
, int s1
, int h2
, int m2
, int s2
)
352 return h
.ToString() + ":" + m
.ToString() + ":" + s
.ToString();
355 public string timeplus(int h1
, int m1
, int s1
, int h2
, int m2
, int s2
)
373 return h
.ToString() + ":" + m
.ToString() + ":" + s
.ToString();
376 public string audiobat(string input
, string output
)
378 int AACbr
= 1000 * Convert
.ToInt32(AudioBitrateComboBox
.Text
);
379 string br
= AACbr
.ToString();
380 ffmpeg
= "\"" + workPath
+ "\\ffmpeg.exe\" -i \"" + input
+ "\" -vn -sn -v 0 -c:a pcm_s16le -f wav pipe:|";
381 switch (AudioEncoderComboBox
.SelectedIndex
)
384 if (AudioBitrateRadioButton
.Checked
)
386 ffmpeg
+= "\"" + workPath
+ "\\neroAacEnc.exe\" -ignorelength -lc -br " + br
+ " -if - -of \"" + output
+ "\"";
388 if (AudioCustomizeRadioButton
.Checked
)
390 ffmpeg
+= "\"" + workPath
+ "\\neroAacEnc.exe\" -ignorelength " + AudioCustomParameterTextBox
.Text
.ToString() + " -if - -of \"" + output
+ "\"";
395 if (AudioBitrateRadioButton
.Checked
)
397 ffmpeg
+= "\"" + workPath
+ "\\qaac.exe\" -q 2 --ignorelength -c " + AudioBitrateComboBox
.Text
+ " - -o \"" + output
+ "\"";
399 if (AudioCustomizeRadioButton
.Checked
)
401 ffmpeg
+= "\"" + workPath
+ "\\qaac.exe\" --ignorelength " + AudioCustomParameterTextBox
.Text
.ToString() + " - -o \"" + output
+ "\"";
406 if (Path
.GetExtension(output
) == ".aac")
407 output
= Util
.ChangeExt(output
, ".wav");
408 ffmpeg
= "\"" + workPath
+ "\\ffmpeg.exe\" -y -i \"" + input
+ "\" -f wav \"" + output
+ "\"";
412 ffmpeg
+= "\"" + workPath
+ "\\refalac.exe\" --ignorelength - -o \"" + output
+ "\"";
416 ffmpeg
+= "\"" + workPath
+ "\\flac.exe\" -f --ignore-chunk-sizes -5 - -o \"" + output
+ "\"";
420 if (AudioBitrateRadioButton
.Checked
)
422 ffmpeg
+= "\"" + workPath
+ "\\fdkaac.exe\" --ignorelength -b " + AudioBitrateComboBox
.Text
+ " - -o \"" + output
+ "\"";
424 if (AudioCustomizeRadioButton
.Checked
)
426 ffmpeg
+= "\"" + workPath
+ "\\fdkaac.exe\" --ignorelength " + AudioCustomParameterTextBox
.Text
.ToString() + " - -o \"" + output
+ "\"";
430 ffmpeg
= "\"" + workPath
+ "\\ffmpeg.exe\" -i \"" + input
+ "\" -c:a ac3 -b:a " + AudioBitrateComboBox
.Text
.ToString() + "k \"" + output
+ "\"";
434 ffmpeg
= "\"" + workPath
+ "\\ffmpeg.exe\" -i \"" + input
+ "\" -vn -sn -c:a copy -y -map 0:a:0 " + "\"" + output
+ "\"";
440 aac
= ffmpeg
+ "\r\n";
444 private void btnaudio_Click(object sender
, EventArgs e
)
446 openFileDialog1
.Filter
= "音频(*.mp4;*.aac;*.mp2;*.mp3;*.m4a;*.ac3)|*.mp4;*.aac;*.mp2;*.mp3;*.m4a;*.ac3|所有文件(*.*)|*.*";
447 DialogResult result
= openFileDialog1
.ShowDialog();
448 if (result
== DialogResult
.OK
)
450 nameaudio
= openFileDialog1
.FileName
;
451 txtaudio
.Text
= nameaudio
;
455 private void btnvideo_Click(object sender
, EventArgs e
)
457 openFileDialog1
.Filter
= "视频(*.avi;*.mp4;*.m1v;*.m2v;*.m4v;*.264;*.h264;*.hevc)|*.avi;*.mp4;*.m1v;*.m2v;*.m4v;*.264;*.h264;*.hevc|所有文件(*.*)|*.*";
458 DialogResult result
= openFileDialog1
.ShowDialog();
459 if (result
== DialogResult
.OK
)
461 namevideo
= openFileDialog1
.FileName
;
462 txtvideo
.Text
= namevideo
;
466 private void openFileDialog1_FileOk(object sender
, CancelEventArgs e
)
470 private void btnout_Click(object sender
, EventArgs e
)
472 SaveFileDialog savefile
= new SaveFileDialog();
473 savefile
.Filter
= "视频(*.mp4)|*.mp4";
474 DialogResult result
= savefile
.ShowDialog();
475 if (result
== DialogResult
.OK
)
477 nameout
= savefile
.FileName
;
478 txtout
.Text
= nameout
;
482 private void btnmux_Click(object sender
, EventArgs e
)
486 ShowErrorMessage("请选择视频文件");
489 string inputExt
= Path
.GetExtension(txtvideo
.Text
.Trim()).ToLower();
490 if (inputExt
!= ".avi" //Only MPEG-4 SP/ASP video and MP3 audio supported at the current time. To import AVC/H264 video, you must first extract the avi track.
491 && inputExt
!= ".mp4" //MPEG-4 Video
492 && inputExt
!= ".m1v" //MPEG-1 Video
493 && inputExt
!= ".m2v" //MPEG-2 Video
494 && inputExt
!= ".m4v" //MPEG-4 Video
495 && inputExt
!= ".264" //AVC/H264 Video
496 && inputExt
!= ".h264" //AVC/H264 Video
497 && inputExt
!= ".hevc") //HEVC/H265 Video
499 ShowErrorMessage("输入文件: \r\n\r\n" + txtvideo
.Text
.Trim() + "\r\n\r\n是一个mp4box不支持的视频文件!");
505 ShowErrorMessage("请选择输出文件");
508 StringBuilder sb
= new StringBuilder();
509 sb
.Append(Util
.FormatPath(workPath
+ "\\mp4box.exe") + " -add \"" + namevideo
+ "#trackID=1");
510 if (Mp4BoxParComboBox
.Text
!= "")
511 sb
.Append(":par=" + Mp4BoxParComboBox
.Text
);
512 if (cbFPS
.Text
!= "auto" && cbFPS
.Text
!= "")
513 sb
.Append(":fps=" + cbFPS
.Text
);
514 sb
.Append(":name=\""); //输入raw时删除默认添加的gpac字符串
516 sb
.Append(" -add \"" + nameaudio
+ ":name=\"");
517 sb
.Append(" -new \"" + nameout
+ "\" \r\n cmd");
519 batpath
= workPath
+ "\\mux.bat";
520 File
.WriteAllText(batpath
, mux
, UnicodeEncoding
.Default
);
522 Process
.Start(batpath
);
525 private void btnaextract_Click(object sender
, EventArgs e
)
528 ExtractAV(namevideo
, "a", 0);
529 //if (namevideo == "")
531 // MessageBox.Show("请选择视频文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
535 // //aextract = "\"" + workPath + "\\mp4box.exe\" -raw 2 \"" + namevideo + "\"";
537 // aextract += Cmd.FormatPath(workPath + "\\ffmpeg.exe");
538 // aextract += " -i " + Cmd.FormatPath(namevideo);
539 // aextract += " -vn -sn -c:a:0 copy ";
540 // string outfile = Cmd.GetDir(namevideo) +
541 // Path.GetFileNameWithoutExtension(namevideo) + "_抽取音频1" + Path.GetExtension(namevideo);
542 // aextract += Cmd.FormatPath(outfile);
543 // batpath = workPath + "\\aextract.bat";
544 // File.WriteAllText(batpath, aextract, UnicodeEncoding.Default);
545 // LogRecord(aextract);
546 // System.Diagnostics.Process.Start(batpath);
550 private void ExtractAV(string namevideo
, string av
, int streamIndex
)
552 if (string.IsNullOrEmpty(namevideo
))
554 ShowErrorMessage("请选择视频文件");
558 string ext
= Path
.GetExtension(namevideo
);
559 //aextract = "\"" + workPath + "\\mp4box.exe\" -raw 2 \"" + namevideo + "\"";
560 string aextract
= "";
561 aextract
+= Util
.FormatPath(workPath
+ "\\ffmpeg.exe");
562 aextract
+= " -i " + Util
.FormatPath(namevideo
);
565 aextract
+= " -vn -sn -c:a copy -y -map 0:a:" + streamIndex
+ " ";
567 MediaInfo MI
= new MediaInfo();
569 string audioFormat
= MI
.Get(StreamKind
.Audio
, streamIndex
, "Format");
570 string audioProfile
= MI
.Get(StreamKind
.Audio
, streamIndex
, "Format_Profile");
571 if (!string.IsNullOrEmpty(audioFormat
))
573 if (audioFormat
.Contains("MPEG") && audioProfile
== "Layer 3")
575 else if (audioFormat
.Contains("MPEG") && audioProfile
== "Layer 2")
577 else if (audioFormat
.Contains("PCM")) //flv support(PCM_U8 * PCM_S16BE * PCM_MULAW * PCM_ALAW * ADPCM_SWF)
579 else if (audioFormat
== "AAC")
581 else if (audioFormat
== "AC3")
583 else if (audioFormat
== "ALAC")
590 ShowInfoMessage("该轨道无音频");
596 aextract
+= " -an -sn -c:v copy -y -map 0:v:" + streamIndex
+ " ";
600 throw new Exception("未知流!");
602 string suf
= "_audio_";
607 suf
+= "index" + streamIndex
;
608 string outfile
= Util
.GetDir(namevideo
) +
609 Path
.GetFileNameWithoutExtension(namevideo
) + suf
+ ext
;
610 aextract
+= Util
.FormatPath(outfile
);
611 //aextract = vextract;
612 batpath
= workPath
+ "\\" + av
+ "extract.bat";
613 File
.WriteAllText(batpath
, aextract
, UnicodeEncoding
.Default
);
615 System
.Diagnostics
.Process
.Start(batpath
);
618 private void ExtractTrack(string namevideo
, int streamIndex
)
620 if (string.IsNullOrEmpty(namevideo
))
622 ShowErrorMessage("请选择视频文件");
626 //aextract = "\"" + workPath + "\\mp4box.exe\" -raw 2 \"" + namevideo + "\"";
627 string aextract
= "";
628 aextract
+= Util
.FormatPath(workPath
+ "\\ffmpeg.exe");
629 aextract
+= " -i " + Util
.FormatPath(namevideo
);
630 aextract
+= " -map 0:" + streamIndex
+ " -c copy ";
631 string suf
= "_抽取流Index" + streamIndex
;
632 string outfile
= Util
.GetDir(namevideo
) +
633 Path
.GetFileNameWithoutExtension(namevideo
) + suf
+ '.' +
634 FormatExtractor
.Extract(workPath
, namevideo
)[streamIndex
].Format
;
635 aextract
+= Util
.FormatPath(outfile
);
636 batpath
= workPath
+ "\\mkvextract.bat";
637 File
.WriteAllText(batpath
, aextract
, UnicodeEncoding
.Default
);
639 System
.Diagnostics
.Process
.Start(batpath
);
642 private void button1_Click(object sender
, EventArgs e
)
644 ShowInfoMessage(String
.Format(" \r\n有任何建议或疑问可以通过以下方式联系小丸。\nQQ:57655408\n微博:weibo.com/xiaowan3\n百度贴吧ID:小丸到达\n\n\t\t\t发布日期:2012年10月17日\n\t\t\t- ( ゜- ゜)つロ 乾杯~"), "关于");
647 private void btnvextract_Click(object sender
, EventArgs e
)
650 ExtractAV(namevideo
, "v", 0);
651 //if (namevideo == "")
653 // MessageBox.Show("请选择视频文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
657 // //vextract = "\"" + workPath + "\\mp4box.exe\" -raw 1 \"" + namevideo + "\"";
659 // vextract += Cmd.FormatPath(workPath + "\\ffmpeg.exe");
660 // vextract += " -i " + Cmd.FormatPath(namevideo);
661 // vextract += " -an -sn -c:v:0 copy ";
662 // string outfile = Cmd.GetDir(namevideo) +
663 // Path.GetFileNameWithoutExtension(namevideo) + "_抽取视频1" + Path.GetExtension(namevideo);
664 // vextract += Cmd.FormatPath(outfile);
665 // batpath = workPath + "\\vextract.bat";
666 // File.WriteAllText(batpath, vextract, UnicodeEncoding.Default);
667 // LogRecord(vextract);
668 // System.Diagnostics.Process.Start(batpath);
672 private void txtvideo_TextChanged(object sender
, EventArgs e
)
676 if (txtvideo
.Text
.Trim().Length
> 0)
678 if (!File
.Exists(txtvideo
.Text
.Trim()))
680 throw new Exception("输入文件: \r\n\r\n" + txtvideo
.Text
.Trim() + "\r\n\r\n不存在!");
682 string inputExt
= Path
.GetExtension(txtvideo
.Text
.Trim()).ToLower();
683 //if (inputExt != ".avi" //Only MPEG-4 SP/ASP video and MP3 audio supported at the current time. To import AVC/H264 video, you must first extract the avi track.
684 // && inputExt != ".mp4" //MPEG-4 Video
685 // && inputExt != ".m1v" //MPEG-1 Video
686 // && inputExt != ".m2v" //MPEG-2 Video
687 // && inputExt != ".m4v" //MPEG-4 Video
688 // && inputExt != ".264" //AVC/H264 Video
689 // && inputExt != ".h264" //AVC/H264 Video
690 // && inputExt != ".hevc") //HEVC/H265 Video
692 // throw new Exception("输入文件: \r\n\r\n" + txtvideo.Text.Trim() + "\r\n\r\n是一个mp4box不支持的视频文件!");
694 if (inputExt
== ".264" || inputExt
== ".h264" || inputExt
== ".hevc")
696 ShowWarningMessage("H.264或者HEVC流文件mp4box将会自动侦测帧率\r\n如果侦测不到将默认为25fps\r\n如果你知道该文件的帧率建议手动设置");
698 namevideo
= txtvideo
.Text
;
699 txtout
.Text
= Util
.ChangeExt(txtvideo
.Text
, "_Mux.mp4");
704 txtvideo
.Text
= string.Empty
;
705 ShowErrorMessage(ex
.Message
);
709 private void txtaudio_TextChanged(object sender
, EventArgs e
)
713 if (txtaudio
.Text
.Trim().Length
> 0)
715 if (!File
.Exists(txtaudio
.Text
.Trim()))
717 throw new Exception("输入文件: \r\n\r\n" + txtaudio
.Text
.Trim() + "\r\n\r\n不存在!");
719 string inputExt
= Path
.GetExtension(txtaudio
.Text
.Trim()).ToLower();
720 if (inputExt
!= ".mp4"
721 && inputExt
!= ".aac" //ADIF or RAW formats not supported
722 && inputExt
!= ".mp3"
723 && inputExt
!= ".m4a"
724 && inputExt
!= ".mp2"
725 && inputExt
!= ".ac3")
727 throw new Exception("输入文件: \r\n\r\n" + txtaudio
.Text
.Trim() + "\r\n\r\n是一个mp4box不支持的音频文件!");
729 nameaudio
= txtaudio
.Text
;
734 txtaudio
.Text
= string.Empty
;
735 ShowErrorMessage(ex
.Message
);
739 private void txtout_TextChanged(object sender
, EventArgs e
)
741 nameout
= txtout
.Text
;
744 private void Form1_FormClosed(object sender
, FormClosedEventArgs e
)
746 #region Delete Temp Files
748 if (SetupDeleteTempFileCheckBox
.Checked
&& !workPath
.Equals("!undefined"))
750 List
<string> deleteFileList
= new List
<string>();
752 string systemDisk
= Environment
.GetFolderPath(Environment
.SpecialFolder
.System
).Substring(0, 3);
753 string systemTempPath
= systemDisk
+ @"windows\temp";
755 //Delete all BAT files
756 DirectoryInfo theFolder
= new DirectoryInfo(workPath
);
757 foreach (FileInfo NextFile
in theFolder
.GetFiles())
759 if (NextFile
.Extension
.Equals(".bat"))
760 deleteFileList
.Add(NextFile
.FullName
);
763 //string[] deletedfiles = { tempPic, "msg.vbs", tempavspath, "temp.avs", "clip.bat", "aextract.bat", "vextract.bat",
764 // "x264.bat", "aac.bat", "auto.bat", "mux.bat", "flv.bat", "mkvmerge.bat", "mkvextract.bat", "tmp.stat.mbtree", "tmp.stat" };
765 string[] deletedfiles
= { "temp.wav", "temp.aac", "temp.mp4", "concat.txt", tempPic
, tempavspath
, workPath
+ "msg.vbs", startpath
+ "\\x264_2pass.log.mbtree",
766 startpath
+ "\\x264_2pass.log", "temp.hevc", startpath
+ "\\x265_2pass.log", startpath
+ "\\x265_2pass.log.cutree" };
767 deleteFileList
.AddRange(deletedfiles
);
769 foreach (string file
in deleteFileList
)
775 #endregion Delete Temp Files
777 #region Save Settings
781 #endregion Save Settings
784 private void txtvideo4_TextChanged(object sender
, EventArgs e
)
786 if (File
.Exists(txtvideo4
.Text
.ToString()))
788 namevideo4
= txtvideo4
.Text
;
789 //string finish = namevideo4.Insert(namevideo4.LastIndexOf(".")-1,"");
790 //string ext = namevideo4.Substring(namevideo4.LastIndexOf(".") + 1, 3);
791 //finish += "_clip." + ext;
792 string finish
= namevideo4
.Insert(namevideo4
.LastIndexOf("."), "_output");
793 txtout5
.Text
= finish
;
797 private void txtout5_TextChanged(object sender
, EventArgs e
)
799 nameout5
= txtout5
.Text
;
802 private void btnvideo4_Click(object sender
, EventArgs e
)
804 openFileDialog1
.Filter
= "视频(*.mp4;*.flv;*.mkv)|*.mp4;*.flv;*.mkv|所有文件(*.*)|*.*";
805 DialogResult result
= openFileDialog1
.ShowDialog();
806 if (result
== DialogResult
.OK
)
808 namevideo4
= openFileDialog1
.FileName
;
809 txtvideo4
.Text
= namevideo4
;
813 private void btnout5_Click(object sender
, EventArgs e
)
815 SaveFileDialog savefile
= new SaveFileDialog();
816 savefile
.Filter
= "视频(*.*)|*.*";
817 DialogResult result
= savefile
.ShowDialog();
818 if (result
== DialogResult
.OK
)
820 nameout5
= savefile
.FileName
;
821 txtout5
.Text
= nameout5
;
825 public static bool IsWindowsVistaOrNewer
827 get { return (Environment.OSVersion.Platform == PlatformID.Win32NT) && (Environment.OSVersion.Version.Major >= 6); }
835 private void InitParameter()
837 x264CRFNum
.Value
= 24;
838 x264BitrateNum
.Value
= 800;
839 x264AudioParameterTextBox
.Text
= "--abitrate 128";
840 x264AudioModeComboBox
.SelectedIndex
= 0;
841 x264DemuxerComboBox
.SelectedIndex
= 2;
842 x264WidthNum
.Value
= 0;
843 x264HeightNum
.Value
= 0;
844 x264CustomParameterTextBox
.Text
= "";
845 x264PriorityComboBox
.SelectedIndex
= 2;
846 AudioEncoderComboBox
.SelectedIndex
= 0;
847 AudioCustomParameterTextBox
.Text
= "";
848 AudioBitrateComboBox
.Text
= "128";
849 OnePicAudioBitrateNum
.Value
= 128;
850 OnePicFPSNum
.Value
= 1;
851 OnePicCRFNum
.Value
= 24;
852 AVSScriptTextBox
.Text
= "";
853 BlackFPSNum
.Value
= 1;
854 BlackCRFNum
.Value
= 51;
855 BlackBitrateNum
.Value
= 900;
856 SetupDeleteTempFileCheckBox
.Checked
= true;
857 TransposeComboBox
.SelectedIndex
= 1;
860 private void LoadSettings()
865 x264CRFNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["x264CRF"]);
866 x264BitrateNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["x264Bitrate"]);
867 x264AudioParameterTextBox
.Text
= ConfigurationManager
.AppSettings
["x264AudioParameter"];
868 x264AudioModeComboBox
.SelectedIndex
= Convert
.ToInt32(ConfigurationManager
.AppSettings
["x264AudioMode"]);
869 x264ExeComboBox
.SelectedIndex
= Convert
.ToInt32(ConfigurationManager
.AppSettings
["x264Exe"]);
870 x264DemuxerComboBox
.SelectedIndex
= Convert
.ToInt32(ConfigurationManager
.AppSettings
["x264Demuxer"]);
871 x264WidthNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["x264Width"]);
872 x264HeightNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["x264Height"]);
873 x264CustomParameterTextBox
.Text
= ConfigurationManager
.AppSettings
["x264CustomParameter"];
874 x264PriorityComboBox
.SelectedIndex
= Convert
.ToInt32(ConfigurationManager
.AppSettings
["x264Priority"]);
875 x264extraLine
.Text
= ConfigurationManager
.AppSettings
["x264ExtraParameter"];
876 AVSScriptTextBox
.Text
= ConfigurationManager
.AppSettings
["AVSScript"];
877 AudioEncoderComboBox
.SelectedIndex
= Convert
.ToInt32(ConfigurationManager
.AppSettings
["AudioEncoder"]);
878 AudioCustomParameterTextBox
.Text
= ConfigurationManager
.AppSettings
["AudioCustomParameter"];
879 AudioBitrateComboBox
.Text
= ConfigurationManager
.AppSettings
["AudioBitrate"];
880 OnePicAudioBitrateNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["OnePicAudioBitrate"]);
881 OnePicFPSNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["OnePicFPS"]);
882 OnePicCRFNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["OnePicCRF"]);
883 BlackFPSNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["BlackFPS"]);
884 BlackCRFNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["BlackCRF"]);
885 BlackBitrateNum
.Value
= Convert
.ToDecimal(ConfigurationManager
.AppSettings
["BlackBitrate"]);
886 SetupDeleteTempFileCheckBox
.Checked
= Convert
.ToBoolean(ConfigurationManager
.AppSettings
["SetupDeleteTempFile"]);
887 CheckUpdateCheckBox
.Checked
= Convert
.ToBoolean(ConfigurationManager
.AppSettings
["CheckUpdate"]);
888 x264ThreadsComboBox
.SelectedIndex
= Convert
.ToInt32(ConfigurationManager
.AppSettings
["x264Threads"]);
889 TrayModeCheckBox
.Checked
= Convert
.ToBoolean(ConfigurationManager
.AppSettings
["TrayMode"]);
890 SplashScreenCheckBox
.Checked
= Convert
.ToBoolean(ConfigurationManager
.AppSettings
["SplashScreen"]);
891 SetupPlayerTextBox
.Text
= ConfigurationManager
.AppSettings
["PreviewPlayer"];
892 string SubLangExt
= Convert
.ToString(ConfigurationManager
.AppSettings
["SubLanguageExtension"]);
893 MuxFormatComboBox
.SelectedIndex
= Convert
.ToInt32(ConfigurationManager
.AppSettings
["MuxFormat"]);
894 x264BatchSubSpecialLanguage
.DataSource
= SubLangExt
.Split(',');
895 if (x264ExeComboBox
.SelectedIndex
== -1)
897 x264ExeComboBox
.SelectedIndex
= x264ExeComboBox
.Items
.IndexOf("x264_32-8bit");
900 if (int.Parse(ConfigurationManager
.AppSettings
["LanguageIndex"]) == -1) //First Startup
902 string culture
= System
.Threading
.Thread
.CurrentThread
.CurrentCulture
.Name
;
906 languageComboBox
.SelectedIndex
= 0;
910 languageComboBox
.SelectedIndex
= 0;
914 languageComboBox
.SelectedIndex
= 1;
918 languageComboBox
.SelectedIndex
= 1;
922 languageComboBox
.SelectedIndex
= 1;
926 languageComboBox
.SelectedIndex
= 2;
930 languageComboBox
.SelectedIndex
= 3;
938 languageComboBox
.SelectedIndex
= int.Parse(ConfigurationManager
.AppSettings
["LanguageIndex"]);
940 if (CheckUpdateCheckBox
.Checked
&& Util
.IsConnectInternet())
944 CheckUpadateDelegate checkUpdateDelegate
= CheckUpdate
;
945 checkUpdateDelegate
.BeginInvoke(out d
, out f
, new AsyncCallback(CheckUpdateCallBack
), null);
947 x264ExeComboBox_SelectedIndexChanged(null, null);
955 private void SaveSettings()
957 Configuration cfa
= ConfigurationManager
.OpenExeConfiguration(ConfigurationUserLevel
.None
);
958 cfa
.AppSettings
.Settings
["x264CRF"].Value
= x264CRFNum
.Value
.ToString();
959 cfa
.AppSettings
.Settings
["x264Bitrate"].Value
= x264BitrateNum
.Value
.ToString();
960 cfa
.AppSettings
.Settings
["x264AudioParameter"].Value
= x264AudioParameterTextBox
.Text
;
961 cfa
.AppSettings
.Settings
["x264AudioMode"].Value
= x264AudioModeComboBox
.SelectedIndex
.ToString();
962 cfa
.AppSettings
.Settings
["x264Exe"].Value
= x264ExeComboBox
.SelectedIndex
.ToString();
963 cfa
.AppSettings
.Settings
["x264Demuxer"].Value
= x264DemuxerComboBox
.SelectedIndex
.ToString();
964 cfa
.AppSettings
.Settings
["x264Width"].Value
= x264WidthNum
.Value
.ToString();
965 cfa
.AppSettings
.Settings
["x264Height"].Value
= x264HeightNum
.Value
.ToString();
966 cfa
.AppSettings
.Settings
["x264CustomParameter"].Value
= x264CustomParameterTextBox
.Text
;
967 cfa
.AppSettings
.Settings
["x264Priority"].Value
= x264PriorityComboBox
.SelectedIndex
.ToString();
968 cfa
.AppSettings
.Settings
["x264ExtraParameter"].Value
= x264extraLine
.Text
;
969 cfa
.AppSettings
.Settings
["AVSScript"].Value
= AVSScriptTextBox
.Text
;
970 cfa
.AppSettings
.Settings
["AudioEncoder"].Value
= AudioEncoderComboBox
.SelectedIndex
.ToString();
971 cfa
.AppSettings
.Settings
["AudioCustomParameter"].Value
= AudioCustomParameterTextBox
.Text
;
972 cfa
.AppSettings
.Settings
["AudioParameter"].Value
= AudioBitrateComboBox
.Text
;
973 cfa
.AppSettings
.Settings
["OnePicAudioBitrate"].Value
= OnePicAudioBitrateNum
.Value
.ToString();
974 cfa
.AppSettings
.Settings
["OnePicFPS"].Value
= OnePicFPSNum
.Value
.ToString();
975 cfa
.AppSettings
.Settings
["OnePicCRF"].Value
= OnePicCRFNum
.Value
.ToString();
976 cfa
.AppSettings
.Settings
["BlackFPS"].Value
= BlackFPSNum
.Value
.ToString();
977 cfa
.AppSettings
.Settings
["BlackCRF"].Value
= BlackCRFNum
.Value
.ToString();
978 cfa
.AppSettings
.Settings
["BlackBitrate"].Value
= BlackBitrateNum
.Value
.ToString();
979 cfa
.AppSettings
.Settings
["SetupDeleteTempFile"].Value
= SetupDeleteTempFileCheckBox
.Checked
.ToString();
980 cfa
.AppSettings
.Settings
["CheckUpdate"].Value
= CheckUpdateCheckBox
.Checked
.ToString();
981 cfa
.AppSettings
.Settings
["TrayMode"].Value
= TrayModeCheckBox
.Checked
.ToString();
982 cfa
.AppSettings
.Settings
["LanguageIndex"].Value
= languageComboBox
.SelectedIndex
.ToString();
983 cfa
.AppSettings
.Settings
["SplashScreen"].Value
= SplashScreenCheckBox
.Checked
.ToString();
984 cfa
.AppSettings
.Settings
["x264Threads"].Value
= x264ThreadsComboBox
.SelectedIndex
.ToString();
985 cfa
.AppSettings
.Settings
["PreviewPlayer"].Value
= SetupPlayerTextBox
.Text
;
986 cfa
.AppSettings
.Settings
["MuxFormat"].Value
= MuxFormatComboBox
.SelectedIndex
.ToString(); ;
988 ConfigurationManager
.RefreshSection("appSettings"); // 刷新命名节,在下次检索它时将从磁盘重新读取它。记住应用程序要刷新节点
993 private void Form1_Load(object sender
, EventArgs e
)
995 SYSTEM_INFO pSI
= new SYSTEM_INFO();
996 GetSystemInfo(ref pSI
);
997 int processorNumber
= (int)pSI
.dwNumberOfProcessors
;
999 x264ThreadsComboBox
.Items
.Add("auto");
1000 for (int i
= 1; i
<= 16; i
++)
1002 x264ThreadsComboBox
.Items
.Add(i
.ToString());
1004 //Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-TW");
1005 //use YAHEI in VistaOrNewer
1006 //if (IsWindowsVistaOrNewer)
1008 // FontFamily myFontFamily = new FontFamily("微软雅黑"); //采用哪种字体
1009 // Font myFont = new Font(myFontFamily, 9, FontStyle.Regular); //字是那种字体,显示的风格
1010 // this.Font = myFont;
1014 startpath
= System
.Windows
.Forms
.Application
.StartupPath
;
1015 workPath
= startpath
+ "\\tools";
1016 if (!Directory
.Exists(workPath
))
1018 MessageBox
.Show("tools文件夹没有解压喔~ 工具箱里没有工具的话运行不起来的喔~", "(这只丸子)",
1019 MessageBoxButtons
.OK
, MessageBoxIcon
.Error
);
1020 Environment
.Exit(1);
1022 //Directory.CreateDirectory(workPath);
1023 //string diskSymbol = startpath.Substring(0, 1);
1025 //string systemDisk = Environment.GetFolderPath(Environment.SpecialFolder.System).Substring(0, 3);
1026 //string systemTempPath = systemDisk + @"windows\temp";
1027 string systemTempPath
= Environment
.GetEnvironmentVariable("TEMP", EnvironmentVariableTarget
.Machine
);
1028 tempavspath
= systemTempPath
+ "\\temp.avs";
1029 tempPic
= systemTempPath
+ "\\marukotemp.jpg";
1033 DirectoryInfo folder
= new DirectoryInfo(workPath
);
1034 List
<string> x264exe
= new List
<string>();
1035 foreach (FileInfo FileName
in folder
.GetFiles())
1037 if ((FileName
.Name
.ToLower().Contains("x264") || FileName
.Name
.ToLower().Contains("xxxx")) && Path
.GetExtension(FileName
.Name
) == ".exe")
1039 x264exe
.Add(FileName
.Name
);
1042 x264exe
= x264exe
.OrderByDescending(i
=> i
.Substring(7)).ToList();
1043 x264ExeComboBox
.Items
.AddRange(x264exe
.ToArray());
1046 DirectoryInfo avspath
= new DirectoryInfo(workPath
+ "\\avsfilter");
1047 List
<string> avsfilters
= new List
<string>();
1048 foreach (FileInfo FileName
in avspath
.GetFiles())
1050 if (Path
.GetExtension(FileName
.Name
) == ".dll")
1052 avsfilters
.Add(FileName
.Name
);
1055 AVSFilterComboBox
.Items
.AddRange(avsfilters
.ToArray());
1057 //ReleaseDate = System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location); //获得程序编译时间
1058 ReleaseDatelabel
.Text
= ReleaseDate
.ToString("yyyy-M-d");
1061 if (File
.Exists(startpath
+ "\\help.rtf"))
1063 HelpTextBox
.LoadFile(startpath
+ "\\help.rtf");
1069 string preset
= workPath
+ "\\preset";
1070 if (!Directory
.Exists(preset
))
1071 Directory
.CreateDirectory(preset
);
1072 DirectoryInfo TheFolder
= new DirectoryInfo(preset
);
1073 foreach (FileInfo FileName
in TheFolder
.GetFiles())
1075 VideoPresetComboBox
.Items
.Add(FileName
.Name
.Replace(".txt", ""));
1077 if (File
.Exists("preset.xml"))
1079 xdoc
= XDocument
.Load("preset.xml");
1080 XElement xAudios
= xdoc
.Element("root").Element("Audio");
1081 foreach (XElement item
in xAudios
.Elements())
1083 AudioPresetComboBox
.Items
.Add(item
.Attribute("Name").Value
);
1084 AudioPresetComboBox
.SelectedIndex
= 0;
1089 private void button2_Click(object sender
, EventArgs e
)
1091 openFileDialog1
.Filter
= "视频(*.mkv)|*.mkv";
1092 DialogResult result
= openFileDialog1
.ShowDialog();
1093 if (result
== DialogResult
.OK
)
1095 namevideo6
= openFileDialog1
.FileName
;
1096 txtvideo6
.Text
= namevideo6
;
1100 private void button3_Click(object sender
, EventArgs e
)
1102 if (namevideo6
== "")
1104 ShowErrorMessage("请选择视频文件");
1108 mkvextract
= workPath
+ "\\ mkvextract.exe tracks \"" + namevideo6
+ "\" 1:video.h264 2:audio.aac";
1109 batpath
= workPath
+ "\\mkvextract.bat";
1110 File
.WriteAllText(batpath
, mkvextract
, UnicodeEncoding
.Default
);
1111 System
.Diagnostics
.Process
.Start(batpath
);
1115 private void button4_Click(object sender
, EventArgs e
)
1117 openFileDialog1
.Filter
= "视频(*.mp4)|*.mp4|所有文件(*.*)|*.*";
1118 DialogResult result
= openFileDialog1
.ShowDialog();
1119 if (result
== DialogResult
.OK
)
1121 namevideo5
= openFileDialog1
.FileName
;
1122 txtvideo5
.Text
= namevideo5
;
1126 private void button5_Click(object sender
, EventArgs e
)
1128 openFileDialog1
.Filter
= "音频(*.mp3)|*.mp3|音频(*.aac)|*.aac|所有文件(*.*)|*.*";
1129 DialogResult result
= openFileDialog1
.ShowDialog();
1130 if (result
== DialogResult
.OK
)
1132 nameaudio3
= openFileDialog1
.FileName
;
1133 txtaudio3
.Text
= nameaudio3
;
1137 private void button6_Click(object sender
, EventArgs e
)
1139 SaveFileDialog savefile
= new SaveFileDialog();
1140 savefile
.Filter
= "视频(*.mkv)|*.mkv";
1141 DialogResult result
= savefile
.ShowDialog();
1142 if (result
== DialogResult
.OK
)
1144 nameout6
= savefile
.FileName
;
1145 txtout6
.Text
= nameout6
;
1149 private void button7_Click(object sender
, EventArgs e
)
1151 if (namevideo5
== "")
1153 ShowErrorMessage("请选择视频文件");
1155 else if (nameaudio3
== "")
1157 ShowErrorMessage("请选择音频文件");
1159 else if (nameout6
== "")
1161 ShowErrorMessage("请选择输出文件");
1165 mkvmerge
= workPath
+ "\\mkvmerge.exe -o \"" + nameout6
+ "\" \"" + namevideo5
+ "\" \"" + nameaudio3
+ "\"";
1166 batpath
= workPath
+ "\\mkvmerge.bat";
1167 File
.WriteAllText(batpath
, mkvmerge
, UnicodeEncoding
.Default
);
1168 System
.Diagnostics
.Process
.Start(batpath
);
1172 private void button2_Click_1(object sender
, EventArgs e
)
1174 openFileDialog1
.Filter
= "所有文件(*.*)|*.*";
1175 DialogResult result
= openFileDialog1
.ShowDialog();
1176 if (result
== DialogResult
.OK
)
1178 namevideo5
= openFileDialog1
.FileName
;
1179 txtvideo5
.Text
= namevideo5
;
1183 private void button6_Click_1(object sender
, EventArgs e
)
1185 openFileDialog1
.Filter
= "视频(*.mkv)|*.mkv";
1186 DialogResult result
= openFileDialog1
.ShowDialog();
1187 if (result
== DialogResult
.OK
)
1189 namevideo6
= openFileDialog1
.FileName
;
1190 txtvideo6
.Text
= namevideo6
;
1194 private void button7_Click_1(object sender
, EventArgs e
)
1196 if (namevideo5
== "" && nameaudio3
== "")
1198 ShowErrorMessage("请选择文件");
1202 if (txtaudio3
.Text
!= "" && txtsub
.Text
!= "")
1204 mkvmerge
= "\"" + workPath
+ "\\mkvmerge.exe\" -o \"" + nameout6
+ "\" \"" + namevideo5
+ "\" \"" + nameaudio3
+ "\" \"" + namesub
+ "\"";
1206 if (txtaudio3
.Text
== "" && txtsub
.Text
== "")
1208 mkvmerge
= "\"" + workPath
+ "\\mkvmerge.exe\" -o \"" + nameout6
+ "\" \"" + namevideo5
+ "\"";
1210 if (txtaudio3
.Text
!= "" && txtsub
.Text
== "")
1212 mkvmerge
= "\"" + workPath
+ "\\mkvmerge.exe\" -o \"" + nameout6
+ "\" \"" + namevideo5
+ "\" \"" + nameaudio3
+ "\"";
1214 if (txtaudio3
.Text
== "" && txtsub
.Text
!= "")
1216 mkvmerge
= "\"" + workPath
+ "\\mkvmerge.exe\" -o \"" + nameout6
+ "\" \"" + namevideo5
+ "\" \"" + namesub
+ "\"";
1218 mkvmerge
+= "\r\ncmd";
1219 batpath
= workPath
+ "\\mkvmerge.bat";
1220 File
.WriteAllText(batpath
, mkvmerge
, UnicodeEncoding
.Default
);
1221 LogRecord(mkvmerge
);
1222 System
.Diagnostics
.Process
.Start(batpath
);
1226 private void button4_Click_1(object sender
, EventArgs e
)
1228 SaveFileDialog savefile
= new SaveFileDialog();
1229 savefile
.Filter
= "视频(*.mkv)|*.mkv";
1230 DialogResult result
= savefile
.ShowDialog();
1231 if (result
== DialogResult
.OK
)
1233 nameout6
= savefile
.FileName
;
1234 txtout6
.Text
= nameout6
;
1238 private void button3_Click_1(object sender
, EventArgs e
)
1240 openFileDialog1
.Filter
= "音频(*.mp3;*.aac;*.ac3)|*.mp3;*.aac;*.ac3|所有文件(*.*)|*.*";
1241 DialogResult result
= openFileDialog1
.ShowDialog();
1242 if (result
== DialogResult
.OK
)
1244 nameaudio3
= openFileDialog1
.FileName
;
1245 txtaudio3
.Text
= nameaudio3
;
1249 private void button5_Click_1(object sender
, EventArgs e
)
1251 openFileDialog1
.Filter
= "字幕(*.ass;*.ssa;*.srt)|*.ass;*.ssa;*.srt|所有文件(*.*)|*.*";
1252 DialogResult result
= openFileDialog1
.ShowDialog();
1253 if (result
== DialogResult
.OK
)
1255 namesub
= openFileDialog1
.FileName
;
1256 txtsub
.Text
= namesub
;
1260 private void button8_Click(object sender
, EventArgs e
)
1262 if (namevideo6
== "")
1264 ShowErrorMessage("请选择视频文件");
1268 int i
= namevideo6
.IndexOf(".mkv");
1269 string mkvname
= namevideo6
.Remove(i
);
1270 mkvextract
= "\"" + workPath
+ "\\mkvextract.exe\" tracks \"" + namevideo6
+ "\" 1:\"" + mkvname
+ "_video.h264\" 2:\"" + mkvname
+ "_audio.aac\"";
1271 batpath
= workPath
+ "\\mkvextract.bat";
1272 File
.WriteAllText(batpath
, mkvextract
, UnicodeEncoding
.Default
);
1273 System
.Diagnostics
.Process
.Start(batpath
);
1277 private void txtvideo5_TextChanged(object sender
, EventArgs e
)
1279 if (File
.Exists(txtvideo5
.Text
.ToString()))
1281 namevideo5
= txtvideo5
.Text
;
1282 string finish
= namevideo5
.Remove(namevideo5
.LastIndexOf("."));
1283 finish
+= "_mkv封装.mkv";
1284 txtout6
.Text
= finish
;
1288 private void txtaudio3_TextChanged(object sender
, EventArgs e
)
1290 nameaudio3
= txtaudio3
.Text
;
1293 private void txtsub_TextChanged(object sender
, EventArgs e
)
1295 namesub
= txtsub
.Text
;
1298 private void txtout6_TextChanged_1(object sender
, EventArgs e
)
1300 nameout6
= txtout6
.Text
;
1303 private void txtvideo6_TextChanged(object sender
, EventArgs e
)
1305 namevideo6
= txtvideo6
.Text
;
1308 private void btnAutoAdd_Click(object sender
, EventArgs e
)
1310 openFileDialog1
.Multiselect
= true;
1311 openFileDialog1
.Filter
= "所有文件(*.*)|*.*";
1312 DialogResult result
= openFileDialog1
.ShowDialog();
1313 if (result
== DialogResult
.OK
)
1315 lbAuto
.Items
.AddRange(openFileDialog1
.FileNames
);
1319 private void btnAutoDel_Click(object sender
, EventArgs e
)
1321 if (lbAuto
.Items
.Count
> 0)
1323 if (lbAuto
.SelectedItems
.Count
> 0)
1325 int index
= lbAuto
.SelectedIndex
;
1326 lbAuto
.Items
.RemoveAt(lbAuto
.SelectedIndex
);
1327 if (index
== lbAuto
.Items
.Count
)
1329 lbAuto
.SelectedIndex
= index
- 1;
1331 if (index
>= 0 && index
< lbAuto
.Items
.Count
&& lbAuto
.Items
.Count
> 0)
1333 lbAuto
.SelectedIndex
= index
;
1339 private void btnAutoClear_Click(object sender
, EventArgs e
)
1341 lbAuto
.Items
.Clear();
1344 private void lbAuto_DragDrop(object sender
, DragEventArgs e
)
1346 ListBox listbox
= (ListBox
)sender
;
1347 if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
, false))
1349 String
[] files
= (String
[])e
.Data
.GetData(DataFormats
.FileDrop
);
1350 foreach (String s
in files
)
1352 listbox
.Items
.Add(s
);
1356 indexoftarget
= listbox
.IndexFromPoint(listbox
.PointToClient(new Point(e
.X
, e
.Y
)));
1357 if (indexoftarget
!= ListBox
.NoMatches
)
1359 string temp
= listbox
.Items
[indexoftarget
].ToString();
1360 listbox
.Items
[indexoftarget
] = listbox
.Items
[indexofsource
];
1361 listbox
.Items
[indexofsource
] = temp
;
1362 listbox
.SelectedIndex
= indexoftarget
;
1366 private void lbAuto_DragEnter(object sender
, DragEventArgs e
)
1368 //if (e.Data.GetDataPresent(DataFormats.FileDrop))
1369 // e.Effect = DragDropEffects.All;
1370 //else e.Effect = DragDropEffects.None;
1373 private void lbAuto_DragOver(object sender
, DragEventArgs e
)
1375 //拖动源和放置的目的地一定是一个ListBox
1376 ListBox listbox
= (ListBox
)sender
;
1377 if (e
.Data
.GetDataPresent(typeof(System
.String
)) && ((ListBox
)sender
).Equals(listbox
))
1379 e
.Effect
= DragDropEffects
.Move
;
1381 else if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
))
1383 e
.Effect
= DragDropEffects
.Link
;
1385 else e
.Effect
= DragDropEffects
.None
;
1388 private void lbAuto_MouseDown(object sender
, MouseEventArgs e
)
1390 indexofsource
= ((ListBox
)sender
).IndexFromPoint(e
.X
, e
.Y
);
1391 if (indexofsource
== 65535)
1393 if (indexofsource
!= ListBox
.NoMatches
)
1395 ((ListBox
)sender
).DoDragDrop(((ListBox
)sender
).Items
[indexofsource
].ToString(), DragDropEffects
.All
);
1399 public string VideoBatch(string input
, string output
)
1401 bool hasAudio
= false;
1403 string tempVideo
= "temp.mp4";
1404 string tempAudio
= "temp.aac";
1407 MediaInfo MI
= new MediaInfo();
1409 string audio
= MI
.Get(StreamKind
.Audio
, 0, "Format");
1410 if (!string.IsNullOrEmpty(audio
)) { hasAudio = true; }
1411 string sub
= (x264BatchSubCheckBox
.Checked
) ? GetSubtitlePath(input
) : string.Empty
;
1413 if (x264AudioModeComboBox
.SelectedIndex
== 0 && hasAudio
) //如果压制音频
1414 aextract
= audiobat(input
, tempAudio
);
1416 if (x264ExeComboBox
.SelectedItem
.ToString().ToLower().Contains("x264"))
1419 x264
= x264bat(input
, tempVideo
, 1, sub
) + "\r\n" +
1420 x264bat(input
, tempVideo
, 2, sub
);
1421 else x264
= x264bat(input
, tempVideo
, 0, sub
);
1422 if (x264AudioModeComboBox
.SelectedIndex
!= 0 || !hasAudio
)
1423 x264
= x264
.Replace(tempVideo
, output
);
1425 else if (x264ExeComboBox
.SelectedItem
.ToString().ToLower().Contains("x265"))
1427 tempVideo
= "temp.hevc";
1429 x264
= x265bat(input
, tempVideo
, 1) + "\r\n" +
1430 x265bat(input
, tempVideo
, 2);
1431 else x264
= x265bat(input
, tempVideo
, 0);
1432 if (x264AudioModeComboBox
.SelectedIndex
!= 0 || !hasAudio
)
1434 x264
+= "\r\n\"" + workPath
+ "\\mp4box.exe\" -add \"" + tempVideo
+ "#trackID=1:name=\" -new \"" + output
+ "\" \r\n";
1435 x264
+= "del \"" + tempVideo
+ "\"";
1441 if (VideoBatchFormatComboBox
.Text
== "mp4")
1442 mux
= boxmuxbat(tempVideo
, tempAudio
, output
);
1444 mux
= ffmuxbat(tempVideo
, tempAudio
, output
);
1445 if (x264AudioModeComboBox
.SelectedIndex
== 0 && hasAudio
) //如果压制音频
1446 bat
+= aextract
+ x264
+ mux
+ " \r\ndel " + tempVideo
+ "\r\ndel " + tempAudio
+ "\r\n";
1452 private void btnBatchAuto_Click(object sender
, EventArgs e
)
1454 if (lbAuto
.Items
.Count
== 0)
1456 ShowErrorMessage("请输入视频!");
1460 if (x264ExeComboBox
.SelectedIndex
== -1)
1462 ShowErrorMessage("请选择X264程序");
1467 for (int i
= 0; i
< this.lbAuto
.Items
.Count
; i
++)
1469 string input
= lbAuto
.Items
[i
].ToString();
1471 if (Directory
.Exists(x264PathTextBox
.Text
))
1472 output
= x264PathTextBox
.Text
+ "\\" + Path
.GetFileNameWithoutExtension(input
) + "_batch." + VideoBatchFormatComboBox
.Text
;
1474 output
= Util
.ChangeExt(input
, "_batch." + VideoBatchFormatComboBox
.Text
);
1475 bat
+= VideoBatch(lbAuto
.Items
[i
].ToString(), output
);
1479 System
.Threading
.Thread
.CurrentThread
.CurrentUICulture
= new System
.Globalization
.CultureInfo(GetCultureName());
1480 WorkingForm wf
= new WorkingForm(bat
, lbAuto
.Items
.Count
);
1483 //batpath = workPath + "\\auto.bat";
1484 //File.WriteAllText(batpath, bat, UnicodeEncoding.Default);
1485 //System.Diagnostics.Process.Start(batpath);
1488 private void lbffmpeg_MouseDown(object sender
, MouseEventArgs e
)
1490 indexofsource
= ((ListBox
)sender
).IndexFromPoint(e
.X
, e
.Y
);
1491 if (indexofsource
!= ListBox
.NoMatches
)
1493 ((ListBox
)sender
).DoDragDrop(((ListBox
)sender
).Items
[indexofsource
].ToString(), DragDropEffects
.All
);
1497 private void lbffmpeg_DragDrop(object sender
, DragEventArgs e
)
1499 if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
, false))
1501 String
[] files
= (String
[])e
.Data
.GetData(DataFormats
.FileDrop
);
1502 foreach (String s
in files
)
1504 (sender
as ListBox
).Items
.Add(s
);
1507 ListBox listbox
= (ListBox
)sender
;
1508 indexoftarget
= listbox
.IndexFromPoint(listbox
.PointToClient(new Point(e
.X
, e
.Y
)));
1509 if (indexoftarget
!= ListBox
.NoMatches
)
1511 string temp
= listbox
.Items
[indexoftarget
].ToString();
1512 listbox
.Items
[indexoftarget
] = listbox
.Items
[indexofsource
];
1513 listbox
.Items
[indexofsource
] = temp
;
1514 listbox
.SelectedIndex
= indexoftarget
;
1518 private void lbffmpeg_DragOver(object sender
, DragEventArgs e
)
1520 //拖动源和放置的目的地一定是一个ListBox
1521 if (e
.Data
.GetDataPresent(typeof(System
.String
)) && ((ListBox
)sender
).Equals(lbffmpeg
))
1523 e
.Effect
= DragDropEffects
.Move
;
1525 else if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
))
1527 e
.Effect
= DragDropEffects
.Link
;
1529 else e
.Effect
= DragDropEffects
.None
;
1532 private void btnffmpegAdd_Click(object sender
, EventArgs e
)
1534 openFileDialog1
.Multiselect
= true;
1535 openFileDialog1
.Filter
= "所有文件(*.*)|*.*";
1536 DialogResult result
= openFileDialog1
.ShowDialog();
1537 if (result
== DialogResult
.OK
)
1539 lbffmpeg
.Items
.AddRange(openFileDialog1
.FileNames
);
1543 private void btnffmpegDel_Click(object sender
, EventArgs e
)
1545 if (lbffmpeg
.Items
.Count
> 0)
1547 if (lbffmpeg
.SelectedItems
.Count
> 0)
1549 int index
= lbffmpeg
.SelectedIndex
;
1550 lbffmpeg
.Items
.RemoveAt(lbffmpeg
.SelectedIndex
);
1551 if (index
== lbffmpeg
.Items
.Count
)
1553 lbffmpeg
.SelectedIndex
= index
- 1;
1555 if (index
>= 0 && index
< lbffmpeg
.Items
.Count
&& lbffmpeg
.Items
.Count
> 0)
1557 lbffmpeg
.SelectedIndex
= index
;
1563 private void btnffmpegClear_Click(object sender
, EventArgs e
)
1565 lbffmpeg
.Items
.Clear();
1568 private void btnBatchMP4_Click(object sender
, EventArgs e
)
1570 if (lbffmpeg
.Items
.Count
!= 0)
1572 string ext
= MuxFormatComboBox
.Text
;
1574 for (int i
= 0; i
< lbffmpeg
.Items
.Count
; i
++)
1576 string filePath
= lbffmpeg
.Items
[i
].ToString();
1577 //如果是源文件的格式和目标格式相同则跳过
1578 if (Path
.GetExtension(filePath
).Contains(ext
))
1580 string finish
= filePath
.Remove(filePath
.LastIndexOf(".") + 1) + ext
;
1584 MediaInfo MI
= new MediaInfo();
1586 string audio
= MI
.Get(StreamKind
.Audio
, 0, "Format");
1587 if (audio
.ToLower() != "aac")
1589 //string tempAudio = Util.ChangeExt(filePath, "_temp.aac");
1590 //AudioEncoderComboBox.SelectedIndex = 1;
1591 //aextract = audiobat(filePath, tempAudio);
1592 mux
+= "\"" + workPath
+ "\\ffmpeg.exe\" -y -i \"" + lbffmpeg
.Items
[i
].ToString() + "\" -c:v copy -c:a " + MuxAacEncoderComboBox
.Text
+ " \"" + finish
+ "\" \r\n";
1596 mux
+= "\"" + workPath
+ "\\ffmpeg.exe\" -y -i \"" + lbffmpeg
.Items
[i
].ToString() + "\" -c copy \"" + finish
+ "\" \r\n";
1600 batpath
= workPath
+ "\\mux.bat";
1601 File
.WriteAllText(batpath
, mux
, UnicodeEncoding
.Default
);
1603 Process
.Start(batpath
);
1605 else ShowErrorMessage("请输入视频!");
1608 private void txtvideo8_TextChanged(object sender
, EventArgs e
)
1610 namevideo8
= txtvideo8
.Text
;
1613 private void btnvextract8_Click(object sender
, EventArgs e
)
1616 ExtractAV(namevideo8
, "v", 0);
1617 //if (namevideo8 == "")
1619 // MessageBox.Show("请选择视频文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1623 // vextract = "\"" + workPath + "\\FLVExtractCL.exe\" -v \"" + namevideo8 + "\"";
1624 // batpath = workPath + "\\vextract.bat";
1625 // File.WriteAllText(batpath, vextract, UnicodeEncoding.Default);
1626 // LogRecord(vextract);
1627 // System.Diagnostics.Process.Start(batpath);
1631 private void btnaextract8_Click(object sender
, EventArgs e
)
1634 ExtractAV(namevideo8
, "a", 0);
1635 //if (namevideo8 == "")
1637 // MessageBox.Show("请选择视频文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
1641 // aextract = "\"" + workPath + "\\FLVExtractCL.exe\" -a \"" + namevideo8 + "\"";
1642 // batpath = workPath + "\\aextract.bat";
1643 // File.WriteAllText(batpath, aextract, UnicodeEncoding.Default);
1644 // LogRecord(aextract);
1645 // System.Diagnostics.Process.Start(batpath);
1649 private void btnvideo8_Click(object sender
, EventArgs e
)
1651 openFileDialog1
.Filter
= "视频(*.flv;*.hlv)|*.flv;*.hlv";
1652 DialogResult result
= openFileDialog1
.ShowDialog();
1653 if (result
== DialogResult
.OK
)
1655 namevideo8
= openFileDialog1
.FileName
;
1656 txtvideo8
.Text
= namevideo
;
1660 private void btnpreview9_Click(object sender
, EventArgs e
)
1662 if (AVSScriptTextBox
.Text
!= "")
1664 string filepath
= workPath
+ "\\temp.avs";
1665 File
.WriteAllText(filepath
, AVSScriptTextBox
.Text
.ToString(), UnicodeEncoding
.Default
);
1666 if (File
.Exists(SetupPlayerTextBox
.Text
))
1668 Process
.Start(SetupPlayerTextBox
.Text
, filepath
);
1672 PreviewForm pf
= new PreviewForm();
1674 pf
.axWindowsMediaPlayer1
.URL
= filepath
;
1679 ShowErrorMessage("请输入正确的AVS脚本!");
1683 private void txtout_MouseDoubleClick(object sender
, MouseEventArgs e
)
1685 if (File
.Exists(txtout
.Text
.ToString()))
1687 System
.Diagnostics
.Process
.Start(txtout
.Text
.ToString());
1691 private void txtout3_MouseDoubleClick(object sender
, MouseEventArgs e
)
1693 if (File
.Exists(AudioOutputTextBox
.Text
.ToString()))
1695 System
.Diagnostics
.Process
.Start(AudioOutputTextBox
.Text
.ToString());
1699 private void txtout6_MouseDoubleClick(object sender
, MouseEventArgs e
)
1701 if (File
.Exists(txtout6
.Text
.ToString()))
1703 System
.Diagnostics
.Process
.Start(txtout6
.Text
.ToString());
1707 private void txtout9_MouseDoubleClick(object sender
, MouseEventArgs e
)
1709 if (File
.Exists(txtout9
.Text
.ToString()))
1711 System
.Diagnostics
.Process
.Start(txtout9
.Text
.ToString());
1715 private void txtvideo9_TextChanged(object sender
, EventArgs e
)
1717 if (File
.Exists(txtvideo9
.Text
.ToString()))
1719 namevideo9
= txtvideo9
.Text
;
1720 string finish
= namevideo9
.Remove(namevideo9
.LastIndexOf("."));
1721 finish
+= "_AVS压制.mp4";
1722 txtout9
.Text
= finish
;
1725 //if (txtvideo9.Text != "")
1727 // if (txtAVS.Text != "")
1729 // txtAVS.Text = txtAVS.Text.Replace(prevideo9, txtvideo9.Text);
1733 // DirectoryInfo TheFolder = new DirectoryInfo("avsfilter");
1734 // foreach (FileInfo FileName in TheFolder.GetFiles())
1736 // avs += "LoadPlugin(\"" + workpath + "\\avsfilter\\" + FileName + "\")\r\n";
1738 // avs += "\r\nDirectShowSource(\"" + namevideo9 + "\",23.976,convertFPS=True)\r\nConvertToYV12()\r\n" + "TextSub(\"" + namesub9 + "\")\r\n";
1739 // txtAVS.Text = avs;
1742 // prevideo9 = txtvideo9.Text;
1746 private void txtsub9_TextChanged(object sender
, EventArgs e
)
1748 namesub9
= txtsub9
.Text
;
1750 //if (txtAVS.Text != "")
1752 // txtAVS.Text=txtAVS.Text.Replace(namesub9, txtsub9.Text);
1753 // namesub9 = txtsub9.Text;
1757 // namesub9 = txtsub9.Text;
1758 // DirectoryInfo TheFolder = new DirectoryInfo("avsfilter");
1759 // foreach (FileInfo FileName in TheFolder.GetFiles())
1761 // avs += "LoadPlugin(\"" + workpath + "\\avsfilter\\" + FileName + "\")\r\n";
1763 // avs += "\r\nDirectShowSource(\"" + namevideo9 + "\",23.976,convertFPS=True)\r\nConvertToYV12()\r\n" + "TextSub(\"" + namesub9 + "\")\r\n";
1764 // txtAVS.Text = avs;
1769 private void txtout9_TextChanged(object sender
, EventArgs e
)
1771 nameout9
= txtout9
.Text
;
1774 private void btnAVS9_Click(object sender
, EventArgs e
)
1776 x264DemuxerComboBox
.SelectedIndex
= 0; //压制AVS始终使用分离器为auto
1778 if (string.IsNullOrEmpty(nameout9
))
1780 ShowErrorMessage("请选择输出文件");
1783 if (Path
.GetExtension(nameout9
).ToLower() != ".mp4")
1785 ShowErrorMessage("仅支持MP4输出", "不支持的输出格式");
1788 if (File
.Exists(txtout9
.Text
.Trim()))
1790 DialogResult dgs
= ShowQuestion("目标文件:\r\n\r\n" + txtout9
.Text
.Trim() + "\r\n\r\n已经存在,是否覆盖继续压制?", "目标文件已经存在");
1791 if (dgs
== DialogResult
.No
) return;
1794 string tempVideo
= "temp.mp4";
1795 string filepath
= tempavspath
;
1796 //string filepath = workpath + "\\temp.avs";
1797 File
.WriteAllText(filepath
, AVSScriptTextBox
.Text
, UnicodeEncoding
.Default
);
1800 bool hasAudio
= false;
1801 MediaInfo MI
= new MediaInfo();
1802 MI
.Open(namevideo9
);
1803 string audio
= MI
.Get(StreamKind
.Audio
, 0, "Format");
1804 if (!string.IsNullOrEmpty(audio
)) { hasAudio = true; }
1807 if (AVSwithAudioCheckBox
.Checked
&& hasAudio
)
1809 if (!File
.Exists(txtvideo9
.Text
))
1811 ShowErrorMessage("请选择视频文件");
1814 aextract
= audiobat(namevideo9
, "temp.aac");
1817 if (x264ExeComboBox
.SelectedItem
.ToString().ToLower().Contains("x264"))
1820 x264
= x264bat(filepath
, tempVideo
, 1) + "\r\n" +
1821 x264bat(filepath
, tempVideo
, 2);
1822 else x264
= x264bat(filepath
, tempVideo
);
1823 if (!AVSwithAudioCheckBox
.Checked
|| !hasAudio
)
1824 x264
= x264
.Replace(tempVideo
, nameout9
);
1826 else if (x264ExeComboBox
.SelectedItem
.ToString().ToLower().Contains("x265"))
1828 tempVideo
= "temp.hevc";
1830 x264
= x265bat(filepath
, tempVideo
, 1) + "\r\n" +
1831 x265bat(filepath
, tempVideo
, 2);
1832 else x264
= x265bat(filepath
, tempVideo
);
1833 if (!AVSwithAudioCheckBox
.Checked
|| !hasAudio
)
1835 x264
+= "\r\n\"" + workPath
+ "\\mp4box.exe\" -add \"" + tempVideo
+ "#trackID=1:name=\" -new \"" + nameout9
+ "\" \r\n";
1836 x264
+= "del \"" + tempVideo
+ "\"";
1840 if (AVSwithAudioCheckBox
.Checked
&& hasAudio
) //如果包含音频
1841 mux
= boxmuxbat(tempVideo
, "temp.aac", nameout9
);
1842 auto
= aextract
+ x264
+ "\r\n" + mux
+ " \r\n";
1844 System
.Threading
.Thread
.CurrentThread
.CurrentUICulture
= new System
.Globalization
.CultureInfo(GetCultureName());
1845 WorkingForm wf
= new WorkingForm(auto
);
1848 //auto += "\r\ncmd";
1849 //batpath = workPath + "\\x264avs.bat";
1850 //File.WriteAllText(batpath, auto, UnicodeEncoding.Default);
1851 //System.Diagnostics.Process.Start(batpath);
1854 private void btnout9_Click(object sender
, EventArgs e
)
1856 SaveFileDialog savefile
= new SaveFileDialog();
1857 savefile
.Filter
= "视频(*.mp4)|*.mp4";
1858 DialogResult result
= savefile
.ShowDialog();
1859 if (result
== DialogResult
.OK
)
1861 txtout9
.Text
= nameout9
= savefile
.FileName
;
1865 private void btnAVSone_Click(object sender
, EventArgs e
)
1867 if (String
.IsNullOrEmpty(nameout9
))
1869 ShowErrorMessage("请选择输出文件");
1873 string filepath
= workPath
+ "\\temp.avs";
1874 File
.WriteAllText(filepath
, AVSScriptTextBox
.Text
, UnicodeEncoding
.Default
);
1875 x264
= x264bat(filepath
, "temp.mp4");
1877 aextract
= audiobat(namevideo9
, "temp.aac");
1879 mux
= ffmuxbat("temp.mp4", "temp.aac", nameout9
);
1880 auto
= aextract
+ x264
+ "\r\n" + mux
+ " \r\ncmd";
1881 batpath
= workPath
+ "\\auto.bat";
1882 File
.WriteAllText(batpath
, auto
, UnicodeEncoding
.Default
);
1883 System
.Diagnostics
.Process
.Start(batpath
);
1887 private void button6_Click_2(object sender
, EventArgs e
)
1889 //if (Directory.Exists("avsfilter"))
1891 // DirectoryInfo TheFolder = new DirectoryInfo("avsfilter");
1892 // foreach (FileInfo FileName in TheFolder.GetFiles())
1894 // avs += "LoadPlugin(\"" + workpath + "\\avsfilter\\" + FileName + "\")\r\n";
1897 avs
+= "LoadPlugin(\"avsfilter\\VSFilter.DLL\")\r\n";
1898 avs
+= string.Format("\r\nLWLibavVideoSource(\"{0}\",23.976,convertFPS=True)\r\nConvertToYV12()\r\nCrop(0,0,0,0)\r\nAddBorders(0,0,0,0)\r\n" + "TextSub(\"{1}\")\r\n#LanczosResize(1280,960)\r\n", namevideo9
, namesub9
);
1899 //avs += "\r\nDirectShowSource(\"" + namevideo9 + "\",23.976,convertFPS=True)\r\nConvertToYV12()\r\nCrop(0,0,0,0)\r\nAddBorders(0,0,0,0)\r\n" + "TextSub(\"" + namesub9 + "\")\r\n#LanczosResize(1280,960)\r\n";
1900 AVSScriptTextBox
.Text
= avs
;
1904 private void txth264_TextChanged(object sender
, EventArgs e
)
1908 private void txtvideo_MouseDoubleClick(object sender
, MouseEventArgs e
)
1910 if (File
.Exists(txtvideo
.Text
.ToString()))
1912 System
.Diagnostics
.Process
.Start(txtvideo
.Text
.ToString());
1916 private void txtvideo4_MouseDoubleClick(object sender
, MouseEventArgs e
)
1918 if (File
.Exists(txtvideo4
.Text
.ToString()))
1920 System
.Diagnostics
.Process
.Start(txtvideo4
.Text
.ToString());
1924 private void txtout5_MouseDoubleClick(object sender
, MouseEventArgs e
)
1926 if (File
.Exists(txtout5
.Text
.ToString()))
1928 System
.Diagnostics
.Process
.Start(txtout5
.Text
.ToString());
1932 private void txtvideo8_MouseDoubleClick(object sender
, MouseEventArgs e
)
1934 if (File
.Exists(txtvideo8
.Text
.ToString()))
1936 System
.Diagnostics
.Process
.Start(txtvideo8
.Text
.ToString());
1940 private void txtvideo9_MouseDoubleClick(object sender
, MouseEventArgs e
)
1942 if (File
.Exists(txtvideo9
.Text
.ToString()))
1944 System
.Diagnostics
.Process
.Start(txtvideo9
.Text
.ToString());
1948 private void txtvideo6_MouseDoubleClick(object sender
, MouseEventArgs e
)
1950 if (File
.Exists(txtvideo6
.Text
.ToString()))
1952 System
.Diagnostics
.Process
.Start(txtvideo6
.Text
.ToString());
1956 private void txtvideo5_MouseDoubleClick(object sender
, MouseEventArgs e
)
1958 if (File
.Exists(txtvideo5
.Text
.ToString()))
1960 System
.Diagnostics
.Process
.Start(txtvideo5
.Text
.ToString());
1964 private void txtaudio3_MouseDoubleClick(object sender
, MouseEventArgs e
)
1966 if (File
.Exists(txtaudio3
.Text
.ToString()))
1968 System
.Diagnostics
.Process
.Start(txtaudio3
.Text
.ToString());
1972 private void timer1_Tick(object sender
, EventArgs e
)
1974 Process
[] processes
= Process
.GetProcesses();
1975 for (int i
= 0; i
< processes
.GetLength(0); i
++)
1977 //我是要找到我需要的YZT.exe的进程,可以根据ProcessName属性判断
1978 if (processes
[i
].ProcessName
.Equals(Path
.GetFileNameWithoutExtension(x264ExeComboBox
.Text
)))
1980 switch (x264PriorityComboBox
.SelectedIndex
)
1982 case 0: processes
[i
].PriorityClass
= ProcessPriorityClass
.Idle
; break;
1983 case 1: processes
[i
].PriorityClass
= ProcessPriorityClass
.BelowNormal
; break;
1984 case 2: processes
[i
].PriorityClass
= ProcessPriorityClass
.Normal
; break;
1985 case 3: processes
[i
].PriorityClass
= ProcessPriorityClass
.AboveNormal
; break;
1986 case 4: processes
[i
].PriorityClass
= ProcessPriorityClass
.High
; break;
1987 case 5: processes
[i
].PriorityClass
= ProcessPriorityClass
.RealTime
; break;
1993 private void btnsub9_Click(object sender
, EventArgs e
)
1995 openFileDialog1
.Filter
= "字幕(*.ass;*.ssa;*.srt)|*.ass;*.ssa;*.srt|所有文件(*.*)|*.*";
1996 DialogResult result
= openFileDialog1
.ShowDialog();
1997 if (result
== DialogResult
.OK
)
1999 namesub9
= openFileDialog1
.FileName
;
2000 txtsub9
.Text
= namesub9
;
2004 private void btnvideo9_Click(object sender
, EventArgs e
)
2006 openFileDialog1
.Filter
= "视频(*.mp4;*.flv;*.mkv;*.wmv)|*.mp4;*.flv;*.mkv;*.wmv|所有文件(*.*)|*.*";
2007 DialogResult result
= openFileDialog1
.ShowDialog();
2008 if (result
== DialogResult
.OK
)
2010 namevideo9
= openFileDialog1
.FileName
;
2011 txtvideo9
.Text
= namevideo9
;
2015 private void button9_Click(object sender
, EventArgs e
)
2017 AVSScriptTextBox
.Clear();
2020 private void btnClip_Click(object sender
, EventArgs e
)
2022 if (namevideo4
== "")
2024 ShowErrorMessage("请选择视频文件");
2026 else if (nameout5
== "")
2028 ShowErrorMessage("请选择输出文件");
2032 //int h1 = int.Parse(maskb.Text.ToString().Substring(0, 2));
2033 //int m1 = int.Parse(maskb.Text.ToString().Substring(3, 2));
2034 //int s1 = int.Parse(maskb.Text.ToString().Substring(6, 2));
2035 //int h2 = int.Parse(maske.Text.ToString().Substring(0, 2));
2036 //int m2 = int.Parse(maske.Text.ToString().Substring(3, 2));
2037 //int s2 = int.Parse(maske.Text.ToString().Substring(6, 2));
2038 //clip = "\"" + workPath + "\\ffmpeg.exe\" -ss " + maskb.Text + " -to " + maske.Text + " -i \"" + namevideo4 + "\" -acodec copy -vcodec copy \"" + nameout5 + "\" \r\ncmd";
2040 // "<workPath>\ffmpeg.exe" -i "<namevideo4>" -ss <maskb.Text> -to <maske.Text> -c copy "<nameout5>"
2041 clip
= String
.Format(@"""{0}\ffmpeg.exe"" -i ""{1}"" -ss {2} -to {3} -y -c copy ""{4}""",
2042 workPath
, namevideo4
, maskb
.Text
, maske
.Text
, nameout5
) + Environment
.NewLine
+ "cmd";
2043 batpath
= workPath
+ "\\clip.bat";
2045 File
.WriteAllText(batpath
, clip
, UnicodeEncoding
.Default
);
2046 Process
.Start(batpath
);
2050 private void cbX264_SelectedIndexChanged(object sender
, EventArgs e
)
2052 StreamReader sr
= new StreamReader(workPath
+ "\\preset\\" + VideoPresetComboBox
.Text
+ ".txt", System
.Text
.Encoding
.Default
);
2053 x264CustomParameterTextBox
.Text
= sr
.ReadToEnd();
2057 private void cbFPS_SelectedIndexChanged(object sender
, EventArgs e
)
2059 string ext
= Path
.GetExtension(namevideo
).ToLower();
2060 if (cbFPS
.SelectedIndex
!= 0 && ext
!= ".264" && ext
!= ".h264" && ext
!= ".hevc")
2062 ShowWarningMessage("只有扩展名为.264 .h264 .hevc的流文件设置帧率(fps)才有效");
2063 cbFPS
.SelectedIndex
= 0;
2067 private void btnMIopen_Click(object sender
, EventArgs e
)
2069 openFileDialog1
.Filter
= "视频(*.mp4;*.flv;*.mkv)|*.mp4;*.flv;*.mkv|所有文件(*.*)|*.*";
2070 DialogResult result
= openFileDialog1
.ShowDialog();
2071 if (result
== DialogResult
.OK
)
2073 MIvideo
= openFileDialog1
.FileName
;
2074 MediaInfoTextBox
.Text
= MediaInfo(MIvideo
);
2078 private void btnMIplay_Click(object sender
, EventArgs e
)
2080 Process
.Start(MIvideo
);
2083 private void btnMIcopy_Click(object sender
, EventArgs e
)
2085 Clipboard
.SetText(MItext
);
2088 private void btnvideo7_Click(object sender
, EventArgs e
)
2090 openFileDialog1
.Filter
= "视频(*.mkv)|*.mkv";
2091 DialogResult result
= openFileDialog1
.ShowDialog();
2092 if (result
== DialogResult
.OK
)
2094 namevideo6
= openFileDialog1
.FileName
;
2095 txtvideo6
.Text
= namevideo6
;
2099 private void btnextract7_Click(object sender
, EventArgs e
)
2102 ExtractTrack(namevideo6
, 0);
2103 //if (namevideo6 == "")
2105 // MessageBox.Show("请选择视频文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
2109 // int i = namevideo6.IndexOf(".");
2110 // string mkvname = namevideo6.Remove(i);
2111 // QQButton btn = (QQButton)sender;
2112 // switch (btn.Name)
2114 // case "MkvExtract1Button":
2115 // mkvextract = "\"" + workPath + "\\mkvextract.exe\" tracks \"" + namevideo6 + "\" 1:\"" + mkvname + "_audio.aac\"";
2117 // case "MkvExtract2Button":
2118 // mkvextract = "\"" + workPath + "\\mkvextract.exe\" tracks \"" + namevideo6 + "\" 2:\"" + mkvname + "_track2\"";
2120 // case "MkvExtract3Button":
2121 // mkvextract = "\"" + workPath + "\\mkvextract.exe\" tracks \"" + namevideo6 + "\" 3:\"" + mkvname + "_track3\"";
2123 // case "MkvExtract4Button":
2124 // mkvextract = "\"" + workPath + "\\mkvextract.exe\" tracks \"" + namevideo6 + "\" 4:\"" + mkvname + "_track4\"";
2126 // case "btnextract7":
2127 // mkvextract = "\"" + workPath + "\\mkvextract.exe\" tracks \"" + namevideo6 + "\" 0:\"" + mkvname + "_video.h264\"";
2130 // batpath = workPath + "\\mkvextract.bat";
2131 // File.WriteAllText(batpath, mkvextract, UnicodeEncoding.Default);
2132 // LogRecord(mkvextract);
2133 // System.Diagnostics.Process.Start(batpath);
2137 private void MkvExtract1Button_Click(object sender
, EventArgs e
)
2140 ExtractTrack(namevideo6
, 1);
2143 private void MkvExtract2Button_Click(object sender
, EventArgs e
)
2146 ExtractTrack(namevideo6
, 2);
2149 private void MkvExtract3Button_Click(object sender
, EventArgs e
)
2152 ExtractTrack(namevideo6
, 3);
2155 private void MkvExtract4Button_Click(object sender
, EventArgs e
)
2158 ExtractTrack(namevideo6
, 4);
2161 private void txtMI_TextChanged(object sender
, EventArgs e
)
2163 MItext
= MediaInfoTextBox
.Text
;
2166 private void txtAVScreate_Click(object sender
, EventArgs e
)
2170 private void linkLabel2_LinkClicked(object sender
, LinkLabelLinkClickedEventArgs e
)
2172 System
.Diagnostics
.Process
.Start("http://www.sosg.net/read.php?tid=480646");
2175 private void btnaextract2_Click(object sender
, EventArgs e
)
2178 ExtractAV(namevideo
, "a", 1);
2179 //if (namevideo == "")
2181 // MessageBox.Show("请选择视频文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
2185 // //aextract = "\"" + workPath + "\\mp4box.exe\" -raw 3 \"" + namevideo + "\"";
2187 // aextract += Cmd.FormatPath(workPath + "\\ffmpeg.exe");
2188 // aextract += " -i " + Cmd.FormatPath(namevideo);
2189 // aextract += " -vn -sn -c:a:1 copy ";
2190 // string outfile = Cmd.GetDir(namevideo) +
2191 // Path.GetFileNameWithoutExtension(namevideo) + "_抽取音频2" + Path.GetExtension(namevideo);
2192 // aextract += Cmd.FormatPath(outfile);
2193 // batpath = workPath + "\\aextract.bat";
2194 // File.WriteAllText(batpath, aextract, UnicodeEncoding.Default);
2195 // LogRecord(aextract);
2196 // System.Diagnostics.Process.Start(batpath);
2200 private void btnaextract3_Click(object sender
, EventArgs e
)
2203 ExtractAV(namevideo
, "a", 2);
2204 //if (namevideo == "")
2206 // MessageBox.Show("请选择视频文件", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
2210 // //aextract = "\"" + workPath + "\\mp4box.exe\" -raw 4 \"" + namevideo + "\"";
2212 // aextract += Cmd.FormatPath(workPath + "\\ffmpeg.exe");
2213 // aextract += " -i " + Cmd.FormatPath(namevideo);
2214 // aextract += " -vn -sn -c:a:2 copy ";
2215 // string outfile = Cmd.GetDir(namevideo) +
2216 // Path.GetFileNameWithoutExtension(namevideo) + "_抽取音频3" + Path.GetExtension(namevideo);
2217 // aextract += Cmd.FormatPath(outfile);
2218 // batpath = workPath + "\\aextract.bat";
2219 // File.WriteAllText(batpath, aextract, UnicodeEncoding.Default);
2220 // LogRecord(aextract);
2221 // System.Diagnostics.Process.Start(batpath);
2225 private void txtvideo6_TextChanged_1(object sender
, EventArgs e
)
2227 if (File
.Exists(txtvideo6
.Text
.ToString()))
2229 namevideo6
= txtvideo6
.Text
;
2235 private void AboutBtn_Click(object sender
, EventArgs e
)
2237 DateTime CompileDate
= System
.IO
.File
.GetLastWriteTime(this.GetType().Assembly
.Location
); //获得程序编译时间
2240 "小丸工具箱 七七版\r\n主页:http://www.maruko.in/ \r\n编译日期:" + CompileDate
.ToString(),
2242 QQMessageBoxIcon
.Information
,
2243 QQMessageBoxButtons
.OK
);
2246 private void HomePageBtn_Click(object sender
, EventArgs e
)
2248 System
.Diagnostics
.Process
.Start("http://www.maruko.in/");
2255 private void x264VideoBtn_Click(object sender
, EventArgs e
)
2257 openFileDialog1
.Filter
= "视频(*.mp4;*.flv;*.mkv;*.avi;*.wmv;*.mpg;*.avs)|*.mp4;*.flv;*.mkv;*.avi;*.wmv;*.mpg;*.avs|所有文件(*.*)|*.*";
2258 DialogResult result
= openFileDialog1
.ShowDialog();
2259 if (result
== DialogResult
.OK
)
2261 namevideo2
= openFileDialog1
.FileName
;
2262 x264VideoTextBox
.Text
= namevideo2
;
2266 private void x264OutBtn_Click(object sender
, EventArgs e
)
2268 SaveFileDialog savefile
= new SaveFileDialog();
2269 savefile
.Filter
= "MPEG-4 视频(*.mp4)|*.mp4|Flash 视频(*.flv)|*.flv|Matroska 视频(*.mkv)|*.mkv|AVI 视频(*.avi)|*.avi|H.264 流(*.raw)|*.raw";
2270 savefile
.FileName
= Path
.GetFileName(x264OutTextBox
.Text
);
2271 DialogResult result
= savefile
.ShowDialog();
2272 if (result
== DialogResult
.OK
)
2274 nameout2
= savefile
.FileName
;
2275 x264OutTextBox
.Text
= nameout2
;
2279 private void x264SubBtn_Click(object sender
, EventArgs e
)
2281 openFileDialog1
.Filter
= "字幕(*.ass;*.ssa;*.srt)|*.ass;*.ssa;*.srt|所有文件(*.*)|*.*";
2282 DialogResult result
= openFileDialog1
.ShowDialog();
2283 if (result
== DialogResult
.OK
)
2285 namesub2
= openFileDialog1
.FileName
;
2286 x264SubTextBox
.Text
= namesub2
;
2290 private void x264StartBtn_Click(object sender
, EventArgs e
)
2294 if (string.IsNullOrEmpty(namevideo2
))
2296 ShowErrorMessage("请选择视频文件");
2300 if (!string.IsNullOrEmpty(namesub2
) && !File
.Exists(namesub2
))
2302 ShowErrorMessage("字幕文件不存在,请重新选择");
2306 if (string.IsNullOrEmpty(nameout2
))
2308 ShowErrorMessage("请选择输出文件");
2312 if (x264ExeComboBox
.SelectedIndex
== -1)
2314 ShowErrorMessage("请选择X264程序");
2319 if (x264ThreadsComboBox
.SelectedIndex
== -1)
2321 x264ThreadsComboBox
.SelectedIndex
= 0;
2325 if (File
.Exists(x264OutTextBox
.Text
.Trim()))
2327 DialogResult dgs
= ShowQuestion("目标文件:\r\n\r\n" + x264OutTextBox
.Text
.Trim() + "\r\n\r\n已经存在,是否覆盖继续压制?", "目标文件已经存在");
2328 if (dgs
== DialogResult
.No
) return;
2332 if (Path
.GetExtension(x264VideoTextBox
.Text
) == ".avs")
2334 //if (File.Exists(tempavspath)) File.Delete(tempavspath);
2335 File
.Copy(x264VideoTextBox
.Text
, tempavspath
, true);
2336 namevideo2
= tempavspath
;
2337 x264DemuxerComboBox
.SelectedIndex
= 0; //压制AVS始终使用分离器为auto
2340 #endregion validation
2342 string ext
= Path
.GetExtension(nameout2
).ToLower();
2343 bool hasAudio
= false;
2344 string tempVideo
= Util
.ChangeExt(namevideo2
, "_temp.mp4");
2345 string tempAudio
= Util
.ChangeExt(namevideo2
, "_temp.aac");
2347 MediaInfo MI
= new MediaInfo();
2348 MI
.Open(namevideo2
);
2349 string audio
= MI
.Get(StreamKind
.Audio
, 0, "Format");
2350 if (!string.IsNullOrEmpty(audio
)) { hasAudio = true; }
2352 if (x264AudioModeComboBox
.SelectedIndex
== 0 && hasAudio
) //如果压制音频
2353 aextract
= audiobat(namevideo2
, tempAudio
);
2355 if (x264ExeComboBox
.SelectedItem
.ToString().ToLower().Contains("x264"))
2358 x264
= x264bat(namevideo2
, tempVideo
, 1, namesub2
) + "\r\n" +
2359 x264bat(namevideo2
, tempVideo
, 2, namesub2
);
2360 else x264
= x264bat(namevideo2
, tempVideo
, 0, namesub2
);
2361 if (x264AudioModeComboBox
.SelectedIndex
!= 0 || !hasAudio
)
2362 x264
= x264
.Replace(tempVideo
, nameout2
);
2364 else if (x264ExeComboBox
.SelectedItem
.ToString().ToLower().Contains("x265"))
2366 tempVideo
= Util
.ChangeExt(namevideo2
, "_temp.hevc");
2369 ShowErrorMessage("不支持的格式输出,x265当前工具箱仅支持MP4输出");
2373 x264
= x265bat(namevideo2
, tempVideo
, 1) + "\r\n" +
2374 x265bat(namevideo2
, tempVideo
, 2);
2375 else x264
= x265bat(namevideo2
, tempVideo
, 0);
2376 if (x264AudioModeComboBox
.SelectedIndex
!= 0 || !hasAudio
)
2378 x264
+= "\r\n\"" + workPath
+ "\\mp4box.exe\" -add \"" + tempVideo
+ "#trackID=1:name=\" -new \"" + Util
.ChangeExt(nameout2
, ".mp4") + "\" \r\n";
2379 x264
+= "del \"" + tempVideo
+ "\"";
2384 if (x264AudioModeComboBox
.SelectedIndex
== 0 && hasAudio
) //如果包含音频
2387 mux
= boxmuxbat(tempVideo
, tempAudio
, Util
.ChangeExt(nameout2
, ext
));
2389 mux
= ffmuxbat(tempVideo
, tempAudio
, Util
.ChangeExt(nameout2
, ext
));
2390 x264
= aextract
+ x264
+ mux
+ "\r\n"
2391 + "del \"" + tempVideo
+ "\"\r\n"
2392 + "del \"" + tempAudio
+ "\"\r\n";
2395 System
.Threading
.Thread
.CurrentThread
.CurrentUICulture
= new System
.Globalization
.CultureInfo(GetCultureName());
2396 WorkingForm wf
= new WorkingForm(x264
);
2399 //x264 += "\r\ncmd";
2400 //batpath = workPath + "\\x264.bat";
2401 //File.WriteAllText(batpath, x264, UnicodeEncoding.Default);
2402 //System.Diagnostics.Process.Start(batpath);
2405 private void x264AddPresetBtn_Click(object sender
, EventArgs e
)
2408 string preset
= workPath
+ "\\preset";
2409 if (!Directory
.Exists(preset
)) Directory
.CreateDirectory(preset
);
2411 batpath
= workPath
+ "\\preset\\" + PresetNameTextBox
.Text
+ ".txt";
2412 File
.WriteAllText(batpath
, x264CustomParameterTextBox
.Text
, UnicodeEncoding
.Default
);
2414 VideoPresetComboBox
.Items
.Clear();
2415 if (Directory
.Exists(workPath
+ "\\preset"))
2417 DirectoryInfo TheFolder
= new DirectoryInfo(preset
);
2418 foreach (FileInfo FileName
in TheFolder
.GetFiles())
2420 VideoPresetComboBox
.Items
.Add(FileName
.Name
.Replace(".txt", ""));
2423 VideoPresetComboBox
.SelectedIndex
= VideoPresetComboBox
.FindString(PresetNameTextBox
.Text
);
2426 private void x264DeletePresetBtn_Click(object sender
, EventArgs e
)
2428 if (ShowQuestion("确定要删除这条预设参数?", "提示") == DialogResult
.Yes
)
2430 string preset
= workPath
+ "\\preset";
2431 batpath
= workPath
+ "\\preset\\" + VideoPresetComboBox
.Text
+ ".txt";
2432 File
.Delete(batpath
);
2433 VideoPresetComboBox
.Items
.Clear();
2434 if (Directory
.Exists(preset
))
2436 DirectoryInfo TheFolder
= new DirectoryInfo(preset
);
2437 foreach (FileInfo FileName
in TheFolder
.GetFiles())
2439 VideoPresetComboBox
.Items
.Add(FileName
.Name
.Replace(".txt", ""));
2442 if (VideoPresetComboBox
.Items
.Count
> 0) VideoPresetComboBox
.SelectedIndex
= 0;
2446 private void x264Mode2RadioButton_CheckedChanged(object sender
, EventArgs e
)
2449 lbrate
.Visible
= true;
2450 x264BitrateNum
.Visible
= true;
2451 label12
.Visible
= true;
2452 //x264FpsComboBox.Visible = true;
2453 //lbFPS2.Visible = true;
2454 lbwidth
.Visible
= true;
2455 lbheight
.Visible
= true;
2456 x264WidthNum
.Visible
= true;
2457 x264HeightNum
.Visible
= true;
2458 MaintainResolutionCheckBox
.Visible
= true;
2459 lbcrf
.Visible
= false;
2460 x264CRFNum
.Visible
= false;
2461 label4
.Visible
= false;
2462 x264CustomParameterTextBox
.Visible
= false;
2463 VideoPresetComboBox
.Visible
= false;
2464 x264AddPresetBtn
.Visible
= false;
2465 x264DeletePresetBtn
.Visible
= false;
2466 PresetNameTextBox
.Visible
= false;
2469 private void x264Mode3RadioButton_CheckedChanged(object sender
, EventArgs e
)
2472 label4
.Visible
= true;
2473 x264CustomParameterTextBox
.Visible
= true;
2474 VideoPresetComboBox
.Visible
= true;
2475 x264AddPresetBtn
.Visible
= true;
2476 x264DeletePresetBtn
.Visible
= true;
2477 PresetNameTextBox
.Visible
= true;
2478 lbwidth
.Visible
= false;
2479 lbheight
.Visible
= false;
2480 x264WidthNum
.Visible
= false;
2481 x264HeightNum
.Visible
= false;
2482 MaintainResolutionCheckBox
.Visible
= false;
2483 lbrate
.Visible
= false;
2484 x264BitrateNum
.Visible
= false;
2485 label12
.Visible
= false;
2486 lbcrf
.Visible
= false;
2487 x264CRFNum
.Visible
= false;
2488 //x264FpsComboBox.Visible = false;
2489 //lbFPS2.Visible = false;
2492 private void x264Mode1RadioButton_CheckedChanged(object sender
, EventArgs e
)
2495 lbcrf
.Visible
= true;
2496 x264CRFNum
.Visible
= true;
2497 //x264FpsComboBox.Visible = true;
2498 //lbFPS2.Visible = true;
2499 lbwidth
.Visible
= true;
2500 lbheight
.Visible
= true;
2501 x264WidthNum
.Visible
= true;
2502 x264HeightNum
.Visible
= true;
2503 MaintainResolutionCheckBox
.Visible
= true;
2504 lbrate
.Visible
= false;
2505 x264BitrateNum
.Visible
= false;
2506 label12
.Visible
= false;
2507 label4
.Visible
= false;
2508 x264CustomParameterTextBox
.Visible
= false;
2509 VideoPresetComboBox
.Visible
= false;
2510 x264AddPresetBtn
.Visible
= false;
2511 x264DeletePresetBtn
.Visible
= false;
2512 PresetNameTextBox
.Visible
= false;
2515 private void x264PriorityComboBox_SelectedIndexChanged(object sender
, EventArgs e
)
2517 string processName
= x264ExeComboBox
.Text
;
2518 processName
= processName
.Replace(".exe", "");
2519 Process
[] processes
= Process
.GetProcesses();
2520 //if (x264PriorityComboBox.SelectedIndex == 4 || x264PriorityComboBox.SelectedIndex == 5)
2522 // if (MessageBox.Show("优先级那么高的话会严重影响其他进程的运行速度,\r\n是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
2524 // x264PriorityComboBox.SelectedIndex = 2;
2528 for (int i
= 0; i
< processes
.GetLength(0); i
++)
2530 //我是要找到我需要的YZT.exe的进程,可以根据ProcessName属性判断
2531 if (processes
[i
].ProcessName
.Equals(processName
))
2533 switch (x264PriorityComboBox
.SelectedIndex
)
2535 case 0: processes
[i
].PriorityClass
= ProcessPriorityClass
.Idle
; break;
2536 case 1: processes
[i
].PriorityClass
= ProcessPriorityClass
.BelowNormal
; break;
2537 case 2: processes
[i
].PriorityClass
= ProcessPriorityClass
.Normal
; break;
2538 case 3: processes
[i
].PriorityClass
= ProcessPriorityClass
.AboveNormal
; break;
2539 case 4: processes
[i
].PriorityClass
= ProcessPriorityClass
.High
; break;
2540 case 5: processes
[i
].PriorityClass
= ProcessPriorityClass
.RealTime
; break;
2546 private void x264VideoTextBox_TextChanged(object sender
, EventArgs e
)
2548 string path
= x264VideoTextBox
.Text
;
2549 if (File
.Exists(path
))
2552 x264OutTextBox
.Text
= Util
.ChangeExt(namevideo2
, "_x264.mp4");
2554 if (Path
.GetExtension(namevideo2
) != ".avs")
2556 string[] subExt
= { ".ass", ".ssa", ".srt" }
;
2557 foreach (string ext
in subExt
)
2559 if (File
.Exists(Util
.ChangeExt(namevideo2
, ext
)))
2561 x264SubTextBox
.Text
= Util
.ChangeExt(namevideo2
, ext
);
2569 private void x264OutTextBox_TextChanged(object sender
, EventArgs e
)
2571 nameout2
= x264OutTextBox
.Text
;
2574 private void x264SubTextBox_TextChanged(object sender
, EventArgs e
)
2576 namesub2
= x264SubTextBox
.Text
;
2579 private void x264BatchClearBtn_Click(object sender
, EventArgs e
)
2581 lbAuto
.Items
.Clear();
2584 private void x264BatchDeleteBtn_Click(object sender
, EventArgs e
)
2586 if (lbAuto
.Items
.Count
> 0)
2588 if (lbAuto
.SelectedItems
.Count
> 0)
2590 int index
= lbAuto
.SelectedIndex
;
2591 lbAuto
.Items
.RemoveAt(lbAuto
.SelectedIndex
);
2592 if (index
== lbAuto
.Items
.Count
)
2594 lbAuto
.SelectedIndex
= index
- 1;
2596 if (index
>= 0 && index
< lbAuto
.Items
.Count
&& lbAuto
.Items
.Count
> 0)
2598 lbAuto
.SelectedIndex
= index
;
2604 private void x264BatchAddBtn_Click(object sender
, EventArgs e
)
2606 openFileDialog1
.Multiselect
= true;
2607 openFileDialog1
.Filter
= "所有文件(*.*)|*.*";
2608 DialogResult result
= openFileDialog1
.ShowDialog();
2609 if (result
== DialogResult
.OK
)
2611 lbAuto
.Items
.AddRange(openFileDialog1
.FileNames
);
2620 /// 是否安装 Apple Application Support
2622 /// <returns>true:安装 false:没有安装</returns>
2623 private bool isAppleAppSupportInstalled()
2625 Microsoft
.Win32
.RegistryKey uninstallNode_1
= Microsoft
.Win32
.Registry
.LocalMachine
.OpenSubKey(@"Software\Wow6432Node\Apple Inc.\Apple Application Support"); //x64 OS
2626 Microsoft
.Win32
.RegistryKey uninstallNode_2
= Microsoft
.Win32
.Registry
.LocalMachine
.OpenSubKey(@"Software\Apple Inc.\Apple Application Support"); //x86 OS
2627 if (uninstallNode_1
!= null || uninstallNode_2
!= null)
2637 private void AudioEncoderComboBox_SelectedIndexChanged(object sender
, EventArgs e
)
2639 switch (AudioEncoderComboBox
.SelectedIndex
)
2642 if (File
.Exists(txtaudio2
.Text
))
2643 AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_AAC.mp4");
2644 AudioBitrateComboBox
.Enabled
= true;
2645 AudioBitrateRadioButton
.Enabled
= true;
2646 AudioCustomizeRadioButton
.Enabled
= true;
2650 if (!isAppleAppSupportInstalled())
2652 if (ShowQuestion("Apple Application Support未安装.\r\n音频编码器QAAC可能无法使用.\r\n\r\n是否前往QuickTime下载页面?", "Apple Application Support未安装") == DialogResult
.Yes
)
2653 System
.Diagnostics
.Process
.Start("http://www.apple.com/cn/quicktime/download");
2655 if (File
.Exists(txtaudio2
.Text
))
2656 AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_AAC.m4a");
2657 AudioBitrateComboBox
.Enabled
= true;
2658 AudioBitrateRadioButton
.Enabled
= true;
2659 AudioCustomizeRadioButton
.Enabled
= true;
2663 if (File
.Exists(txtaudio2
.Text
))
2664 AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_WAV.wav");
2665 AudioBitrateComboBox
.Enabled
= false;
2666 AudioBitrateRadioButton
.Enabled
= false;
2667 AudioCustomizeRadioButton
.Enabled
= false;
2671 if (File
.Exists(txtaudio2
.Text
))
2672 AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_ALAC.m4a");
2673 AudioBitrateComboBox
.Enabled
= false;
2674 AudioBitrateRadioButton
.Enabled
= false;
2675 AudioCustomizeRadioButton
.Enabled
= false;
2679 if (File
.Exists(txtaudio2
.Text
))
2680 AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_FLAC.flac");
2681 AudioBitrateComboBox
.Enabled
= false;
2682 AudioBitrateRadioButton
.Enabled
= false;
2683 AudioCustomizeRadioButton
.Enabled
= false;
2687 if (File
.Exists(txtaudio2
.Text
))
2688 AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_AAC.m4a");
2689 AudioBitrateComboBox
.Enabled
= true;
2690 AudioBitrateRadioButton
.Enabled
= true;
2691 AudioCustomizeRadioButton
.Enabled
= true;
2699 private void AudioListBox_DragDrop(object sender
, DragEventArgs e
)
2701 ListBox listbox
= (ListBox
)sender
;
2702 if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
, false))
2704 String
[] files
= (String
[])e
.Data
.GetData(DataFormats
.FileDrop
);
2705 foreach (String s
in files
)
2707 listbox
.Items
.Add(s
);
2711 indexoftarget
= listbox
.IndexFromPoint(listbox
.PointToClient(new Point(e
.X
, e
.Y
)));
2712 if (indexoftarget
!= ListBox
.NoMatches
)
2714 string temp
= listbox
.Items
[indexoftarget
].ToString();
2715 listbox
.Items
[indexoftarget
] = listbox
.Items
[indexofsource
];
2716 listbox
.Items
[indexofsource
] = temp
;
2717 listbox
.SelectedIndex
= indexoftarget
;
2721 private void AudioListBox_DragOver(object sender
, DragEventArgs e
)
2723 ListBox listbox
= (ListBox
)sender
;
2724 if (e
.Data
.GetDataPresent(typeof(System
.String
)) && ((ListBox
)sender
).Equals(listbox
))
2726 e
.Effect
= DragDropEffects
.Move
;
2728 else if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
))
2730 e
.Effect
= DragDropEffects
.Link
;
2732 else e
.Effect
= DragDropEffects
.None
;
2735 private void AudioListBox_MouseDown(object sender
, MouseEventArgs e
)
2737 indexofsource
= ((ListBox
)sender
).IndexFromPoint(e
.X
, e
.Y
);
2738 if (indexofsource
!= ListBox
.NoMatches
)
2740 ((ListBox
)sender
).DoDragDrop(((ListBox
)sender
).Items
[indexofsource
].ToString(), DragDropEffects
.All
);
2744 private void AudioBatchButton_Click(object sender
, EventArgs e
)
2746 if (AudioListBox
.Items
.Count
!= 0)
2748 string finish
, outputExt
, codec
;
2750 switch (AudioEncoderComboBox
.SelectedIndex
)
2752 case 0: outputExt
= "mp4"; codec
= "AAC"; break;
2753 case 1: outputExt
= "m4a"; codec
= "AAC"; break;
2754 case 2: outputExt
= "wav"; codec
= "WAV"; break;
2755 case 3: outputExt
= "m4a"; codec
= "ALAC"; break;
2756 case 4: outputExt
= "flac"; codec
= "FLAC"; break;
2757 case 5: outputExt
= "m4a"; codec
= "AAC"; break;
2758 default: outputExt
= "aac"; codec
= "AAC"; break;
2760 for (int i
= 0; i
< this.AudioListBox
.Items
.Count
; i
++)
2762 string outname
= "_" + codec
+ "." + outputExt
;
2763 finish
= Util
.ChangeExt(AudioListBox
.Items
[i
].ToString(), outname
);
2764 aac
+= audiobat(AudioListBox
.Items
[i
].ToString(), finish
);
2768 batpath
= workPath
+ "\\aac.bat";
2769 File
.WriteAllText(batpath
, aac
, UnicodeEncoding
.Default
);
2771 System
.Diagnostics
.Process
.Start(batpath
);
2773 else ShowErrorMessage("请输入文件!");
2776 private void btnaudio2_Click(object sender
, EventArgs e
)
2778 openFileDialog1
.Filter
= "所有文件(*.*)|*.*";
2779 DialogResult result
= openFileDialog1
.ShowDialog();
2780 if (result
== DialogResult
.OK
)
2782 nameaudio2
= openFileDialog1
.FileName
;
2783 txtaudio2
.Text
= nameaudio2
;
2787 private void btnout3_Click(object sender
, EventArgs e
)
2789 SaveFileDialog savefile
= new SaveFileDialog();
2790 savefile
.Filter
= "所有文件(*.*)|*.*";
2791 //savefile.Filter = "音频(*.aac;*.wav;*.m4a;*.flac)|*.aac*.wav;*.m4a;*.flac;";
2792 DialogResult result
= savefile
.ShowDialog();
2793 if (result
== DialogResult
.OK
)
2795 switch (AudioEncoderComboBox
.SelectedIndex
)
2798 nameout3
= savefile
.FileName
+ ".mp4";
2802 nameout3
= savefile
.FileName
+ ".m4a";
2806 nameout3
= savefile
.FileName
+ ".wav";
2810 nameout3
= savefile
.FileName
+ ".m4a";
2814 nameout3
= savefile
.FileName
+ ".flac";
2818 nameout3
= savefile
.FileName
+ ".m4a";
2825 AudioOutputTextBox
.Text
= nameout3
;
2829 private void btnaac_Click(object sender
, EventArgs e
)
2831 if (nameaudio2
== "")
2833 ShowErrorMessage("请选择音频文件");
2835 else if (nameout3
== "")
2837 ShowErrorMessage("请选择输出文件");
2841 //ffmpeg = "\"" + workpath + "\\ffmpeg.exe\" -y -i \"" + nameaudio2 + "\" -f wav temp.wav";
2842 //int AACbr = 1024 * Convert.ToInt32(numq.Value.ToString());
2843 //string br = AACbr.ToString();
2844 //neroaac = "\"" + workpath + "\\neroAacEnc.exe\" -ignorelength -lc -br " + br + " -if \"temp.wav\" -of \"" + nameout3 + "\"";
2845 //aac = ffmpeg + "&&" + neroaac + "\r\ncmd";
2846 batpath
= workPath
+ "\\aac.bat";
2847 File
.WriteAllText(batpath
, audiobat(nameaudio2
, nameout3
), UnicodeEncoding
.Default
);
2848 LogRecord(audiobat(nameaudio2
, nameout3
));
2849 System
.Diagnostics
.Process
.Start(batpath
);
2853 private void txtaudio2_TextChanged(object sender
, EventArgs e
)
2855 if (File
.Exists(txtaudio2
.Text
.ToString()))
2857 nameaudio2
= txtaudio2
.Text
;
2858 switch (AudioEncoderComboBox
.SelectedIndex
)
2860 case 0: AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_AAC.mp4"); break;
2861 case 1: AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_AAC.m4a"); break;
2862 case 2: AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_WAV.wav"); break;
2863 case 3: AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_ALAC.m4a"); break;
2864 case 4: AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_FLAC.flac"); break;
2865 case 5: AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_AAC.m4a"); break;
2866 default: AudioOutputTextBox
.Text
= Util
.ChangeExt(txtaudio2
.Text
, "_AAC.aac"); break;
2871 private void txtout3_TextChanged(object sender
, EventArgs e
)
2873 nameout3
= AudioOutputTextBox
.Text
;
2876 private void txtaudio2_MouseDoubleClick(object sender
, MouseEventArgs e
)
2878 if (File
.Exists(txtaudio2
.Text
.ToString()))
2880 System
.Diagnostics
.Process
.Start(txtaudio2
.Text
.ToString());
2884 private void radioButton5_CheckedChanged(object sender
, EventArgs e
)
2886 lbaacrate
.Visible
= false;
2887 lbaackbps
.Visible
= false;
2888 AudioBitrateComboBox
.Visible
= false;
2889 AudioCustomParameterTextBox
.Visible
= true;
2890 AudioPresetLabel
.Visible
= true;
2891 AudioPresetComboBox
.Visible
= true;
2894 private void radioButton4_CheckedChanged(object sender
, EventArgs e
)
2896 lbaacrate
.Visible
= true;
2897 lbaackbps
.Visible
= true;
2898 AudioBitrateComboBox
.Visible
= true;
2899 AudioCustomParameterTextBox
.Visible
= false;
2900 AudioPresetLabel
.Visible
= false;
2901 AudioPresetComboBox
.Visible
= false;
2904 private void AudioAddButton_Click(object sender
, EventArgs e
)
2906 openFileDialog1
.Multiselect
= true;
2907 openFileDialog1
.Filter
= "所有文件(*.*)|*.*";
2908 DialogResult result
= openFileDialog1
.ShowDialog();
2909 if (result
== DialogResult
.OK
)
2911 AudioListBox
.Items
.AddRange(openFileDialog1
.FileNames
);
2915 private void AudioDeleteButton_Click(object sender
, EventArgs e
)
2917 if (AudioListBox
.Items
.Count
> 0)
2919 if (AudioListBox
.SelectedItems
.Count
> 0)
2921 int index
= AudioListBox
.SelectedIndex
;
2922 AudioListBox
.Items
.RemoveAt(AudioListBox
.SelectedIndex
);
2923 if (index
== AudioListBox
.Items
.Count
)
2925 AudioListBox
.SelectedIndex
= index
- 1;
2927 if (index
>= 0 && index
< AudioListBox
.Items
.Count
&& AudioListBox
.Items
.Count
> 0)
2929 AudioListBox
.SelectedIndex
= index
;
2935 private void AudioClearButton_Click(object sender
, EventArgs e
)
2937 AudioListBox
.Items
.Clear();
2944 private void GenerateAVS()
2946 //if (Directory.Exists("avsfilter"))
2948 // DirectoryInfo TheFolder = new DirectoryInfo("avsfilter");
2949 // foreach (FileInfo FileName in TheFolder.GetFiles())
2951 // avs += "LoadPlugin(\"" + workpath + "\\avsfilter\\" + FileName + "\")\r\n";
2954 avsBuilder
.Remove(0, avsBuilder
.Length
);
2955 string vsfilterDLLPath
= Path
.Combine(workPath
, @"avsfilter\VSFilter.DLL");
2956 string LSMASHSourceDLLPath
= Path
.Combine(workPath
, @"avsfilter\LSMASHSource.DLL");
2957 string undotDLLPath
= Path
.Combine(workPath
, @"avsfilter\UnDot.DLL");
2958 avsBuilder
.AppendLine("LoadPlugin(\"" + vsfilterDLLPath
+ "\")");
2959 avsBuilder
.AppendLine("LoadPlugin(\"" + LSMASHSourceDLLPath
+ "\")");
2961 if (UndotCheckBox
.Checked
)
2962 avsBuilder
.AppendLine("LoadPlugin(\"" + undotDLLPath
+ "\")");
2963 avsBuilder
.AppendLine("LWLibavVideoSource(\"" + namevideo9
+ "\")");
2964 avsBuilder
.AppendLine("ConvertToYV12()");
2965 if (UndotCheckBox
.Checked
)
2966 avsBuilder
.AppendLine("Undot()");
2967 if (TweakCheckBox
.Checked
)
2968 avsBuilder
.AppendLine("Tweak(" + TweakChromaNumericUpDown
.Value
.ToString() + ", " + TweakSaturationNumericUpDown
.Value
.ToString() + ", " + TweakBrightnessNumericUpDown
.Value
.ToString() + ", " + TweakContrastNumericUpDown
.Value
.ToString() + ")");
2969 if (LevelsCheckBox
.Checked
)
2970 avsBuilder
.AppendLine("Levels(0," + LevelsNumericUpDown
.Value
.ToString() + ",255,0,255)");
2971 if (LanczosResizeCheckBox
.Checked
)
2972 avsBuilder
.AppendLine("LanczosResize(" + AVSWidthNumericUpDown
.Value
.ToString() + "," + AVSHeightNumericUpDown
.Value
.ToString() + ")");
2973 if (SharpenCheckBox
.Checked
)
2974 avsBuilder
.AppendLine("Sharpen(" + SharpenNumericUpDown
.Value
.ToString() + ")");
2975 if (CropCheckBox
.Checked
)
2976 avsBuilder
.AppendLine("Crop(" + AVSCropTextBox
.Text
+ ")");
2977 if (AddBordersCheckBox
.Checked
)
2978 avsBuilder
.AppendLine("AddBorders(" + AddBorders1NumericUpDown
.Value
.ToString() + "," + AddBorders2NumericUpDown
.Value
.ToString() + "," + AddBorders3NumericUpDown
.Value
.ToString() + "," + AddBorders4NumericUpDown
.Value
.ToString() + ")");
2979 if (!string.IsNullOrEmpty(txtsub9
.Text
))
2981 if (Path
.GetExtension(namesub9
) == ".idx")
2982 avsBuilder
.AppendLine("vobsub(\"" + namesub9
+ "\")");
2984 avsBuilder
.AppendLine("TextSub(\"" + namesub9
+ "\")");
2986 if (TrimCheckBox
.Checked
)
2987 avsBuilder
.AppendLine("Trim(" + TrimStartNumericUpDown
.Value
.ToString() + "," + TrimEndNumericUpDown
.Value
.ToString() + ")");
2988 AVSScriptTextBox
.Text
= avsBuilder
.ToString();
2993 private void TweakCheckBox_CheckedChanged(object sender
, EventArgs e
)
2998 private void LanczosResizeCheckBox_CheckedChanged(object sender
, EventArgs e
)
3003 private void AddBordersCheckBox_CheckedChanged(object sender
, EventArgs e
)
3008 private void CropCheckBox_CheckedChanged(object sender
, EventArgs e
)
3013 private void TrimCheckBox_CheckedChanged(object sender
, EventArgs e
)
3018 private void LevelsCheckBox_CheckedChanged(object sender
, EventArgs e
)
3023 private void SharpenCheckBox_CheckedChanged(object sender
, EventArgs e
)
3028 private void UndotCheckBox_CheckedChanged(object sender
, EventArgs e
)
3033 private void TweakChromaNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3038 private void TweakSaturationNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3043 private void TweakBrightnessNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3048 private void TweakContrastNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3053 private void AVSWidthNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3058 private void AVSHeightNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3063 private void AddBorders1NumericUpDown_ValueChanged(object sender
, EventArgs e
)
3068 private void AddBorders2NumericUpDown_ValueChanged(object sender
, EventArgs e
)
3073 private void AddBorders3NumericUpDown_ValueChanged(object sender
, EventArgs e
)
3078 private void AddBorders4NumericUpDown_ValueChanged(object sender
, EventArgs e
)
3083 private void AVSCropTextBox_TextChanged(object sender
, EventArgs e
)
3088 private void TrimStartNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3093 private void TrimEndNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3098 private void LevelsNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3103 private void SharpenNumericUpDown_ValueChanged(object sender
, EventArgs e
)
3112 private void ExtractMP4Button_Click(object sender
, EventArgs e
)
3114 openFileDialog1
.Filter
= "视频(*.mp4)|*.mp4|所有文件(*.*)|*.*";
3115 DialogResult result
= openFileDialog1
.ShowDialog();
3116 if (result
== DialogResult
.OK
)
3118 namevideo
= openFileDialog1
.FileName
;
3119 ExtractMP4TextBox
.Text
= namevideo
;
3123 private void txtAVS_TextChanged(object sender
, EventArgs e
)
3125 Match m
= Regex
.Match(AVSScriptTextBox
.Text
, "ource\\(\"[a-zA-Z]:\\\\.+\\.\\w+\"");
3128 string str
= m
.ToString();
3129 str
= str
.Replace("ource(\"", "");
3130 str
= str
.Replace("\"", "");
3131 str
= Util
.ChangeExt(str
, "_AVS.mp4");
3136 public void Log(string path
)
3138 ProcessStartInfo start
= new ProcessStartInfo(path
);//设置运行的命令行文件问ping.exe文件,这个文件系统会自己找到
3139 //如果是其它exe文件,则有可能需要指定详细路径,如运行winRar.exe
3140 start
.CreateNoWindow
= false;//不显示dos命令行窗口
3141 start
.RedirectStandardOutput
= true;//
3142 start
.RedirectStandardInput
= true;//
3143 start
.UseShellExecute
= false;//是否指定操作系统外壳进程启动程序
3144 Process p
= Process
.Start(start
);
3145 StreamReader reader
= p
.StandardOutput
;//截取输出流
3146 string line
= reader
.ReadLine();//每次读取一行
3147 StringBuilder log
= new StringBuilder(2000);
3148 while (!reader
.EndOfStream
)
3150 log
.Append(line
+ "\r\n");
3151 line
= reader
.ReadLine();
3153 p
.WaitForExit();//等待程序执行完退出进程
3154 File
.WriteAllText(startpath
+ "\\log.txt", log
.ToString(), UnicodeEncoding
.Default
);
3156 reader
.Close();//关闭流
3159 public void LogRecord(string log
)
3161 Util
.ensureDirectoryExists(logPath
);
3162 File
.AppendAllText(logFileName
,
3163 "===========" + DateTime
.Now
.ToString() + "===========\r\n" + log
+ "\r\n\r\n", UnicodeEncoding
.Default
);
3166 private void DeleteLogButton_Click(object sender
, EventArgs e
)
3168 if (Directory
.Exists(logPath
))
3170 Util
.DeleteDirectoryIfExists(logPath
, true);
3171 ShowInfoMessage("已经删除日志文件。");
3173 else ShowInfoMessage("没有找到日志文件。");
3176 private void ViewLogButton_Click(object sender
, EventArgs e
)
3178 if (File
.Exists(logFileName
))
3180 System
.Diagnostics
.Process
.Start(logFileName
);
3182 else ShowInfoMessage("没有找到日志文件。");
3185 private void x264PathButton_Click(object sender
, EventArgs e
)
3187 FolderBrowserDialog fbd
= new FolderBrowserDialog();
3188 if (fbd
.ShowDialog() == DialogResult
.OK
)
3189 x264PathTextBox
.Text
= fbd
.SelectedPath
;
3192 private void ExtractMP4TextBox_TextChanged(object sender
, EventArgs e
)
3194 namevideo
= ExtractMP4TextBox
.Text
;
3197 private void MaintainResolutionCheckBox_CheckedChanged(object sender
, EventArgs e
)
3199 if (MaintainResolutionCheckBox
.Checked
)
3201 x264WidthNum
.Value
= 0;
3202 x264HeightNum
.Value
= 0;
3203 x264WidthNum
.Enabled
= false;
3204 x264HeightNum
.Enabled
= false;
3208 x264WidthNum
.Enabled
= true;
3209 x264HeightNum
.Enabled
= true;
3213 #region globalization
3215 public static void SetLang(string lang
, Form form
, Type formType
)
3217 System
.Threading
.Thread
.CurrentThread
.CurrentUICulture
= new System
.Globalization
.CultureInfo(lang
);
3220 System
.ComponentModel
.ComponentResourceManager resources
= new System
.ComponentModel
.ComponentResourceManager(formType
);
3221 resources
.ApplyResources(form
, "$this");
3222 AppLang(form
, resources
);
3226 private static void AppLang(Control control
, System
.ComponentModel
.ComponentResourceManager resources
)
3228 foreach (Control c
in control
.Controls
)
3230 resources
.ApplyResources(c
, c
.Name
);
3231 AppLang(c
, resources
);
3235 private void languageComboBox_SelectedIndexChanged(object sender
, EventArgs e
)
3238 x264Mode1RadioButton
.Checked
= true;
3239 AudioBitrateRadioButton
.Checked
= true;
3240 int x264AudioModeComboBoxIndex
= 0;
3241 switch (languageComboBox
.SelectedIndex
)
3244 SetLang("zh-CN", this, typeof(MainForm
));
3245 this.Text
= String
.Format("小丸工具箱 {0}", Assembly
.GetExecutingAssembly().GetName().Version
.Build
);
3246 x264PriorityComboBox
.Items
.Clear();
3247 x264PriorityComboBox
.Items
.AddRange(new string[] { "低", "低于标准", "普通", "高于标准", "高", "实时" }
);
3248 x264PriorityComboBox
.SelectedIndex
= 2;
3249 x264AudioModeComboBoxIndex
= x264AudioModeComboBox
.SelectedIndex
;
3250 x264AudioModeComboBox
.Items
.Clear();
3251 x264AudioModeComboBox
.Items
.Add("压制音频");
3252 x264AudioModeComboBox
.Items
.Add("无音频流");
3253 x264AudioModeComboBox
.SelectedIndex
= x264AudioModeComboBoxIndex
;
3254 x264VideoTextBox
.EmptyTextTip
= "可以把文件拖拽到这里";
3255 x264SubTextBox
.EmptyTextTip
= "双击清空字幕文件文本框";
3256 //x264OutTextBox.EmptyTextTip = "宽度和高度全为0即不改变分辨率";
3257 x264PathTextBox
.EmptyTextTip
= "字幕文件和视频文件在同一目录下且同名,不同名仅有语言后缀时请在右方选择或输入";
3258 //txtvideo3.EmptyTextTip = "音频参数在音频选项卡设定";
3259 ExtractMP4TextBox
.EmptyTextTip
= "抽取的视频或音频在原视频目录下";
3260 txtvideo8
.EmptyTextTip
= "抽取的视频或音频在原视频目录下";
3261 txtvideo6
.EmptyTextTip
= "抽取的视频或音频在原视频目录下";
3263 if (File
.Exists(startpath
+ "\\help.rtf"))
3265 HelpTextBox
.LoadFile(startpath
+ "\\help.rtf");
3270 SetLang("zh-TW", this, typeof(MainForm
));
3271 this.Text
= String
.Format("小丸工具箱 {0}", Assembly
.GetExecutingAssembly().GetName().Version
.Build
);
3272 x264PriorityComboBox
.Items
.Clear();
3273 x264PriorityComboBox
.Items
.AddRange(new string[] { "低", "在標準以下", "標準", "在標準以上", "高", "即時" }
);
3274 x264PriorityComboBox
.SelectedIndex
= 2;
3275 x264AudioModeComboBoxIndex
= x264AudioModeComboBox
.SelectedIndex
;
3276 x264AudioModeComboBox
.Items
.Clear();
3277 x264AudioModeComboBox
.Items
.Add("壓制音頻");
3278 x264AudioModeComboBox
.Items
.Add("無音頻流");
3279 x264AudioModeComboBox
.SelectedIndex
= x264AudioModeComboBoxIndex
;
3280 x264VideoTextBox
.EmptyTextTip
= "可以把文件拖拽到這裡";
3281 x264SubTextBox
.EmptyTextTip
= "雙擊清空字幕檔案文本框";
3282 //x264OutTextBox.EmptyTextTip = "寬度和高度全為0即不改變解析度";
3283 x264PathTextBox
.EmptyTextTip
= "字幕和視頻在同一資料夾下且同名,不同名僅有語言後綴時請在右方選擇或輸入";
3284 //txtvideo3.EmptyTextTip = "音頻參數需在音頻選項卡设定";
3285 ExtractMP4TextBox
.EmptyTextTip
= "新檔案生成在原資料夾";
3286 txtvideo8
.EmptyTextTip
= "新檔案生成在原資料夾";
3287 txtvideo6
.EmptyTextTip
= "新檔案生成在原資料夾";
3289 if (File
.Exists(startpath
+ "\\help_zh_tw.rtf"))
3291 HelpTextBox
.LoadFile(startpath
+ "\\help_zh_tw.rtf");
3296 SetLang("en-US", this, typeof(MainForm
));
3297 this.Text
= String
.Format("Maruko Toolbox {0}", Assembly
.GetExecutingAssembly().GetName().Version
.Build
);
3298 x264PriorityComboBox
.Items
.Clear();
3299 x264PriorityComboBox
.Items
.AddRange(new string[] { "Idle", "BelowNormal", "Normal", "AboveNormal", "High", "RealTime" }
);
3300 x264PriorityComboBox
.SelectedIndex
= 2;
3301 x264AudioModeComboBoxIndex
= x264AudioModeComboBox
.SelectedIndex
;
3302 x264AudioModeComboBox
.Items
.Clear();
3303 x264AudioModeComboBox
.Items
.Add("with audio");
3304 x264AudioModeComboBox
.Items
.Add("no audio");
3305 x264AudioModeComboBox
.SelectedIndex
= x264AudioModeComboBoxIndex
;
3306 x264VideoTextBox
.EmptyTextTip
= "Drag file here";
3307 x264SubTextBox
.EmptyTextTip
= "Clear subtitle text box by double click";
3308 //x264OutTextBox.EmptyTextTip = "Both the width and height equal zero means using original resolution";
3309 x264PathTextBox
.EmptyTextTip
= "Subtitle and Video must be of the same name and in the same folder";
3310 //txtvideo3.EmptyTextTip = "It is necessary to set audio parameter in the Audio tab";
3311 ExtractMP4TextBox
.EmptyTextTip
= "New file will be created in the original folder";
3312 txtvideo8
.EmptyTextTip
= "New file will be created in the original folder";
3313 txtvideo6
.EmptyTextTip
= "New file will be created in the original folder";
3315 if (File
.Exists(startpath
+ "\\help.rtf"))
3317 HelpTextBox
.LoadFile(startpath
+ "\\help.rtf");
3322 SetLang("ja-JP", this, typeof(MainForm
));
3323 this.Text
= String
.Format("Maruko Toolbox {0}", Assembly
.GetExecutingAssembly().GetName().Version
.Build
);
3324 x264PriorityComboBox
.Items
.Clear();
3325 x264PriorityComboBox
.Items
.AddRange(new string[] { "低", "通常以下", "通常", "通常以上", "高", "リアルタイム" }
);
3326 x264PriorityComboBox
.SelectedIndex
= 2;
3327 x264AudioModeComboBoxIndex
= x264AudioModeComboBox
.SelectedIndex
;
3328 x264AudioModeComboBox
.Items
.Clear();
3329 x264AudioModeComboBox
.Items
.Add("オーディオ付き");
3330 x264AudioModeComboBox
.Items
.Add("オーディオなし");
3331 x264AudioModeComboBox
.SelectedIndex
= x264AudioModeComboBoxIndex
;
3332 x264VideoTextBox
.EmptyTextTip
= "ビデオファイルをここに引きずってください";
3333 x264SubTextBox
.EmptyTextTip
= "ダブルクリックで字幕を削除する";
3334 //x264OutTextBox.EmptyTextTip = "Both the width and height equal zero means using original resolution";
3335 x264PathTextBox
.EmptyTextTip
= "字幕とビデオは同じ名前と同じフォルダにある必要があります";
3336 //txtvideo3.EmptyTextTip = "It is necessary to set audio parameter in the Audio tab";
3337 ExtractMP4TextBox
.EmptyTextTip
= "新しいファイルはビデオファイルのあるディレクトリに生成する";
3338 txtvideo8
.EmptyTextTip
= "新しいファイルはビデオファイルのあるディレクトリに生成する";
3339 txtvideo6
.EmptyTextTip
= "新しいファイルはビデオファイルのあるディレクトリに生成する";
3340 if (File
.Exists(startpath
+ "\\help.rtf"))
3342 HelpTextBox
.LoadFile(startpath
+ "\\help.rtf");
3351 private string GetCultureName()
3353 string name
= "zh-CN";
3354 switch (languageComboBox
.SelectedIndex
)
3374 #endregion globalization
3376 public static void RunProcess(string exe
, string arg
)
3378 Thread thread
= new Thread(() =>
3380 ProcessStartInfo psi
= new ProcessStartInfo(exe
, arg
);
3381 psi
.CreateNoWindow
= true;
3382 Process p
= new Process();
3386 MessageBox
.Show("ts");
3389 thread
.IsBackground
= true;
3393 private void AVSSaveButton_Click(object sender
, EventArgs e
)
3395 SaveFileDialog savefile
= new SaveFileDialog();
3396 savefile
.Filter
= "AVS(*.avs)|*.avs";
3397 DialogResult result
= savefile
.ShowDialog();
3398 if (result
== DialogResult
.OK
)
3400 File
.WriteAllText(savefile
.FileName
, AVSScriptTextBox
.Text
, UnicodeEncoding
.Default
);
3404 private void MuxReplaceAudioButton_Click(object sender
, EventArgs e
)
3406 if (namevideo
== "")
3408 ShowErrorMessage("请选择视频文件");
3411 if (nameaudio
== "")
3413 ShowErrorMessage("请选择音频文件");
3418 ShowErrorMessage("请选择输出文件");
3422 //mux = "\"" + workPath + "\\ffmpeg.exe\" -y -i \"" + namevideo + "\" -c:v copy -an \"" + workPath + "\\video_noaudio.mp4\" \r\n";
3423 //mux += "\"" + workPath + "\\ffmpeg.exe\" -y -i \"" + workPath + "\\video_noaudio.mp4\" -i \"" + nameaudio + "\" -vcodec copy -acodec copy \"" + nameout + "\" \r\n";
3424 //mux += "del \"" + workPath + "\\video_noaudio.mp4\" \r\n";
3425 mux
= "\"" + workPath
+ "\\ffmpeg.exe\" -y -i \"" + namevideo
+ "\" -i \""+ nameaudio
+"\" -map 0:v -c:v copy -map 1:0 -c:a copy \"" + txtout
.Text
+ "\" \r\n";
3426 batpath
= workPath
+ "\\mux.bat";
3427 File
.WriteAllText(batpath
, mux
, UnicodeEncoding
.Default
);
3429 Process
.Start(batpath
);
3434 private void AudioPicButton_Click(object sender
, EventArgs e
)
3436 openFileDialog1
.Filter
= "图片(*.jpg;*.jpeg;*.png;*.bmp;*.gif)|*.jpg;*.jpeg;*.png;*.bmp;*.gif|所有文件(*.*)|*.*";
3437 DialogResult result
= openFileDialog1
.ShowDialog();
3438 if (result
== DialogResult
.OK
)
3440 AudioPicTextBox
.Text
= openFileDialog1
.FileName
;
3444 private void AudioPicAudioButton_Click(object sender
, EventArgs e
)
3446 openFileDialog1
.Filter
= "音频(*.aac;*.mp3;*.mp4;*.wav)|*.aac;*.mp3;*.mp4;*.wav|所有文件(*.*)|*.*";
3447 DialogResult result
= openFileDialog1
.ShowDialog();
3448 if (result
== DialogResult
.OK
)
3450 AudioPicAudioTextBox
.Text
= openFileDialog1
.FileName
;
3454 private void AudioOnePicOutputButton_Click(object sender
, EventArgs e
)
3456 SaveFileDialog savefile
= new SaveFileDialog();
3457 savefile
.Filter
= "MP4视频(*.mp4)|*.mp4|FLV视频(*.flv)|*.flv";
3458 savefile
.FileName
= "Single";
3459 DialogResult result
= savefile
.ShowDialog();
3460 if (result
== DialogResult
.OK
)
3462 AudioOnePicOutputTextBox
.Text
= savefile
.FileName
;
3466 public int SecondsFromHHMMSS(string hhmmss
)
3468 int hh
= int.Parse(hhmmss
.Substring(0, 2));
3469 int mm
= int.Parse(hhmmss
.Substring(3, 2));
3470 int ss
= int.Parse(hhmmss
.Substring(6, 2));
3471 return hh
* 3600 + mm
* 60 + ss
;
3474 private void AudioOnePicButton_Click(object sender
, EventArgs e
)
3476 if (!File
.Exists(AudioPicTextBox
.Text
))
3478 ShowErrorMessage("请选择图片文件");
3480 else if (!File
.Exists(AudioPicAudioTextBox
.Text
))
3482 ShowErrorMessage("请选择音频文件");
3484 else if (AudioOnePicOutputTextBox
.Text
== "")
3486 ShowErrorMessage("请选择输出文件");
3490 System
.Drawing
.Image img
= System
.Drawing
.Image
.FromFile(AudioPicTextBox
.Text
);
3491 // if not even number, chop 1 pixel out
3492 int newWidth
= (img
.Width
% 2 == 0 ? img
.Width
: img
.Width
- 1);
3493 int newHeight
= (img
.Height
% 2 == 0 ? img
.Height
: img
.Height
- 1);
3495 if (img
.Width
% 2 != 0 || img
.Height
% 2 != 0)
3497 Bitmap bmp
= new Bitmap(img
);
3498 cropArea
= new Rectangle(0, 0, newWidth
, newHeight
);
3499 img
= (Image
)bmp
.Clone(cropArea
, bmp
.PixelFormat
);
3502 //if (img.Width % 2 != 0 || img.Height % 2 != 0)
3504 // MessageBox.Show("图片的长和宽必须是偶数。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Warning);
3508 //if (img.RawFormat.Equals(ImageFormat.Jpeg))
3510 // File.Copy(AudioPicTextBox.Text, tempPic, true);
3514 System
.Drawing
.Imaging
.Encoder ImageEncoder
= System
.Drawing
.Imaging
.Encoder
.Quality
;
3515 EncoderParameter ep
= new EncoderParameter(ImageEncoder
, 100L);
3516 EncoderParameters eps
= new EncoderParameters(1);
3517 ImageCodecInfo ImageCoderType
= getImageCoderInfo("image/jpeg");
3519 img
.Save(tempPic
, ImageCoderType
, eps
);
3520 //img.Save(tempPic, ImageFormat.Jpeg);
3523 MediaInfo MI
= new MediaInfo();
3524 MI
.Open(AudioPicAudioTextBox
.Text
);
3525 int seconds
= SecondsFromHHMMSS(MI
.Get(StreamKind
.General
, 0, "Duration/String3"));
3526 string ffPath
= Path
.Combine(workPath
, "ffmpeg.exe");
3527 string neroPath
= Path
.Combine(workPath
, "neroaacenc.exe");
3528 if (AudioCopyCheckBox
.Checked
)
3530 mux
= "\"" + ffPath
+ "\" -loop 1 -r " + OnePicFPSNum
.Value
.ToString() + " -t " + seconds
.ToString() + " -f image2 -i \"" + tempPic
+ "\" -c:v libx264 -crf " + OnePicCRFNum
.Value
.ToString() + " -y SinglePictureVideo.mp4\r\n";
3531 mux
+= "\"" + ffPath
+ "\" -i SinglePictureVideo.mp4 -i \"" + AudioPicAudioTextBox
.Text
+ "\" -c:v copy -c:a copy -y \"" + AudioOnePicOutputTextBox
.Text
+ "\"\r\n";
3532 mux
+= "del SinglePictureVideo.mp4\r\n";
3537 mux
= "\"" + ffPath
+ "\" -i \"" + AudioPicAudioTextBox
.Text
+ "\" -f wav - |" + neroPath
+ " -br " + OnePicAudioBitrateNum
.Value
.ToString() + "000 -ignorelength -if - -of audio.mp4 -lc\r\n";
3538 mux
+= "\"" + ffPath
+ "\" -loop 1 -r " + OnePicFPSNum
.Value
.ToString() + " -t " + seconds
.ToString() + " -f image2 -i \"" + tempPic
+ "\" -c:v libx264 -crf " + OnePicCRFNum
.Value
.ToString() + " -y SinglePictureVideo.mp4\r\n";
3539 mux
+= "\"" + ffPath
+ "\" -i SinglePictureVideo.mp4 -i audio.mp4 -c:v copy -c:a copy -y \"" + AudioOnePicOutputTextBox
.Text
+ "\"\r\n";
3540 mux
+= "del SinglePictureVideo.mp4\r\ndel audio.mp4\r\n";
3544 string audioPath = AddExt(Path.GetFileName(AudioPicAudioTextBox.Text), "_atmp.mp4");
3545 string videoPath = AddExt(Path.GetFileName(AudioPicAudioTextBox.Text), "_vtmp.mp4");
3546 string picturePath = "c:\\" + Path.GetFileNameWithoutExtension(AudioPicTextBox.Text) + "_tmp.jpg";
3547 if (AudioCopyCheckBox.Checked)
3549 mux = "ffmpeg -loop 1 -r " + AudioOnePicFPSNum.Value.ToString() + " -t " + seconds.ToString() + " -f image2 -i \"" + picturePath + "\" -vcodec libx264 -crf 24 -y \"" + videoPath + "\"\r\n";
3550 mux += "ffmpeg -i \"" + videoPath + "\" -i \"" + AudioPicAudioTextBox.Text + "\" -c:v copy -c:a copy -y \"" + AudioOnePicOutputTextBox.Text + "\"\r\n";
3551 mux += "del \"" + videoPath + "\"\r\ndel \"" + picturePath + "\"\r\n";
3555 mux = "ffmpeg -i \"" + AudioPicAudioTextBox.Text + "\" -f wav - |neroaacenc -br " + AudioOnePicAudioBitrateNum.Value.ToString() + "000 -ignorelength -if - -of \"" + audioPath + "\" -lc\r\n";
3556 mux += "ffmpeg -loop 1 -r " + AudioOnePicFPSNum.Value.ToString() + " -t " + seconds.ToString() + " -f image2 -i \"" + picturePath + "\" -vcodec libx264 -crf 24 -y \"" + videoPath + "\"\r\n";
3557 mux += "ffmpeg -i \"" + videoPath + "\" -i \"" + audioPath + "\" -c:v copy -c:a copy -y \"" + AudioOnePicOutputTextBox.Text + "\"\r\n";
3558 mux += "del \"" + videoPath + "\"\r\ndel \"" + audioPath + "\"\r\ndel \"" + picturePath + "\"\r\n";
3561 batpath
= Path
.Combine(workPath
, Path
.GetRandomFileName() + ".bat");
3562 File
.WriteAllText(batpath
, mux
, UnicodeEncoding
.Default
);
3564 Process
.Start(batpath
);
3568 private void txtMI_DragDrop(object sender
, DragEventArgs e
)
3570 MIvideo
= ((System
.Array
)e
.Data
.GetData(DataFormats
.FileDrop
)).GetValue(0).ToString();
3571 MediaInfoTextBox
.Text
= MediaInfo(MIvideo
);
3574 private void txtMI_DragEnter(object sender
, DragEventArgs e
)
3576 if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
))
3577 e
.Effect
= DragDropEffects
.Link
;
3578 else e
.Effect
= DragDropEffects
.None
;
3581 private void AudioPicAudioTextBox_TextChanged(object sender
, EventArgs e
)
3583 if (File
.Exists(AudioPicAudioTextBox
.Text
.ToString()))
3585 AudioOnePicOutputTextBox
.Text
= Util
.ChangeExt(AudioPicAudioTextBox
.Text
, "_SP.flv");
3592 /// <param name="ImageCoderType">编码类型</param>
3593 /// <returns>ImageCodecInfo</returns>
3594 private ImageCodecInfo
getImageCoderInfo(string ImageCoderType
)
3596 ImageCodecInfo
[] coderTypeArray
= ImageCodecInfo
.GetImageEncoders();
3597 foreach (ImageCodecInfo coderType
in coderTypeArray
)
3599 if (coderType
.MimeType
.Equals(ImageCoderType
))
3609 private void BlackVideoButton_Click(object sender
, EventArgs e
)
3611 openFileDialog1
.Filter
= "FLV视频(*.flv)|*.flv";
3612 DialogResult result
= openFileDialog1
.ShowDialog();
3613 if (result
== DialogResult
.OK
)
3615 BlackVideoTextBox
.Text
= openFileDialog1
.FileName
;
3619 private void BlackOutputButton_Click(object sender
, EventArgs e
)
3621 SaveFileDialog savefile
= new SaveFileDialog();
3622 savefile
.Filter
= "FLV视频(*.flv)|*.flv";
3623 DialogResult result
= savefile
.ShowDialog();
3624 if (result
== DialogResult
.OK
)
3626 BlackOutputTextBox
.Text
= savefile
.FileName
;
3630 private void BlackPicButton_Click(object sender
, EventArgs e
)
3632 openFileDialog1
.Filter
= "图片(*.jpg;*.jpeg;*.png;*.bmp;*.gif)|*.jpg;*.jpeg;*.png;*.bmp;*.gif|所有文件(*.*)|*.*";
3633 DialogResult result
= openFileDialog1
.ShowDialog();
3634 if (result
== DialogResult
.OK
)
3636 BlackPicTextBox
.Text
= openFileDialog1
.FileName
;
3640 private void BlackStartButton_Click(object sender
, EventArgs e
)
3643 if (!File
.Exists(BlackVideoTextBox
.Text
) || Path
.GetExtension(BlackVideoTextBox
.Text
) != ".flv")
3645 ShowErrorMessage("请选择FLV视频文件");
3649 MediaInfo MI
= new MediaInfo();
3650 MI
.Open(BlackVideoTextBox
.Text
);
3651 double videobitrate
= double.Parse(MI
.Get(StreamKind
.General
, 0, "BitRate"));
3652 double targetBitrate
= (double)BlackBitrateNum
.Value
;
3654 if (!File
.Exists(BlackPicTextBox
.Text
) && BlackNoPicCheckBox
.Checked
== false)
3656 ShowErrorMessage("请选择图片文件或勾选使用黑屏");
3659 if (BlackOutputTextBox
.Text
== "")
3661 ShowErrorMessage("请选择输出文件");
3665 if (videobitrate
< 1000000)
3667 ShowInfoMessage("此视频不需要后黑。");
3670 if (videobitrate
> 5000000)
3672 ShowInfoMessage("此视频码率过大,请先压制再后黑。");
3677 int videoWidth
= int.Parse(MI
.Get(StreamKind
.Video
, 0, "Width"));
3678 int videoHeight
= int.Parse(MI
.Get(StreamKind
.Video
, 0, "Height"));
3679 if (BlackNoPicCheckBox
.Checked
)
3681 Bitmap bm
= new Bitmap(videoWidth
, videoHeight
);
3682 Graphics g
= Graphics
.FromImage(bm
);
3683 //g.FillRectangle(Brushes.White, new Rectangle(0, 0, 800, 600));
3684 g
.Clear(Color
.Black
);
3685 bm
.Save(tempPic
, ImageFormat
.Jpeg
);
3691 System
.Drawing
.Image img
= System
.Drawing
.Image
.FromFile(BlackPicTextBox
.Text
);
3692 int sourceWidth
= img
.Width
;
3693 int sourceHeight
= img
.Height
;
3694 if (img
.Width
% 2 != 0 || img
.Height
% 2 != 0)
3696 ShowErrorMessage("图片的长和宽必须都是偶数。");
3700 if (img
.Width
!= videoWidth
|| img
.Height
!= videoHeight
)
3702 ShowErrorMessage("图片的长和宽和视频不一致。");
3706 if (img
.RawFormat
.Equals(ImageFormat
.Jpeg
))
3708 File
.Copy(BlackPicTextBox
.Text
, tempPic
, true);
3712 System
.Drawing
.Imaging
.Encoder ImageEncoder
= System
.Drawing
.Imaging
.Encoder
.Quality
;
3713 EncoderParameter ep
= new EncoderParameter(ImageEncoder
, 100L);
3714 EncoderParameters eps
= new EncoderParameters(1);
3715 ImageCodecInfo ImageCoderType
= getImageCoderInfo("image/jpeg");
3717 img
.Save(tempPic
, ImageCoderType
, eps
);
3718 //img.Save(tempPic, ImageFormat.Jpeg);
3721 int blackSecond
= 300;
3723 if (BlackSecondComboBox
.Text
== "auto")
3725 int seconds
= SecondsFromHHMMSS(MI
.Get(StreamKind
.General
, 0, "Duration/String3"));
3726 double s
= videobitrate
/ 1000.0 * (double)seconds
/ targetBitrate
- (double)seconds
;
3727 blackSecond
= (int)s
;
3728 BlackSecondComboBox
.Text
= blackSecond
.ToString();
3732 blackSecond
= int.Parse(Regex
.Replace(BlackSecondComboBox
.Text
.ToString(), @"\D", "")); //排除除数字外的所有字符
3736 mux
= "\"" + workPath
+ "\\ffmpeg\" -loop 1 -r " + BlackFPSNum
.Value
.ToString() + " -t " + blackSecond
.ToString() + " -f image2 -i \"" + tempPic
+ "\" -c:v libx264 -crf " + BlackCRFNum
.Value
.ToString() + " -y black.flv\r\n";
3737 mux
+= string.Format("\"{0}\\flvbind\" \"{1}\" \"{2}\" black.flv\r\n", workPath
, BlackOutputTextBox
.Text
, BlackVideoTextBox
.Text
);
3738 mux
+= "del black.flv\r\n";
3740 batpath
= Path
.Combine(workPath
, Path
.GetRandomFileName() + ".bat");
3741 File
.WriteAllText(batpath
, mux
, UnicodeEncoding
.Default
);
3743 Process
.Start(batpath
);
3746 private void BlackVideoTextBox_TextChanged(object sender
, EventArgs e
)
3748 string path
= BlackVideoTextBox
.Text
;
3749 if (File
.Exists(path
))
3751 BlackOutputTextBox
.Text
= Util
.ChangeExt(path
, "_black.flv");
3757 private void BlackNoPicCheckBox_CheckedChanged(object sender
, EventArgs e
)
3759 BlackPicTextBox
.Enabled
= !BlackNoPicCheckBox
.Checked
;
3760 BlackPicButton
.Enabled
= !BlackNoPicCheckBox
.Checked
;
3763 private void BlackSecondComboBox_SelectedIndexChanged(object sender
, EventArgs e
)
3765 if (BlackSecondComboBox
.Text
!= "auto")
3767 BlackBitrateNum
.Enabled
= false;
3771 BlackBitrateNum
.Enabled
= true;
3775 private void SetDefaultButton_Click(object sender
, EventArgs e
)
3781 private void MediaInfoTextBox_KeyDown(object sender
, KeyEventArgs e
)
3783 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.A
)
3785 ((TextBox
)sender
).SelectAll();
3789 private void AVSScriptTextBox_KeyDown(object sender
, KeyEventArgs e
)
3791 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.A
)
3793 ((TextBox
)sender
).SelectAll();
3797 private void x264CustomParameterTextBox_KeyDown(object sender
, KeyEventArgs e
)
3799 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.A
)
3801 ((TextBox
)sender
).SelectAll();
3807 public delegate bool CheckUpadateDelegate(out DateTime newdate
, out bool isFullUpdate
);
3809 public void CheckUpdateCallBack(IAsyncResult ar
)
3813 AsyncResult result
= (AsyncResult
)ar
;
3814 CheckUpadateDelegate func
= (CheckUpadateDelegate
)result
.AsyncDelegate
;
3818 bool needUpdate
= func
.EndInvoke(out NewDate
, out isFullUpdate
, ar
);
3823 DialogResult dr
= MessageBox
.Show(string.Format("新版已于{0}发布,是否前往官网下载?", NewDate
.ToString("yyyy-M-d")), "喜大普奔", MessageBoxButtons
.YesNo
, MessageBoxIcon
.Information
);
3824 if (dr
== DialogResult
.Yes
)
3826 Process
.Start("http://www.maruko.in/");
3831 DialogResult dr
= MessageBox
.Show(string.Format("新版已于{0}发布,是否自动升级?(文件约1.5MB)", NewDate
.ToString("yyyy-M-d")), "喜大普奔", MessageBoxButtons
.YesNo
, MessageBoxIcon
.Information
);
3832 if (dr
== DialogResult
.Yes
)
3834 FormUpdater formUpdater
= new FormUpdater(startpath
, NewDate
.ToString());
3835 formUpdater
.ShowDialog(this);
3841 //MessageBox.Show("已经是最新版了喵!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
3844 catch (Exception
) { }
3847 public bool CheckUpdate(out DateTime NewDate
, out bool isFullUpdate
)
3849 WebRequest request
= WebRequest
.Create("http://mtbftest.sinaapp.com/version.php");
3850 WebResponse wrs
= request
.GetResponse();
3851 // read the response ...
3852 Stream dataStream
= wrs
.GetResponseStream();
3853 // Open the stream using a StreamReader for easy access.
3854 StreamReader reader
= new StreamReader(dataStream
);
3855 // Read the content.
3856 string responseFromServer
= reader
.ReadToEnd();
3857 Regex dateReg
= new Regex(@"Date20\S+Date");
3858 Regex VersionReg
= new Regex(@"Version\d+Version");
3859 Match dateMatch
= dateReg
.Match(responseFromServer
);
3860 Match versionMatch
= VersionReg
.Match(responseFromServer
);
3861 NewDate
= DateTime
.Parse("1990-03-08");
3862 isFullUpdate
= false;
3863 if (dateMatch
.Success
)
3865 string date
= dateMatch
.Value
.Replace("Date", "");
3866 string version
= versionMatch
.Value
.Replace("Version", "");
3867 NewDate
= DateTime
.Parse(date
);
3868 int NewVersion
= int.Parse(version
);
3869 int s
= DateTime
.Compare(NewDate
, ReleaseDate
);
3871 int currentVersion
= System
.Reflection
.Assembly
.GetExecutingAssembly().GetName().Version
.Minor
;
3872 if (NewVersion
> currentVersion
)
3874 isFullUpdate
= true;
3878 isFullUpdate
= false;
3880 //DateTime CompileDate = System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location); //获得程序编译时间
3881 if (s
== 1) //NewDate is later than ReleaseDate
3893 private void CheckUpdateButton_Click(object sender
, EventArgs e
)
3895 if (Util
.IsConnectInternet())
3897 WebRequest request
= WebRequest
.Create("http://mtbftest.sinaapp.com/version.php");
3898 request
.Credentials
= CredentialCache
.DefaultCredentials
;
3899 // Get the response.
3900 request
.BeginGetResponse(new AsyncCallback(OnResponse
), request
);
3904 ShowErrorMessage("这台电脑似乎没有联网呢~");
3908 protected void OnResponse(IAsyncResult ar
)
3910 WebRequest wrq
= (WebRequest
)ar
.AsyncState
;
3911 WebResponse wrs
= wrq
.EndGetResponse(ar
);
3912 // read the response ...
3913 Stream dataStream
= wrs
.GetResponseStream();
3914 // Open the stream using a StreamReader for easy access.
3915 StreamReader reader
= new StreamReader(dataStream
);
3916 // Read the content.
3917 string responseFromServer
= reader
.ReadToEnd();
3918 Regex dateReg
= new Regex(@"Date20\S+Date");
3919 Regex VersionReg
= new Regex(@"Version\d+Version");
3920 Match dateMatch
= dateReg
.Match(responseFromServer
);
3921 Match versionMatch
= VersionReg
.Match(responseFromServer
);
3922 DateTime NewDate
= DateTime
.Parse("1990-03-08");
3923 bool isFullUpdate
= false;
3924 if (dateMatch
.Success
)
3926 string date
= dateMatch
.Value
.Replace("Date", "");
3927 string version
= versionMatch
.Value
.Replace("Version", "");
3928 NewDate
= DateTime
.Parse(date
);
3929 int NewVersion
= int.Parse(version
);
3930 int s
= DateTime
.Compare(NewDate
, ReleaseDate
);
3932 int currentVersion
= System
.Reflection
.Assembly
.GetExecutingAssembly().GetName().Version
.Minor
;
3933 if (NewVersion
> currentVersion
)
3935 isFullUpdate
= true;
3939 isFullUpdate
= false;
3941 //DateTime CompileDate = System.IO.File.GetLastWriteTime(this.GetType().Assembly.Location); //获得程序编译时间
3942 if (s
== 1) //NewDate is later than ReleaseDate
3946 DialogResult dr
= MessageBox
.Show(string.Format("新版已于{0}发布,是否前往官网下载?", NewDate
.ToString("yyyy-M-d")), "喜大普奔", MessageBoxButtons
.YesNo
, MessageBoxIcon
.Information
);
3947 if (dr
== DialogResult
.Yes
)
3949 Process
.Start("http://www.maruko.in/");
3954 DialogResult dr
= MessageBox
.Show(string.Format("新版已于{0}发布,是否自动升级?(文件约1.5MB)", NewDate
.ToString("yyyy-M-d")), "喜大普奔", MessageBoxButtons
.YesNo
, MessageBoxIcon
.Information
);
3955 if (dr
== DialogResult
.Yes
)
3957 FormUpdater formUpdater
= new FormUpdater(startpath
, date
);
3958 formUpdater
.ShowDialog(this);
3964 ShowInfoMessage("已经是最新版了喵!");
3969 ShowInfoMessage("啊咧~似乎未能获取版本信息,请点击软件主页按钮查看最新版本。");
3973 #endregion CheckUpdate
3975 private void x264ShutdownCheckBox_CheckedChanged(object sender
, EventArgs e
)
3977 shutdownState
= x264ShutdownCheckBox
.Checked
;
3980 private void TrayModeCheckBox_CheckedChanged(object sender
, EventArgs e
)
3982 trayMode
= TrayModeCheckBox
.Checked
;
3985 private void ReleaseDatelabel_DoubleClick(object sender
, EventArgs e
)
3987 SplashForm sf
= new SplashForm();
3992 private void AudioCopyCheckBox_CheckedChanged(object sender
, EventArgs e
)
3994 OnePicAudioBitrateNum
.Enabled
= !AudioCopyCheckBox
.Checked
;
3997 private void HelpTextBox_LinkClicked(object sender
, LinkClickedEventArgs e
)
3999 Process
.Start(e
.LinkText
);
4002 private void labelAudio_Click(object sender
, EventArgs e
)
4004 tabControl
.SelectedIndex
= 1;
4007 private void SetupAVSPlayerButton_Click(object sender
, EventArgs e
)
4009 openFileDialog1
.Filter
= "程序(*.exe)|*.exe|所有文件(*.*)|*.*";
4010 DialogResult result
= openFileDialog1
.ShowDialog();
4011 if (result
== DialogResult
.OK
)
4013 SetupPlayerTextBox
.Text
= openFileDialog1
.FileName
;
4017 private void AVSAddFilterButton_Click(object sender
, EventArgs e
)
4019 string vsfilterDLLPath
= Path
.Combine(workPath
, @"avsfilter\" + AVSFilterComboBox
.Text
);
4020 string text
= "LoadPlugin(\"" + vsfilterDLLPath
+ "\")" + "\r\n";
4021 AVSScriptTextBox
.Text
= text
+ AVSScriptTextBox
.Text
;
4024 private void AudioJoinButton_Click(object sender
, EventArgs e
)
4026 if (AudioListBox
.Items
.Count
== 0)
4028 ShowErrorMessage("请输入文件!");
4031 else if (AudioOutputTextBox
.Text
== "")
4033 ShowErrorMessage("请选择输出文件");
4036 StringBuilder sb
= new StringBuilder();
4038 string ext
= Path
.GetExtension(AudioListBox
.Items
[0].ToString());
4039 string finish
= Util
.ChangeExt(AudioOutputTextBox
.Text
, ext
);
4040 for (int i
= 0; i
< this.AudioListBox
.Items
.Count
; i
++)
4042 if (Path
.GetExtension(AudioListBox
.Items
[i
].ToString()) != ext
)
4044 ShowErrorMessage("只允许合并相同格式文件。");
4047 sb
.AppendLine("file '" + AudioListBox
.Items
[i
].ToString() + "'");
4048 File
.WriteAllText("concat.txt", sb
.ToString());
4049 ffmpeg
= "\"" + workPath
+ "\\ffmpeg.exe\" -f concat -i concat.txt -y -c copy " + finish
;
4051 ffmpeg
+= "\r\ncmd";
4052 batpath
= workPath
+ "\\concat.bat";
4053 File
.WriteAllText(batpath
, ffmpeg
, UnicodeEncoding
.Default
);
4055 System
.Diagnostics
.Process
.Start(batpath
);
4060 private void tabControl_DragOver(object sender
, DragEventArgs e
)
4062 if (e
.Data
.GetDataPresent(DataFormats
.FileDrop
))
4064 e
.Effect
= DragDropEffects
.All
;
4065 Point pt
= new Point(e
.X
+ 2, e
.Y
+ 2);
4066 pt
= PointToClient(pt
);
4067 int pi
= GetTabPageByTab(pt
);
4070 tabControl
.SelectedIndex
= pi
;
4073 else e
.Effect
= DragDropEffects
.None
;
4077 /// Finds the TabPage whose tab is contains the given point.
4079 /// <param name="pt">The point (given in client coordinates) to look for a TabPage.</param>
4080 /// <returns>The TabPage whose tab is at the given point (null if there isn't one).</returns>
4081 private int GetTabPageByTab(Point pt
)
4085 for (int i
= 0; i
< tabControl
.TabPages
.Count
; i
++)
4087 Rectangle a
= tabControl
.GetTabRect(i
);
4089 if (tabControl
.GetTabRect(i
).Contains(pt
))
4091 tp
= tabControl
.TabPages
[i
];
4099 private void MainForm_KeyDown(object sender
, KeyEventArgs e
)
4101 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D1
)
4103 tabControl
.SelectedIndex
= 0;
4105 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D2
)
4107 tabControl
.SelectedIndex
= 1;
4109 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D3
)
4111 tabControl
.SelectedIndex
= 2;
4113 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D4
)
4115 tabControl
.SelectedIndex
= 3;
4117 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D5
)
4119 tabControl
.SelectedIndex
= 4;
4121 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D6
)
4123 tabControl
.SelectedIndex
= 5;
4125 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D7
)
4127 tabControl
.SelectedIndex
= 6;
4129 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D8
)
4131 tabControl
.SelectedIndex
= 7;
4133 if (e
.Modifiers
== Keys
.Control
&& e
.KeyCode
== Keys
.D9
)
4135 tabControl
.SelectedIndex
= 8;
4139 #endregion TabControl
4141 private void gmkvextractguibButton_Click(object sender
, EventArgs e
)
4143 string path
= workPath
+ "\\gMKVExtractGUI.exe";
4145 if (File
.Exists(path
))
4147 System
.Diagnostics
.Process
.Start(path
);
4151 ShowErrorMessage("请检查\r\n\r\n" + path
+ "\r\n\r\n是否存在", "未找到程序!");
4155 private void FeedbackButton_Click(object sender
, EventArgs e
)
4157 FeedbackForm ff
= new FeedbackForm();
4161 private void x264SubTextBox_DoubleClick(object sender
, EventArgs e
)
4163 x264SubTextBox
.Clear();
4166 private void RotateButton_Click(object sender
, EventArgs e
)
4168 if (namevideo4
== "")
4170 ShowErrorMessage("请选择视频文件");
4172 else if (nameout5
== "")
4174 ShowErrorMessage("请选择输出文件");
4178 clip
= String
.Format(@"""{0}\ffmpeg.exe"" -i ""{1}"" -vf ""transpose={2}"" -y ""{3}""",
4179 workPath
, namevideo4
, TransposeComboBox
.SelectedIndex
, nameout5
) + Environment
.NewLine
+ "cmd";
4180 batpath
= workPath
+ "\\clip.bat";
4181 File
.WriteAllText(batpath
, clip
, UnicodeEncoding
.Default
);
4182 Process
.Start(batpath
);
4186 private void AudioPresetComboBox_SelectedIndexChanged(object sender
, EventArgs e
)
4188 XElement x
= xdoc
.Element("root").Element("Audio").Elements().Where(_
=> _
.Attribute("Name").Value
== AudioPresetComboBox
.Text
).First();
4189 AudioCustomParameterTextBox
.Text
= x
.Value
;
4192 private void lbAuto_DrawItem(object sender
, DrawItemEventArgs e
)
4194 if (e
.Index
< 0 || e
.Index
>= 65535)
4198 SolidBrush BlueBrush
= new SolidBrush(Color
.Blue
);
4199 SolidBrush BlackBrush
= new SolidBrush(Color
.Black
);
4200 Color vColor
= Color
.Black
;
4201 string input
= lbAuto
.Items
[e
.Index
].ToString();
4202 if (!string.IsNullOrEmpty(GetSubtitlePath(input
)))
4204 e
.Graphics
.DrawString(Convert
.ToString(lbAuto
.Items
[e
.Index
]), e
.Font
, BlueBrush
, e
.Bounds
);
4208 e
.Graphics
.DrawString(Convert
.ToString(lbAuto
.Items
[e
.Index
]), e
.Font
, BlackBrush
, e
.Bounds
);
4213 private string GetSubtitlePath(string videoPath
)
4217 string[] subExt
= { ".ass", ".ssa", ".srt" }
;
4218 if (x264BatchSubSpecialLanguage
.Text
!= "none")
4219 splang
= "." + x264BatchSubSpecialLanguage
.Text
;
4220 foreach (string ext
in subExt
)
4222 if (File
.Exists(videoPath
.Remove(videoPath
.LastIndexOf(".")) + splang
+ ext
))
4224 sub
= videoPath
.Remove(videoPath
.LastIndexOf(".")) + splang
+ ext
;
4231 private void x264ExeComboBox_SelectedIndexChanged(object sender
, EventArgs e
)
4233 if (x264ExeComboBox
.SelectedIndex
== -1)
4236 if (x264ExeComboBox
.SelectedItem
.ToString().ToLower().Contains("x265"))
4238 x264SubTextBox
.Enabled
= false;
4239 x264SubBtn
.Enabled
= false;
4240 x264BatchSubCheckBox
.Enabled
= false;
4241 x264BatchSubSpecialLanguage
.Enabled
= false;
4242 x264DemuxerComboBox
.Enabled
= false;
4243 VideoBatchFormatComboBox
.Text
= "mp4";
4244 VideoBatchFormatComboBox
.Enabled
= false;
4248 x264SubTextBox
.Enabled
= true;
4249 x264SubBtn
.Enabled
= true;
4250 x264BatchSubCheckBox
.Enabled
= true;
4251 x264BatchSubSpecialLanguage
.Enabled
= true;
4252 x264DemuxerComboBox
.Enabled
= true;
4253 VideoBatchFormatComboBox
.Enabled
= true;
4255 //if (x264ExeComboBox.SelectedItem.ToString().ToLower().Contains("ffmpeg"))
4257 // x264Mode3RadioButton.Checked = true;
4258 // x264Mode1RadioButton.Enabled = false;
4259 // x264Mode2RadioButton.Enabled = false;
4263 // x264SubTextBox.Enabled = true;
4264 // x264Mode1RadioButton.Checked = true;
4265 // x264Mode1RadioButton.Enabled = true;
4266 // x264Mode2RadioButton.Enabled = true;
4267 // x264Mode3RadioButton.Enabled = true;