Skip to content
streamneo.
Use Cases14 min read

FFmpeg Command for Looping a 4K 60fps Video to YouTube Live

A practical FFmpeg template for looping a 4K 60fps video to YouTube Live, with bitrate, testing, monitoring and failure planning.

sn.
StreamNeoPublished 4 October 2026
Worth sharing?

A prerecorded 4K 60fps file can be looped to YouTube Live with FFmpeg by repeating the input, pacing it in real time, encoding it at 3840×2160 and 60fps, and sending the result to the event’s ingest URL and stream key. The command below is a starting template, not a guarantee that a particular computer or connection will run continuously.

The important choice comes before the command: decide whether you are sending a finished recording or producing a live feed. Looping works for a finished file. It does not replace a production system for cameras, presenters, changing scenes or live audio.

Choose between a prerecorded file and a live feed

A prerecorded playout is the simpler case. You have a finished video, perhaps a devotional programme, an ambience loop, a lecture or a sequence of local updates, and want FFmpeg to send it repeatedly. The encoder reads the file, converts it to the required output format and hands the stream to YouTube.

A live production feed is different. Its input may be a camera, a microphone, a screen capture, an OBS scene or several sources mixed together. In that situation, FFmpeg may be used as the final encoder or relay, but -stream_loop -1 is not the solution. There is no finished file to repeat, and the priority is keeping the production input available and correctly timed.

This distinction also affects failure recovery. A prerecorded file can often be restarted from the beginning or from a known playlist position. A live feed may need its capture device, scene collection, audio mixer and source connections restored before the encoder can resume.

For a channel that plays the same completed programme repeatedly, start by checking whether the file already has the correct frame rate, dimensions, audio and colour characteristics. If it does not, FFmpeg can convert them, but every conversion adds work for the computer. A 4K60 conversion is substantially more demanding than sending a compatible file without scaling or frame-rate conversion.

If you are combining several recordings, first decide how they should be joined. The guidance in how to mix gaming VODs in one YouTube Live stream is relevant to the editorial problem of combining files, even though the source material may be different.

Select a continuous-stream workflow

There are three practical ways to approach a continuous YouTube channel.

Workflow What it does Main advantage Main limitation
FFmpeg on your own computer Reads and encodes the file locally, then uploads it Direct control and no separate playout service The computer, power and connection must remain available
FFmpeg on a rented machine Runs the same type of process away from your desk Useful when your home connection or computer is unsuitable You still need to manage the machine, process and recovery
Cloud file playout Uploads the file and keeps the broadcast running away from your computer Removes the need to leave a local encoder running You must check the service’s supported resolution, codec, audio and YouTube workflow

The local FFmpeg route is attractive when you already have a suitable computer and want to inspect every setting. It is less attractive when the machine is also used for work, sleeps after inactivity, receives automatic updates or is connected through a network that changes overnight.

A rented machine can run unattended, but it does not remove operational responsibility. You still need to confirm that the virtual machine can encode 4K60 in real time, that its upload path is suitable, and that the process starts again after a fault. A machine being powered on is not the same as a stream being healthy.

Cloud file playout is a different operating model. For a finished video, StreamNeo removes the need to keep your own computer running by taking the uploaded file and continuing the YouTube broadcast with automatic monitoring and restart behaviour. You still need to prepare the file, supply the correct YouTube credentials and inspect the live event before relying on it.

If you are comparing local and rented machines, see the practical considerations in the best VPS setup for a 24/7 children’s story stream. For an India-based operation, the low-cost setup for a recorded coaching stream covers many of the same decisions about leaving equipment and connectivity running.

Whichever workflow you choose, keep the source file, the command or configuration, the event details and the recovery instructions together. Do not store a live stream key in a public article, shared screenshot or shell history that other people can access.

Use a 4K60 FFmpeg template

The following command is for a standard dynamic-range H.264 stream from a local file that already contains audio. Replace the filename, ingest URL and stream key with the values for your own YouTube Live event.

ffmpeg -re -stream_loop -1 -i "input.mp4" \
  -map 0:v:0 -map 0:a:0? \
  -vf "scale=3840:2160:force_original_aspect_ratio=decrease,pad=3840:2160:(ow-iw)/2:(oh-ih)/2" \
  -r 60 -c:v libx264 -pix_fmt yuv420p -preset veryfast \
  -b:v 50M -maxrate 50M -bufsize 100M -x264-params "nal-hrd=cbr" \
  -g 120 -keyint_min 120 -sc_threshold 0 \
  -c:a aac -b:a 128k -ar 44100 \
  -f flv "<YOUTUBE_INGEST_URL>/<STREAM_KEY>"

-stream_loop -1 asks FFmpeg to repeat the input indefinitely. The -re option paces file input at its normal playback rate rather than allowing FFmpeg to read as fast as the computer can process it. These are separate requirements: repeating a file does not by itself make the output behave like a live stream.

