Ingest RTSP, SRT, or RTMP streams into Wowza Streaming Engine for playback with WebRTC
Updated on 04/20/2023 12:25 pm PDT
Learn how to use Wowza Streaming Engine™ media server software to ingest a non-WebRTC source stream over RTSP, SRT, or RTMP and play it back with WebRTC on mobile and desktop browsers that support WebRTC APIs.
This workflow provides flexibility with publishing streams to Wowza Streaming Engine while maintaining the benefits of WebRTC for playback, including:
- Low latency when compared with HTTP-based streaming.
- Browser-based playback without plugins or protocol-specific, proprietary players.
- Robust feature set of the open-source WebRTC framework.
In addition to outputting the stream for playback with WebRTC, you can also output the stream using any other playback protocols that Wowza Streaming Engine supports. This allows a scaled approach for delivery using a content delivery network (CDN) in addition to direct WebRTC browser connections.
Note: Wowza Streaming Engine™ media server software version 4.7.7 and later supports WebRTC streaming. However, we recommend that you update to version 4.8.5 or later to capitalize on expanded functionality and enhancements to publisher reliability.
Before you start
Before you start, set up WebRTC playback according to Set up WebRTC streaming with Wowza Streaming Engine.
1. Configure a non-WebRTC to WebRTC workflow
When planning a non-WebRTC to WebRTC workflow, consider whether you’ll need to transcode the stream to achieve your goal of WebRTC playback.
By default, Wowza Streaming Engine transmuxes the stream into the HLS, MPEG-DASH, RTSP/RTP, and RTMP protocols for playback at scale. Transcoding is required when the ingest source stream has a different audio codec, video codec, or video encoding profile from the WebRTC output.
The workflows in this article provide a few possibilities for non-WebRTC ingest to WebRTC playback, but they aren’t an exhaustive list. Transcoding introduces latency into the media delivery pipeline, so transcoded workflows will have a longer startup time and higher latency than a passthrough video-only workflow.
Set up an RTSP source for a passthrough video-only stream
In this example workflow, you ingest a stream from an IP camera or RTSP encoder into Wowza Streaming Engine, pass through the video and audio, and output a video-only WebRTC stream.
- RTSP source – H.264 video, AAC audio
- WebRTC output – H.264 video only
Note: If you require audio playback, you need to transcode the audio stream from the AAC audio codec to the Opus audio codec for WebRTC audio output.
Configure the RTSP source
You should be aware of the following best practices when setting up an IP camera or RTSP encoder to prepare for playback using WebRTC:
- Baseline profile
For the greatest interoperability with all potential playback clients, set the profile setting on your IP camera or encoder to Baseline. If you choose to set the profile to Main or High, ensure that the camera doesn’t encode with B-frames. If you’re unable to disable B-frames in the source stream, you’ll need to send the video source through the Wowza Streaming Engine transcoder to remove them.
- 720p resolution and 30 fps frame rate with H.264 video
For the greatest playback compatibility when encoding with H.264, the recommended resolution is 720p with a frame rate of 30 fps.
- Tune for low latency
To maintain low latency, you may need to tune your RTSP source for low-latency streaming. If your camera doesn't have B-frame-specific tuning, low latency tuning may also result in a bitstream without B-frames. Refer to documentation for your IP camera or encoder on how to tune for low latency. See Tune for latency to tune Wowza Streaming Engine for low latency.
Stream RTSP to Wowza Streaming Engine
- To send a stream from an RTSP source like an IP camera into Wowza Streaming Engine, use one of the following configurations:
- After you’ve configured your RTSP source to stream to Wowza Streaming Engine, jump to Test playback to test WebRTC playback.
Set up an SRT source for a transcoded audio, passthrough video stream
In this example workflow, you ingest an SRT stream from an encoder into Wowza Streaming Engine, transcode the audio codec from AAC to Opus, pass through the video, and output a WebRTC stream with video and audio.
- SRT source – H.264 video, AAC audio
- WebRTC output – H.264 video, Opus audio
Configure the SRT source
You should be aware of the following best practices when setting up an SRT encoder to prepare for playback using WebRTC:
- Baseline profile
For the greatest interoperability with all potential playback clients, set the profile setting on the encoder to Baseline. If you choose to set the profile to Main or High, ensure that the camera doesn’t encode with B-frames. If you’re unable to disable B-frames in the source stream, you’ll need to send the video source through the Wowza Streaming Engine transcoder to remove them.
- 720p resolution and 30 fps frame rate with H.264 video
For the greatest playback compatibility when encoding with H.264, the recommended resolution is 720p with a frame rate of 30 fps.
- 48 kHz audio sample rate
Set the audio sample rate to 48 kHz, which is the maximum sample rate supported by the Opus audio codec. If your source uses a different sample rate, see the following transcoding information to use the <Resample> property.
- Stereo audio
Configure the audio stream source for stereo. If you must send an incoming mono audio stream, see the following transcoding information to use the default.scaleChannels decoding parameter.
Configure Wowza Streaming Engine for audio-only transcoding
- Open the Application.xml file for your application ([install-dir]/conf/[application-name]) in a text editor.
- In the <Transcoder> container element, configure the following properties:
- Set the <LiveStreamTranscoder> property to transcoder:
<LiveStreamTranscoder>transcoder</LiveStreamTranscoder>
- Set the <Templates> property to a transcoder template file name that you'll create in the next step, for example, audioonly-webrtc.xml.
<Templates>audioonly-webrtc.xml</Templates>
- Navigate to [install-dir]/transcoder/templates, duplicate the audioonly.xml file, and rename it. For example, audioonly-webrtc.xml.
- Open the new transcoder template file in a text editor and make the following changes:
- In the <Encode>/<Audio> container element, set <Codec> to Opus and specify a valid value for <Bitrate>.
- If your source does not support an audio sample rate of 48000, add the <Resample> property in and set it to 48000.
<Audio>
<Codec>Opus</Codec>
<Bitrate>96000</Bitrate>
<Resample>
<Enable>true</Enable>
<SampleRate>48000</SampleRate>
<Channels>2</Channels>
</Resample>
<Parameters>
</Parameters>
</Audio>
- If your source isn't configured to send stereo audio, in the <Decode>/<Audio>/<Parameters> container element, add the default.scaleChannels parameter and set it to 2 to force any mono audio frames to stereo by duplicating the mono stream for both the left and right channels.
<Decode>
<Audio>
<Parameters>
<Parameter>
<Name>default.scaleChannels</Name>
<Value>2</Value>
<Type>Integer</Type>
</Parameter>
</Parameters>
</Audio>
</Decode>
- To adjust the audio level in the transcoded output, add the opus.gain parameter to the <Encoder>/<Audio>/<Parameters> container in the transcoder template.
<Parameter>
<Name>opus.gain</Name>
<Value>12.5</Value>
<Type>Double</Type>
</Parameter>
- If latency is a concern, see Tune for latency for additional options.
- Save the changes and restart Wowza Streaming Engine.
Stream SRT to Wowza Streaming Engine
- To send a stream from an SRT source into Wowza Streaming Engine, create a stream file to re-stream a MPEG-TS-based SRT stream according to Ingest and publish an SRT stream with Wowza Streaming Engine.
- After you’ve configured your SRT source and audio-only transcoding, jump to Test playback to test WebRTC playback.
Set up an RTMP source for a transcoded video and audio stream
In this example workflow, you'll ingest an RTMP stream from a camera or encoder into Wowza Streaming Engine, transcode the audio codec from AAC to Opus, transcode the video profile from High to Main, and output a WebRTC stream with video and audio.
- RTMP source – H.264 video with the High profile, AAC audio
- WebRTC output – H.264 video with the Main profile, Opus audio
Configure the RTMP source
You should be aware of the following best practices when setting up an RTMP encoder to prepare for playback using WebRTC:
- No B-frames
Ensure that the camera doesn’t encode with B-frames. If you’re unable to disable B-frames in the source stream, use the Wowza Streaming Engine transcoder to remove them.
- 720p resolution and 30 fps frame rate with H.264 video
For the greatest playback compatibility when encoding with H.264, the recommended resolution is 720p with a frame rate of 30 fps.
- 48 kHz audio sample rate
Set the sample rate for audio to 48kHz, the maximum sample rate supported by the Opus audio codec. If your source uses a different sample rate, see the following transcoding information to use the <Resample> property.
- Stereo audio
Configure the audio stream source for stereo. If you must send an incoming mono audio stream, see transcoder setup information below to use the default.scaleChannels decoding parameter.
Configure Wowza Streaming Engine for video and audio transcoding
- Using a text editor, open [install-dir]/conf/[application-name]/Application.xml and set the <Transcoder>/<LiveStreamTranscoder> element to transcoder:
<LiveStreamTranscoder>transcoder</LiveStreamTranscoder>
- Next, set the <Transcoder>/<Templates> element to a transcoder template file name that you'll create in the next step, for example, transcode-webrtc.xml.
<Templates>transcode-webrtc.xml</Templates>
- Navigate to [install-dir]/transcoder/templates, duplicate the transcode.xml file, and rename it. For example, transcode-webrtc.xml.
- Open the new transcoder template file in a text editor and make the following adjustments:
- Depending on the quality of your incoming stream, enable the template's <Encode> block for 720p or 360p by setting <Enable> to true.
- In the <Encode>/<Video> container, ensure <Codec> is set to H.264, and set <Profile> to your desired setting. For this example, use main.
- If you’re unable to turn off B-frames in your RTMP encoder, you can turn them off with the default MainConcept encoder or by using NVENC encoding to remove them. If you use QuickSync encoding, note that B-frames are only removed in the Baseline profile. See Configure B-frame support for the Transcoder in Wowza Streaming Engine to turn off B-frames with MainConcept.
<Video>
<Codec>H.264</Codec>
<Implementation>default</Implementation>
<GPUID>-1</GPUID>
<FrameSize>
<FitMode>fit-height</FitMode>
<Width>1280</Width>
<Height>720</Height>
</FrameSize>
<Profile>main</Profile>
...
</Video>
- In the <Encode>/<Audio> container, set <Codec> to Opus, and enter a valid value for <Bitrate>.
- If your source does not support setting the audio sample rate to 48000, set a <Resample> parameter in your <Audio> encode to this value.
<Audio>
<Codec>Opus</Codec>
<Bitrate>96000</Bitrate>
<Resample>
<Enable>true</Enable>
<SampleRate>48000</SampleRate>
<Channels>2</Channels>
</Resample>
<Parameters>
</Parameters>
</Audio>
- If your source isn't configured to send stereo audio, in the <Decode>/<Audio> container, set the default.scaleChannels parameter to 2 to force any mono audio frames to stereo by duplicating the mono stream for both the left and right channels.
<Decode>
<Audio>
<Parameters>
<Parameter>
<Name>default.scaleChannels</Name>
<Value>2</Value>
<Type>integer</Type>
</Parameter>
</Parameters>
</Audio>
</Decode>
- To adjust the audio level in the transcoded output, add the opus.gain parameter to the <Encoder>/<Audio>/<Parameters> container in the transcoder template.
<Parameter>
<Name>opus.gain</Name>
<Value>12.5</Value>
<Type>Double</Type>
</Parameter>
- If latency is a concern, see Tune for latency for additional options.
- Save the changes.
Stream RTMP to Wowza Streaming Engine
- To send a stream from an RTMP source into Wowza Streaming Engine, complete the steps in Set up live streaming using an RTMP-based encoder in Wowza Streaming Engine.
- After you’ve configured your RTMP source and video and audio transcoding, jump to Test playback to test WebRTC playback.
2. (Optional) Tune for latency
The expected latency of passthrough streams that output WebRTC is one second or less. Transcoding, however, introduces latency into the media delivery pipeline. Streams that require audio or video transcoding have an expected latency of two seconds or less. While some amount of latency is expected due to frame buffering in your encoder, there are steps you can take to tune the WebRTC stream for low latency, depending on the source and whether it needs to be transcoded.
- Open the Application.xml file for your application ([install-dir]/conf/[application-name]) in a text editor.
- In the <Streams> container element, set <StreamType> to live-lowlatency .
<Streams>
<StreamType>live-lowlatency</StreamType>
...
</Streams>
- Open your Transcoder template ([install-dir]/transcoder/templates) in a text editor.
- Disable the <SortBuffer> in the <PostProcess> container element by setting <Enable> to false.
<PostProcess>
<SortBuffer>
<Enable>false</Enable>
...
</SortBuffer>
</PostProcess>
- Save your changes to both files and restart Wowza Streaming Engine.
3. Test WebRTC playback
Now that your custom live application and source stream ingest is set up, you can test out your workflow. In production environments, a WebRTC playback page must be hosted on a web server utilizing SSL/TLS encryption. For testing and learning purposes, Wowza provides a hosted WebRTC playback test page so you can see WebRTC in action more quickly.
WebRTC test page requirements
- Wowza Streaming Engine – version 4.8.5 or later
- Browsers – latest version of Chrome, Firefox, Safari, and Microsoft Edge version 79 and later. There is a resolved known issue with publishing and playing WebRTC streams using Safari on iOS 15. See WebRTC publishing and playback fails with Safari on iOS 15 for updates.
- Screen share – not supported on mobile devices, Safari, or Firefox
- Ensure that your IP camera or encoder is sending a source stream to Wowza Streaming Engine.
- In a browser tab, go to the WebRTC play hosted test page.
- In the Signaling URL field, enter the secure WebSocket URL to connect to the Wowza Streaming Engine WebRTC sessions listener:
wss://[ssl-certificate-domain-name]/webrtc-session.json
where ssl-certificate-domain-name is the secure domain name for your Wowza Streaming Engine instance.
If using Wowza StreamLock, for example, the Signaling URL looks something like this:
wss://5ab4321c0d123.streamlock.net/webrtc-session.json
If you are connecting WebRTC sessions using a port other than the standard SSL/TLS port 443, you must include that non-standard port in the Signaling URL:
wss://5ab4321c0d123.streamlock.net:[SSL-port-number]/webrtc-session.json
- Enter an Application Name that matches the WebRTC live application you configured.
- For Stream Name, enter a name for the stream, such as myStream.
- To play the WebRTC stream from Wowza Streaming Engine, click Play.
To test playback in a different browser or with a different device, click Copy config () to copy the configuration settings and share them.
Tip: When you're ready to implement WebRTC for production, consider using the Wowza Flowplayer Real-Time Streaming (WebRTC) plugin for playback. You can purchase Wowza Flowplayer and use it with Wowza Streaming Engine for playback.
Note: To test playback over other protocols, enable other playback protocols for the application you configured for WebRTC by clicking the Setup tab for your application and enabling any of the protocols listed under Playback Types. Then, you can use the playback URL for the protocol you want to test with the player of your choice or the Video Test Players webpage.
Next steps
More resources