- MK.IO
- How To
- Live Streaming
- Set up the source stream using GStreamer
Set up the source stream using GStreamer
Use GStreamer, a command-line tool to configure your source stream.
We recommend using GStreamer v1.18 or later.
Example
Section titled “Example”gst-launch-1.0 -v videotestsrc ! video/x-raw,width=1920,height=1080,framerate=30/1 ! x264enc tune=zerolatency bitrate=500 speed-preset=superfast key-int-max=60 ! h264parse ! queue ! mux. audiotestsrc ! audio/x-raw,rate=44100 ! voaacenc bitrate=128000 ! queue ! mux. flvmux streamable=true name=mux ! rtmpsink location="rtmp://<rtmp-server-ip-or-url>/<path>"Command breakdown
Section titled “Command breakdown”Let’s break down each part of the command in detail:
Video component
Section titled “Video component”| Command | Description |
|---|---|
videotestsrc | This is a test video source in GStreamer, which generates a test pattern. Replace this with your actual video source (e.g. v4l2src for webcams). |
video/x-raw,width=1920,height=1080,framerate=30/1 | This caps filter sets the resolution and framerate of the raw video (1920x1080 sets the resolution to 1080p). |
x264enc | This encodes the video to H.264. Commonly used options: tune=zerolatency: Lowers latency, which is essential for live streaming.bitrate=500: Sets the bitrate to 500 kbps. Adjust as needed based on network conditions and quality requirements. speed-preset=superfast: Defines the encoding speed. superfast offers low latency at the cost of higher bandwidth; adjust as needed. key-int-max=60: Sets the keyframe interval to 60 frames, which is 2 seconds at 30 frames per second (FPS). This value needs to match the Input key frame intervalset in MK.IO UI . h264parse: Ensures the video stream is in the correct H.264 format for RTMP. |
Audio component
Section titled “Audio component”| Command | Description |
|---|---|
audiotestsrc | A test audio source for generating sample audio. Replace with your own audio source. |
voaacenc | Encodes the audio to AAC, which is compatible with RTMP. |
queue | Adds buffers between streams to help with sync issues. |
RTMP component
Section titled “RTMP component”| Command | Description |
|---|---|
flvmux | Packs the H.264 video (and audio if included) into an FLV container, suitable for RTMP. |
rtmpsink | Sends the output stream to an RTMP server. |
location="rtmp://<rtmp-server-ip-or-url>/<path>" | The RTMP input URL for your streaming destination, provided by MK.IO when creating a Live Event. |