To generate HLS streams at multiple bitrates, transcoding is required. Therefore, LiveStreamingServerNet integrates with FFmpeg to enable Adaptive Bitrate HLS Transcoding. However, it’s important to note that transcoding is more resource-intensive compared to transmuxing.
Install FFmpeg
To use the Adaptive HLS Transcoder, FFmpeg must be installed in advance.
By default, the FFmpeg and FFprobe executables are located using the helper function ExecutableFinder.FindExecutableFromPATH, which first searches through all the directories defined in the PATH environment variable and then the current directory.
Adaptive HLS Transcoder
Similar to the built-in HLS Transmuxer, the resulting HLS files can be served via ASP.NET Core and Cloud Storage Services. Please refer to the previous tutorials for the serving part. This section will focus on enabling the Adaptive HLS Transcoder.
Step 1: Add the Required Packages
Add the necessary packages using the following commands:
With this configuration, LiveStreamingServerNet will create an Adaptive HLS Transcoder whenever an RTMP stream is published to port 1935. The Adaptive HLS Transcoder will transcode the incoming stream into at most three streams with resolutions of 360p, 480p, and 720p, depending on the resolution of the incoming stream.
Step 3: Launch Your Live Streaming Server
To execute your live streaming server, run the following command:
dotnet run
Optimizing the Performance
Bypassing Audio Transcoding
Transcoding demands significant computational resources. Therefore, bypassing audio transcoding can potentially lead to a reduction in resource utilization. However, this strategy requires that the incoming audio stream is encoded with AAC codec.