Skip to content

Conversation

@chundonglinlin
Copy link
Member

@chundonglinlin chundonglinlin commented Mar 1, 2023

This PR is for HEVC over WebRTC, right now only Safari.

Note that Chrome/Firefox/Edge does not support HEVC over WebRTC, for detail, please see #465

First, please build SRS with HEVC support:

./configure --h265=on
make
./objs/srs -c conf/rtc.conf

Then, please enable HEVC for WebRTC in Safari, Develop > Experimental Features > WebRTC H265 codec

image

Next, open webrtc://127.0.0.1/live/livestream?codec=hevc in Safari to push WebRTC stream to SRS:

image

Now, open webrtc://127.0.0.1/live/livestream?codec=hevc in Safari to pull the WebRTC stream.

image

If want to view the log for Safari WebRTC:

image

image

@chundonglinlin chundonglinlin changed the title HEVC: webrtc support hevc in safari. HEVC: webrtc support hevc on safari. Mar 1, 2023
@winlinvip winlinvip added the ReadyToMerge Can be merged with the final review. label Mar 6, 2023
@winlinvip winlinvip changed the title HEVC: webrtc support hevc on safari. HEVC: webrtc support hevc on safari. v6.0.34 Mar 7, 2023
@winlinvip winlinvip merged commit 2708752 into ossrs:develop Mar 7, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 29, 2023
xiaozhihong added a commit that referenced this pull request May 13, 2025
## 1. Usage
### Launch Chrome with H.265 enabled: 
```bash
# Windows: 
C:\Program Files\Google\Chrome\Application>"C:\Program Files\Google\Chrome\Application\chrome.exe" --enable-features=WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled

# macOS:
open -a "Google Chrome" --args --enable-features=WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled
```

> Note: The latest Chrome browser (version 136) fully enables this by
default, so there's no need to launch it with any extra parameters.

### Launch SRS with `rtmp2rtc.conf`
```bash
./objs/srs -c conf/rtmp2rtc.conf
```

### Push H.265 with RTMP
```bash
ffmpeg -stream_loop -1 -re -i input.mp4 -c:v libx265 -preset fast -b:v 2000k -maxrate 2000k -bufsize 4000k -bf 0 -c:a aac -b:a 128k -ar 44100 -ac 2 -f flv rtmp://localhost/live/livestream
```

### Play with WebRTC
```bash
http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream
```


![image](https://github.com/user-attachments/assets/bdbf4c67-b7e2-4dc6-92a1-93e2c78e00fe)


## 2. Parameter Combinations for SDP
sendrecv offer
```bash
--enable-features=WebRtcAllowH265Send,PlatformHEVCEncoderSupport,WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled
```

sendonly offer
```bash
--enable-features=WebRtcAllowH265Send,PlatformHEVCEncoderSupport
```

recvonly offer
```bash
--enable-features=WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled
```

## 3. How to test if H.265 is working
* Browser Test for supporting H265


https://webrtc.github.io/samples/src/content/peerconnection/change-codecs/


![image](https://github.com/user-attachments/assets/174476df-a7aa-4951-9880-56328ec75065)

* How to test Safari: #3441
* Debug in Safari

![image](https://github.com/user-attachments/assets/6cf94fca-e3ed-46d2-a102-a472f1699b4e)


---------

Co-authored-by: chundonglinlin <[email protected]>
Co-authored-by: winlin <[email protected]>
Co-authored-by: john <[email protected]>

---------

Co-authored-by: chundonglinlin <[email protected]>
Co-authored-by: john <[email protected]>
winlinvip pushed a commit that referenced this pull request May 14, 2025
```bash
C:\Program Files\Google\Chrome\Application>"C:\Program Files\Google\Chrome\Application\chrome.exe" --enable-features=WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled

open -a "Google Chrome" --args --enable-features=WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled
```

> Note: The latest Chrome browser (version 136) fully enables this by
default, so there's no need to launch it with any extra parameters.

```bash
./objs/srs -c conf/rtmp2rtc.conf
```

```bash
ffmpeg -stream_loop -1 -re -i input.mp4 -c:v libx265 -preset fast -b:v 2000k -maxrate 2000k -bufsize 4000k -bf 0 -c:a aac -b:a 128k -ar 44100 -ac 2 -f flv rtmp://localhost/live/livestream
```

```bash
http://localhost:1985/rtc/v1/whep/?app=live&stream=livestream
```

![image](https://github.com/user-attachments/assets/bdbf4c67-b7e2-4dc6-92a1-93e2c78e00fe)

sendrecv offer
```bash
--enable-features=WebRtcAllowH265Send,PlatformHEVCEncoderSupport,WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled
```

sendonly offer
```bash
--enable-features=WebRtcAllowH265Send,PlatformHEVCEncoderSupport
```

recvonly offer
```bash
--enable-features=WebRtcAllowH265Receive --force-fieldtrials=WebRTC-Video-H26xPacketBuffer/Enabled
```

* Browser Test for supporting H265

https://webrtc.github.io/samples/src/content/peerconnection/change-codecs/

![image](https://github.com/user-attachments/assets/174476df-a7aa-4951-9880-56328ec75065)

* How to test Safari: #3441
* Debug in Safari

![image](https://github.com/user-attachments/assets/6cf94fca-e3ed-46d2-a102-a472f1699b4e)

---------

Co-authored-by: chundonglinlin <[email protected]>
Co-authored-by: winlin <[email protected]>
Co-authored-by: john <[email protected]>

---------

Co-authored-by: chundonglinlin <[email protected]>
Co-authored-by: john <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ReadyToMerge Can be merged with the final review. TransByAI Translated by AI/GPT.

Development

Successfully merging this pull request may close these issues.

3 participants