To rotate local videos in a YouTube Live stream from Ubuntu, use FFmpeg to send the media and Python to coordinate FFmpeg with YouTube’s Live Streaming API. The API creates or selects a stream, creates and binds a broadcast, and manages its state; it does not turn a normal YouTube channel playlist into a live-video source. This guide covers a fixed sequential playlist and the building blocks for a supervised rotation, but file edits and process restarts need to be tested on your setup.
How the pieces fit together
A YouTube Live setup has two separate jobs:
- Media delivery: FFmpeg reads video files and sends their audio and video to YouTube’s current ingest endpoint using the channel’s stream key.
- Broadcast management: Python authenticates to the YouTube Live Streaming API to create or select a stream, create and bind a broadcast, check status, and request lifecycle transitions.
Google describes a broadcast as “a distinct YouTube video.” A liveBroadcast is the event viewers watch; a liveStream represents the incoming feed. A stream can be reused for broadcasts at different times, and Google documents that one stream may be bound to up to three broadcasts. See Google’s explanation of broadcasts and streams.
As an Amazon Associate I earn from qualifying purchases.
The API is not an encoder or process supervisor. Your Python program must handle API calls separately from FFmpeg startup, shutdown, logs, exit codes, and recovery choices. The exact Google client package and version should be pinned and checked in your implementation.
Prepare Ubuntu and your video files
Check the channel and software first
- Confirm live streaming is enabled for the YouTube channel you will authorize. The reviewed documentation does not establish a special India-only API workflow or a rule that all Indian channels are eligible.
- Install an Ubuntu-supported FFmpeg package, or choose and pin a deliberate build. Check the local
ffmpegmanual and version: online FFmpeg documentation may describe options newer than the package on your machine. An older distribution manpage is not evidence of the version on a current Ubuntu installation. - Install a supported Google API client for Python and keep track of its version. Follow its OAuth setup for the channel account and the permissions required for write operations.
- Use UTC timestamps in ISO 8601 format for scheduled API requests. The scheduled start time must be in the future when you create the broadcast.
Create a concat list
FFmpeg’s concat demuxer reads a text list and processes the named files one after another as though their packets had been joined. See the FFmpeg concat demuxer documentation. For example, save this as playlist.txt:
#1 Best Overall
- Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM)
- Includes 128GB Micro SD Card pre-loaded with 64-bit Raspberry Pi OS, USB MicroSD Card Reader
- CanaKit Turbine Black Case for the Raspberry Pi 5
- CanaKit Low Noise Bearing System Fan
- Mega Heat Sink - Black Anodized
file '/srv/videos/first.mp4'
file '/srv/videos/second.mp4'
file '/srv/videos/third.mp4'
Use paths that are accessible to the Ubuntu user running FFmpeg. The concat demuxer expects compatible inputs: the files need the same streams, codecs, and time base. Duration inaccuracies can produce artifacts or gaps. If your files differ, normalize or transcode them in advance rather than assuming a stream-copy command will work cleanly. Test the complete list, including transitions between its last and first files if you intend to loop it.
Choose your rotation strategy
A static concat list is the straightforward choice for a fixed sequence. For changing content, make a supervisor decide when to stop and restart FFmpeg with a revised list, or implement another deliberate rotation method. Do not assume editing playlist.txt changes what an already-running process reads. The concat documentation does not establish live reload behavior or guarantee gap-free rotation; test restart gaps and transitions with your installed FFmpeg version and actual media.
Authenticate Python and protect credentials
Authorize a Python client for the correct channel using OAuth and a scope that permits the write operations your program needs. Google’s broadcast insertion reference lists the YouTube and YouTube force-SSL scopes for writes; consult the insert reference and the client’s current authentication guidance when setting up credentials.
Rank #2
- Includes Raspberry Pi 4 4GB Model B with 1.5GHz 64-bit quad-core CPU (4GB RAM)
- Includes Pre-Loaded 32GB EVO+ Micro SD Card (Class 10), USB MicroSD Card Reader
- CanaKit Premium High-Gloss Raspberry Pi 4 Case with Integrated Fan Mount, CanaKit Low Noise Bearing System Fan
- CanaKit 3.5A USB-C Raspberry Pi 4 Power Supply (US Plug) with Noise Filter, Set of Heat Sinks, Display Cable - 6 foot (Supports up to 4K60p)
- CanaKit USB-C PiSwitch (On/Off Power Switch for Raspberry Pi 4)
- Keep OAuth client secrets, refresh credentials, and the YouTube stream key out of source control.
- Do not print credentials or the stream key in command logs, exception traces, or alerts. Redact them from diagnostic output.
- Restrict file permissions on credential files and on any configuration that contains a key.
- Log operational details such as timestamps, process exit status, and API state without logging secrets.
Create, bind, verify, and start a broadcast
The common API lifecycle is to create or select a liveStream, create a scheduled liveBroadcast, bind the broadcast to the stream, verify that the feed is active, and then request the appropriate transition. Google’s implementation guide describes this sequence. Its Python client reference exposes methods such as list, insert, bind, and transition; see the generated Python client reference.
- Select or create the stream. Use an existing
liveStreamor insert one with the delivery settings appropriate to your channel and encoder. A stream’s settings can be reused for separately scheduled events in a typical single-encoder setup. - Create the broadcast. Call
liveBroadcasts.insertwith the required event details, including a title, future scheduled start time, and privacy status. Use a UTC ISO 8601 timestamp. Ensure the authorized account has live streaming enabled. - Bind the event to the feed. Call
liveBroadcasts.bindwith the broadcast and stream identifiers. A broadcast must be associated with a stream to receive its feed. - Start FFmpeg. Supply the concat list and the channel’s current ingest endpoint and stream key. Keep the key out of the command text you save or display in logs. Do not copy a generic resolution, bitrate, protocol, or ingest address from an example: these depend on the channel’s ingest configuration and your media.
- Check stream status and health. Confirm YouTube reports the bound stream as active and that the intended broadcast is selected. Google’s Python client reference says to confirm the bound stream’s status is active before transitioning a broadcast to testing.
- Transition deliberately. Request the relevant broadcast transition only after verification. Google documents
testingandlivestates; do not treat a successful API request as proof that viewers are receiving healthy video.
Google documents the API methods and required authorization, but a complete production script also needs error handling for API failures, token refresh, process supervision, and shutdown. Build those as separate responsibilities rather than assuming the API itself starts or restarts FFmpeg.
Playlist changes, recovery, and reliability
For a supervised rotation, define what triggers a change, how the current FFmpeg process is stopped, how a new list is prepared, and what the program does if startup fails. Decide whether a restart gap is acceptable and verify the result with the actual files and channel. The available documentation does not promise that a concat list can be edited live, that a restart is uninterrupted, or that a long-running process will remain stable indefinitely.
Rank #3
- Not including the Raspberry Pi 5 (8GB), the Crowpi advanced version comes with the Raspberry Pi 5
- ELECROW Black Case for the Raspberry Pi 5, CrowPi is equipped with a 9-inch HD touchscreen along with a camera; All the regular components used in DIY electronics are packed into the CrowPi development board, such as LCD, LED matrix, buzzer, light sensor, PIR sensor, ultrasonic sensor, IR sensor, etc
- Raspberry Pi Sensors: The Crowpi raspberry pi 5 programming kit is jam-packed with lots of buttons such as 19 different sensors in a tidy easy to use package; You don't have to wait and wire things
- Build Quality: Solid ABS shell and well made components in one place make it strong and convenient to travel
- Programming Lessons: This raspberry pi 5 learning kit ships with step by step instructions and provides 21 lessons to take you through identifying components reading code and running it in the terminal
- Record FFmpeg’s exit status and timestamp, plus the relevant API state, while redacting secrets.
- Use bounded retries and alerting instead of an unlimited rapid restart loop.
- Check stream status and health before deciding whether to restart the encoder or change broadcast state.
- Test recovery from an FFmpeg exit and from a dropped ingest connection on the exact Ubuntu, FFmpeg, and channel configuration you plan to use.
Troubleshooting
Broadcast insertion fails
Check that OAuth has the necessary scope, live streaming is enabled for the channel, required fields such as title, scheduled start time, and privacy status are present, and the start time is valid and in the future. Inspect the API error details against Google’s insert reference.
The stream is not active
Inspect the stream’s status and health before requesting a broadcast transition. Confirm FFmpeg started successfully, is using the current ingest configuration and correct key, and is sending compatible media. The Python client guidance calls for an active bound stream before the transition to testing.
Files produce artifacts, gaps, or fail to join
Compare their stream layouts, codecs, time bases, and durations against the concat demuxer requirements. Normalize or transcode mismatched inputs, then test transitions through the entire list.
Rank #4
- Fully assembled for plug-and-play operation
- Includes Raspberry Pi 5 with 8GB RAM
- 256 GB PCIe Pi NVMe SSD (Pre-loaded with Pi 64-Bit OS)
- M.2 HAT+
- CanaKit Turbine Black Case for the Pi 5
Playlist edits do not change playback
Do not expect an existing FFmpeg process to reload a modified list. Use the supervisor’s tested restart or rotation procedure and account for any resulting gap.
The stream stops unexpectedly
Check redacted FFmpeg logs, exit status, timestamps, and YouTube API state to locate whether the encoder or broadcast state changed. Add retry limits and alerts, and test the recovery path; uninterrupted uptime is not guaranteed by the documented concat or API behavior.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesCost and operating trade-offs
This approach uses local Ubuntu compute and storage, plus the work of maintaining OAuth, the API client, FFmpeg, and supervision. The sources cited here do not benchmark performance, reliability, or cost for local disks versus network-mounted media, or for stream-copy concatenation versus transcoding. Choose based on your files and host, then test the actual workload; no hardware purchase is required by the API workflow.
Best Value
- 【What you Get】You will get 1*Pi 5 8GB Single Board,1*RasTech Case,1*Active Cooler,1*Screwdriver,1*Installation instructions,12-month free warranty, lifetime service, 24-hour prompt and friendly response.
- 【More Connectors】There are two USB 3.0 ports(5Gbps simultaneously) and two USB 2.0 ports, which triple total bandwidth ,support any combination of up to two cameras or displays. Peak SD card performance is doubled through support for the SDR104 high-speed mode. It provides a smooth desktop experience for you. Offer Gigabit Ethernet and a PCIe interface, along with dual-band Wi-Fi and Bluetooth 5.0/BLE wireless capability. The RasTech Pi 5 Kit use the new 27W 5.1V 5A USB-C power connector.
- 【 Support Dual 4Kp60 Display 】Each of the two microHDMI sockets can control a 4K display at 60 Hertz, now support HDR, offering super HD video for media streaming projects. RPi 5 is the first RPi model that comes with a PCI Express port (PCIe 2.0 x1 with 500 MB/s) to attach SSDs (requires separate M.2 HAT).
- 【 Excellent Chips And Applications】Pi 5 is a full-size Pi computer using silicon built in-house at Pi. The RP1 “southbridge” provides the bulk of the I/O capabilities for Pi 5. Pi 5 is more friendly and convenient in the development of Internet of Things, Web development, machine identification, automatic control and other electronic equipment applications and network.
- 【 Faster CPU, Better GPU 】 Pi 5 features a Broadcom BCM2712 64-bit quad-core Arm Cortex-A76 processor running at 2.4GHz, it delivers a 2–3× increase in CPU performance relative to RaspberryPi 4. The 800MHz VideoCore VII GPU is compatible to OpenGL ES 3.1 and Vulkan 1.2, substantial uplift in graphics performance. Pi 5 Offers lightning-fast CPU speed, a PCI Express interface, a Real Time Clock (RTC) and a power button and runs significantly cooler than Pi 4.
Or let it run in the cloud
If your goal is to keep uploaded videos live on YouTube without maintaining a local Ubuntu encoder, StreamNeo runs the loop in the cloud. Upload a recording or build a playlist, add your YouTube stream key, and go live. Nothing has to stay on at home; it supports any quality up to 4K 60fps as uploaded at one flat price per slot, and automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. Start your free day on StreamNeo.
Frequently Asked Questions
Does this method use a normal YouTube channel playlist as the live video source?
No. FFmpeg reads the local video files in sequence; Python manages the YouTube broadcast and stream API calls.
Can I change the concat list without restarting FFmpeg?
The concat documentation does not establish live reload behavior. Use and test a deliberate restart or rotation procedure.
Does the API guarantee uninterrupted 24/7 streaming?
No. The documented API lifecycle and concat behavior do not guarantee uninterrupted operation; test supervision and recovery on your setup.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




