Installing FFmpeg on an Ubuntu VPS is a short apt task; making a prerecorded gaming video behave like a live YouTube broadcast is a separate setup. You need to verify the installed build, upload the video, copy the current YouTube ingest details, and test real-time pacing and loop behaviour before relying on a rerun.
The commands below are a starting point, not a guarantee that every file or VPS will stream cleanly. Ubuntu package versions vary by release, YouTube settings can change, and repeated media can produce timestamp problems.
Update apt and install FFmpeg
Connect to the VPS over SSH using an account with sudo access. Refresh apt's package index, then install the distribution's FFmpeg package:
sudo apt update
sudo apt install ffmpeg
APT checks the configured Ubuntu repositories and offers the package available for that release. Accept the package manager's proposed installation after reviewing the changes. You do not need to add an unrelated repository just to follow this basic route. Ubuntu documents its package-management process in the Ubuntu Server documentation.
These two commands do not configure YouTube, upload your video, or create a live broadcast. They only install FFmpeg and its package dependencies. Keep that distinction clear when troubleshooting: a successful installation is evidence that the command-line tool is available, not that your channel is eligible or your VPS can sustain the stream.
If apt reports that it cannot find the package, check that the VPS is actually running Ubuntu, that its repositories are configured, and that sudo apt update completed without repository errors. Avoid copying package versions or repository commands written for another Ubuntu release without checking their relevance to the VPS you rented.
Verify the installed version
Run:
ffmpeg -version
The output identifies the installed FFmpeg version and build configuration. Ubuntu's package build depends on the Ubuntu release, so a version number shown on one server does not apply to every VPS. For example, the Ubuntu Noble manual documents the Noble package, but an older or newer release may package a different build. Check the Ubuntu FFmpeg manual alongside your own command output rather than assuming that a tutorial's version is universal.
You can also confirm that the shell can locate the executable with command -v ffmpeg. If the version command fails, resolve that installation problem before uploading a large recording or configuring YouTube. If it succeeds, note that FFmpeg builds can differ in available codecs and options; your own build's help output and the installed manual are more relevant than a command copied without context.
It is useful to keep this output with your deployment notes. If a later update changes behaviour, you can distinguish a change in the media file or command from a changed FFmpeg package. Do not treat the version string as a quality score: what matters here is whether the build supports the options and encoders you intend to use.
Upload the gaming video to the VPS
Copy the recording to a directory you can read as the account that will run FFmpeg. For example, from your own computer you might use scp to send gameplay.mp4 into a directory under your home folder. The exact command depends on your local operating system, SSH username, hostname and chosen destination, so substitute those values rather than treating this illustration as a literal command:
scp gameplay.mp4 username@your-vps:/home/username/videos/
Then connect to the VPS and check that the file exists and that the path is spelled correctly. Use ls -lh /home/username/videos/gameplay.mp4 to inspect the file name and size. Spaces and capital letters matter in paths; quote a path containing spaces when using it in a shell command.
Before streaming, inspect the media streams with ffmpeg -i /home/username/videos/gameplay.mp4. FFmpeg will print information about the video and audio streams. This helps you catch a missing audio track, unexpected dimensions, or an input that is not the file you meant to upload. The command may finish with a non-zero status because it was asked to inspect rather than transcode; read the printed stream details rather than interpreting that alone as a failed upload.
A gaming rerun can contain long quiet sections, menu screens, or changes in motion. Check the beginning, a representative gameplay segment, and the ending locally before sending it live. If you need to standardise framing, see the practical discussion of keeping aspect ratios consistent in an FFmpeg YouTube stream. That is a separate media-preparation decision; do not add scaling or cropping filters until you know what the source contains and what output you want.
The VPS must have enough free storage for the upload and enough processing capacity for the chosen output. A file that uploads successfully can still be difficult to encode in real time on a small VPS. The later test run is where you find out whether the selected settings fit the actual machine.
Get the current YouTube ingest URL and stream key
In YouTube Studio, open the Live Control Room and create or select the broadcast you intend to use. Copy the server URL and stream key shown for that stream. YouTube's encoder setup instructions state that the encoder needs the YouTube Live server URL and stream key to start sending video.
Treat the key like a password. It directs an encoder's feed to your broadcast, so do not paste it into a public tutorial, a screenshot, a shared shell history, or a script stored in a public repository. Keep the credentials private and use the current values from Studio rather than reusing a key found in an example or an old note. This article deliberately uses placeholders, not a real or reusable credential.
YouTube's stream key and server URL are destination settings, while FFmpeg's input path and codec choices are local encoding settings. If Studio does not show an active stream or the wrong broadcast is selected, a technically valid FFmpeg command can still send the feed somewhere you did not intend. Check the scheduled event and its destination before pressing Enter. If you have several broadcasts, this guide to finding which scheduled broadcast is using an RTMP stream key can help you think through the association.
Also check that the channel can go live. YouTube lists channel verification, absence of recent live-streaming restrictions and a minimum age requirement among its eligibility conditions; consult the current YouTube live-streaming requirements rather than relying on an old checklist. Eligibility problems are not fixed by changing FFmpeg flags.
For a one-off test, keep the destination information close at hand but private. Do not leave a command containing the key in a place other people can read. A protected configuration method or a private shell environment can reduce accidental exposure, though you should still review permissions and avoid printing secrets into logs.
Build a real-time FFmpeg output command
A prerecorded file normally plays as fast as the machine can decode it unless you tell FFmpeg to read it at its native rate. The -re input option paces reading in real time, so a recording does not simply race through and end immediately. For a YouTube RTMP-style destination, an illustrative command is:
ffmpeg -re -i /home/username/videos/gameplay.mp4 \\
-c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k \\
-pix_fmt yuv420p -g 60 -c:a aac -b:a 128k \\
-f flv 'rtmps://YOUTUBE_INGEST_URL/STREAM_KEY'
This is a template for explaining command structure, not a recommended universal profile. Replace the file path and destination with your own values, using the exact server URL and key supplied by YouTube. The quoted destination illustrates where those values go; it is not a working URL, and you must not publish a filled-in command containing your key.
The input option -re appears before -i, because it applies to reading that input. The codec options configure the output video and audio. -f flv selects the output container used by this RTMP-style pattern. The Ubuntu FFmpeg manual documents real-time input pacing and FLV output patterns; use the FFmpeg manual and the destination YouTube gives you, rather than assuming a generic RTMP address is interchangeable.
The sample's bitrate, buffer, pixel format, GOP setting, preset and audio rate are examples only. Select codec, resolution, frame rate, keyframe interval and bitrate together, based on YouTube's current guidance, the source, the VPS encoder capability and the available outbound capacity. YouTube's live encoder settings vary recommended bitrate by codec, resolution and frame rate. Recheck the current page before choosing settings; a recommendation is not proof that a particular VPS can encode or upload at that rate.
For instance, if your recording is 1080p60, do not simply preserve that output because the source has it. Check whether the VPS can encode those frames in real time and whether its connection can sustain the output with headroom. Lowering output resolution or frame rate can reduce processing and upload demands, but it changes the viewing experience. A local render test can reveal whether the CPU is falling behind before you put the channel live.
Use RTMPS if the current YouTube-provided ingest option supports it, as YouTube recommends secure ingest. Keep an eye on the full command before running it: a mistyped path, a missing audio stream or a destination copied from the wrong event can each produce a different failure. If you need a continuously scheduled channel rather than a gaming rerun, the VPS radio-stream workflow covers a related always-on use case, though its media and scheduling needs may differ.
Test looping and timestamp behaviour
To repeat a file, FFmpeg offers input looping with -stream_loop -1, where the negative count requests indefinite looping. A basic test shape is:
ffmpeg -re -stream_loop -1 -i /home/username/videos/gameplay.mp4 \\
-c:v libx264 -preset veryfast -c:a aac -f flv 'YOUR_PRIVATE_YOUTUBE_DESTINATION'
Do not interpret “indefinite” as a promise that the stream will continue without a hiccup. FFmpeg's loop documentation warns that repeating input does not necessarily rewrite source timestamps, and looping can result in non-monotonic timestamps. The details depend on the input, options and installed build. The FFmpeg filter manual describes the same timestamp caveat for its loop filter; test the exact method you plan to use with your version rather than assuming that input looping and filter looping behave identically.
A sensible test is to send the loop to a private or unlisted test broadcast where you can inspect the stream, then watch beyond the point where the file restarts. Read the FFmpeg output around the boundary for timestamp warnings, observe whether audio and video remain in sync, and check YouTube's stream-health indicator. A short test that ends before the loop point tells you nothing about the transition.
If you see timestamp warnings or the output stalls at the boundary, do not suppress the message and call the problem solved. Try a different loop strategy or timestamp handling only after understanding what it changes, then test again with the same media and destination conditions. Some files have irregular timestamps or variable frame timing, and changing timestamps can have side effects. There is no single flag that makes every gaming recording loop cleanly.
An edit that joins the final and first moments into a continuous file can sometimes be a more predictable editorial choice than repeatedly looping an awkward cut, but it also requires testing and may take extra preparation. Think about what viewers will see: a loading screen or abrupt return to a menu can be more noticeable than a technical warning. For another example of how looping behaves in a continuous YouTube context, see looping music in a church's continuous live stream; the media is different, but the need to test the actual repeat point is relevant.
Monitor the first live run
Start with a supervised test, not an unattended overnight run. Open the broadcast in Live Control Room, run the command, and confirm that YouTube receives a picture and audio. Watch the beginning, let the file reach its loop boundary if you are testing repetition, and check the stream-health feedback. A command that remains open in the terminal is not by itself proof that viewers are receiving a healthy feed.
Watch the VPS as well. If CPU use stays high or FFmpeg reports that it cannot keep pace, the selected encoding settings may exceed the machine's capacity. If output drops or YouTube reports connection trouble, compare the bitrate with the VPS's sustained outbound capacity and leave headroom rather than aiming at the apparent maximum. YouTube recommends checking connection capacity and testing with similar movement and audio to the intended stream; a static desktop test is not representative of gameplay footage.
Check the audio as well as the image. A silent or clipped game recording can be faithfully streamed by a technically correct command. Listen on a separate viewer device if possible, because the encoder's own terminal output will not tell you whether the mix sounds acceptable. Keep a note of the time and any error text if you need to diagnose a restart or reconnect.
A VPS process can stop when the SSH session closes unless it is run under a suitable session manager or service arrangement. Decide how you will supervise and restart it before treating the setup as unattended. If maintaining a Linux process, credentials, logs and recovery routine is more work than you want to own, StreamNeo removes the need to leave your own computer running or nurse a VPS process: you upload the video once, provide the current YouTube stream key, and the broadcast runs in the cloud with monitoring and automatic restart if it drops. It is YouTube-only, so check that it fits your channel and workflow.
After a clean test, document the input path, output settings and recovery steps without documenting a public copy of the key. Recheck the destination when you change broadcasts, and repeat the test if you change the file, codec, FFmpeg package or VPS. An overnight rerun is a different operating commitment from a command that works for a few minutes.
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 the same FFmpeg version come with every Ubuntu release?
No. The package version depends on the Ubuntu release and its configured repositories. Run ffmpeg -version on the VPS you will actually use, and consult documentation for that release when checking option details.
Can I use a fixed YouTube stream key from an example?
No. Get the current server URL and stream key from the relevant broadcast in YouTube Studio. Keep the key private, and do not reuse a credential copied from someone else's command or a public example.
Will -stream_loop -1 guarantee a clean, endless rerun?
No. It requests repeated input, but timestamp behaviour, the media file, the installed FFmpeg build and connection stability all matter. Test across the loop boundary and monitor the output instead of assuming it will run uninterrupted.
What should I check if YouTube does not receive the stream?
Confirm that the channel is eligible to stream, the correct broadcast is open, and the current ingest URL and key are private but correctly entered. Then check the local file path, FFmpeg output, codec settings and VPS network capacity; change one likely cause at a time so the result is interpretable.