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.
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.
This is an example fo H.265 live streaming.
First, build SRS 6.0.31+, and enable H.265:
git checkout develop
./configure --h265=on && make
Next, run SRS with SRT, HTTP-FLV and HLS:
env SRS_LISTEN=1935 SRS_DAEMON=off SRS_LOG_TANK=console \
SRS_SRT_SERVER_ENABLED=on SRS_VHOST_SRT_ENABLED=on SRS_VHOST_SRT_TO_RTMP=on \
SRS_HTTP_SERVER_ENABLED=on SRS_VHOST_HTTP_REMUX_ENABLED=on \
SRS_VHOST_HTTP_REMUX_MOUNT=[vhost]/[app]/[stream].flv SRS_VHOST_HLS_ENABLED=on \
Now, run FFmpeg to publish by SRT with H.265 stream:
ffmpeg -stream_loop -1 -re -i doc/source.flv -acodec copy -vcodec libx265 \
-pes_payload_size 0 -f mpegts 'srt://127.0.0.1:10080?streamid=#!::r=live/livestream,m=publish'
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.
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/ffplay doesn't suport HEVC over RTMP/HTTP-FLV, there are some patches:
- Runner365, support FFmpeg 4/5/6, please see ffmpeg_rtmp_h265. SRS also uses this patch.
- Intel 0001-Add-SVT-HEVC-FLV-support-on-FFmpeg.patch
- Ksvc updates FLV specfication and usage.
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
Note: You can also copy the binary from the docker, or refer to Dockerfile to build by yourself.
Please see FFmpeg Tools for detail.
The known issues for HEVC live streaming:
- Safari HEVC WebRTC doesn't support converting to other protocols, such as RTMP.
- Chrome/Firefox WebRTC doesn't support HEVC, no plan also.
- All browsers support MSE except iOS, and note that HEVC MSE requires GPU hardware decoding.
- 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.
There are some developers that contributed to SRS HEVC feature:
- runner365 The first patch for HEVC for RTMP, HLS and SRT.
- yinjiaoyuan Bug fixed.
- PieerePi Bug fixed.
- qichaoshen82 Bug fixed.
- ZSC714725 Bug fixed.
- bluestn Support HEVC for MP4 and GB28181.
- mapengfei53 Support HEVC for MP4.
- chundonglinlin Support HEVC for SRT.
- duiniuluantanqin Support HEVC for GB28181.
- panda1986 Supprot HEVC for WordPress SrsPlayer.
Really appreciated for mpegts.js, which supports HEVC for HTTP-FLV and HTTP-TS.