如何格式化字符串ffmpeg参数将参数传递给文本框?
我创建了此表格:
我想使用变量ffmpegarguments将参数从文本框传递到ffmpeg类参数。问题在于,在FFMPEG类中,我正在使用这些变量:
文件名和Framerate,因此如何使用文件名和FRAMETER变量将从文本框的输入格式化为FFMPEG参数?
在FFMPEG类中:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Capture_Screen
{
internal class FFmpeg_Capture
{
public string workingDirectory;
public string outputDirectory;
public string ffmpegArguments;
private Process process;
public FFmpeg_Capture()
{
}
public void Start(string FileName, int Framerate)
{
process = new Process();
process.StartInfo.FileName = outputDirectory; // Change the directory where ffmpeg.exe is.
process.EnableRaisingEvents = false;
process.StartInfo.WorkingDirectory = workingDirectory; // The output directory
process.StartInfo.Arguments = @"-y -f gdigrab -framerate " + Framerate +
" -i desktop -preset ultrafast -pix_fmt yuv420p " + FileName;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true; //Redirect stdin
process.StartInfo.CreateNoWindow = true;
process.Start();
}
public void Stop()
{
byte[] qKey = Encoding.GetEncoding("gbk").GetBytes("q"); //Get encoding of 'q' key
process.StandardInput.BaseStream.Write(qKey, 0, 1); //Write 'q' key to stdin of FFmpeg sub-processs
process.StandardInput.BaseStream.Flush(); //Flush stdin (just in case).
process.Close();
process.Dispose();
}
}
}
I created this form :
I want to use the variable ffmpegArguments to pass the arguments from the textBox to the ffmpeg class arguments. the problem is that in the ffmpeg class i'm using the variables :
FileName and Framerate so how can i format the input from the textBox to the ffmpeg arguments with the FileName and Framerate variables ?
In the ffmpeg class :
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Capture_Screen
{
internal class FFmpeg_Capture
{
public string workingDirectory;
public string outputDirectory;
public string ffmpegArguments;
private Process process;
public FFmpeg_Capture()
{
}
public void Start(string FileName, int Framerate)
{
process = new Process();
process.StartInfo.FileName = outputDirectory; // Change the directory where ffmpeg.exe is.
process.EnableRaisingEvents = false;
process.StartInfo.WorkingDirectory = workingDirectory; // The output directory
process.StartInfo.Arguments = @"-y -f gdigrab -framerate " + Framerate +
" -i desktop -preset ultrafast -pix_fmt yuv420p " + FileName;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true; //Redirect stdin
process.StartInfo.CreateNoWindow = true;
process.Start();
}
public void Stop()
{
byte[] qKey = Encoding.GetEncoding("gbk").GetBytes("q"); //Get encoding of 'q' key
process.StandardInput.BaseStream.Write(qKey, 0, 1); //Write 'q' key to stdin of FFmpeg sub-processs
process.StandardInput.BaseStream.Flush(); //Flush stdin (just in case).
process.Close();
process.Dispose();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论