DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
Mountain View desk7 min

How to Install FFmpeg on Raspberry Pi OS for a YouTube Loop Stream

Install FFmpeg on Raspberry Pi OS, then configure a looping file for YouTube Live with practical guidance on stream keys, bitrate, testing, and common errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install FFmpeg from Raspberry Pi OS’s APT repositories with sudo apt update and sudo apt install ffmpeg. That puts the encoder on your Pi; to loop a video to YouTube Live, you also need a local media file, a YouTube stream URL and private stream key, suitable encoding settings, and enough processing and upload capacity.

Install FFmpeg on Raspberry Pi OS

Open a terminal on the Pi or connect to it remotely. Raspberry Pi’s camera documentation uses APT to install FFmpeg, and Raspberry Pi OS documentation describes APT as its package manager. Update the package lists before installing:

As an Amazon Associate I earn from qualifying purchases.

  1. Refresh the package metadata: sudo apt update.

  2. Install FFmpeg: sudo apt install ffmpeg. Review APT’s proposed changes and confirm when prompted.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Check that the executable is available: ffmpeg -version. The command should print the installed build’s version and configuration. This verifies the installation, not that the Pi can encode a particular stream in real time.

    #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

Raspberry Pi OS uses Debian packages. Its documentation identifies Trixie as the latest base and Bookworm as the previous base at the time of writing; available packages and versions can depend on the installed OS release, architecture, and repository state. See the Raspberry Pi OS documentation and the installation example in the Raspberry Pi camera documentation.

If APT cannot find the package

  • Check that the Pi has internet access, then retry sudo apt update.

  • Check that the configured Raspberry Pi OS repositories are enabled for your installation.

    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.
  • Do not make an arbitrary downloaded binary your first workaround. APT is the normal installation route described by Raspberry Pi.

What you need to send a looping video to YouTube

Installing FFmpeg alone does not start a live stream. The setup has three parts: a video file accessible on the Pi, FFmpeg configured to repeat and encode it, and YouTube’s ingest destination and stream key. YouTube provides the destination and key in Live Control Room for use in an encoder; see YouTube’s guide to managing live streams.

Protect the stream key

Treat the key like a password: do not publish it in an article, screenshot, source repository, or command history. Anyone who obtains it may be able to send video to your live stream. Avoid saving it in scripts or logs that other users can read, and regenerate it in YouTube if it is exposed. YouTube’s Live Control Room is where you retrieve the stream URL and key.

Choose a stream profile the Pi can handle

YouTube’s current encoder guidance supports RTMP/RTMPS ingestion, H.264, H.265/HEVC, and AV1 video, frame rates up to 60 fps, AAC or MP3 audio, and constant bitrate (CBR). It recommends a two-second keyframe interval and says not to exceed four seconds. YouTube recommends RTMPS for encrypted transport. Consult its encoder settings and bitrates guidance for current details.

For H.264, YouTube lists these video bitrate figures. They are YouTube ingestion guidance, not measurements of what a Raspberry Pi can encode or a guarantee that a particular internet connection can deliver reliably.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Target profile YouTube video bitrate guidance
720p at 30 fps, H.264 3 Mbps minimum; 8 Mbps recommended
1080p at 30 fps, H.264 5 Mbps minimum; 14 Mbps recommended

Choose the resolution and frame rate based on the Pi’s measured encoding headroom, source material, and connection—not just the highest quality YouTube accepts. YouTube advises keeping total stream bitrate within available upload bandwidth and recommends leaving 20% upload headroom. Its streaming tips also recommend a reliable connection and checking stream health.

Rank #3
CanaKit Raspberry Pi 5 Essentials Starter Kit (4GB RAM)
  • CanaKit Raspberry Pi 5 Essentials Starter Kit

Loop a file to YouTube with FFmpeg

The following is a command template, not a tested universal recipe. It assumes a local file with video and audio, an FFmpeg build with the required encoder and RTMPS protocol support, and a YouTube destination that accepts the URL-and-key form shown. Replace the example file, destination, and key. Never paste a real key into a place that will be shared or retained in shell history.

For an H.264/AAC stream, a template is:

