i try to create a YT Stream over the API. I just intend to create a public visible stream. The Data i want to send later via RTMP with a other software.
I have written this script to create the stream:
import google.oauth2.credentialsimport google_auth_oauthlib.flowimport googleapiclient.discoveryimport googleapiclient.errorsimport subprocess# Set up the OAuth2 credentials# Replace CLIENT_SECRETS_FILE with the path to your client_secret.json fileCLIENT_SECRETS_FILE = "client_secret.json"SCOPES = ["https://www.googleapis.com/auth/youtube.force-ssl"]API_SERVICE_NAME = "youtube"API_VERSION = "v3"flow = google_auth_oauthlib.flow.InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)flow.redirect_uri = 'http://localhost:8080/'authorization_url, state = flow.authorization_url(access_type='offline')credentials = flow.run_local_server(port=8080)# Create a new YouTube client using the credentialsyoutube = googleapiclient.discovery.build(API_SERVICE_NAME, API_VERSION, credentials=credentials)# Define the parameters for the new live streamstream_title = "My Live Stream"stream_description = "This is a live stream created with the YouTube API"stream_privacy_status = "public"stream_body = {'snippet': {'title': stream_title,'description': stream_description, },'status': {'privacyStatus': stream_privacy_status },'cdn': {'ingestionType': 'rtmp','frameRate': '30fps', # Frame-Rate hinzufügen'resolution': '1080p', }}# Call the YouTube API to create the new live streamlive_stream_response = youtube.liveStreams().insert(part="snippet,status,cdn", body=stream_body).execute()# Get the RTMP ingest URL and stream key from the API responsestatus_info = live_stream_response["status"]ingestion_info = live_stream_response["cdn"]["ingestionInfo"]rtmp_url = ingestion_info["streamName"]stream_key = ingestion_info["ingestionAddress"]status = status_info["streamStatus"]# Print the RTMP URL and stream keyprint(f"Status: {status}")print(f"RTMP URL: {rtmp_url}")print(f"Stream Key: {stream_key}")The script looks like it work... the OAuth Consent Screen opens and i select my youtube-channel...Then it creates the live_stream and i can also list the live streams with youtube.liveStreams().list ... if i send a rtmp to the stream i also can see over youtube.liveStreams().list that the stream recieves my data.
But i cannot find the stream in my youtube channel... not in the studio and nowhere else.How to solve it?
I try to create a youtube-live stream.
I expect that the created steam is visible on my youtube channel.
If i list the channels i get back as example:
Channel-ID: [HERE IS MY CHANNEL ID]Status: inactiveIngestion Type: rtmpResolution: variableFrame Rate: variableIngestion Info: Stream Name: [HERE IS MY STREAM KEY] Ingestion Address: rtmp://a.rtmp.youtube.com/live2 Backup Ingestion Address: rtmp://b.rtmp.youtube.com/live2?backup=1Health Status: Status: noData Configuration Issues:Title: Default stream keyDescription: Description for default stream keyID: [HERE IS MY ID]ChannelId is correct .... but it shows no stream at my channel.