The video filter scales the image to fit within 3840×2160 and pads the remaining space. It preserves the source aspect ratio, so a non-16:9 file may acquire bars. Inspect this result before broadcasting. If you want a crop rather than bars, that is a different framing decision and should be tested with the actual content.

The optional audio map prevents FFmpeg from failing at the mapping stage when the file has no audio stream, but it does not solve YouTube’s audio requirement. YouTube’s live ingestion checks can report a missing audio stream. For a silent programme, add a deliberate audio source or create a file with a suitable silent track, then test the resulting stream.

Confirm that your FFmpeg build includes libx264 before using this example. The FFmpeg documentation explains the command-line model and options, but it cannot establish whether a particular computer can encode this workload in real time.

Use the RTMPS ingest address supplied for the event where possible. The final combined form is an ingest URL followed by the stream name or key, but the placeholder in the example is not a URL to copy. YouTube’s Live Broadcast API documentation describes the event and stream resources, including the relationship between a broadcast and its ingest settings.

Configure 2160p60 ingest settings

For the English YouTube Help page reviewed for this article on 3 October 2026, the stated H.264 recommendation for 2160p at 60fps is 50 Mbps, with 14 Mbps listed as the minimum. The template therefore uses a 50 Mbps video rate. YouTube also lists H.265 and AV1 for this class of ingest, with a 35 Mbps recommendation on that page, but the most suitable codec depends on support in your FFmpeg build, available hardware encoding capacity and the requirements of your workflow.

Setting Template value Why it matters
Output size 3840×2160 The 2160p target commonly called 4K
Frame rate 60fps Matches a 4K60 output rather than merely looping the source
Video codec H.264 Broadly practical for this example and listed by YouTube
Video rate 50 Mbps YouTube’s listed H.264 recommendation for 2160p60 on the reviewed page
Rate control CBR-style settings Keeps the outgoing rate more predictable
Keyframes Every 120 frames At 60fps, this represents two seconds
Maximum keyframe interval Four seconds YouTube’s stated maximum, so do not exceed it
Audio AAC, 128 kbps, 44.1 kHz Stereo values listed by YouTube’s guidance
Pixel format yuv420p A common SDR H.264 output format

The -g 120 and -keyint_min 120 values set the keyframe spacing for a 60fps output. -sc_threshold 0 prevents scene changes from shortening the intended interval in this example. YouTube recommends a two-second keyframe frequency and states a maximum of four seconds, so verify the actual encoder output rather than assuming the command has been accepted as intended.

The command is for SDR. The reviewed YouTube guidance recommends Rec. 709 and 8-bit video for SDR. HDR introduces different colour and codec considerations, so do not use this template as an HDR configuration without checking the current YouTube requirements and testing the complete signal path.

YouTube Help pages can vary by locale or change over time. The research for this article found a different 4K60 H.264 range in another official page variant. Before broadcasting, compare the current table in YouTube’s live encoder settings guidance with the settings shown in Live Control Room. Do not combine figures from different page variants without checking which guidance applies to your event.

The bitrate is an ingest setting, not a promise that viewers will receive 4K. YouTube creates delivery versions according to its own processing and the viewer’s device, connection and selected quality. You cannot guarantee viewer-side 4K playback by choosing 3840×2160 at the encoder.

Check encoding and upload capacity

A 50 Mbps video setting needs more upload capacity than the number alone suggests because audio and transport overhead are additional. YouTube advises running an upload speed test, but the reviewed guidance does not specify a universal overhead margin that makes every connection safe. Leave practical headroom rather than treating a speed-test result equal to 50 Mbps as comfortable.

The computer must also encode faster than real time. When FFmpeg prints its progress, watch the reported speed. If it repeatedly falls below real time, the output will eventually lag or the ingest may starve. A process that remains open in a terminal is not proof that frames are arriving at YouTube.

The veryfast preset is only a starting point. A slower preset may improve compression efficiency but requires more processing. A faster preset may reduce CPU demand while producing a larger or less efficient encode at the same visual quality. Test the actual machine with representative movement, not a mostly static opening frame.

Scaling from another resolution, converting frame rate, applying filters and encoding audio all consume resources. If the source is already 3840×2160 at 60fps with suitable audio, removing unnecessary filters may reduce work. If the source is 30fps, forcing -r 60 creates a 60fps output but does not create new detail or motion. Check whether duplicated or converted frames are acceptable for the programme.

Hardware encoding can be the better choice when the computer’s CPU cannot sustain software H.264 at 4K60. The exact encoder name depends on the operating system, graphics hardware and FFmpeg build. Do not replace libx264 with an untested hardware encoder and assume the result will have the same rate control, keyframe behaviour or colour output.

Test the full path before broadcasting

Create a separate YouTube Live event for testing and use its own stream key. Run the complete command with the intended file, output resolution, frame rate, audio and ingest protocol. Do not test only the local FFmpeg process.

In Live Control Room, check that YouTube sees the stream, identifies the expected resolution and frame rate, receives audio and reports healthy ingestion. YouTube specifically advises testing before starting a live stream and using movement and audio representative of the planned broadcast. A static test image can hide encoding, audio or timing problems.

