Capturing a screenshot from an online video stream

I need to capture screenshots from rtmp or http stream. I want to take a screenshot every 10 seconds and save it as a png or jpg file.

I havnt been able to find any programs that do this for me, so I was thinking of writing a C # application using lib from: http://www.broccoliproducts.com/softnotebook/rtmpclient/rtmpclient.php

Unfortunately, it seems that the rtmpClient lib library only captures rtmp streams and saves it to the flv file, which I don't want. Anyone who knows any better libraries that can help me with this?

+4
source share
4 answers

I have found a solution to the problem now. If anyone wants to know, I wrote a small program that uses rtmpdump and ffmpeg to capture an image.

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) + "'"; } 
+3
source

You can use bash if you are running Linux (this may not apply to you, but hopefully helps any Google Googling), so I use it for our streaming product using 'rtmpdump' (apt-get install rtmpdump):

/ scripts / rtmpsnapshot

 #!/bin/bash rtmpdump --live --timeout=9 -r $1 -a $2 -y $3 --stop 1 -o - | avconv -i - -s 720x404 -vframes 1 $4 

called the following:

 /scripts/rtmpsnapshot rtmp://myserver.com/applicationname/ applicationname streamname /tmp/mysnapshot.jpg 
+2
source

You looked at SnagIt! v11.1 ? I just updated my copy and grabbed the video streams and related audio.

I don’t know about the screenshot every 10 seconds, but I know that it has built-in timer features and the ability to isolate individual frames.

Maybe worth a look. I think it comes with a 30 day trial.

0
source

If you are using Windows 7, it has a snippet tool that will capture your screen.

-3
source

Source: https://habr.com/ru/post/1440355/


All Articles