-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVideoEncoder.cs
56 lines (51 loc) · 1.81 KB
/
VideoEncoder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using System;
using System.Collections.Generic;
using SpinnakerNET;
using SpinnakerNET.GenApi;
using System.Threading;
using System.Drawing;
using Emgu.CV;
using System.Collections.Concurrent;
using System.IO.Pipes;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace FetchRig6
{
public class VideoEncoder
{
private readonly string sessionPath;
private string videoFileName { get; set; }
public VideoEncoder(string sessionPath, string videoFileName)
{
this.sessionPath = sessionPath;
this.videoFileName = videoFileName;
}
public class FFProcess
{
private string _pipeName;
private string _videoFileName;
private string inputArgs;
private string outputArgs;
private string fullArgs;
public Process process;
public FFProcess(string pipeName, string videoFileName)
{
_pipeName = @"\\.\pipe\" + pipeName;
_videoFileName = videoFileName;
inputArgs = "-nostats -y -vsync 0 -f rawvideo -s 3208x2200 -pix_fmt gray -framerate 100 -i " + _pipeName + " -an -sn";
outputArgs = "-gpu 0 -vcodec h264_nvenc -r 100 -preset fast -qp 20 " + _videoFileName;
fullArgs = inputArgs + " " + outputArgs;
}
public void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "ffmpeg.exe";
startInfo.Arguments = fullArgs;
startInfo.CreateNoWindow = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
process = Process.Start(startInfo);
}
}
}
}