Deliver HLS live streams using CMAF and HEVC with Wowza Streaming Engine

One of the benefits of the open Common Media Application Format (CMAF) standard is that it supports HEVC, the next-generation video codec. Wowza Streaming Engine™ media server software version 4.7.8 and later supports CMAF and (in preview release) HEVC, which means you can use Wowza Streaming Engine 4.7.8 or later to ingest or transcode to the HEVC codec, generate HLS output using the CMAF packetizer, and deliver single or adaptive bitrate HEVC live steams for playback on iOS devices.

About streaming using CMAF and HEVC


High Efficiency Video Coding (HEVC), or H.265, is a video codec developed as a successor to the H.264/MPEG-4 standard. HEVC enables greater compression than H.264 and supports multi-core parallel encoding and decoding, making it a much more robust, efficient, and scalable process. HEVC also provides substantially better video quality than H.264 at lower bitrates, and it supports higher bit depths, enhanced chroma formats, multiple camera views, and 3D, giving it a wide range of applications from mobile streaming to ultra HD home cinema to medical imaging.

Adoption of HEVC by encoding technologies and players is evolving. CMAF supports HEVC, and Apple supports HEVC using QuickTime Player on current versions of iOS (devices) and macOS (desktop).

HEVC has been in preview release in Wowza Streaming Engine since version 4.1. You can ingest HEVC source streams directly, or you can enable HEVC for single and adaptive bitrate live streams by using Transcoder, which runs in Wowza Streaming Engine on Windows and Linux (but not macOS). Not all HEVC configuration options are available in Wowza Streaming Engine Manager; you must configure them in XML.

In sum, delivering HEVC live streams for HLS playback using Wowza Streaming Engine requires two things—CMAF packetization and Transcoder—both of which involve manual configuration in XML.

Note: Wowza Streaming Engine must be properly licensed to enable Transcoder. For details, see Licensing Transcoder.

Prepare a live application to deliver a CMAF-packetized HLS stream


First, configure a CMAF live stream by editing a live application's configuration file; you can't configure CMAF streaming in Wowza Streaming Engine Manager. For simplicity, we’ll use the default live application that installs with Wowza Streaming Engine.

  1. Navigate to [install-dir]/conf/live and open Application.xml file in a text editor.
  2. In the <Streams> container element, make sure the StreamType property is live. The XML looks like this:
<Streams>
    ...
    <StreamType>live</StreamType>
    ...
</Streams>
  1. For the LiveStreamPacketizers property, specify cmafstreamingpacketizer. The XML looks like this:
<Streams>
    ...
    <LiveStreamPacketizers>cmafstreamingpacketizer</LiveStreamPacketizers>
    ...
</Streams>

Note: You can specify additional packetizers, including cupertinostreamingpacketizer, in a comma-separated list, but none of them support HEVC.

  1. For the HTTPStreamers property, specify HLS streaming. The XML looks like this:
<HTTPStreamers>cupertinostreaming</HTTPStreamers>

Note: As with packetizers, you can specify additional HTTP streamers in a comma-separated list. However, they're unnecessary for, and irrelevant to, HLS-based HEVC streaming.

  1. Save your changes.

Enable HEVC transcoding


  1. In the Application.xml file, look for the <Transcoder> element and enable transcoding by setting the LiveStreamTranscoder property to transcoder. The XML looks like this:
<Transcoder>
	<LiveStreamTranscoder>transcoder</LiveStreamTranscoder>
	…
</Transcoder>
  1. Enable the HEVC/H.265 Transcoder template by setting the Templates property to transcode-h265-divx.xml. The XML looks like this:
<Transcoder>
	…
    <Templates>transcode-h265-divx.xml</Templates>
</Transcoder>
  1. Save your changes and restart Wowza Streaming Engine.

Configure the HEVC transcoder template


Configure HEVC transcoding by editing the H.265 Transcoder template file.

  1. Navigate to [install-dir]/transcoder/templates and open transcode-h265-divx.xml in a text editor.  
  2. In the <PostProcess> block, set the BufferSize to 5000. This will help keep the audio and video synchronized in the transcoded output renditions, however, it may also increase latency before playback starts. Adjust the buffer size as needed to maintain A/V synchronization while minimizing latency.
  3. Edit the <Encode> and <Decode> blocks as desired.

The H.265 template includes three encode profiles that you can enable, disable, or edit:

  • A 720p high-definition, medium-bandwidth profile at 5,000,000 bits per second (approximately 4.8 Mbps). This encode is enabled by default.
  • A 1080p full high-definition, high-bandwidth profile at 8,000,000 bits per second (approximately 7.6 Mbps), disabled by default.
  • A 4K ultra-high-definition, high-bandwidth profile at 12,000,000 bits per second (approximately 11.4 Mbps), also disabled by default.
  1. Save your changes.

Adjust CPU resources


By default, Transcoder is configured to use fewer CPU resources than HEVC encoding may require. To address this discrepancy, adjust the mainconcept-h265.performance_level parameter in the H.265 Transcoder template.

Note: These instructions apply to Wowza Streaming Engine instances that run Transcoder on a standard hardware configuration. If you run Transcoder on GPU-accelerated hardware, see any of the articles listed on the Hardware acceleration page and the documentation for your graphics card for recommendations on managing resources when transcoding using HEVC.

  1. In transcode-h265-divx.xml, locate the <Parameters> block for the video encode(s) you're using.
  2. Add the mainconcept-h265.performance_level parameter. The XML looks like this:
