Compare commits

..

6 Commits
1.1 ... master

Author SHA1 Message Date
zabpehely 2dcfa5132b Update README.md 2024-01-28 20:19:01 +01:00
LouisLam ac63e215ff fix drop frame rate 2020-05-16 20:37:12 +08:00
LouisLam d9b13cb1a7 fix drop frame rate 2020-05-16 20:36:47 +08:00
LouisLam 01bbdde60c update version 2020-05-11 00:45:17 +08:00
LouisLam a5cfc0e42d increase quality to almost lossless 2020-05-11 00:37:18 +08:00
LouisLam 37c1e1b6bc close ffmpeg and improve quality 2020-05-10 19:57:59 +08:00
4 changed files with 64 additions and 10 deletions

3
Form1.Designer.cs generated
View File

@ -109,7 +109,7 @@
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
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;
//
// FilePath
@ -117,6 +117,7 @@
this.FilePath.HeaderText = "File Path";
this.FilePath.Name = "FilePath";
this.FilePath.ReadOnly = true;
this.FilePath.Width = 272;
//
// Status
//

View File

@ -22,6 +22,8 @@ namespace CompressH265 {
private int runningProcessCount = 0;
private LinkedList<Process> processList = new LinkedList<Process>();
public Form1() {
InitializeComponent();
}
@ -114,11 +116,24 @@ namespace CompressH265 {
return;
}
// Get FPS
var fps = GetFPS(inputFilename);
var fpsParam = "";
if (fps > 0) {
fpsParam = "-r " + fps;
}
// Converting
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.CreateNoWindow = true;
MessageBox.Show(process.StartInfo.Arguments);
var rowID = nextTaskID++;
var msgQueue = new Queue<string>();
dataGridView1.Rows.Insert(rowID, shortName, "Preparing...");
@ -160,6 +175,41 @@ namespace CompressH265 {
runningProcessCount++;
process.Start();
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) {
@ -215,13 +265,16 @@ namespace CompressH265 {
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
if (runningProcessCount > 0) {
var result = MessageBox.Show("Are you sure want to stop the processing?", "Stop process",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
var result = MessageBox.Show("Are you sure want to stop the processing?", "Stop process", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
e.Cancel = (result == DialogResult.No);
if (result == DialogResult.Yes) {
foreach (var p in processList) {
p.Kill();
}
} else {
e.Cancel = true;
}
}
}
}
}

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.3.0.0")]
[assembly: AssemblyFileVersion("1.3.0.0")]

View File

@ -7,7 +7,7 @@ Compress or convert your video files to h.265 (hevc) format with one-click, make
# Download
https://github.com/louislam/lazy-compress-h265/releases
https://gitea.ath.cx/zabpehely/lazy-compress-h265/releases
# Features