tencent cloud

Feedback

Robot Streaming (TUIRoomKit)

Last updated: 2024-07-02 17:06:35

    Description of the Feature

    TUIRoomKit supports the use of robot push streaming, allowing users to push local or online media files into the room. In some scenarios, meetings may require the push of pre-recorded instructional videos or online video streams to online classrooms for users to watch and learn. TUIRoomKit can meet these needs, achieving automated and efficient video playback.
    To use this feature, you need to subscribe to the TUIRoomKit Monthly Package. An robot stream will be considered a user in a room, which will incur call duration fees. For more information, please refer to the Billing of Audio and Video Duration. Transcoding operations will be performed during the process of connecting robot streams, thereby incurring transcoding fees. For more information, please refer to the Billing of On-Cloud MixTranscoding.
    
    
    

    Application Scenario

    Watching together, listening together, playing together, and learning together – experiences that previously required offline, face-to-face interaction are increasingly being moved online. The ability to watch movies, listen to music, and then discuss and share opinions with friends thousands of miles away is a magical real-time interactive experience that is loved by young people today, becoming a focus and mainstream direction of current audio and video products.
    TUIRoomKit input media stream feature allows sharing of external media streams within a room. Users can use this feature to share music, movies, lectures, courses, and other media content with other users in the room, engaging in real-time interaction with them. Platforms can leverage this new feature of TUIRoomKit to quickly implement a watch together scenario. In addition to watching movies and listening to music together, the input media stream capability of TUIRoomKit can also bring more innovative possibilities to the platform in scenarios such as interactive classrooms, sports competitions, and web conferences.
    
    
    

    Usage: Using RTMP for streaming

    TUIRoomKit supports RTMP standard protocol for streaming. Depending on the situation, you can choose to install OBS, FFmpeg, or other RTMP libraries for streaming.

    Using FFmpeg to publish streams

    FFmpeg requires specific command configuration parameters for different scenarios, so you should have some experience with FFmpeg. Below are commonly used FFmpeg Command Line options; for more FFmpeg Options, please refer to the FFmpeg official website.

    FFmpeg Command Line

    ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url}

    Common FFmpeg Options

    Option
    Description
    -re
    Reads input at native frame rate, generally only used for reading local files
    Among them, the configurable options for output_file_options include:
    Option
    Description
    -c:v
    Video Encoding, recommended to use libx264
    -b:v
    Video bitrate, for example, 1500k means 1500kbps
    -r
    Video Frame Rate
    -profile:v
    Video profile, specifying baseline will not encode B frames, TUIRoomKit backend does not support B frames
    -g
    GOP frame interval
    -c:a
    Audio Encoding, recommended to use libfdk_aac
    -ac
    Number of channels, fill in 2 or 1
    -b:a
    Audio Bitrate
    -f
    Specify format, fixed fill in flv, send to TUIRoomKit using FLV container

    Usage

    The following example uses FFmpeg command to read files and push to TUIRoomKit, note the quotes around the URL.
    ffmpeg -loglevel debug -re -i sample.flv -c:v libx264 -preset ultrafast -profile:v baseline -g 30 -sc_threshold 0 -b:v 1500k -c:a libfdk_aac -ac 2 -b:a 128k -f flv 'rtmp://rtmp.rtc.qq.com/push/yourRoomId?userid=yourUserId&sdkappid=xxxxxxxxx&usersig=xxxxxxxxxx'
    The explanations for the parameters in the above command are as follows:
    Parameter
    Meaning
    -i sample.flv
    The media file that needs to be streamed to TUIRoomKit. You can replace sample.flv with the local or online media file you need to stream.
    yourRoomId
    The Room ID you need to stream to. You need to replace yourRoomId with your actual RoomId.
    userId
    The UserID you need to stream with. You need to change the value after "=" to the actual userId.
    sdkappid
    Your sdkappid, which you have previously obtained in Activate Service. You need to change the value after "=" to the actual sdkAppID.
    usersig
    Your usersig, which you have obtained when logging into TUIRoomKit. You need to change the value after "=" to the actual userSig.
    When you need to implement the above feature in code, you can use the relevant FFmpeg library on your platform or invoke FFmpeg through the command line to achieve the above command.

    Using OBS to publish streams

    Prerequisites

    You have installed OBS.

    Step 1. Select a source

    In the Sources panel at the bottom, click **+**, and select a source based on your needs. Common sources include the following:
    Source
    Note
    Image
    Publishes a single image
    Image Slide Show
    Publishes multiple images (you can determine the order of playback and whether to loop the playback)
    Scene
    Inserts an entire scene to enable various streaming effects
    Media Source
    Uploads a local file and publishes it as a live stream
    Text
    Adds real-time text to your stream
    Window Capture
    Captures and publishes the window you select in real time
    Video Capture Device
    Captures and publishes the images captured by a camera in real time
    Audio Input Capture
    Audio live streaming (audio input device)
    Audio Output Capture
    Audio live streaming (audio output device)
    
    
    

    Step 2. Set publishing parameters

    1. In the Controls panel at the bottom, click Settings.
    img
    
    
    2. Click Stream and select Custom for Service.
    3. Enter rtmp://intl-rtmp.rtc.qq.com/push/ for Server.
    4. Enter a stream key in the following format:
    Room ID?sdkappid=Application&userid=User ID&usersig=Signature
    Replace "Room ID", "Application ID", "User ID", and "Signature" with the actual values, for example:
    yourRoomId?sdkappid=140*****66&userid=******rtmp2&usersig=eJw1jdE***************ZLgi5UAgOzoMhrayt*cjbmiCJ699T09juc833IMT94Ld7I0iHZqVDzvVAqkZsG-IKlzLiXOnEhswHu1iUyTc9pv*****D8MQwoA496Ke6U1ip4EAH4UMc5H9pSmv6MeTBWLamhwFnWRBZ8qKGRj8Yp-wVbv*mGMVZqS7w-mMDQL
    
    
    

    Step 3. Configure the output

    Because RTMP does not support B-frames, set the video encoding parameters as follows to remove B-frames.
    1. Go to Controls > Settings > Output.
    2. Select Advanced for Output Mode. The recommended Keyframe Interval is 1 or 2. For CPU Usage Preset, select ultrafast. For Profile, select baseline. For Tune, select zerolatency. And for x264 Options, enter threads=1, and then click OK.
    Warning:
    You need to remove the B-frames in RTMP streams, otherwise the connection will be disconnected after pushing. To achieve this, select baseline for Profile.
    
    
    

    Step 4. Set video parameters

    You can set video resolution and frame rate under the Video section of Settings. Resolution determines the clarity of video shown to audience members. The higher the resolution, the clearer the video. Frame rate (frames per second) determines playback smoothness. Typical frame rate falls in the range of 24 fps to 30 fps. Playback may stutter if frame rate is lower than 16 fps. Video games require higher frame rate and tend to stutter at a frame rate lower than 30 fps.
    
    

    Step 5. Configure advanced settings

    To reduce end-to-end delay, we recommend you do not enable Stream Delay.
    Keep Automatically Reconnect enabled and make Retry Delay as short as possible so that the publisher can be reconnected quickly after a disconnection occurs due to network jitter.
    
    

    Step 6. Publish the stream

    1. In the Controls panel at the bottom, click Start Streaming.
    
    
    2. If streaming is successful, the bottom bar will show streaming statistics, and the entry of a user will be recorded by the monitoring dashboard.
    
    

    

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support