Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To rotate local videos in a YouTube Live stream, use FFmpeg to play the files in sequence and Python to manage the YouTube broadcast, start and supervise FFmpeg, and respond to failures. A YouTube channel playlist does not itself become the live stream’s video source. The steps below cover a fixed playlist and explain how to handle changes deliberately; dynamic edits and uninterrupted operation need testing on your actual setup.

How the pieces fit together

YouTube’s Live Streaming API manages broadcast events and their connection to a stream. FFmpeg reads the video files and produces the audio-video feed sent to YouTube. Python coordinates those jobs: it can prepare the file list, make API calls, launch FFmpeg, record process status, and decide what to do after an error.

  • A live broadcast is a distinct event viewers can watch and becomes a distinct YouTube video. It must be bound to a stream.
  • A live stream represents the incoming audio-video feed and its delivery settings. Google says a stream can be reused for broadcasts at different times and can be bound to up to three broadcasts.
  • An encoder process, such as FFmpeg, supplies the media. The API does not read your playlist files or supervise the encoder process.

See Google’s broadcast API reference, stream API reference, and implementation guide for the object model and workflow.

Check channel access and prepare Ubuntu

Confirm live streaming is enabled

Check that the channel you will authorize can livestream before building the automation. Google documents disabled live streaming as a possible cause of API failures; the sources reviewed do not establish a special India-only API workflow or eligibility rule. Confirm availability in the channel itself rather than assuming it from location.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
  • 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

Install and verify FFmpeg

Use an FFmpeg package supported by your Ubuntu release, or a deliberately pinned build. Check the installed version and its local manual before relying on command options: FFmpeg’s online documentation may track a newer revision than the package on your machine. The old Ubuntu Bionic FFmpeg manpage is a distribution-specific reference, not evidence of the version installed on a current Ubuntu system. The FFmpeg documentation is useful for the command-line interface.

Keep credentials out of code and logs

Use OAuth authorization for the YouTube channel and an appropriate write scope. Google’s broadcast insertion reference lists the YouTube and YouTube force-SSL scopes for write operations. Store OAuth credentials, refresh credentials, and the stream key in a protected configuration or secret store; do not commit them to source control or print them in logs. See Google’s broadcast insert reference.

Rank #2
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
  • 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)

Prepare a playlist FFmpeg can read

Build a concat-demuxer file list

Put the media paths in a text file in the order you want them played. FFmpeg’s concat demuxer reads a list of files sequentially as if their packets had been joined; see the concat demuxer documentation.

For example, a list can have this form, with paths adjusted to your Ubuntu host and filenames:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
ELECROW CrowPi Case Kit for Raspberry Pi 5, 9-Inch Display
  • 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
file '/srv/live/part-01.mp4'
file '/srv/live/part-02.mp4'
file '/srv/live/part-03.mp4'

Use paths the FFmpeg process can access. If paths contain characters that need special handling, validate the list with the installed FFmpeg version before scheduling a broadcast.

Choose compatible files or normalize them first

The concat demuxer expects the inputs to have the same streams, codecs, and time base. Duration inaccuracies can cause artifacts or gaps. A stream-copy approach is therefore most appropriate when the files are already compatible; heterogeneous files may need to be normalized or transcoded in advance. Do not assume that a command that works for one set of files will work unchanged for another.

Rank #4
CanaKit Raspberry Pi 5 Desktop PC with SSD (Fully Assembled) (256 GB SSD)
  • 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

Create and bind the YouTube broadcast

For scheduled events, the API lifecycle is to create or select a stream, insert a broadcast, bind the broadcast to the stream, verify the incoming feed, and then transition the broadcast. Google’s getting-started guide documents this sequence.

  1. Authorize the channel. Use OAuth credentials with a supported write scope. Use the Google API Python client for the YouTube Data API, and pin and verify the client version in your own environment; its Python client reference exposes methods such as list, insert, bind, and transition.
  2. Select or create a liveStream. Reuse a suitable existing stream or create one and retain its ID and ingest settings securely. In a single-encoder setup, stream settings can be configured once and reused for separately scheduled events.
  3. Insert a liveBroadcast. Supply the required broadcast details, including its title, scheduled start time, and privacy status. Use a future UTC timestamp in ISO 8601 format; the API requires the scheduled start time to be in the future.
  4. Bind the event to the stream. Call liveBroadcasts.bind with the broadcast and stream IDs. A broadcast is not connected to the encoder feed merely because both exist.
  5. Start FFmpeg and verify the feed. Use the current ingest endpoint and stream key associated with the channel’s stream configuration. Do not hard-code a stream key in a script or example. Inspect FFmpeg output and the stream’s status and health in YouTube Studio or through the API.
  6. Transition only when ready. Confirm that the correct event is selected and the bound stream is active before transitioning. Google’s Python client reference specifically notes checking the bound stream’s active status before a transition to testing; follow the applicable broadcast lifecycle for the event.