<Encode>
    <Enable>true</Enable>
    <Name>[name]</Name>
    ...
    <Video>
        ...
        <Parameter>
            <Name>mainconcept-h265.performance_level</Name>
            <Value>1</Value>
            <Type>Long</Type>
        </Parameter> 
    </Video>
    ...
</Encode>

Specify a value from 1 (lowest quality, lowest CPU usage) to 30 (highest quality, highest CPU usage). You may have to experiment to find the right value. If you set it higher than your available CPU resources can handle, real-time encoding will lag and eventually stop. When this happens, skip frame messages appear in the Wowza Streaming Engine logs.

  1. Save your changes.

Prepare stream name groups for adaptive bitrate streaming


After the HEVC Transcoder template is configured, you must create a Synchronized Multimedia Integration Language (SMIL) file for the adaptive bitrate stream. NGRP syntax isn't supported for adaptive bitrate CMAF streams.

  1. Using a text editor, create a file that uses your stream name and a .smil file extension (for example, myStream.smil) and save it to the [install-dir]/content folder.

Note: Make sure your editor doesn't append a .txt file extension to the SMIL file name.

  1. Enter stream information using the names and values defined in your Transcoder template. Here’s a basic example that assumes all three HEVC encodes are enabled:
<smil>
    <head></head>
    <body>
        <switch>
            <video src="myStream_720" audio-bitrate="100000">
                <param name="audioOnly" value="TRUE" valuetype="data"/>
                <param name="cupertinoTag" value="EXT-X-MEDIA" valuetype="data"/>
                <param name="cupertinoTag.GROUP-ID" value="aac" valuetype="data"/>
            </video>
            <video src="myStream_720" width="1280" height="720" video-bitrate="5000000">
                <param name="videoCodecId" value="hvc1" valuetype="data"/>
                <param name="videoOnly" value="TRUE" valuetype="data"/>
                <param name="cupertinoTag.AUDIO" value="aac" valuetype="data"/>
                <param name="audioCodecId" value="mp4a.40.2" valuetype="data"/>
            </video>
            <video src="myStream_1080" width="1920" height="1080" video-bitrate="8000000">
                <param name="videoCodecId" value="hvc1" valuetype="data"/>
                <param name="videoOnly" value="TRUE" valuetype="data"/>
                <param name="cupertinoTag.AUDIO" value="aac" valuetype="data"/>
                <param name="audioCodecId" value="mp4a.40.2" valuetype="data"/>
            </video>
            <video src="myStream_4k" width="4096" height="2160" video-bitrate="12000000">
                <param name="videoCodecId" value="hvc1" valuetype="data"/>
                <param name="videoOnly" value="TRUE" valuetype="data"/>
                <param name="cupertinoTag.AUDIO" value="aac" valuetype="data"/>
                <param name="audioCodecId" value="mp4a.40.2" valuetype="data"/>
            </video>
        </switch>
    </body>
</smil>

The <switch> container element contains a <video> element for each stream rendition as well as an audio-only entry. For more information on the SMIL configuration, see Set up adaptive bitrate streaming for Apple HLS in the article "Create adaptive bitrate CMAF streams using Wowza Streaming Engine."

Connect a source to Wowza Streaming Engine


Although you enabled CMAF packetization in the Application.xml configuration file, your live application is available in Wowza Streaming Engine Manager, where you can establish a connection to a live source.

  1. In Wowza Streaming Engine Manager, click Applications in the menu bar and select your live application in the contents panel.
  2. Click Sources (Live) in the contents panel.
  3. Select the encoder or camera you want to use as your source. Click Learn more under any tile for detailed instructions on how to connect that encoder or camera, including how to configure source authentication.

If your encoder or camera isn't listed, click Other Encoders or use the Application Connection Settings in the Help panel to publish the stream to Wowza Streaming Engine. For more information about how to enter the connection settings in your source encoder or camera, consult that device or software's documentation. These articles may also help:

Test stream playback


Test adaptive bitrate HEVC HLS playback

Test playback in a player that supports HLS playback of HEVC-coded streams, for example QuickTime Player on macOS or iOS, or the Akamai HLS test player. For details on Apple’s support for HEVC, see Using HEIF or HEVC media on Apple devices.

Note: Wowza Player doesn't support HEVC.

If only cmafstreamingpacketizer is enabled, specify the HEVC stream's playback URL using the format: 

http://[wowza-ip-address]/[application]/[application-instance]/[stream-name]/playlist.m3u8 

If cmafstreamingpacketizer and cupertinostreamingpacketizer are enabled, specify the HEVC stream's playback URL using the format:

http://[wowza-ip-address]/[application]/[application-instance]/[stream-name]/playlist_sfm4s.m3u8 

Where:

  • [wowza-ip-address] is the IP address or domain and port of Wowza Streaming Engine (default port 1935)
  • [application] is the application name
  • [application-instance] is the name of the application instance (if omitted, defaults to _definst_)
  • [stream-name] is the SMIL file, with a smil: prefix

For example, the playlist URL for an adaptive bitrate HEVC HLS stream that uses the address mycompany.com, the default live application, and the default stream name myStream is:

http://mycompany.com:1935/live/smil:myStream.smil/playlist.m3u8

or

http://mycompany.com:1935/live/smil:myStream.smil/playlist_sfm4s.m3u8

Test single bitrate HEVC HLS playback

To test playback of a single bitrate HEVC HLS stream, follow the conventions described above for testing adaptive bitrate playback, but for [stream-name] use the stream name appended with _[rendition]. For example:

http://mycompany.com:1935/live/myStream_720p/playlist.m3u8

or

http://mycompany.com:1935/live/myStream_720p/playlist_sfm4s.m3u8

More resources