Listen at the beginning, middle and loop boundary. Some files have audio that ends slightly before the picture, a discontinuity at the loop point or an audio stream that FFmpeg maps differently from the one you expected. A video can appear correct while YouTube reports a missing or unusable audio stream.

Watch the loop transition. If it produces a flash, silence, abrupt frame or long pause, decide whether that is acceptable for your audience. A seamless loop may require preparing the source file rather than adding more command-line options. For a devotional or ambience channel, a short discontinuity can be more noticeable than it would be in a lecture with frequent cuts.

Test a long enough section to expose heat, memory, upload and timing problems. A short successful connection does not establish that the machine will remain stable overnight. YouTube’s health messages are more useful than assuming success because FFmpeg has not printed an error.

If the channel will be operated from a home connection, test at the time when other people normally use the line. For an India-based household or small office, evening demand, Wi-Fi interference and router changes can matter more than a speed test taken beside an idle connection. Prefer wired networking for the encoder where practical.

Monitor stream health during operation

Keep two views available: FFmpeg’s local progress and YouTube’s Live Control Room health indicators. FFmpeg can show that it is reading and encoding, while YouTube can show whether the ingest is arriving too slowly, has an unsupported format or has a stream characteristic that needs attention.

Check the outgoing resolution, frame rate, codec, audio presence and keyframe behaviour after the event begins. Do not infer the actual result solely from the command. Filters, encoder defaults, source properties and protocol handling can change what reaches the platform.

For 4K, YouTube’s guidance says the low-latency improvement option is unavailable and that these streams use normal latency. That is relevant if you are expecting a near-live conversation with viewers. A prerecorded channel normally values stable playout over the lowest possible delay.

Record the warnings you see during the test. Common areas include unsupported codec or container, no audio, a keyframe interval above the limit, unsupported resolution and video ingestion starvation. Fix one cause at a time so you know which change helped.

Do not use viewer playback as the only health check. A viewer may have a cached segment or may be watching an automatically selected lower quality. Conversely, a viewer’s temporary buffering does not necessarily prove that the encoder has failed. Use YouTube’s ingest status and local process output together.

If you need to compare the running cost and operational burden of keeping your own machine online, the VPS cost guide for a 24/7 rain sounds stream in India provides a useful way to separate connection, machine and maintenance concerns.

Plan for equipment and network failures

A local command depends on more than FFmpeg. The computer needs power, cooling, storage access, a working network interface and a connection that remains available. A power cut, router restart, operating-system update or thermal problem can stop the broadcast even when the command itself is correct.

Use a restart plan rather than relying on memory. Decide how the process should be launched, where logs should be written, how the stream key is protected and who will check the event. If you use a system service or supervisor, test its behaviour by stopping the process deliberately. Confirm that it does not create several competing encoders after a fault.

A backup connection can help with a network outage, but switching connections can also change the route, address or available upload capacity. Test the failover while using a non-production event. Mobile data may have usage limits or variable performance, so do not assume it is equivalent to a fixed connection.

Protect the stream key. If it is exposed, revoke or regenerate it in YouTube and update the workflow. Keep the key out of screenshots, public repositories and shared commands. The event’s ingest URL and stream name should be copied from the intended broadcast rather than reused from an old test.

A recovery plan should state what happens after a short failure and after a long one. You may restart the same event, create a new event or wait for YouTube to process the interruption. The correct choice depends on the channel’s scheduling and audience expectations. None of these steps guarantees uninterrupted operation.

For a setup based on OBS rather than a file-only FFmpeg process, the power-cut guide for OBS streaming in India covers related recovery decisions. The same principle applies here: test the failure path before you need it.

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 -stream_loop -1 guarantee a 24/7 stream?

No. It repeats the input file, but the computer still needs to encode and upload in real time. Power, hardware, software and network failures can stop the process, and YouTube may report an ingest problem even while FFmpeg remains open.

Is 50 Mbps always the correct 4K60 bitrate?

The reviewed English YouTube Help page lists 50 Mbps as the recommended H.264 video bitrate for 2160p at 60fps, with 14 Mbps as its listed minimum. Official page variants can differ, so check the current YouTube guidance and Live Control Room settings for your event before using the value.

Can I loop a 30fps file and call it 4K60?

You can output 3840×2160 at 60fps, but setting -r 60 does not add genuine motion detail to a 30fps source. Test the resulting frame pacing and decide whether duplicated or converted frames are acceptable for the programme.

What if the file has no audio?

The optional audio map in the example allows FFmpeg to continue past the mapping stage, but YouTube expects a supported audio stream for the live ingest. Add a suitable audio or silent track deliberately, then verify audio presence and health in Live Control Room before broadcasting.

YOU’VE REACHED THE END

Keep the ideas coming.

More guides, useful tools and a little help for your next broadcast.

Back to the journal ↗
YOUR NEXT READ

A little more to explore.

More Use Cases guides ↗ · All topics ↗