To install FFmpeg on Raspberry Pi OS, refresh APT’s package list and install the ffmpeg package. Then verify that the executable runs; installation alone does not start a YouTube stream or confirm that your Pi can encode your video reliably.
The steps below separate package installation from the later work of preparing a source file, choosing encoding settings and connecting to YouTube Live. The loop command is an assumption-based template, not a universal recipe: the right options depend on your Pi model, FFmpeg build, video, audio and network.
Check Raspberry Pi OS and open a terminal
You need a working Raspberry Pi OS installation and access to a terminal. Open Terminal on the desktop, or connect remotely using a terminal session if you already administer the Pi that way. The commands below are entered at a shell prompt, not in a browser or in the YouTube Live Control Room.
If you are following along on a headless Pi, confirm that you are connected to the intended device before installing anything. A command-line prompt may look similar across more than one computer. You can check the device name with hostname, and use cat /etc/os-release to see identifying information about the installed operating system. These checks help you avoid updating another Linux machine by mistake.
Raspberry Pi OS releases and repository contents can change. The important point for this procedure is not a particular release name: it is that APT should be using the repositories configured for your installation. Raspberry Pi’s operating-system documentation describes OS and package-management basics. Follow the documentation for your installed release if its repository configuration needs attention.
A bootable microSD card is common on a Raspberry Pi, but it is not a special FFmpeg requirement. If you are still preparing a new device, Raspberry Pi’s getting-started guide covers boot media and initial setup. For an existing Pi that already starts Raspberry Pi OS, continue with its current storage and system rather than changing hardware just to install FFmpeg.
Refresh APT package metadata
Run:
sudo apt update
APT maintains package information from the repositories configured on the Pi. This command refreshes that information so the next package operation can find available package versions. It does not upgrade every installed application, and it does not install FFmpeg by itself.
The command may ask for your account password. While typing, the terminal may show no characters; that is normal. Enter the password and press Return. Read the output for errors, especially messages about unreachable repositories, DNS, or expired metadata. If the update fails, resolve that issue before trying to install the package, because APT may otherwise be working from stale or incomplete information.
Raspberry Pi’s camera software documentation includes the APT installation command for FFmpeg. Its example is useful confirmation that this is the normal package route on Raspberry Pi OS, but package availability still depends on your configured repositories and release. Avoid treating a command from an older forum post as proof that your present package lists are healthy.
Install FFmpeg with APT
After apt update completes successfully, install the package:
sudo apt install ffmpeg
APT shows the packages it plans to install and may ask you to confirm. Review the prompt and enter Y if the proposed changes look appropriate. APT resolves dependencies and installs the package from the configured repositories; there is no need to fetch an arbitrary binary from a download site as the default approach.
If APT says it cannot locate ffmpeg, check that the Pi can reach the network and that the Raspberry Pi OS repositories appropriate to this installation are enabled. Also check that the preceding update completed without repository errors. Do not respond by downloading a random executable: an unverified binary can be the wrong architecture, have unexpected dependencies or come from an untrusted source.
A successful package installation means APT has completed its package operation. It does not establish which encoders are present in the installed build, how quickly your particular Pi can encode a given source, or whether a future stream will remain healthy. Those are separate checks. The package route is the installation step; the stream configuration comes later.
Verify the FFmpeg executable
Check that the command is available and prints its build information:
ffmpeg -version
A version banner and configuration details indicate that the shell found and ran an FFmpeg executable. This is a verification suggestion, not a claim that a command has been run on your device. If the shell reports that ffmpeg is not found, review the APT installation output and confirm that the package operation finished successfully. You can also ask APT about the package with dpkg -s ffmpeg.
Before composing a stream command, inspect the capabilities of your own build. For example, ffmpeg -encoders lists encoders that this executable reports. The list does not tell you how fast an encoder will run on your Pi under your intended workload, so you still need a practical test. In particular, do not assume that a hardware encoder is available simply because the board has video-related hardware or because an online command uses one.
Keep the installation and streaming problems distinct. If ffmpeg -version works but a later command fails, FFmpeg is installed; the issue may instead be a misspelled filename, an unsupported codec option, an unavailable encoder, a malformed destination or a network problem. That distinction makes troubleshooting less circular.
Confirm the input video and audio assumptions
Before choosing a command, identify what you intend to loop. Use the exact path to the local file, and check that the Pi can read it. A filename containing spaces must be quoted in shell commands. A file that plays on a desktop is not automatically a file your particular FFmpeg build can decode, so inspect it rather than guessing about its streams and formats.
The example later assumes one local video file with a video stream and an audio stream, and uses software H.264 video encoding with AAC audio. If your file has no audio, remove the audio mapping and audio-encoding options rather than asking FFmpeg to select a stream that does not exist. If it has multiple audio tracks, decide which one is wanted. A command that silently chooses the wrong language or a commentary track is not a useful loop just because it connects.
Check whether the source’s dimensions and frame rate suit the output you want. A Pi may be able to read and pass through a format that it cannot re-encode at the desired rate in real time. Resizing, changing frame rate and encoding all use resources. Start with a modest target and test on the actual device, especially if it will be doing other work at the same time.
Long-running playback adds its own considerations. Confirm that the file is complete and that its ending joins acceptably to its beginning; FFmpeg looping cannot hide a visible jump or an abrupt audio cut. If you are building a playlist from several files rather than repeating one, the input and transition design differ. This guide’s example is for a single-file loop.
For a longer discussion of file rotation rather than repeating one input, see ways to loop multiple MP4 files. If the content includes music, check the rights and YouTube’s current requirements before broadcasting; the practical issue is not solved by changing the command. Our guide to copyrighted music on a YouTube live stream covers that separate question.
Prepare a YouTube Live stream and key
Create or select a broadcast in YouTube’s Live Control Room, then obtain the ingest destination and stream key shown for your encoder. YouTube’s stream setup instructions explain where these values come from. The encoder needs both a destination URL and the key to send a broadcast to your channel; installing FFmpeg supplies neither.
Treat the key like a password. Do not paste a real key into an article, screenshot, public source repository or command that you will later share. A command containing the key may also be saved in shell history or visible to other users of the Pi. Prefer a private method of entering the key and restrict access to any file used to hold it. If you think the key has been exposed, use YouTube’s controls to replace or reset it.
YouTube’s current encoder settings guidance covers supported ingest formats and recommends RTMPS for encrypted transport. Use the destination scheme YouTube supplies and confirm that your FFmpeg build can use it. YouTube’s guidance lists H.264, H.265/HEVC and AV1 video, AAC or MP3 audio, constant bitrate, and a recommended two-second keyframe interval. These are platform recommendations, not evidence that every codec or setting is available or sustainable on every Pi.
Do not make a public broadcast your first test. If available for your setup, use a private or unlisted test broadcast and inspect the preview and stream-health information in YouTube. Make sure the selected broadcast is the one you intend to test. The key is associated with the ingest configuration, while the audience visibility is controlled in YouTube; keep both parts in mind before you start sending video.
Adapt a loop command to the source
The following is an assumption-based example for a single local file named loop.mp4, with video and audio streams, and a build that supports the listed software encoders and the chosen RTMPS destination. Replace the placeholder path and destination details. Do not copy the angle-bracket placeholders literally, and do not paste a real key into a public document.
ffmpeg -re -stream_loop -1 -i "./loop.mp4" \
-map 0:v:0 -map 0:a:0 \
-c:v libx264 -preset veryfast -b:v 3M -maxrate 3M -bufsize 6M \
-r 30 -g 60 -pix_fmt yuv420p \
-c:a aac -b:a 128k -ar 44100 \
-f flv "rtmps://YOUR_INGEST_DESTINATION/YOUR_STREAM_KEY"
This illustrates the moving parts, not a tested command for a specific Raspberry Pi or media file. -stream_loop -1 asks FFmpeg to repeat the input indefinitely, while -re reads it at its native playback pace rather than sending the file as quickly as possible. The two -map options explicitly select the first video and first audio streams. Remove or change these if the source has no audio or the desired track is elsewhere.
The video options select software H.264 encoding, a preset, a bitrate target, a frame rate, a keyframe interval expressed in frames, and a pixel format. At 30 frames per second, a GOP of 60 frames corresponds to a two-second interval. The -bufsize value is part of rate control; it is not a promise of a particular visual quality. Confirm that libx264 appears in ffmpeg -encoders before relying on it. A slower or different preset may change CPU demand and encoding behaviour.
The bitrate in the example is chosen to illustrate a modest H.264 720p/30 target; the command does not scale the source to 720p, so set output dimensions deliberately if the source differs. YouTube’s encoder table gives 3 Mbps as the minimum and 8 Mbps as the recommended video bitrate for 720p at 30 fps H.264. For 1080p/30 H.264, it gives 5 Mbps minimum and 14 Mbps recommended. Those figures describe YouTube ingest guidance, not a performance guarantee for a Raspberry Pi. Choose output size and rate based on the device’s measured headroom and the connection you actually have.
YouTube advises keeping the total stream bitrate within available upload bandwidth and recommends leaving 20% headroom. Audio contributes to the total, as do any other concurrent uploads on the same connection. For more context on choosing a stable target, see our YouTube bitrate settings guide. The recommendations there are useful background, but measure your connection rather than assuming a nominal plan speed is available continuously.
If the source has different dimensions, frame rate, codec or audio layout, adapt the command instead of treating this one as a template to paste unchanged. If you want to change output resolution, use an appropriate scaling filter and verify that the Pi can sustain the extra work. Hardware encoding may reduce CPU use on some configurations, but its availability and quality are build- and model-dependent; see how hardware encoding affects power use for the trade-offs. When the recurring problem is keeping a computer powered and available to continue a file-based broadcast, StreamNeo removes that particular burden by letting you upload the file and keep the stream running without leaving your Pi on; it does not change YouTube’s ingest requirements or make an unsuitable source suitable.
Test the stream and inspect YouTube health
Start with a short private or unlisted test. Watch the terminal for errors, then inspect the YouTube preview and stream-health indicators. Confirm that moving images appear, the intended audio is audible, the loop returns cleanly to the beginning, and the broadcast is attached to the correct channel and visibility setting. A process that has not exited is not enough evidence that viewers are receiving a healthy stream.
Watch the Pi while the test runs. Check CPU load, temperature and whether the output continues at the intended pace; look for dropped frames or repeated warnings in FFmpeg’s output. If encoding falls behind, try reducing resolution or frame rate, lowering the target bitrate where appropriate, or using an encoder your build supports and your Pi can sustain. Make one change at a time so you can tell whether it helped.
Check the network as well as the device. A bitrate that fits the advertised upload speed may still exceed what is consistently available over Wi-Fi or during other household use. YouTube recommends a reliable connection and upload headroom. If the stream health reports instability, test a lower output rate, reduce competing traffic or use a more dependable connection before relying on the setup overnight.
A successful short test does not prove that a stream will run indefinitely. Leave a longer test appropriate to your use case, including a check that the source loops as expected and audio remains present. If you plan an always-on channel, consider what happens after a power cut, router restart or process exit, and decide how you will notice and recover from those events. This guide does not configure a service manager or guarantee automatic recovery.
If the terminal reports an encoder error, revisit the installed build and the exact codec options. If YouTube reports an ingest or key problem, re-check the destination and key in the Live Control Room without exposing the key. If YouTube receives video but reports poor health, investigate encoding load and upload capacity separately. Installing FFmpeg was one prerequisite; successful installation is not the same as a ready, stable broadcast.
Before committing, compare the operating options on the pricing page. When the file and channel are ready, start free — 24-hour trial, no card.
FAQ
Does installing FFmpeg start a YouTube Live stream?
No. Installation makes the FFmpeg executable available, but you still need a readable media input, a suitable command and YouTube’s ingest destination and stream key. You must test the resulting broadcast and check YouTube’s stream-health information.
Will the example work on every Raspberry Pi?
No. The Pi model, operating-system repositories, FFmpeg build, source streams, desired output and network all affect the result. Check the encoders available in your build and test whether the device can sustain the chosen settings before relying on it.
What if my video has no audio track?
The example maps the first audio stream and encodes it as AAC, so remove or adjust those audio options if the source has no audio. Confirm the input’s streams first; do not assume FFmpeg will create the audio you intend.
What should I do if APT cannot find FFmpeg?
Check network access, the configured Raspberry Pi OS repositories and the output from sudo apt update, then try the package installation again. Avoid downloading an arbitrary binary as a shortcut; package availability can vary with repository configuration and OS release.