The exact ingest address, protocol, resolution, bitrate, and encoding settings depend on the channel’s current ingest configuration and media. Use the values shown for your stream in YouTube rather than treating any one set of values as universal.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
RasTech Raspberry Pi 5 8GB Kit with Active Cooler and Pi5 Case
  • 【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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Launch and supervise FFmpeg from Python

Keep API work and media-process management as separate responsibilities in the program. Python can call the API to create, bind, list, and transition broadcasts, while a process supervisor starts FFmpeg and handles its output, exit code, shutdown, and recovery decisions. Log timestamps, process exit status, and relevant API state, but redact credentials and keys.

For a fixed playlist, the supervisor can launch FFmpeg against the concat list and monitor whether the process remains alive. If the process exits unexpectedly, record the failure and use a deliberate retry policy with limits and alerting. A retry is a recovery attempt, not a guarantee that viewers will see uninterrupted output. Test reconnection behavior against the installed FFmpeg build and the channel’s ingest setup.

Handle playlist changes deliberately

The concat documentation establishes sequential reading from a text file; it does not guarantee that arbitrary edits to that file are reloaded by an already-running process. Do not promise that changing the list updates the live output immediately.

  • Fixed playlist: prepare and validate the file list before starting the encoder. This is the simplest approach to reason about.
  • Supervisor-controlled rotation: have Python decide when to stop or restart the media process with an updated list. Document the behavior, test the transition with the actual files, and account for a possible restart gap.
  • Incompatible media: normalize or transcode inputs ahead of time rather than expecting stream-copy concatenation to reconcile different stream layouts or codecs.
  • Network-mounted files: ensure the Ubuntu process can access every path for the entire playback period and test how it behaves if the mount or network becomes unavailable. The sources establish no performance or reliability advantage over local storage.

Troubleshoot common failures

Symptom What to check Practical response
Broadcast insertion fails OAuth authorization and scope, live-streaming enablement, required title, future scheduled start time, privacy status, and the API error details. Correct the missing or invalid field or authorization, then retry the API call. Google’s insert reference lists required fields and relevant errors.
Broadcast cannot transition Whether the broadcast is bound to the intended stream and whether that stream is active. Inspect stream status and health, start the encoder if needed, and transition only after the feed is active.
Artifacts or gaps between files Stream layout, codecs, time bases, and the accuracy of file durations. Make the inputs compatible or normalize them before concatenation; validate the result with the installed FFmpeg version.
FFmpeg exits or the stream drops FFmpeg output, exit status, timestamps, the current ingest configuration, and YouTube stream state. Record the event without secrets, apply a bounded retry policy, and alert an operator when retries fail. Recovery and continuous playback are not guaranteed by the API or concat demuxer.
Editing the list does not change playback Whether the running process actually rereads the list. Use a tested supervisor-controlled restart or rotation strategy; do not assume a live reload.

Or let it run in the cloud

If your goal is an always-on YouTube stream from uploaded videos rather than a Python/Ubuntu system to maintain, 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 streams your upload as made, up to 4K 60fps, at one price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card. Monthly pricing is $9.99 per month. In India, UPI and cards are supported. Start the free first day with StreamNeo.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Quick Recap

Bestseller No. 1
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
CanaKit Raspberry Pi 5 Starter Kit PRO - Turbine Black (128GB Edition) (8GB RAM)
Includes Raspberry Pi 5 with 2.4Ghz 64-bit quad-core CPU (8GB RAM); CanaKit Turbine Black Case for the Raspberry Pi 5
$259.95
Bestseller No. 2
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
CanaKit Raspberry Pi 4 4GB Starter PRO Kit - 4GB RAM
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
$159.99
Bestseller No. 4
CanaKit Raspberry Pi 5 Desktop PC with SSD (Fully Assembled) (256 GB SSD)
CanaKit Raspberry Pi 5 Desktop PC with SSD (Fully Assembled) (256 GB SSD)
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)
$339.97

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.