If you’ve ever needed to create a simple RTSP stream for testing, VLC offers an easy solution. You can use the GUI or CLI to stream a local video file via RTSP. This should work on Mac, Linux and Windows.
If you don’t have VLC installed, you can download it from the VideoLAN website or using your regular package manager.
With VLC open, select Media -> Stream
Under File Selection, click the Add… button and choose a local file. It will be added to the list.
Press the Stream button. This will open the Stream Output wizard preconfigured with your chosen video file.
Click Next. The destination setup screen will show. From here, select RTSP from the dropdown. If you wish to view the video as it’s being streamed, you can select Display Locally. Finally, click Add.
The RTSP tab will be added and populated with some defaults. You can change the port and path if required. You should make note of these values.
Click Next.
The Transcoding Options page allows you to configure transcoding, if required. RTSP can be used to transport any number of codecs. Your client must be able to decode them. Your choice here will largely be driven by the client you wish to use. You can try without transcoding, or transcode to popular audio/video codecs such as “H.264 + MP3 (MP4)”, which is likely to be decodable by most clients. Pressing the spanner icon gives many more options, but generally the defaults are fine. Click Next after configuring.
The final screen allows you to configure whether to stream all elementary streams. Elementary streams can contain additional data, some of which isn’t necessary for decoding, which might be useful to your client. If you don’t care about sending potentially unnecessary data, you can select this to improve compatibility.
The second part of this screen shows the generated configuration describing the stream. This configuration is useful if you want to automate the process. You can also quickly recreate the same stream via CLI.
Click Stream to begin streaming. If you selected Display Locally earlier, VLC will play your stream in a new window.
Starting a stream via command line
Using the Generated stream output string shown in the GUI, you can start VLC with these settings via the command line to immediately start a stream with the same settings
<path to vlc>/vlc.exe <input file path> <output stream>
Leave a Reply