How Can We Help?
How to stream the TVideoGrabber output to a standalone RTSP server?
– install the mediamtx rtsp server, (the .exe for Windows can be downloaded in the “Releases” section) on one of the computers of the LAN (in the example below with IP address 192.168.0.45)
By default this server works “out of the box”, just to put mediamtx.exe and mediamtx.yml in a folder of your choice and run mediamtx.exe.
First initialize this global variable:
int StreamingEncoderId = -1;
then the typical code to start the streaming is:
// select the video source as usual
VideoGrabber.VideoSource = ...
VideoGrabber....
if (EnableStreaming)
{
if (FStreamingEncoderId) == -1
{
FStreamingEncoderId := VideoGrabber.Encoders_CreateInstanceForStreaming ("rtmp://192.168.0.45:1935/livestream1");
}
VideoGrabber.Encoder_SetInt (FStreamingEncoderId, Enc_Video_Enabled_bool, 1);
VideoGrabber.Encoder_SetStr (FStreamingEncoderId, Enc_Video_Codec, "h264");
VideoGrabber.Encoder_SetInt (FStreamingEncoderId, Enc_Video_BitRate_kb, 768);
// enable this section only if audio is needed
VideoGrabber.Encoder_SetStr (FStreamingEncoderId, Enc_Audio_Codec, "aac");
VideoGrabber.Encoder_SetInt (FStreamingEncoderId, Enc_Audio_Enabled_bool, 1);
VideoGrabber.Encoder_SetInt (FStreamingEncoderId, Enc_Audio_SamplesPerSec, 44100);
// if quality problem increase the number of threads, but this will increase the latency
VideoGrabber.Encoder_SetInt (FStreamingEncoderId, Enc_Video_Thread_Count, 1);
VideoGrabber.Encoder_SetInt (FStreamingEncoderId, Enc_IsActive_bool, 1);
}
VideoGrabber.StartPreview();
– for the TVideoGrabber component(s) that will view the live RTSP stream above, the typical sample code is:
VideoGrabber.VideoSource = vs_IPCamera
VideoGrabber.IPCameraURL = "rtsp://192.168.0.45:8554/livestream1";
VideoGrabber.AudioDeviceRendering = true; // only if audio needed
VideoGrabber.StartPreview();
To create multiple concurrent sessions, just use different stream names, e.g.livestream1, livestream2, mystream3, etc…