October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober 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

Best Free FFmpeg Scripts for Looping Sleep Sounds on YouTube Live

Use FFmpeg’s infinite input loop to run sleep sounds on YouTube Live. Learn the script, encoder settings, testing steps and common fixes.

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

To loop a sleep-sound video from a file on disk, use FFmpeg’s -stream_loop -1 before that file’s -i, then send the output to YouTube over RTMPS. Use -re to read the file at real-time pace. The examples below show a starting point for a video that already contains its sound, plus the decisions to make when you need to combine separate audio and visuals.

Before you start: check channel access and prepare your stream

  • Install FFmpeg and check the version with ffmpeg -version. FFmpeg documentation is regenerated nightly, so if an option behaves differently on your system, compare it with the local ffmpeg -h full output.
  • YouTube says live streaming requires a verified channel, no live-streaming restrictions in the previous 90 days, and a streamer who is at least 16 years old. See YouTube’s live-streaming requirements.
  • In YouTube Studio’s Live Control Room, create or schedule a stream and select the encoder workflow. Copy the server address and stream key shown for that stream; use the current values shown in your account rather than assuming a fixed ingest address.
  • Keep the stream key private. Don’t commit it to a script or share it in logs, screenshots or chat. The commands below use placeholders; replace them locally with the server address and key from the Live Control Room.
  • Use audio and visuals you have permission to stream. This guide does not establish YouTube’s copyright or monetization treatment of sleep-sound streams; check the rights attached to your specific recordings and YouTube’s applicable policies.

Loop a video file that already contains the sleep sounds

If one file contains both the intended visual and audio, this is the simplest setup. The command explicitly selects the first video and audio streams, loops the input indefinitely and reads it at real-time pace.

ffmpeg -stream_loop -1 -re -i "sleep-scene.mp4" 
  -map 0:v:0 -map 0:a:0 
  -c:v libx264 -pix_fmt yuv420p 
  -c:a aac -b:a 128k -ar 44100 
  -g 60 -f flv "rtmps://YOUR_INGEST_ENDPOINT/YOUR_STREAM_KEY"

Replace the filename and RTMPS address with your own. FFmpeg options generally apply to the next input or output, so keep -stream_loop -1 and -re before the input they configure. The example transcodes video and audio; it is illustrative, not a tested universal script. Its -g 60 is a two-second GOP only if the output is 30 fps. If your output frame rate differs, choose the GOP accordingly.

Protect the stream key in a shell variable

For a shell session, you can keep the key out of the command text you save in a script by placing the full URL in an environment variable. Restrict access to the shell history and environment where appropriate; environment variables are not a substitute for a secret manager on a shared system.

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.
export YOUTUBE_RTMPS_URL='rtmps://YOUR_INGEST_ENDPOINT/YOUR_STREAM_KEY'
ffmpeg -stream_loop -1 -re -i "sleep-scene.mp4" 
  -map 0:v:0 -map 0:a:0 
  -c:v libx264 -pix_fmt yuv420p 
  -c:a aac -b:a 128k -ar 44100 
  -g 60 -f flv "$YOUTUBE_RTMPS_URL"

Choose stream copy or transcoding

Use transcoding when the source needs a different codec, frame size, frame rate, audio format or filter. It gives you conversion and filtering options, but uses processing power and can affect quality. The earlier command is a transcoding example.

Stream copy avoids decoding and re-encoding, preserving the encoded streams without an additional quality loss from encoding. It is efficient, but only works when the source streams suit the output container and YouTube’s ingestion settings; it cannot apply filters. If you want to try it with a compatible source, replace the codec options with:

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.
-c copy

For example, keep the loop, pacing, input, explicit maps and RTMPS output from the first command, but use -c copy instead of the -c:v and -c:a encoder options. If YouTube does not accept the resulting stream, check the source codecs and output compatibility, then transcode to supported settings.

Match the output to YouTube’s current encoder guidance

YouTube’s live encoder settings guidance, accessed October 3, 2026, lists the following requirements and recommendations. The page’s bitrate figures are ingestion recommendations, not guarantees or a universal bitrate for every source and connection.

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.
Setting YouTube guidance What to check in your stream
Ingest protocol RTMP or RTMPS; YouTube recommends RTMPS for encrypted delivery into and through Google’s servers. Use the RTMPS address supplied for your stream when available.
Video codec H.264, H.265 (HEVC) or AV1. Check the codec produced by your chosen encoder or preserved by stream copy.
Frame rate Up to 60 fps. Use an output frame rate supported by the Live Control Room and ensure GOP length matches it.
Keyframe interval Recommended: 2 seconds; do not exceed 4 seconds. The sample’s -g 60 is two seconds only at 30 fps. Set GOP and frame rate together.
Audio codec AAC or MP3. 5.1 audio over RTMP/RTMPS is supported only for AAC. The sample converts audio to AAC.
Bitrate mode CBR. The sample does not explicitly set a video bitrate or CBR mode. Consult YouTube’s current resolution, frame-rate and codec table, then set options that suit your chosen output and reliable upload capacity.
Audio sample rate 44.1 kHz stereo; 48 kHz for 5.1. The sample requests 44.1 kHz. Check the source channel layout and select settings for the intended output.
Stereo audio bitrate 128 Kbps. The sample requests 128k for audio.

