To keep an FFmpeg YouTube broadcast running after a reboot or process failure, run FFmpeg in the foreground under a systemd service with a deliberate restart policy. That can restart an exited process; it cannot guarantee YouTube accepts the feed, that the media is valid, or that viewers can watch. Verify the stream in YouTube Live Control Room as well as on the server.
What you need to decide before setting up the service
A service unit supervises a process, not the whole broadcast path. Before configuring it, identify the input (a media file, playlist, or capture source), audio and video streams, target codec, resolution and frame rate, whether to copy streams or transcode, and the times the stream should run. Those choices determine the FFmpeg command and the CPU and network capacity required.
Vultr’s 2025 Ubuntu/OBS guide gives an example profile of 2 vCPUs, 4 GB memory, 80 GB storage, and 3 TB bandwidth. It is an example for that guide, not a measured minimum or capacity guarantee for an FFmpeg service. You cannot choose a reliable instance size without knowing the input and whether FFmpeg will transcode it.
Prepare the Vultr host and FFmpeg
Install a build that supports your output
Install FFmpeg using the supported package source for your Linux distribution, or another trusted build. Confirm the installed build includes the encoder you intend to use and supports RTMPS before creating the service. Vultr’s static-build guide uses older operating-system examples; do not apply its dated installation steps blindly to a different release.
#1 Best Overall
Check the host’s distribution and systemd version before relying on unit options. The Ubuntu systemd manual documents service behavior, but details can vary by installed version.
Check the input and encoding plan
For a file, confirm it exists at a stable path and inspect its video and audio streams. Decide whether it can be stream-copied or needs conversion. Copying avoids a video encode, while transcoding requires an available encoder and enough CPU or supported hardware acceleration. Either approach still needs a compatible output and an upload connection that can sustain the selected bitrate.
Create or select the YouTube stream
- Enable live streaming for the channel. If this is the channel’s first live stream, YouTube says activation may take up to 24 hours.
- Open Live Control Room and create or select the stream. Copy that stream’s server URL and stream key from its settings.
- Prefer the RTMPS ingest URL when YouTube provides one. Use the URL displayed for the selected stream; do not assume a generic endpoint is interchangeable. RTMPS sends the stream over a secure SSL connection.
- Protect the key. YouTube describes stream keys as password-like credentials used by an encoder to send a feed. Do not publish one in a script, screenshot, or support request. Reset it in Live Control Room if it is exposed.
See YouTube’s live stream settings, encoder setup guidance, and RTMPS instructions.
Choose YouTube-compatible output settings
YouTube’s current encoder guidance recommends constant bitrate (CBR), a two-second keyframe interval, and no more than four seconds between keyframes. It lists H.264, H.265/HEVC, and AV1 options, up to 60 fps. Select only a codec and settings supported by your FFmpeg build and sustainable by the source, server, and upload connection.
Recommended Free Tools
Rank #2
The following H.264 values are YouTube’s published bitrate guidance, accessed in 2026. They are recommendations, not proof that a particular Vultr instance or connection can sustain the stream.
| Output | YouTube H.264 bitrate range |
|---|---|
| 720p at 30 fps | 2 Mbps minimum; 8 Mbps recommended |
| 1080p at 30 fps | 5 Mbps minimum; 14 Mbps recommended |
| 1080p at 60 fps | 6 Mbps minimum; 17 Mbps recommended |
| 2160p (4K) at 30 fps | 11 Mbps minimum; 42 Mbps recommended |
Use the row that matches the intended output, not simply the source file’s label. YouTube’s table varies by codec, resolution, and frame rate. Run a speed test and test the actual stream before relying on the setup. YouTube Help advises: “Make sure to test before you start your live stream.” See YouTube’s encoder settings, bitrates, and resolutions.
Build and test the FFmpeg command
The exact command depends on the input and whether you copy or encode audio and video. For a looping file, this is only a structural example, not a tested, ready-to-run command:
ffmpeg -re -stream_loop -1 -i /path/to/input.mp4 [explicit video/audio mapping and codec options] -f flv "$YOUTUBE_RTMPS_URL/$YOUTUBE_STREAM_KEY"
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #3
Replace the bracketed section with explicit stream mapping and codec options appropriate to the source and target. Set the intended video bitrate, CBR behavior, frame rate, and two-second keyframe interval; configure audio as well. Confirm the output container and selected encoders are supported by your installed FFmpeg. Do not put a real stream key in a command entered interactively if that would leave it in shell history.
Before installing the service, run the command in a controlled test and confirm that YouTube receives the feed. A valid command line can still produce an unacceptable stream if the input lacks audio, the chosen encoder is unavailable, or the network cannot sustain the output.
Store the stream key outside the unit file
One deployment choice is a root-controlled environment file, for example /etc/ffmpeg-youtube.env, readable only by root and the service account. Put the URL and key there as environment values, restrict file permissions, and do not commit the file to source control or include it in logs. Another secret-management mechanism may suit your host better; the essential point is to treat the key as a credential and limit access.
Create a foreground systemd service
Run FFmpeg as the service’s main process. Do not append & or shell redirection to ExecStart; systemd’s unit command syntax does not accept shell operators that way. Use an appropriate non-root account and set a working directory that the account can access.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #4
For example, create /etc/systemd/system/ffmpeg-youtube.service and adapt this unit to your paths, user, environment file, and FFmpeg options:
[Unit]
Description=FFmpeg YouTube live stream
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=stream
WorkingDirectory=/srv/stream
EnvironmentFile=/etc/ffmpeg-youtube.env
ExecStart=/usr/bin/ffmpeg -re -stream_loop -1 -i /srv/stream/input.mp4 [explicit video/audio mapping and codec options] -f flv "$YOUTUBE_RTMPS_URL/$YOUTUBE_STREAM_KEY"
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
This illustrates the unit shape, not a turnkey command: replace the bracketed options, confirm the FFmpeg path and input path, and ensure the service account can read the file and environment values. Check the installed systemd manual for the host’s version and use service access controls appropriate to your deployment.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- Ultimate Freshness & Flavor: The condiment caddy’s lower compartment ingeniously holds ice cubes or crushed ice, actively keeping vegetables, sauces, or fruits succulent and fresh for hours. Each top compartment features a removable lid for easy access
- Safe, Stylish & Complete with Accessories: Crafted from sturdy, BPA-free PET plastic, our condiment organizer offers food safety and elegant aesthetics. The set includes 2 metal clips and 5 metal spoons for grabbing and scooping fruits, vegetables, and sauces. The crystal-clear design provides a seamless view of contents, perfect for beautifully presenting fruits, salads, or any treats. (Note: Avoid direct contact with hot food.)
- Modular Capacity for Every Need: Each individual lidded compartment 5.7"(14.4cm) × 3.8"(9.7cm) × 2.4"(6.2cm) holds 2.5 cups, ideal for single servings. The complete set includes 5 removable compartments fitting perfectly into the main tray 15.7"(40.6cm) × 6.2"(15.8cm) × 5.1"(13cm), offering ample total capacity
- Effortless Cleaning & Clear View: Constructed from transparent plastic, this garnish tray offers a clear view of stored food and ice. After use, it conveniently rinses clean with water. For thorough hygiene and longevity, HAND WASHING is highly recommended. (Important: Not dishwasher safe.)
- Versatility for Every Celebration: This fruit tray transforms into your go-to server for family gatherings, picnics, BBQs, and indoor/outdoor parties! Use it as a convenient hot dog/pizza toppings station, stylish bar garnish caddy, vegetable/fruit tray, or a complete taco bar serving set
Choose restart behavior deliberately
Restart=on-failure is the documented systemd recommendation for a long-running service. RestartSec=10 gives a brief pause before a retry; choose a delay appropriate to your setup. Repeated fast failures can hit systemd’s start-rate limit and leave the unit failed. A deliberate systemctl stop is not automatically restarted under this policy.
Enable, start, and inspect the service
- After creating or editing the unit, reload unit definitions:
sudo systemctl daemon-reload. - Enable it at boot and start it now:
sudo systemctl enable --now ffmpeg-youtube.service. - Inspect process-level status:
sudo systemctl status ffmpeg-youtube.service. - Read recent service logs:
sudo journalctl -u ffmpeg-youtube.service -n 100 --no-pager. Follow new messages withsudo journalctl -u ffmpeg-youtube.service -f. - After changing the unit, run
sudo systemctl daemon-reloadand restart it withsudo systemctl restart ffmpeg-youtube.service.
An active unit means systemd sees its main process running. It does not establish that YouTube accepted the feed or that the output is viewable.
Verify the stream at YouTube and from a viewer’s perspective
- Open the stream in Live Control Room and confirm the preview appears.
- Inspect YouTube’s stream health and warnings rather than relying only on FFmpeg output or systemd status.
- Check that both audio and video are present and that the picture, timing, and quality are acceptable.
- Open the watch page as a viewer and confirm playback works.
- Before depending on automatic recovery, test a controlled process stop or failure and observe whether systemd restarts FFmpeg and YouTube resumes receiving a healthy feed.
YouTube recommends testing before an event and monitoring the stream. A restarted process is not the same as successful recovery of a viewable broadcast.
Troubleshoot common failures
| Symptom | Likely cause | What to check or do |
|---|---|---|
| Unit fails immediately | Incorrect executable or input path, inaccessible files, invalid options, or unavailable encoder | Read journalctl -u ffmpeg-youtube.service; verify paths, permissions, and FFmpeg build support. |
| YouTube does not show a preview | Wrong stream URL or key, expired/reset key, unsupported output, or connection issue | Copy the URL and key from the selected Live Control Room stream; verify the key securely and inspect FFmpeg logs and Live Control Room warnings. |
| Service restarts repeatedly | FFmpeg exits because of a bad input, invalid option, missing resource, or network failure | Inspect recent journal entries and correct the underlying error before retrying. Repeated failures may trigger systemd start-rate limiting. |
| Unit is active but viewers see no usable stream | The process is running but YouTube is not receiving a healthy feed, or the media has invalid/missing audio or video | Check Live Control Room preview and health, inspect the output’s audio/video mapping, and verify the watch page. |
| Dropped frames or unstable delivery | Bitrate exceeds sustained upload capacity, or the host cannot encode fast enough | Compare the chosen settings with YouTube’s guidance, test upload capacity, and check CPU usage. Reduce the target or use stream copy if the source already matches the needed output. |
| Service will not restart after a manual stop | Restart=on-failure does not restart an intentional stop |
Start it explicitly with sudo systemctl start ffmpeg-youtube.service. |
Or let it run in the cloud
If your goal is a YouTube channel that loops uploaded videos continuously, StreamNeo is an alternative to maintaining FFmpeg and a Vultr service yourself. Upload a recording or build a playlist, add your YouTube stream key once, and go live. StreamNeo runs the loop in the cloud, so no computer or home connection has to stay on. It streams uploaded videos to YouTube, not from a camera.
Quick Recap
- Any quality up to 4K 60fps as uploaded, at one flat price per slot; no re-encode or quality tiers.
- Automatic recovery if YouTube drops the stream.
- The first day is free with no card. Monthly: $9.99 per month.
See StreamNeo or start the free first 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.

