A Raspberry Pi 5 can send a folder of videos to YouTube Live with FFmpeg, but the right command depends on the files. Start by inspecting a representative video, then decide whether the clips can be stream-copied or must be re-encoded.
For a reliable overnight stream, make the playlist explicit, test one clip, check that the Pi keeps up with playback, and watch YouTube's preview before leaving it unattended. A single command cannot make arbitrary containers, codecs and frame rates compatible.
Check the Raspberry Pi 5 and FFmpeg environment
The Pi should run from a reliable power supply, have enough free storage for its operating system and temporary files, and use a wired network connection where possible. Wi-Fi can work, but a local wireless interruption can stop an otherwise healthy encoder.
Update the package information and check that FFmpeg is installed:
sudo apt update
sudo apt install ffmpeg
ffmpeg -version
ffprobe -version
The exact FFmpeg build matters. It determines which demuxers, muxers and encoders are available, so do not assume that a command copied from another Raspberry Pi will behave identically. Check for the FLV muxer and the encoders you intend to use:
ffmpeg -muxers | grep flv
ffmpeg -encoders | grep -E '264|aac|mp3'
If you are using a Raspberry Pi OS release or another distribution with an older package, note the version before troubleshooting. A missing encoder is a build issue, not evidence that the input file is defective.
The important performance distinction is between copying encoded media and creating new encoded media. Raspberry Pi's official camera documentation states that Raspberry Pi 5 uses software video encoders. That means you should not plan on a dedicated Pi 5 H.264 encoder handling any chosen resolution and frame rate without a local test.
If your goal is to understand the broader hardware trade-off, the discussion of whether FFmpeg needs a GPU for 24/7 YouTube streaming is useful context. It does not replace measuring your own files on your own Pi.
Inspect a representative video file
Do not begin with the playlist command. Pick one ordinary file from the folder, preferably one that represents most of the collection. If the folder contains phone recordings, exported devotional videos, screen recordings and downloaded music videos, inspect one of each group instead of assuming that the first file is typical.
Use ffprobe to print the streams and format information:
ffprobe -v error \
-show_entries stream=index,codec_type,codec_name,profile,width,height,pix_fmt,r_frame_rate,avg_frame_rate,time_base,channels,sample_rate \
-show_entries format=duration,format_name \
-of default=noprint_wrappers=1 \
'/media/videos/01-intro.mp4'
Record the video codec, audio codec, dimensions, frame rate, pixel format, number of streams and duration. The .mp4 ending only identifies a container. It does not tell you whether the video uses H.264, HEVC or another codec, nor whether the audio is AAC, MP3 or something else.
For a concat-demuxer playlist, the files need matching stream layouts, codecs and time bases. In practical terms, clips that look similar in a file manager can still fail at a boundary if they were produced by different applications. Differences in duration metadata can also lead to a gap, a repeated section or other playback artefact.
Inspect every file if the collection is small. For a large folder, inspect samples and then group the material by known export settings. Do not mix files merely because they all play in VLC. A desktop player may quietly decode and convert each file while FFmpeg is trying to pass the streams through unchanged.
You can also ask FFmpeg to decode a short portion without sending it to YouTube:
ffmpeg -v warning -i '/media/videos/01-intro.mp4' -t 60 -f null -
Warnings about damaged timestamps, missing audio or decoding errors deserve attention before you build a continuous stream. A file that plays after a desktop player repairs it may still be unsuitable for an unattended pipeline.
Prepare an explicit folder playlist
Create a text file containing the videos in the exact order you want. An explicit list is safer than relying on shell glob order, which can differ when filenames contain numbers, spaces or mixed case.
For the concat demuxer, a list can look like this:
ffconcat version 1.0
file '/media/videos/01-intro.mp4'
file '/media/videos/02-main.mp4'
file '/media/videos/03-outro.mp4'
Save it as /media/videos/playlist.ffconcat. The paths must be valid on the Pi, not on the computer where the files were originally edited. If the videos are stored on a mounted drive, confirm that the mount is present after a reboot.
Apostrophes, backslashes, leading spaces and unusual characters need careful handling in concat files. Rather than generating a list with an unexamined shell one-liner, create it deliberately or use a script that correctly escapes the filenames. If you control the collection, simple names such as 001-intro.mp4 and 002-main.mp4 make mistakes easier to spot.
The FFmpeg concat demuxer documentation explains the format and its safety rules. The -safe 0 option permits paths that FFmpeg would otherwise reject as unsafe, but it does not make an incorrect or malicious path safe in the wider operating-system sense. Use it only when you have created and checked the playlist.
The concat demuxer is different from joining files by re-encoding them. It reads the listed inputs as one sequence only when their stream properties meet its requirements. If your clips do not match, either prepare them into a common format first or use a filter-based workflow that decodes and encodes the sequence.
For another example of the same ordering problem, see this guide to making FFmpeg stream videos in order from a text file to YouTube. The important idea is not the filename of the list, but that the order is explicit and checked.
Choose stream copy or transcoding
There are two distinct paths.
| Path | Use it when | Main trade-off |
|---|---|---|
| Concat demuxer with stream copy | The clips have matching streams, codecs and time bases, and are already suitable for the intended YouTube output | Very low processing load, but it cannot resize, change codecs, change frame rate or correct incompatible clips |
| Preprocess or concatenate with a filter and encode | The clips differ, or you need one normalised codec, size, frame rate or bitrate | More control and compatibility, but the Pi 5 must perform software encoding and may not keep up |
| RTMPS output | Your FFmpeg build supports the endpoint and you want encrypted ingest | You must use the URL supplied by YouTube and verify that your build accepts it |
Stream copy means FFmpeg copies the already encoded packets instead of decoding and encoding them again. The relevant option is -c copy. It saves CPU time and avoids another generation of quality loss, but it is not a converter. It cannot turn HEVC into H.264, remove an incompatible extra stream, resize a video or establish a new keyframe pattern.
The FFmpeg documentation for stream selection and codecs is worth keeping nearby while you test. If the source streams already meet the output requirements, copying may be the sensible first attempt. If they do not, encode a short representative clip before committing to a long playlist.
For an encoding path, choose the target settings first. YouTube's current guidance for conventional SDR live ingest includes H.264 video, constant bitrate, a keyframe interval of two seconds and no more than four seconds, plus AAC or MP3 audio. Its recommended bitrate depends on the codec, resolution and frame rate, so select the matching row in the YouTube live encoder settings rather than treating one bitrate as universal.
The Pi 5 may handle a modest workload and struggle with another. Resolution, frame rate, filters, source codec, thermal conditions, storage speed and background processes all affect the result. Do not infer real-time capability from the fact that a short file converted successfully faster than playback. Measure whether the process stays ahead of the media clock for the complete test clip.
Configure the YouTube Live output
In YouTube Studio, open Live Control Room and create or select the stream. Copy the stream URL and stream key shown there. YouTube describes the key as the credential that allows the encoder to send to the stream, so treat it like a password. Do not put it in a public script, screenshot, repository or support post. Reset it if it is exposed.
YouTube recommends RTMPS for encrypted ingest. Use the exact RTMPS endpoint provided in Live Control Room rather than replacing it with a guessed address. The endpoint can include a host, application path and key, so keep the key separate while you are preparing the command and paste it only when ready.
A stream-copy starting shape is:
ffmpeg -re -f concat -safe 0 -i /media/videos/playlist.ffconcat \
-stream_loop -1 -c copy -f flv \
'rtmps://INGEST_HOST/APP/STREAM_KEY'
This is an illustrative starting point, not a universal drop-in command. -stream_loop -1 is an input option and its position matters. Confirm the option placement for the FFmpeg version installed on the Pi. Also confirm that the concat list is compatible and that the selected output format accepts the copied streams.
The -re option asks FFmpeg to read the input at approximately its native rate instead of sending a local file as quickly as possible. Without rate control, a file can reach the network far faster than real time. It does not fix bad timestamps or make a codec acceptable to YouTube.
If stream copy fails, stop and identify why. A message about an unsupported codec, mismatched streams or an invalid output does not mean that adding random flags will solve the problem. Normalise the material first, or use a tested encoding command that explicitly selects the video and audio codecs, output size, frame rate, bitrate and keyframe interval.
YouTube's documented procedure also includes checking the preview in Live Control Room and selecting Go live where the stream is scheduled or waiting for that control-room state. You should understand whether your chosen stream is immediately live or requires a separate confirmation.
Test a clip before looping the playlist
Test in layers. First, confirm that FFmpeg can read the representative file. Next, test the playlist locally without a network destination. Finally, send a short test to YouTube and inspect the preview before enabling an overnight loop.
A local concat test can write a short output file:
ffmpeg -v warning -re -f concat -safe 0 \
-i /media/videos/playlist.ffconcat \
-t 120 -c copy -f mpegts /tmp/playlist-test.ts
This tests reading and concatenation, but it does not prove that the copied streams are suitable for YouTube's chosen ingest. A local test with -f null - can also reveal decoding problems while avoiding an output file.
Then test the actual output for a short, representative period. Watch for a stalled preview, missing audio, a black frame at a join, a sudden disconnect or a steadily increasing delay. Check more than the first minute: a problem at the second file boundary will not appear in a single-file test.
If the playlist is meant to repeat, test the loop boundary as well. The loop may expose incorrect duration metadata that was not visible during the first pass. A playlist that runs once is not automatically a reliable 24/7 playlist.
For a stream that contains devotional music, ambience or local information, also check rights and source permissions before making it public. Technical success does not establish permission to broadcast the material. Review YouTube's current policies and the rights for every file.
Monitor Pi resources and YouTube ingest health
Leave a terminal open during the test and observe the encoder rather than relying on the command returning no error. top or htop shows CPU load and memory pressure. vcgencmd measure_temp can show temperature on systems where that utility is available. df -h checks free storage, and ip -s link can help reveal network errors.
The most useful signal for an encoding workflow is whether FFmpeg's reported processing speed stays around real time or above it. If it falls behind, the Pi is not producing frames quickly enough. Lowering the workload may help, but reducing the output size or frame rate changes the stream and must still match the YouTube settings you choose.
Watch for thermal throttling, especially when the Pi is enclosed or placed near other warm equipment. Cooling does not create a hardware encoder, but it can prevent temperature from becoming an additional variable. Keep the test conditions close to the conditions expected during the real stream.
On YouTube, use the Live Control Room preview and health indicators. YouTube advises checking the preview, confirming that the event is accessible and monitoring audio and video quality during the broadcast. A green local process is not enough if the upload connection is unstable or YouTube is reporting ingest problems.
Use a wired connection where practical, keep other large uploads off the same network, and make sure the Pi does not suspend or reboot for unattended updates. If the stream is important, arrange a way to reach the Pi remotely and record the FFmpeg output to a protected log. Do not log the full command with the stream key in a place other people can read.
The Pi approach is useful when the files are already prepared and you are comfortable maintaining the small computer, storage and network. If your main problem is keeping a local machine awake, reconnecting a dropped broadcast and restarting a known video file without leaving a Pi running all night, StreamNeo removes that particular maintenance task by taking an uploaded video and running the YouTube broadcast remotely; it is YouTube-only and does not turn arbitrary source files into compatible media.
If the Pi is not the right fit, compare it with the practical differences in FFmpeg and OBS for 24/7 YouTube streaming from prerecorded videos. For a channel whose priority is avoiding local hardware, the guide to setting up a YouTube lofi radio stream using a cloud server covers a different operating model.
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
Can FFmpeg loop a folder directly?
FFmpeg does not treat a folder as a playlist by itself. Create an ordered concat list, test that the files meet the concat demuxer's compatibility requirements, and then use the installed version's supported input-loop option. Looping repeats the playlist; it does not repair incompatible media.
Do I need to re-encode every video before streaming?
No. If the files have matching streams and are already suitable for the chosen YouTube ingest, stream copy can avoid re-encoding. If codecs, dimensions, frame rates or stream layouts differ, preprocessing or transcoding is the more predictable route.
Can a Raspberry Pi 5 transcode any video in real time?
No such general guarantee is safe. Raspberry Pi 5 uses software video encoders, and the result depends on the codec, resolution, frame rate, filters, cooling and other load. Test a representative clip and confirm that processing keeps pace before scheduling a long broadcast.
Where should I get the YouTube stream key?
Get the stream URL and key from YouTube Studio's Live Control Room. Keep the key private, use the RTMPS endpoint supplied there where supported, and reset the key if it has been exposed.