Exemplo n.º 1
0
#     sys.stdout.write( f"{frame}" )

# Send frames to twitch
    if stream is None:
        print(frame.shape)
        (streamH, streamW) = frame.shape[:2]
        stream = TwitchBufferedOutputStream(
            twitch_stream_key=args["streamkey"],
            width=streamW,
            height=streamH,
            fps=45.,
            enable_audio=False,
            verbose=False)
        print(stream.height, stream.width, "3")

    if stream.get_video_frame_buffer_state() < 15:
        norm_image = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
        norm_image = cv2.normalize(norm_image,
                                   None,
                                   alpha=0,
                                   beta=1,
                                   norm_type=cv2.NORM_MINMAX,
                                   dtype=cv2.CV_32F)
        stream.send_video_frame(norm_image)
#         sys.stdout.write( f"{norm_image}" )
# show the output frame
    cv2.imshow("Frame", frame)
    key = cv2.waitKey(1) & 0xFF

    # if the `q` key was pressed, break from the loop
    if key == ord("q"):
Exemplo n.º 2
0
import os, sys, subprocess
import numpy as np
import gym
import asteroid
import random

from twitchstream.outputvideo import TwitchBufferedOutputStream
from twitchstream.chat import TwitchChatStream

TWITCH_KEY = "live_86944108_XVDMuEvn7AFBEOLuvNeiyCSE4VX4bY"
OAUTH_KEY = "oauth:y56mfwbmq724genm9bchxqi11u5iac"

#env = gym.make("asteroid-v1")
#env._configure("ec2-34-249-73-16.eu-west-1.compute.amazonaws.com", "")

videostream = TwitchBufferedOutputStream(twitch_stream_key=TWITCH_KEY, width=1238, height=822)
#chat = TwitchChatStream(username='******', oauth=OAUTH_KEY)

while True:
    if videostream.get_video_frame_buffer_state() < 30:
        videostream.send_video_frame(np.ones((822, 1238, 3)))