Samuel Shuert | 36336c1 | 2023-11-29 17:17:57 -0500 | [diff] [blame^] | 1 | from __future__ import print_function |
| 2 | from twitchstream.outputvideo import TwitchBufferedOutputStream |
| 3 | import numpy as np |
| 4 | |
| 5 | if __name__ == "__main__": |
| 6 | with TwitchBufferedOutputStream( |
| 7 | twitch_stream_key="live_997764549_DZ2u2aAJTz7VFGASm8REuzeLyhRUzA", |
| 8 | width=1920, |
| 9 | height=1080, |
| 10 | fps=30., |
| 11 | verbose=True, |
| 12 | enable_audio=True) as videostream: |
| 13 | |
| 14 | frame = np.zeros((480, 640, 3)) |
| 15 | |
| 16 | while True: |
| 17 | if videostream.get_video_frame_buffer_state() < 30: |
| 18 | frame = np.random.rand(1080, 1920, 3) |
| 19 | videostream.send_video_frame(frame) |
| 20 | |
| 21 | if videostream.get_audio_buffer_state() < 30: |
| 22 | left_audio = np.random.randn(1470) |
| 23 | right_audio = np.random.randn(1470) |
| 24 | videostream.send_audio(left_audio, right_audio) |