Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
zabpehely | 2dcfa5132b | |
LouisLam | ac63e215ff | |
LouisLam | d9b13cb1a7 | |
LouisLam | 01bbdde60c | |
LouisLam | a5cfc0e42d | |
LouisLam | 37c1e1b6bc |
|
@ -109,7 +109,7 @@
|
||||||
this.dataGridView1.Name = "dataGridView1";
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
this.dataGridView1.ReadOnly = true;
|
this.dataGridView1.ReadOnly = true;
|
||||||
this.dataGridView1.RowTemplate.Height = 24;
|
this.dataGridView1.RowTemplate.Height = 24;
|
||||||
this.dataGridView1.Size = new System.Drawing.Size(587, 141);
|
this.dataGridView1.Size = new System.Drawing.Size(586, 141);
|
||||||
this.dataGridView1.TabIndex = 8;
|
this.dataGridView1.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// FilePath
|
// FilePath
|
||||||
|
@ -117,6 +117,7 @@
|
||||||
this.FilePath.HeaderText = "File Path";
|
this.FilePath.HeaderText = "File Path";
|
||||||
this.FilePath.Name = "FilePath";
|
this.FilePath.Name = "FilePath";
|
||||||
this.FilePath.ReadOnly = true;
|
this.FilePath.ReadOnly = true;
|
||||||
|
this.FilePath.Width = 272;
|
||||||
//
|
//
|
||||||
// Status
|
// Status
|
||||||
//
|
//
|
||||||
|
|
65
Form1.cs
65
Form1.cs
|
@ -22,6 +22,8 @@ namespace CompressH265 {
|
||||||
|
|
||||||
private int runningProcessCount = 0;
|
private int runningProcessCount = 0;
|
||||||
|
|
||||||
|
private LinkedList<Process> processList = new LinkedList<Process>();
|
||||||
|
|
||||||
public Form1() {
|
public Form1() {
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
@ -114,11 +116,24 @@ namespace CompressH265 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get FPS
|
||||||
|
var fps = GetFPS(inputFilename);
|
||||||
|
var fpsParam = "";
|
||||||
|
|
||||||
|
if (fps > 0) {
|
||||||
|
fpsParam = "-r " + fps;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Converting
|
||||||
process.StartInfo.FileName = "ffmpeg.exe";
|
process.StartInfo.FileName = "ffmpeg.exe";
|
||||||
process.StartInfo.Arguments = $"-i \"{inputFilename}\" -vcodec hevc -map_metadata 0 \"{outputFilename}\"";
|
process.StartInfo.Arguments = $" -i \"{inputFilename}\" -vcodec hevc -map_metadata 0 -vf yadif -crf 20 -preset medium {fpsParam} \"{outputFilename}\"";
|
||||||
process.StartInfo.UseShellExecute = false;
|
process.StartInfo.UseShellExecute = false;
|
||||||
process.StartInfo.CreateNoWindow = true;
|
process.StartInfo.CreateNoWindow = true;
|
||||||
|
|
||||||
|
MessageBox.Show(process.StartInfo.Arguments);
|
||||||
|
|
||||||
var rowID = nextTaskID++;
|
var rowID = nextTaskID++;
|
||||||
var msgQueue = new Queue<string>();
|
var msgQueue = new Queue<string>();
|
||||||
dataGridView1.Rows.Insert(rowID, shortName, "Preparing...");
|
dataGridView1.Rows.Insert(rowID, shortName, "Preparing...");
|
||||||
|
@ -160,6 +175,41 @@ namespace CompressH265 {
|
||||||
runningProcessCount++;
|
runningProcessCount++;
|
||||||
process.Start();
|
process.Start();
|
||||||
process.BeginErrorReadLine();
|
process.BeginErrorReadLine();
|
||||||
|
|
||||||
|
processList.AddLast(process);
|
||||||
|
}
|
||||||
|
|
||||||
|
private float GetFPS(string inputFilename) {
|
||||||
|
Process process = new Process();
|
||||||
|
process.StartInfo.FileName = "ffmpeg.exe";
|
||||||
|
process.StartInfo.Arguments = $"-i \"{inputFilename}\"";
|
||||||
|
process.StartInfo.UseShellExecute = false;
|
||||||
|
process.StartInfo.CreateNoWindow = true;
|
||||||
|
process.StartInfo.RedirectStandardError = true;
|
||||||
|
process.Start();
|
||||||
|
process.WaitForExit();
|
||||||
|
string err = process.StandardError.ReadToEnd();
|
||||||
|
|
||||||
|
var end = err.IndexOf(" fps,");
|
||||||
|
|
||||||
|
if (end < 0) {
|
||||||
|
return -1f;
|
||||||
|
}
|
||||||
|
|
||||||
|
var start = end;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (err[start - 1] == ' ') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
start--;
|
||||||
|
|
||||||
|
if (start < 0) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return float.Parse(err.Substring(start, end - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button3_Click(object sender, EventArgs e) {
|
private void button3_Click(object sender, EventArgs e) {
|
||||||
|
@ -215,13 +265,16 @@ namespace CompressH265 {
|
||||||
|
|
||||||
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
|
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
|
||||||
if (runningProcessCount > 0) {
|
if (runningProcessCount > 0) {
|
||||||
var result = MessageBox.Show("Are you sure want to stop the processing?", "Stop process",
|
var result = MessageBox.Show("Are you sure want to stop the processing?", "Stop process", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||||
MessageBoxButtons.YesNo,
|
|
||||||
MessageBoxIcon.Question);
|
|
||||||
|
|
||||||
e.Cancel = (result == DialogResult.No);
|
if (result == DialogResult.Yes) {
|
||||||
|
foreach (var p in processList) {
|
||||||
|
p.Kill();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e.Cancel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.1.0.0")]
|
[assembly: AssemblyVersion("1.3.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.1.0.0")]
|
[assembly: AssemblyFileVersion("1.3.0.0")]
|
Loading…
Reference in New Issue