Skip to main content

SRS Server - H.265 Live Streaming Saving 50% Cost

· 6 min read

Written by Winlin, runner365, yinjiaoyuan, PieerePi, qichaoshen82, ZSC714725, bluestn, mapengfei53, chundonglinlin, duiniuluantanqin, panda1986

SRS 6.0 supports HEVC(H.265), for RTMP, HTTP-FLV, HTTP-TS, HLS, MPEG-DASH, WebRTC(Safari), DVR FLV, DVR MP4 and WordPress SrsPlayer, etc.

Generally, H.265 is 50% off than H.264, so you only need to pay 50% bills if H.265.

Now, you're able to use HEVC(H.265) in live streaming.

Why Important?

H.265 uses less bandwidth than H.264, which means lower bandwidth cost, or higher quality in same bandwidth.

Furthermore, if want 8K live streaming, you must use H.265, because H.264 doesn't support 8K resolution.

Please note that there are still some traps for H.265 live streaming.

Status of H.265

The status of H.265, for different use scenarios.

Part 1, publisher or encoder for H.265.

  • Publish SRT stream by FFmpeg.
  • Publish SRT stream by OBS.
  • Publish RTMP stream by FFmpeg, patch is here
  • Push WebRTC by Safari, should be enabled by user.
  • Not supported: Chrome/Firefox push WebRTC stream.
  • Not supported: OBS publish RTMP stream.

Part 2, play stream by FFmpeg/ffplay for H.265.

  • Play HTTP-TS by FFmpeg.
  • Play HLS by FFmpeg.
  • Play MPEG-DASH by FFmpeg.
  • Play SRT by FFmpeg.
  • Play HTTP-TS by ffplay.
  • Play HLS by ffplay.
  • Play MPEG-DASH by ffplay.
  • Play SRT by ffplay.
  • Play RTMP by FFmpeg, with patch.
  • Play HTTP-FLV by FFmpeg, with patch.
  • Play RTMP by fflay, with patch.
  • Play HTTP-FLV by ffplay, with patch.

Part 3, play stream by H5 MSE for H.265.

  • Play HTTP-TS by Chrome, using mpegts.js.
  • Play HTTP-FLV by Chrome, using mpegts.js.
  • Play WebRTC stream by Safari, should be enabled by user.
  • Not supported: Play HLS by hls.js.
  • Not supported: Play MPEG-DASH by dash.js.
  • Not supported: Play WebRTC by Chrome/Firefox.

Part 4, play stream by VLC for H.265.

  • Play HTTP-TS by VLC.
  • Play SRT by VLC.
  • Play HLS by VLC.
  • Play MPEG-DASH by VLC.
  • Not supported: Play RTMP by VLC.
  • Not supported: Play HTTP-FLV by VLC.

Part 5, other features for H.265.

  • DVR to FLV or MP4 file.
  • Parse HEVC metadata for HTTP-API.
  • Black box test support HEVC.
  • Patch FFmpeg in SRS dev-docker.
  • Support HEVC for WordPress plugin SrsPlayer.
  • Not supported: Update srs-stack for HEVC.
  • Not supported: Edge server supports publish HEVC stream to origin.
  • Not supported: Edge server supprots play HEVC stream from origin.
  • Not supported: HTTP Callback takes HEVC metadata.
  • Not supported: Prometheus Exporter supports HEVC metadata.
  • Not supported: Improve coverage for HEVC.
  • Not supported: Supports benchmark for HEVC by srs-bench.

If native iOS or Android application, please use FFmpeg.

Appreciate the patch for Chrome 105 to support HEVC for MSE, it makes the HEVC live streaming possible.

MSE HEVC requires GPU hardware decoding, please open chrome://gpu then search hevc, and it should work if matched.

Usage: Live

This is an example fo H.265 live streaming.

First, run SRS in docker:

docker run --rm -it -p 1935:1935 -p 8080:8080 ossrs/srs:6 \
  ./objs/srs -c conf/docker.conf

Use FFmepg to publish HEVC over RTMP, see FFmpeg Tools:

# For macOS
docker run --rm -it ossrs/srs:encoder ffmpeg -stream_loop -1 -re -i doc/source.flv \
  -acodec copy -vcodec libx265 -f flv rtmp://host.docker.internal/live/livestream

# For linux
docker run --net=host --rm -it ossrs/srs:encoder ffmpeg -stream_loop -1 -re -i doc/source.flv \
  -acodec copy -vcodec libx265 -f flv rtmp://127.0.0.1/live/livestream

Note: Please change the ip host.docker.internal to your SRS's IP.

Done, please open links bellow in browser:

Note: Please use VLC or ffplay to play HLS, because hls.js doesn't support it.

Please follow wiki of SRS to use other protocols.

Usage: WebRTC

Right now, at 2023.03, only Safari support HEVC over WebRTC, neither Chrome nor Firefox supports it.

And, you should enable the HEVC for Safari by clicking Develop > Experimental Features > WebRTC H265 codec.

For detail usage, please follow #465.

Beside HEVC, WebRTC has better support for AV1, Safari/Chrome/Firefox supports AV1, please read #1070 for detail. Note that MSE doesn't support AV1.

Note: Media Source Extensions (MSE) is H5 API for media streaming, on which mpegts.js, hls.js and dash.js bases. Please see MDN: MSE.

FFmpeg Patch

FFmpeg 6 has supported HEVC over RTMP, if you want to build from code, please see FFmpeg Tools.

SRS dev-docker already patched FFmpeg, ffplay and ffprobe, so user can use it:

# For macOS
docker run --rm -it ossrs/srs:encoder ffmpeg -stream_loop -1 -re -i doc/source.flv \
  -acodec copy -vcodec libx265 -f flv rtmp://host.docker.internal/live/livestream

# For linux
docker run --net=host --rm -it ossrs/srs:encoder ffmpeg -stream_loop -1 -re -i doc/source.flv \
  -acodec copy -vcodec libx265 -f flv rtmp://127.0.0.1/live/livestream

Please see FFmpeg Tools for detail.

Known Issues

The known issues for HEVC live streaming:

  1. Safari HEVC WebRTC doesn't support converting to other protocols, such as RTMP.
  2. Chrome/Firefox WebRTC doesn't support HEVC, no plan also.
  3. All browsers support MSE except iOS, and note that HEVC MSE requires GPU hardware decoding.
  4. For H5 player, only mpegts.js supports HEVC, neither hls.js nor dash.js support it.

On some use scenario, HEVC is available now, please evaluate it by yourself.

Cloud Service

At SRS, our goal is to establish a non-profit, open-source community dedicated to creating an all-in-one, out-of-the-box, open-source video solution for live streaming and WebRTC online services.

Additionally, we offer a Cloud service for those who prefer to use cloud service instead of building from scratch. Our cloud service features global network acceleration, enhanced congestion control algorithms, client SDKs for all platforms, and some free quota.

To learn more about our cloud service, click here.

Thanks

There are some developers that contributed to SRS HEVC feature:

Really appreciated for mpegts.js, which supports HEVC for HTTP-FLV and HTTP-TS.

Contact

Welcome for more discussion at discord.