Fla*_*ron 5 c# image-capture video-capture rtmp video-streaming
我需要从rtmp或http视频流中捕获屏幕截图。我想每10秒捕获一次屏幕截图,并将其另存为png或jpg文件。
我没有能够找到适合我的任何程序,因此我考虑使用以下库中的lib在C#中编写应用程序:http : //www.broccoliproducts.com/softnotebook/rtmpclient/rtmpclient.php
不幸的是,似乎rtmpClient库仅捕获rtmp流并将其保存到flv文件中,这不是我想要的。有谁知道可以帮助我的更好的libs吗?
我现在找到了解决问题的方法。如果有人想知道,我写了一个使用rtmpdump和ffmpeg捕获图像的小程序。
static void Main(string[] args)
{
const string rtmpDump = "rtmpdump.exe";
const string rtmpDumpArguments = "-v -r rtmp://{stream} -o 1.flv -B 1";
sRunExternalExe(rtmpDump, rtmpDumpArguments);
const string ffmpeg = "ffmpeg.exe";
const string ffmpegArguments = "-i 1.flv -ss 00:00:01 -an -r 1 -vframes 1 -s 400x300 -y 1.jpg";
RunExternalExe(ffmpeg, ffmpegArguments);
var theFile = new FileInfo("1.flv");
if (theFile.Exists)
{
File.Delete("1.flv");
}
}
public static string RunExternalExe(string filename, string arguments = null)
{
var process = new Process();
process.StartInfo.FileName = filename;
if (!string.IsNullOrEmpty(arguments))
{
process.StartInfo.Arguments = arguments;
}
process.StartInfo.CreateNoWindow = true;
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.RedirectStandardOutput = true;
var stdOutput = new StringBuilder();
process.OutputDataReceived += (sender, args) => stdOutput.Append(args.Data);
string stdError = null;
try
{
process.Start();
process.BeginOutputReadLine();
stdError = process.StandardError.ReadToEnd();
process.WaitForExit();
}
catch (Exception e)
{
throw new Exception("OS error while executing " + Format(filename, arguments) + ": " + e.Message, e);
}
if (process.ExitCode == 0 || process.ExitCode == 2)
{
return stdOutput.ToString();
}
else
{
var message = new StringBuilder();
if (!string.IsNullOrEmpty(stdError))
{
message.AppendLine(stdError);
}
if (stdOutput.Length != 0)
{
message.AppendLine("Std output:");
message.AppendLine(stdOutput.ToString());
}
throw new Exception(Format(filename, arguments) + " finished with exit code = " + process.ExitCode + ": " + message);
}
}
private static string Format(string filename, string arguments)
{
return "'" + filename +
((string.IsNullOrEmpty(arguments)) ? string.Empty : " " + arguments) +
"'";
}
Run Code Online (Sandbox Code Playgroud)
你看过SnagIt 了吗!v11.1?我刚刚升级了我的副本,它将捕获视频流和相关音频。
我不知道每 10 秒的屏幕截图,但我确实知道它具有内置计时器功能,以及隔离各个帧的能力。
也许值得一瞧。我认为它有 30 天的试用期。
归档时间: |
|
查看次数: |
5225 次 |
最近记录: |