0

所以我正在编写 ac# 应用程序,它允许用户将视频以像素为单位缩放到自定义尺寸。我正在努力从 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}\""

输入用户在像素高度文本框中输入的文本的正确方法是什么?

非常感谢。

4

1 回答 1

0

您之前的问题更正确。当只进行插值会更简单时,您正在混合 concat 和插值

$"-i \"{localStoragePath}\" -vf scale=-1:{pixelsheight.Text} \"{resizedFiePath}\""

我还将 pixelHeight 设为 NumericUpDown 而不是文本,以防止因必须确保在文本框中输入数字而感到头疼


停止复制大量电影文件,方法是将它们全部读入内存中的字节数组,将其复制到另一个字节数组,然后将文件读入另一个您从不使用的文件,然后写入磁盘。在 500mb 的电影上运行 ffmpeg 将花费 1.5gb 的内存。使用 System.IO.File.Copy 它不会使用任何内存

于 2021-01-06T07:36:01.293 回答