bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
12.19k stars 1.53k forks source link

Add HLS support for h265 rtsp. #469

Closed Prakash2101 closed 1 year ago

Prakash2101 commented 3 years ago

Describe the feature

Description The Server support HLS for h264 rtsp but when I tried using h265 rtsp it is unable to create .m3u8 file. I think for HLS it doesn't have h265 decoder.

please add HLS support for h265 rtsp.

robusoft-tangye commented 3 years ago

I tested with a H.265 video file today. Use VLC media player played url like rtsp://my-server-ip:8554/s1 steam, video and audio both OK. But use Chrome or Firefox to access url like http://my-server-ip:8888/s1/ , video is always black, audio is OK.

aler9 commented 3 years ago

Hello, the problem with HLS and H265 is that most browsers don't support H265. The only exception is Safari on iOS and macOS:

https://caniuse.com/?search=hevc

Therefore, even if this is implemented, it would benefit few users.

Prakash2101 commented 3 years ago

@aler9, Not an issue, can you please add this feature.

1021683053 commented 2 years ago

您好,HLS 和 H265 的问题是大多数浏览器不支持 H265。唯一的例外是 iOS 和 macOS 上的 Safari:

https://caniuse.com/?search=hevc

因此,即使实现了这一点,也不会使少数用户受益。

Web can use H.265 decoder like this https://github.com/numberwolf/h265web.js or https://github.com/ffmpegwasm/ffmpeg.wasm

aler9 commented 2 years ago

@1021683053 a WASM H265 decoder is very interesting, but it requires too much CPU to produce quality results.

Web streaming is heavily influenced by browser support, and if browsers continue not to support H265, transcoding from cameras to browsers can't be done. If you have a H265 feed and want to preserve throughput or quality, you have to perform a server-side re-encoding from H265 to VP9 and use WebRTC, or from H265 to AV1 and use Media Source Extensions.

mihailj commented 2 years ago

Hello Alessandro,

Chromium-based browsers (including Edge) have enabled by default h265 decoding for platforms with hardware support.

https://bugs.chromium.org/p/chromium/issues/detail?id=460703

See also here the updated table:

https://caniuse.com/?search=H265

This is quite a game-changer so it would be great if you can reconsider implementing HLS support for h265 codec.

Thanks, Mihail

gitslav commented 2 years ago

Hi @aler9. This project is an amazing work :) I know that Chrome does not support h265 but Edge is rising on windows as Safari is (my default browser on Mac) too. Plus HLS h265 is consumed by a lot of players that run on Android (Google's ExoPlayer) and iOS. Hardware support is available in every end user device. It will be great if support is considered in this project 👍

gitslav commented 2 years ago

The good thing is that my last comment aged badly and Chrome already supports h265! https://bitmovin.com/google-adds-hevc-support-chrome/ @aler9 this is huge news for this project and video on the web in general.

Anyone can check their browser support here https://ott.dolby.com/codec_test/index.html

brunobaraobr commented 1 year ago

hello, i would also like to request hls support on h265. recently google chrome added native hevc h265 support from versions 107+

aler9 commented 1 year ago

H265/HLS is being implemented in #1342. Please be aware that your browser must support the H265 codec in order for the functionality to work. I'll add a test page to the README that allows to test your browser for supported codecs.

aler9 commented 1 year ago

This is now supported since v0.21.1

mihailj commented 1 year ago

Hello Alessandro,

I am very happy to see this working, thanks a lot for your amazing work! 👍 🥳

I've been testing this feature and found that it works great most of the time, with some exceptions.

For example with this HEVC file:

https://we.tl/t-rgoQZ7nVGv

This is the ffmpeg command that I'm using to publish the video to rtsp-simple-server:

ffmpeg -re -i ./bbb-1920x1080-cfg02.mkv -c copy -an -f rtsp -rtsp_transport tcp rtsp://0.0.0.0:8554/test

I'm running the default configuration file with only these HLS settings changed:

hlsAlwaysRemux: yes
hlsVariant: fmp4

And this is the rtsp-simple-server log:

2023/01/09 15:16:22 INF [RTSP] [session ed59a992] is publishing to path 'test', with TCP, 1 track (H265)
2023/01/09 15:16:22 INF [HLS] [muxer test] created automatically
2023/01/09 15:16:22 INF [HLS] [muxer test] is converting into HLS, 1 track (H265)
2023/01/09 15:16:23 INF [HLS] [muxer test] ERR: muxer error: unable to extract DTS: SPS not received yet
2023/01/09 15:16:33 INF [HLS] [muxer test] is converting into HLS, 1 track (H265)
2023/01/09 15:16:33 WAR [RTSP] [session ed59a992] PACI packets are not supported (yet)
2023/01/09 15:16:33 INF [HLS] [muxer test] ERR: muxer error: unable to extract DTS: SPS not received yet
2023/01/09 15:16:43 INF [HLS] [muxer test] is converting into HLS, 1 track (H265)
2023/01/09 15:16:45 INF [HLS] [muxer test] ERR: muxer error: unable to extract DTS: invalid SPS: SubLayerProfilePresentFlag not supported yet
2023/01/09 15:16:55 INF [HLS] [muxer test] is converting into HLS, 1 track (H265)
2023/01/09 15:16:56 WAR [RTSP] [session ed59a992] invalid aggregation unit (invalid size)
2023/01/09 15:16:56 INF [HLS] [muxer test] ERR: muxer error: unable to extract DTS: invalid SPS: SubLayerProfilePresentFlag not supported yet
2023/01/09 15:17:06 INF [HLS] [muxer test] is converting into HLS, 1 track (H265)
2023/01/09 15:17:08 INF [HLS] [muxer test] ERR: muxer error: unable to extract DTS: invalid SPS: SubLayerLevelPresentFlag not supported yet
2023/01/09 15:17:18 INF [HLS] [muxer test] is converting into HLS, 1 track (H265)
2023/01/09 15:17:18 WAR [RTSP] [session ed59a992] PACI packets are not supported (yet)
2023/01/09 15:17:18 INF [HLS] [muxer test] ERR: muxer error: unable to extract DTS: invalid SPS: ScalingListDataPresentFlag not supported yet

In this case the HLS endpoint is not playable. Hope that you can figure out if there's something wrong with the file or the muxer...

Regards, Mihail

aler9 commented 1 year ago

@mihailj please open a dedicated issue and provide again the file, thanks.