【发布时间】:2021-04-11 14:26:48
【问题描述】:
所以我正在编写一个 c# 应用程序,它允许用户以像素为单位将视频缩放到自定义尺寸。我正在努力从 mpeg psi 参数的文本框中获取用户输入:
代码如下:
var localStoragePath = Path.Combine(Path.GetTempPath(), name);
var directoryPath = Path.GetDirectoryName(localStoragePath);
Directory.CreateDirectory(directoryPath);
File.WriteAllBytes(localStoragePath, bytes);
Progress.Text = ($"File copy successful: {File.Exists(localStoragePath)}");
var readBack = File.ReadAllBytes(localStoragePath);
Progress.Text = ($"Read file Back: {readBack.Length}, {localStoragePath}");
var resizedFolderPath = @"C:\upscaledvideohere";
Directory.CreateDirectory(resizedFolderPath);
var resizedFiePath = Path.Combine(resizedFolderPath, Path.GetFileName(localStoragePath));
var psi = new ProcessStartInfo();
psi.FileName = @"C:\ffmpeg-2020-12-27-git-bff6fbead8-full_build\bin\ffmpeg.exe";
psi.Arguments = $"-i \"{localStoragePath}\" -vf scale=" + pixelsheight.Text "\"{resizedFiePath}\"";
psi.RedirectStandardOutput = false;
psi.RedirectStandardError = false;
psi.UseShellExecute = true;
Progress.Text = ($"Args: {psi.Arguments}");
对于
psi.Arguments = $"-i \"{localStoragePath}\" -vf scale=" + pixelsheight.Text "\"{resizedFiePath}\""
为用户在像素高度文本框中输入的文本输入文本的正确方法是什么?
非常感谢。
【问题讨论】:
-
我不是已经回答了吗?
-
不,谢谢。这是这里的第一条评论。
-
您错过了“+”和“$”。应该是
$"-i \"{localStoragePath}\" -vf scale=" + pixelsheight.Text + $" \"{resizedFiePath}\"" -
这是这里的第一条评论 - 我指的是this question
-
@KyleWang 实际上应该对整个事情进行插值,因为它在我已经回答的问题中
标签: c# visual-studio winforms ffmpeg