Skip to main content
Version: 2.17

Video Codecs

In this guide, we’ll explain how to use H.264, VP8, and H.265 (HEVC) video codecs in Ant Media Server.

Currently, WebRTC relies on specific codecs for video streaming, and Ant Media Server supports H.264 and VP8 for it.

Protocols like HLS, LL-HLS, and CMAF (DASH) support H.265 codec to provide maximum compatibility and quality options. WebRTC does not officially support H.265 yet.

  • While H.264 & VP8 codecs can be enabled directly from the basic application settings, H.265 codec must be enabled from Advanced settings.

codec-support

info

VP8 and H.264 are mandatory in WebRTC as per RFC 7742. However, not all browsers support these codecs at the same time.

  • Each codec can be enabled or disabled based on your requirements. This guide will cover how to enable and configure these codecs in different scenarios.

Enable and Configure H.264 & VP8 Codecs

In this section, learn about the H264 and VP8 video codecs.

Enable H.264 and VP8 Codec Together

Both H.264 & VP8 can be enabled in the basic application settings.

h264andvp8

  • SFU Mode (No adaptive bitrate): Ant Media Server ingests a WebRTC stream in either H.264 or VP8; if both are available, H.264 is prioritized. The original stream is forwarded to players without transcoding.

  • Adaptive Bitrate Mode (if you have at least one adaptive bitrate): If at least one adaptive bitrate is enabled, the stream is transcoded into multiple bitrates for both H.264 and VP8. This ensures compatibility across devices that support either codec. See Adaptive streaming for details.

Enable Only H.264 Codec

h264

  • SFU Mode:: Only H.264 streams are ingested and forwarded without transcoding.
  • Adaptive Bitrate Mode: The stream is transcoded into multiple H.264 bitrates. Devices that support H.264 can play the stream.

You can check if your device supports H.264 at this link.

Enable Only VP8 Codec

vp8

  • SFU Mode: Only VP8 streams are ingested and forwarded.
  • Adaptive Bitrate Mode: VP8 is transcoded into multiple bitrates.
info

HLS and MP4 recording require H.264 codec. Enabling only VP8 will limit recording (WebM) and playback (WebRTC) options.

Enable and Configure H.265 (HEVC) Codec

HEVC (H.265) provides better video quality at the same bitrate, making it ideal for bandwidth-sensitive environments.

  1. Enable H.265 in Configuration

H.265 is disabled by default. Enable it via Advanced settings:

  • Go to the advanced application settings & set

    "h265Enabled": true,
  • If H.264 & VP8 are also true, AMS will accept streams with all three codecs.

  • If H.264 & VP8 are false, AMS will only accept streams with H.265:

"h264Enabled": false,
"vp8Enabled": false,
"h265Enabled": true,

h265

  • Scroll down and save after making changes.
  1. Send an RTMP Stream to Ant Media Server
  • Use a tool like OBS to send an RTMP stream with H.265 video codec. See the Enhanced RTMP document for details.
  1. Play H.265 Stream
  • Most Android devices natively support H.265 playback via HLS, LL-HLS, and DASH.
  • You can also use VLC or third-party players for H.265 playback.
  1. Play H.265 Stream on browsers

Most browsers do not yet support H.265 playback. Check H.265 supported browsers.

  1. Play H.265 transcoded streams with H.264
  • Since H.265 support is limited in browsers/WebRTC, enable H.264 alongside H.265 and use Adaptive streaming:
"h264Enabled": true,
"h265Enabled": true,
  • Enable at least one adaptive bitrate. AMS will transcode incoming H.265 streams to H.264, ensuring browser and SDK compatibility.

h265andh264

Wrap-Up

By configuring H.264, VP8, and H.265, you can optimize video streams for both compatibility and quality.

Now you can ingest, transcode, and deliver streams in the codec combination that fits your use case, ensuring smooth playback across devices, browsers, and protocols.