Files
facefusion/tests/stream_helper.py
T
Harisreedhar ab24cd3f2e Implement basic webrtc stream (#1054)
* implement basic webrtc_stream

* add aiortc to requirements.txt

* update aiortc version

* rename variables with rtc_ prefix

* changes

* changes

* change helper to assert_helper and stream_helper

* rename variables with rtc_ prefix

* add error handling

* return whole connection

* remove monkey patch and some cleaning

* cleanup

* tiny adjustments

* tiny adjustments

* proper typing and naming for rtc offer set

* - remove async from on_video_track method
- rename source -> target
- add audio

* audio always before video

---------

Co-authored-by: henryruhs <info@henryruhs.com>
2026-03-17 14:02:40 +01:00

22 lines
515 B
Python

from aiortc import RTCPeerConnection, VideoStreamTrack
from facefusion.types import RtcOfferSet
async def create_rtc_offer() -> RtcOfferSet:
rtc_connection = RTCPeerConnection()
rtc_connection.addTrack(VideoStreamTrack())
rtc_offer = await rtc_connection.createOffer()
await rtc_connection.setLocalDescription(rtc_offer)
rtc_offer_set : RtcOfferSet =\
{
'sdp': rtc_connection.localDescription.sdp,
'type': rtc_connection.localDescription.type
}
await rtc_connection.close()
return rtc_offer_set