5

rtmpまたはhttpビデオストリームからスクリーンショットをキャプチャする必要があります。10秒ごとにスクリーンショットをキャプチャして、pngまたはjpgファイルとして保存したいと思います。

私はこれを行うプログラムを見つけることができなかったので、次のライブラリを使用してC#でアプリケーションを作成することを考えていました: http ://www.broccoliproducts.com/softnotebook/rtmpclient/rtmpclient.php

残念ながら、rtmpClient libはrtmpストリームのみをキャプチャし、それをflvファイルに保存しているようです。これは私が望んでいることではありません。これで私を助けることができるより良いlibsを知っている人はいますか?

4

4 に答える 4

5

私は今問題の解決策を見つけました。誰かが知りたければ、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) +
            "'";
    }
于 2012-10-17T18:39:34.670 に答える
2

Linux を使用している場合は bash を使用できます (これはあなたには当てはまらないかもしれませんが、うまくいけば誰のグーグルにも役立ちます)。

/scripts/rtmpsnapshot

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

そのように呼ばれます:

/scripts/rtmpsnapshot rtmp://myserver.com/applicationname/ applicationname streamname /tmp/mysnapshot.jpg
于 2013-03-20T11:00:02.390 に答える
0

SnagItを見たことがありますか。v11.1 ? コピーをアップグレードしたところ、ビデオ ストリームと関連するオーディオがキャプチャされます。

10 秒ごとのスクリーンショットについてはわかりませんが、タイマー機能が組み込まれており、個々のフレームを分離する機能があることは知っています。

一見の価値があるかもしれません。30日間の試用版が付属していると思います。

于 2012-10-17T17:51:27.267 に答える
-4

Windows 7 を使用している場合は、画面をキャプチャするスニペット ツールが付属しています。

于 2012-10-17T17:59:56.000 に答える