    ' set your own RTSP URL and facebook key
	' enable/disable StreamDesktop to switch between screen and IP camera as source

    Dim StreamingEncoderId As Integer = -1

    Private Sub btnPlay_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPlay.Click

        Dim StreamDesktop As Boolean = True

        If StreamDesktop Then
            VideoGrabber1.VideoSource = VidGrab.TVideoSource.vs_ScreenRecording
            VideoGrabber1.UseNearestVideoSize(1920, 1080, True)
        Else
            VideoGrabber1.VideoSource = VidGrab.TVideoSource.vs_IPCamera
            VideoGrabber1.IPCameraURL = "rtsp://... your URL "
        End If
        VideoGrabber1.AudioSource = VidGrab.TAudioSource.as_Silent

        StreamingEncoderId = VideoGrabber1.Encoders_CreateInstanceForStreaming("rtmps://live-api-s.facebook.com:443/rtmp/FB-613202114689260-0-Ab068DGkxkj_cbiR2b313")
        If (StreamingEncoderId = -1) Then
            ' error
        Else
            VideoGrabber1.Encoder_SetStr(StreamingEncoderId, VidGrab.TEncoder_str.Enc_Video_Codec, "h264")
            VideoGrabber1.Encoder_SetInt(StreamingEncoderId, VidGrab.TEncoder_int.Enc_Video_Enabled_bool, 1)
            VideoGrabber1.Encoder_SetInt(StreamingEncoderId, VidGrab.TEncoder_int.Enc_Audio_Enabled_bool, 1)
            VideoGrabber1.Encoder_SetInt(StreamingEncoderId, VidGrab.TEncoder_int.Enc_Video_BitRate_kb, 2500)
            VideoGrabber1.Encoder_SetInt(StreamingEncoderId, VidGrab.TEncoder_int.Enc_Video_rc_MaxBitRate_kb, 2500)
            VideoGrabber1.Encoder_SetInt(0, VidGrab.TEncoder_int.Enc_Video_rc_BufferSize_kb, 5000)
            VideoGrabber1.Encoder_SetInt(StreamingEncoderId, VidGrab.TEncoder_int.Enc_Video_IDR_Interval, 50)
            VideoGrabber1.Encoder_SetInt(StreamingEncoderId, VidGrab.TEncoder_int.Enc_IsActive_bool, 1)
            VideoGrabber1.StartPreview()
        End If
    End Sub

