October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
VGSources
FFmpeg

How to Convert a Video for a Nonstop YouTube Live Stream with FFmpeg

Use FFmpeg’s input loop option to repeat a video into YouTube Live, with encoder settings matched to YouTube’s current guidance and a test-first workflow.

By VGSources Team 7 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To loop a local video into YouTube Live with FFmpeg, put -stream_loop -1 before the input file’s -i, pace it with -re, encode or copy it using settings that match YouTube’s current guidance, and send it to YouTube over RTMPS. Looping and encoding are separate jobs: the loop repeats the file, while the output settings determine the stream’s video, audio, bitrate, and keyframes. This setup can run continuously, but it cannot guarantee an uninterrupted stream; the file, computer, upload connection, stream key, and YouTube’s stream health all matter.

What you need before you start

  • A local video file you have the rights and permission to broadcast.
  • FFmpeg built with the input, encoder, and FLV/RTMPS support your workflow needs. Confirm support in your installed build rather than assuming every build includes the same components.
  • A YouTube Live stream configured in YouTube Studio, with its stream URL and stream key.
  • Stable upload capacity for the stream’s total bitrate, plus spare headroom. YouTube recommends leaving 20% upload headroom.
  • A computer able to encode the chosen resolution and frame rate for the duration of the broadcast, if you are re-encoding.

FFmpeg is software, so this local-file workflow does not require a capture card or dedicated hardware encoder. Before broadcasting, make sure your use of the video and audio complies with YouTube’s rules and that you have the necessary rights; the technical setup does not establish permission to rebroadcast material.

Choose the output settings before building the command

Start with the file’s actual resolution, frame rate, aspect ratio, scan type, and audio. If those already fit your intended stream and YouTube’s supported settings, conversion may not be necessary. Re-encode when you need a different codec, bitrate, frame rate, dimensions, or audio format. Choose the target as a complete set: resolution, frame rate, codec, bitrate, and keyframe interval affect one another.

H.264 bitrate examples published by YouTube

The following are H.264 figures in YouTube Help’s English-language live encoder table. They are technical recommendations, not independent performance-test results. Check the current table before a broadcast because platform guidance can change.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Ingestion resolution and frame rate Minimum video bitrate Recommended video bitrate
1080p at 60 fps 6 Mbps 17 Mbps
1080p at 30 fps 5 Mbps 14 Mbps
720p at 60 fps 3 Mbps 8 Mbps
720p at 30 fps 3 Mbps 8 Mbps

These numbers apply to H.264, not automatically to other codecs. YouTube’s table gives AV1 and H.265/HEVC separate recommendations. For example, it recommends 10 Mbps for 1080p30 and 12 Mbps for 1080p60 with AV1 or H.265, with a 4 Mbps minimum for both cases. Use the row for the codec, resolution, and frame rate you actually select.

Codec, keyframes, and audio

  • Video codec: YouTube’s published encoder settings list H.264, H.265/HEVC, and AV1. For a conventional SDR H.264 stream, its guidance recommends CBR. H.265 is the recommended HDR video codec in that guidance; AV1 is not supported for HDR.
  • Keyframes: YouTube recommends a two-second keyframe interval and says it should not exceed four seconds. In FFmpeg/libx264, -g sets a GOP length in frames; calculate it for your output frame rate. For example, 60 frames is two seconds at 30 fps, but not at other frame rates.
  • Audio: The listed audio codecs include AAC and MP3. YouTube’s settings page gives 128 Kbps for stereo audio and 384 Kbps for 5.1 surround, and specifies 44.1 kHz audio. Confirm the channel layout and bitrate match your source and intended output.
  • Picture format: YouTube’s advanced settings include square pixels, progressive scan, CABAC, and Rec. 709 for SDR. Avoid blindly applying filters: use scaling, frame-rate conversion, or other filters only when the source and target require them.

YouTube says it automatically transcodes live streams into output formats for different viewers. That does not remove the need to send a valid, stable source stream.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

Sources: YouTube Help: Choose live encoder settings, bitrates, and resolutions.

Prepare YouTube Live and protect the stream key

  1. In YouTube Studio, create or open the live stream you intend to use and locate its stream URL and stream key. Exact controls can vary with YouTube’s interface and stream setup.
  2. Use the RTMPS ingest URL where available and supported by your FFmpeg build. YouTube recommends RTMPS; the URL and key are configured in the encoder.
  3. Keep the stream key private. Treat it like a password: anyone who obtains it may be able to send a stream to your channel. Do not publish it in a command screenshot, shared log, or public script.
  4. Check the stream’s visibility and planned start before sending the feed. Use a private or otherwise appropriate test when you do not want the test broadcast shown publicly.

