implemented live streaming to an rtmp server
This commit is contained in:
parent
7f75b31176
commit
f6c6ba96bc
@ -9,12 +9,12 @@ using System.IO;
|
||||
public class RT3script : MonoBehaviour
|
||||
{
|
||||
public RenderTexture colorImage, depthImage;
|
||||
public string outputRTMP = "rtmp://your_monaserver_address/live/stream_key";
|
||||
public string outputRTMP = "rtmp://localhost/live/HoloPipeline";
|
||||
public string mp4name = "my_movie_depth_ffmpeg.mp4";
|
||||
|
||||
public Texture2D outputImage;
|
||||
|
||||
public int targetFrameRate = 30;
|
||||
public int targetFrameRate = 60;
|
||||
int frameCount = 0;
|
||||
|
||||
private Process ffmpegProcess;
|
||||
@ -35,7 +35,7 @@ public class RT3script : MonoBehaviour
|
||||
|
||||
colorImage = new RenderTexture(256,256,16,RenderTextureFormat.ARGB32);
|
||||
depthImage = new RenderTexture(256,256,16,RenderTextureFormat.ARGB32);
|
||||
outputImage = new Texture2D(512,512, TextureFormat.RGBA32, false);
|
||||
outputImage = new Texture2D(512,512, TextureFormat.RGB24, false);
|
||||
|
||||
Camera c = GetComponent<Camera>();
|
||||
c.targetTexture = colorImage;
|
||||
@ -73,12 +73,12 @@ public class RT3script : MonoBehaviour
|
||||
// Graphics.CopyTexture(colorImage, 0, 0, 0, 0, 256, 256, outputImage, 0, 0, 0, 0);
|
||||
// Graphics.CopyTexture(depthImage, 0, 0, 0, 0, 256, 256, outputImage, 0, 0, 256, 0);
|
||||
|
||||
// RenderTexture.active = colorImage;
|
||||
// outputImage.ReadPixels(new Rect(0, 0, 256, 256), 0, 0);
|
||||
// outputImage.Apply();
|
||||
RenderTexture.active = colorImage;
|
||||
outputImage.ReadPixels(new Rect(0, 0, 256, 256), 0, 0);
|
||||
outputImage.Apply();
|
||||
|
||||
RenderTexture.active = depthImage;
|
||||
outputImage.ReadPixels(new Rect(0, 0, depthImage.width, depthImage.height), 0, 0);
|
||||
outputImage.ReadPixels(new Rect(0, 0, depthImage.width, depthImage.height), 0, 256);
|
||||
outputImage.Apply();
|
||||
RenderTexture.active = null;
|
||||
|
||||
@ -113,8 +113,7 @@ public class RT3script : MonoBehaviour
|
||||
{
|
||||
// Setup FFmpeg process with arguments for RTMP streaming
|
||||
string ffmpegArgs = $"-y -f rawvideo -vcodec rawvideo -pix_fmt rgb24 -s {outputImage.width}x{outputImage.height} " +
|
||||
// $"-r {targetFrameRate} -i pipe:0 -c:v libx264 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -f flv {outputRTMP}";
|
||||
$"-r 30 -i pipe:0 -c:v libx264 -preset ultrafast -pix_fmt yuv420p \"{outputMP4}\"";
|
||||
$"-r {targetFrameRate} -i pipe:0 -c:v libx264 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -f flv {outputRTMP}";
|
||||
|
||||
ffmpegProcess = new Process();
|
||||
ffmpegProcess.StartInfo.FileName = "F:\\ffmpeg-7.1-full_build\\bin\\ffmpeg.exe";
|
||||
|
Loading…
x
Reference in New Issue
Block a user