For H.264, the page lists 1080p30 at 5 Mbps minimum and 14 Mbps recommended, and 720p30 at 3 Mbps minimum and 8 Mbps recommended. YouTube’s AV1 and H.265 rows give different values. Use the table for your codec, resolution and frame rate instead of treating one figure as right for every stream.

Use separate audio and visual files

If your sleep sounds are in an audio file and you want a separate visual, the inputs must both loop and the output must include a compatible video stream. The exact command depends on the files and desired visual treatment. A static image, a gently animated video and a generated visual are different setups; this guide does not present one untested command as universally suitable for all of them.

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
  • For a visual video file that already contains the desired look, map the audio and video streams you intend to use. If the audio file is separate, loop that input too, and verify the output duration and synchronization before going live.
  • For a static image paired with audio, the image must be supplied as video output rather than relying on an audio-only stream. Choose a frame rate and compatible encoding settings, and test the resulting stream in the Live Control Room.
  • For an audio-only file, do not assume a standalone audio stream will be accepted by your chosen YouTube live workflow. Provide a compatible visual stream unless you have verified that the specific destination accepts the stream shape you plan to send.

An FFmpeg-user discussion from 2020 includes an individual suggestion about silent audio with a static-image stream, but it is dated community advice, not proof of a universal YouTube requirement or an official sleep-sounds workflow: the discussion.

Preflight the stream, then monitor it while live

  1. Confirm that the media plays locally and contains the intended audio and visual tracks. Use explicit -map options when the input has multiple tracks so an unintended track is not selected.
  2. Check the output settings against the current Live Control Room options and YouTube’s encoder guidance. Confirm the codec, resolution, frame rate, keyframe interval, bitrate mode, audio codec and sample rate.
  3. Run a private or unlisted test stream if appropriate for your channel, using representative audio and visual movement. YouTube recommends a preflight test and an upload-speed check.
  4. Watch stream health in the Live Control Room during the test and the live session. Monitor FFmpeg’s output and available upstream bandwidth as well.
  5. Confirm the loop returns to the start cleanly, with no unintended gap or abrupt change that makes the sound unsuitable for your stream.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common looping and live-stream problems

Symptom Likely checks What to do
The file plays once and stops. Check whether -stream_loop -1 is before the input’s -i. Move the option before the relevant input. FFmpeg options generally apply to the next input or output.
The stream runs too quickly or YouTube reports unstable delivery. Check whether a file input is being read at real-time pace and whether upload capacity is reliable. Use -re on file input for real-time pacing and test upload speed. FFmpeg cautions against low read rates on actual capture devices or live streams, where packets may be lost.
YouTube reports an unsupported or unhealthy stream. Check the Live Control Room diagnostics, codec, container compatibility, bitrate mode, resolution, frame rate, keyframe interval and audio settings. Compare the actual output with YouTube’s current guidance; change the settings or transcode if the source is incompatible.
The picture or sound is wrong or missing. Check the input’s available streams and the -map selections. Map the intended audio and video streams explicitly. If the source lacks a visual, supply a compatible visual source for the chosen live workflow.
Encoding stalls or the stream disconnects. Review FFmpeg logs, CPU headroom, upstream bandwidth, YouTube’s stream-health diagnostics, timestamps and whether the input loop returns cleanly. Reduce processing load or output demands if resources are constrained, correct timestamp or compatibility issues shown in logs, and test again. These are diagnostic checks, not a guarantee that any one cause applies.

A 2022 FFmpeg-user post describes one person’s looping YouTube setup and reports CPU pressure and stream-health trouble. Treat it as an anecdotal troubleshooting prompt, not evidence that its flags are optimal or that the same fault is typical: the post.

Free tools Windows power users keep installed

One-click scans. No signup required.

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.

Or let it run in the cloud

If you want the stream to continue without a home computer running, StreamNeo is an alternative for keeping a YouTube channel live from uploaded videos. Upload a recording or build a playlist, add your YouTube stream key once, and go live; StreamNeo loops it in the cloud. Nothing has to stay on at home. Any quality up to 4K 60fps streams as uploaded at one flat price per slot, with automatic recovery if YouTube drops the stream. The first day is free with no card.

Monthly: $9.99 per month. See StreamNeo or its pricing. Start your free first day with StreamNeo.

Frequently Asked Questions

Does FFmpeg keep looping if my computer is shut down?

No. A local FFmpeg process needs the computer running; for a stream that continues without a home computer, use a cloud-based workflow.

Can I use any sleep-sound recording?

Only use recordings whose rights permit your intended YouTube livestream. This guide does not determine the licensing terms for a particular recording.

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

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 *

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.