ffmpeg -re -stream_loop -1 -i "/path/to/video.mp4" -c:v libx264 -preset veryfast -b:v 8M -maxrate 8M -bufsize 16M -pix_fmt yuv420p -r 30 -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -b:a 128k -ar 44100 -f flv "rtmps://YOUR_YOUTUBE_INGEST_URL/YOUR_STREAM_KEY"

  • -stream_loop -1 repeats the input indefinitely; -re reads the file at its intended playback rate rather than sending it as fast as possible.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • -c:v libx264 selects the H.264 encoder when that encoder is present in the installed build. Check available encoders with ffmpeg -encoders; do not assume every build or Pi model has the same capabilities.

  • -b:v 8M, -maxrate 8M, and -bufsize 16M illustrate an 8 Mbps video target. That matches YouTube’s recommended video bitrate for 720p/30 H.264, but does not establish that your Pi can encode it or that your connection can sustain the total audio-plus-video rate. For 1080p/30 H.264, YouTube lists 14 Mbps recommended video bitrate; test before selecting that profile.

  • -r 30 sets 30 fps. -g 60 and -keyint_min 60 set a 60-frame GOP at 30 fps, corresponding to a two-second keyframe interval; -sc_threshold 0 avoids extra scene-cut keyframes in this example. YouTube recommends a two-second interval and no more than four seconds.

    Rank #4
    SANOOV Raspberry Pi 5 4GB Kit, 4GB RAM Single Board Computer with Active Cooler and ABS Case, Complete Raspberry Pi 5 Starter Kit for IoT Robotics Retro Gaming
    • All-in-One Complete Kit: This SANOOV RPi 5 bundle comes with Raspberry Pi 5 4GB RAM single board, active cooler, durable ABS case and screwdriver. No extra parts needed, ready to use right out of the box for beginners and hobbyists
    • Powerful Single Board Computer: Equipped with 4GB RAM and high-performance processor, delivers fast running speed for 4K playback, AI projects, programming and daily computing tasks. SANOOV for raspberry pi 5 4GB is equipped with broadcom 64 quad-core Arm Cortex A76 processor with gigabit ethernet and upgraded with IEEE 802.11ac Wi-Fi, Bluetooth 5.0 dual-band 2.4Ghz and 5Ghz and Power Over Ethernet (POE). Upgrading delivers 2-3 x speed vs Pi 4, redefining the experience
    • Efficient Active Cooler: Effectively lowers operating temperature and prevents performance throttling. Runs quietly even under long-time heavy load, ensures stable operation all day long. SANOOV RPi 5 4GB kit offer an active cooler, which combines an aluminium heatsink with a high-performance PWM fan. Active cooler is fully compatible with the Pi OS, which can effectively reduce the temperature of RPi5 and ensure its good performance during long-term high load operation
    • Sturdy ABS Protective Case: Well-fitted for Raspberry Pi 5 board, can be secured with 4 screws to effectively protect the Pi 5 motherboard from damage, reserves full access to all ports and buttons. SANOOV uses ABS material to produce the case, which has a softer texture and feel. Meanwhile, SANOOV case adopts a layered design for easy disassembly and installation. (Tip: The Case cannot install M.2 HAT Add on Board and Solid State Drive!)
    • Wide Application & Full Compatibility: Seamlessly compatible with official OS and mainstream peripheral accessories for Raspberry Pi 5. Whether you are a beginner, student, electronics hobbyist or professional developer, this all-in-one kit meets your diverse needs. It excels in IoT projects, robotics design, retro gaming devices, home media servers and other DIY creations. Backed by a large global community, you can easily find guides, technical support and shared projects online
  • -c:a aac -b:a 128k -ar 44100 encodes an AAC audio track. If your source has no audio, or you need a different audio treatment, adjust the audio mapping and options rather than assuming this example fits.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • -f flv is used for the RTMP-style output. Use YouTube’s RTMPS destination where your FFmpeg build supports it, and follow the current URL format shown in Live Control Room.

For another profile, change the video bitrate and frame-rate/GOP values together. A 720p/30 profile is a more modest starting point than 1080p/30, but the appropriate choice depends on the particular Pi, input, and network. The official guidance does not establish one command or performance level for every model, OS image, or FFmpeg build.

Test before relying on the stream

  1. Start a private or unlisted test broadcast in YouTube Live Control Room and use its current ingest URL and stream key.

  2. Run the command and watch FFmpeg’s output for errors, speed, and dropped frames. On the Pi, observe CPU load and whether the stream remains stable over time.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  3. Check YouTube’s stream health and confirm that video, audio, resolution, and frame rate arrive as intended.

    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.
  4. Confirm that the file loops cleanly at its end. A loop restarts the same uploaded file; it does not by itself create a playlist of different videos.

  5. Only switch to a public broadcast once the test is stable and the video and audio are yours to stream or otherwise cleared for use.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

YouTube copyright and reused-content considerations

A technically successful loop is not automatically permitted or eligible for monetization. You are responsible for rights to the video, music, and other material in the file; a live stream can be interrupted or restricted if it contains material you do not have permission to use. YouTube’s monetization review also considers whether a channel’s videos offer original value rather than being reused with little meaningful change. Review YouTube’s current channel monetization policies and copyright guidance before running a repeated broadcast, especially if monetization matters to you.

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

Troubleshoot common problems

Symptom Likely cause What to check
Unable to locate package ffmpeg APT metadata is stale, the Pi is offline, or the configured repositories do not expose the package. Check connectivity, run sudo apt update, and verify the Raspberry Pi OS repository configuration.
FFmpeg reports an unknown encoder or protocol The installed build lacks the requested encoder or RTMPS support. Inspect ffmpeg -encoders and ffmpeg -protocols; use an option supported by your build or an available package from configured OS repositories.
YouTube does not receive the stream The URL/key is wrong, the key was rotated, transport is unsupported, or the connection is blocked or unstable. Copy the current destination and key from Live Control Room, protect the key, verify RTMPS support, and check connectivity and stream health.
Encoding falls behind or frames drop The selected codec, resolution, frame rate, or bitrate exceeds the Pi’s available processing capacity. Try a lower resolution or frame rate, then retest while monitoring CPU load and FFmpeg’s reported speed. The achievable profile depends on the model and build.
Stream health degrades despite stable encoding Available upload bandwidth may be insufficient for the total bitrate or fluctuate over time. Check the connection, reduce bitrate if needed, and leave the upload headroom YouTube recommends.
Audio is missing or unintended The source may have no audio stream, or the example’s audio encoding does not match the source or intended output. Inspect the input streams with ffmpeg -i "/path/to/video.mp4" and adjust audio mapping and encoding accordingly.
The loop fails or ends unexpectedly The input path is wrong, the file cannot be decoded, or the input option is not supported as expected by the installed FFmpeg build. Test playback of the source locally, verify the path and permissions, and check FFmpeg’s error output before restarting the live test.

Or let it run in the cloud

If you want the video to keep looping without leaving the Pi or another computer on, StreamNeo runs an uploaded video as a 24/7 YouTube stream from the cloud. The basic setup is three steps: upload a recording or build a playlist, add your YouTube stream key once, and go live.

Start your free StreamNeo day.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.