YouTube Streaming
This guide describes the YouTube-side setup for streaming an OpenIPC camera to YouTube Live with HLS ingestion. It is useful for long-running camera streams where temporary network drops should not permanently stop the event.
Requirements
Before starting:
- enable live streaming on the YouTube account;
- use the YouTube account connected to the target channel;
- be ready to authorize requests with Google OAuth 2.0;
- use the YouTube Data API sample tool at YouTube Live API code samples.
HLS and H.265
Use YouTube HLS ingestion for this setup. YouTube’s reference documentation is Delivering Content via HLS.
The important stream settings are:
"cdn": { "ingestionType": "hls", "frameRate": "variable", "resolution": "variable"}variable frame rate and resolution are useful for camera streams where the exact video mode may change or where the stream is not a fixed 1080p/60fps broadcast.
Create a Live Stream
- Open YouTube Live API code samples.
- Select
liveStreamsas the resource. - Select
insertas the method. - Open the
insertuse case in the table. - In the request body, set the
cdnobject to HLS with variable frame rate and resolution:
"cdn": { "ingestionType": "hls", "frameRate": "variable", "resolution": "variable"}- In the credentials section:
- select
Google OAuth 2.0; - select the
https://www.googleapis.com/auth/youtubescope; - deselect
API Key.
- select
- Press
Executeand authorize the request with the YouTube-connected account. - Confirm that the response status is
200. - Save the stream
idfrom the response. You will need it when binding the broadcast.
Create a Broadcast
- Open YouTube Live API code samples.
- Select
liveBroadcastsas the resource. - Select
insertas the method. - Open the
insertuse case. - Fill the broadcast snippet:
"snippet": { "title": "My Hometown Camera", "scheduledStartTime": "2026-12-31T00:00:00.000Z", "scheduledEndTime": "2027-01-01T00:00:00.000Z"}Use a start time in the future. The scheduled end time must be after the scheduled start time.
- In the credentials section:
- select
Google OAuth 2.0; - select the
https://www.googleapis.com/auth/youtubescope; - deselect
API Key.
- select
- Press
Executeand authorize the request. - Confirm that the response status is
200. - Save the broadcast
idfrom the response.
Bind the Broadcast to the Stream
- Open YouTube Live API code samples.
- Select
liveBroadcastsas the resource. - Select
bindas the method. - Open the
Bind a broadcast to a streamuse case. - Set:
idto the broadcast ID from the previous step;streamIdto the live stream ID from the stream creation step.
- Use Google OAuth 2.0 with the
https://www.googleapis.com/auth/youtubescope and no API key. - Press
Executeand confirm a200response.
Go Live
Open YouTube Studio, click Create, then Go live.
After the YouTube side is prepared, configure the camera or streaming host to send video to the HLS ingestion endpoint returned by YouTube.
Troubleshooting
The API Call Fails
Check that live streaming is enabled for the YouTube account and that the request uses OAuth 2.0 with the YouTube scope. An API key alone is not enough for creating and binding streams.
The Broadcast Stops After a Disconnect
Use a scheduled broadcast with a start date far in the future. This reduces the chance that a temporary camera disconnect ends the event permanently.
Wrong Stream Parameters
Use HLS ingestion with variable frame rate and variable resolution unless you are sure the camera always sends one fixed mode.