For YouTube’s stream controls and settings, see Manage live stream settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Loop and stream a file with FFmpeg

Inspect the source and choose whether to re-encode

Check the file’s video and audio streams, dimensions, frame rate, and codecs before choosing output parameters. Re-encoding is the flexible option when the source does not match the target. Copying already-compatible streams avoids a new encode, but it does not let you change properties that need to be changed. The command below demonstrates re-encoding video and audio.

Use the loop option before the input

-stream_loop -1 is an input option: place it before the corresponding -i. A value of -1 requests indefinite looping. -re paces file reading in real time, which is useful when sending a file as a live source. The FFmpeg documentation describes the loop option at ffmpeg Documentation.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Illustrative command pattern

ffmpeg -stream_loop -1 -re -i input.mp4 
  -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k 
  -g 60 -c:a aac -b:a 128k -f flv 
  "rtmps://<YouTube-ingest>/<stream-key>"

This is an illustrative starting pattern, not a tested command or a universal YouTube preset. Replace the input, RTMPS destination, key, bitrate, frame rate/GOP, and any needed scaling or audio options. The sample’s 4500k is not a YouTube recommendation and does not match every resolution/frame-rate case in its table. Likewise, -g 60 represents a two-second interval only at 30 fps. Select a GOP length that yields the intended interval at your chosen output frame rate. Confirm that your FFmpeg build supports the selected encoder and can connect to the destination.

Check the result before relying on a long run

  1. Start with a private or otherwise appropriate test and use audio and motion representative of the planned stream.
  2. Check YouTube Studio’s stream health and any messages, as well as the actual picture and sound. YouTube Help says, “Make sure to test before you start your live stream.” Its encoder guidance also advises testing with similar audio and movement and monitoring stream health during the event.
  3. Verify that the file loops cleanly at its end. A visible or audible gap, abrupt cut, or mismatch between the file’s final and first frames comes from the source/edit and may remain on every loop.
  4. Monitor upload stability and system load. The bitrate must fit available upload bandwidth; leave the recommended 20% headroom rather than sizing the connection to the video bitrate alone.

YouTube also provides general streaming tips. Testing and monitoring reduce avoidable problems, but cannot guarantee continuity over an unattended broadcast.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common failures

Symptom Likely cause What to check or change
FFmpeg stops after one play The loop option is missing, misspelled, or placed after the input it should affect. Put -stream_loop -1 before that file’s -i. Confirm the process remains active and the source can be read repeatedly.
YouTube does not receive the stream Wrong stream URL or key, unsupported RTMPS support in the build, or an unavailable connection. Recheck the ingest URL and key in YouTube Studio, keep the key private, verify the local FFmpeg build, and inspect FFmpeg’s connection output.
Stream health warns about bitrate or unstable delivery Configured bitrate exceeds reliable upload capacity, or the connection fluctuates. Choose a bitrate from the current YouTube table for the selected codec and format, and leave upload headroom. If needed, reduce resolution, frame rate, or bitrate together rather than changing one value without checking the table.
Video looks wrong or is rejected Output codec, dimensions, frame rate, keyframe interval, pixel format, scan type, or bitrate does not fit the intended configuration. Compare the output settings with YouTube’s current encoder guidance. Check especially that GOP length corresponds to the target frame rate and that the stream uses an appropriate progressive, square-pixel format.
Audio is silent, distorted, or out of sync Source audio layout or encoding is incompatible with the chosen output, or a loop boundary creates a discontinuity. Test the actual audio before going live; verify AAC/MP3 selection, sample rate, bitrate, and channel layout. Listen across the file boundary as well as during a single pass.
Computer cannot sustain the encode Encoding load, heat, or resource contention is too high for the machine over a long run. Test at the intended output settings for a meaningful period. Consider a faster preset or a lower target format, then recheck picture quality and YouTube’s matching bitrate guidance.

Or let it run in the cloud

If you want a prerecorded video to keep a YouTube channel live without leaving a local computer encoding and uploading, StreamNeo is a cloud alternative. Upload a recording or build a playlist, add your YouTube stream key once, and go live; StreamNeo loops the uploaded video from the cloud. It is for YouTube and uploaded videos, not a camera feed.

  • Nothing has to stay on at home: the stream runs in the cloud, so your computer and home connection do not need to remain on.
  • Any quality up to 4K 60fps as uploaded is included at one flat price per slot, with no re-encode or quality tiers.
  • Automatic recovery is included if YouTube drops the stream.
  • The first day is free with no card, one free day per account. The monthly option is $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.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from Patch Notes

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.