Menu Close

How Can We Help?

< Back
You are here:
Print

How to enable UDP streaming through the Multipurpose Encoder?

From the TVideoGrabber SDK the typical sample code is; e.g. to stream the screen capture (adjust eventually destination IP, bitrate, etc…):


VideoGrabber.VideoSource = vs_ScreenRecording;
VideoGrabber.UseNearestVideoSize (1920, 1080, true);
if (FMultipurposeUDPStreamingID == -1) {
  FMultipurposeUDPStreamingID = VideoGrabber.Encoders_CreateInstanceForStreaming ("udp://239.255.0.1:10124");
}
if (FMultipurposeUDPStreamingID > -1) {
  VideoGrabber.Encoder_SetStr (FMultipurposeUDPStreamingID, Enc_Video_Codec, "h264");
  VideoGrabber.Encoder_SetInt (FMultipurposeUDPStreamingID, Enc_Video_Enabled_bool, 1);
   //VideoGrabber.Encoder_SetInt (FMultipurposeUDPStreamingID, Enc_Audio_Enabled_bool, 1);
  VideoGrabber.Encoder_SetInt (FMultipurposeUDPStreamingID, Enc_Video_BitRate_kb, 3000);
  VideoGrabber.Encoder_SetInt (FMultipurposeUDPStreamingID, Enc_Video_rc_MinBitRate_kb, 2800);
  VideoGrabber.Encoder_SetInt (FMultipurposeUDPStreamingID, Enc_Video_rc_MaxBitRate_kb, 3300);
  VideoGrabber.Encoder_SetInt (FMultipurposeUDPStreamingID, Enc_Video_IDR_Interval, 30);
   // uncomment to enable the GPU encoder, if available
   //VideoGrabber.Encoder_SetInt (0, Enc_Video_GPU_Encoder, integer(Enc_GPU_NVidia_NVENC));
   //VideoGrabber.Encoder_SetInt (0, Enc_Video_GPU_Encoder, integer(Enc_GPU_Intel_QSV));
  VideoGrabber.Encoder_SetStr (FMultipurposeUDPStreamingID, Enc_Extra_Parameters, "-preset:v ultrafast");
  VideoGrabber.Encoder_SetInt (FMultipurposeUDPStreamingID, Enc_IsActive_bool, 1);
  VideoGrabber.StartPreview();
}

Table of Contents