Skip to content
Snippets Groups Projects
Commit 2a8f5c5b authored by Anduin Xue's avatar Anduin Xue
Browse files

Use GPU support.

parent f9e2eaff
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ namespace Parser ...@@ -28,7 +28,7 @@ namespace Parser
if (args.Length < 1) if (args.Length < 1)
{ {
Console.WriteLine("Usage: WorkingPath"); Console.WriteLine("Usage: WorkingPath [useGPU]");
Console.WriteLine("Current parameters:"); Console.WriteLine("Current parameters:");
foreach (var arg in args) foreach (var arg in args)
{ {
...@@ -48,11 +48,11 @@ namespace Parser ...@@ -48,11 +48,11 @@ namespace Parser
foreach (var file in videos) foreach (var file in videos)
{ {
await Parse(file); await Parse(file, coder: args.Any(a => a.Equals("useGPU", StringComparison.OrdinalIgnoreCase)) ? "hevc_nvenc" : "libx265");
} }
} }
private async Task Parse(string filePath) private async Task Parse(string filePath, string coder)
{ {
var folder = Path.GetDirectoryName(filePath) ?? throw new Exception($"{filePath} is invalid!"); var folder = Path.GetDirectoryName(filePath) ?? throw new Exception($"{filePath} is invalid!");
var baseFileInfo = await _commandService.RunCommand("ffmpeg.exe", $@"-i ""{filePath}""", folder); var baseFileInfo = await _commandService.RunCommand("ffmpeg.exe", $@"-i ""{filePath}""", folder);
...@@ -69,7 +69,7 @@ namespace Parser ...@@ -69,7 +69,7 @@ namespace Parser
Console.WriteLine($"{filePath} WILL be parsed!"); Console.WriteLine($"{filePath} WILL be parsed!");
File.Delete(newFileName); File.Delete(newFileName);
await _commandService.RunCommand("ffmpeg", $@"-i ""{filePath}"" -codec:a copy -codec:v hevc_nvenc -b:v 16M ""{newFileName}""", folder, getOutput: false); await _commandService.RunCommand("ffmpeg", $@"-i ""{filePath}"" -codec:a copy -codec:v {coder} -b:v 16M ""{newFileName}""", folder, getOutput: false);
// Delete old file. // Delete old file.
File.Delete(filePath); File.Delete(filePath);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment