fix drop frame rate
This commit is contained in:
parent
01bbdde60c
commit
d9b13cb1a7
|
@ -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
|
||||
//
|
||||
|
|
48
Form1.cs
48
Form1.cs
|
@ -116,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 -vf yadif -crf 16 -preset medium \"{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...");
|
||||
|
@ -166,6 +179,39 @@ namespace CompressH265 {
|
|||
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) {
|
||||
ProcessStartInfo info = new ProcessStartInfo();
|
||||
info.FileName = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
||||
|
|
Loading…
Reference in New Issue