October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Mountain View desk7 min

Best Free FFmpeg Scripts for Looping Sleep Sounds on YouTube Live

Use FFmpeg’s infinite input loop to run sleep sounds on YouTube Live, with practical scripts, YouTube settings and troubleshooting guidance.

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.

For a local video file that already contains your sleep audio, FFmpeg can loop it indefinitely with -stream_loop -1. Put that option before the input’s -i, read the file at real-time speed with -re, explicitly select its audio and video streams, and send the output to YouTube over RTMPS. The script below is a starting point, not a universal preset: match its codecs, bitrate, frame rate and keyframe interval to your source and YouTube’s current encoder guidance.

Before you start

  • Install FFmpeg and check the installed build with ffmpeg -version. FFmpeg’s online documentation is regenerated nightly, so local help such as ffmpeg -h full can be useful if an option behaves differently on your version.
  • Enable live streaming on your YouTube channel. YouTube says a channel must be verified, have no live-streaming restrictions in the previous 90 days, and the streamer must be at least 16 years old. See YouTube’s live-streaming eligibility and setup guidance.
  • Create or schedule the broadcast in YouTube Live Control Room and obtain its stream key and ingest details. Treat the key like a password: anyone with access may be able to broadcast to your channel.
  • Use audio and visuals you have permission to stream. The technical instructions here do not establish whether a particular sleep-sound recording is licensed for continuous livestream use or eligible for monetization. Check the rights attached to each asset and YouTube’s applicable policies.

Loop a video that already contains the sleep sounds

Use this pattern when one file contains both the image and the audio you want to broadcast:

As an Amazon Associate I earn from qualifying purchases.

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"
  1. Replace sleep-scene.mp4 with your file path.
  2. Replace the example RTMPS destination with the ingest endpoint and stream key shown for your broadcast in YouTube Live Control Room. Do not publish a real key in a shared script, repository or screenshot; use a protected environment variable or secret store when practical.
  3. Run the command and watch both the FFmpeg output and YouTube’s stream-health panel. Confirm the preview has the intended picture and sound before relying on the broadcast.

-stream_loop -1 means infinite input looping. FFmpeg options generally apply to the next input or output, so the loop flag belongs before the relevant -i. -re reads a file at its native rate, which is useful when pacing file input for a live output. FFmpeg cautions against low read rates with actual capture devices or live streams, where packets may be lost. The option behavior is documented in the FFmpeg documentation.

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

The explicit maps select the first video and first audio stream. If the file has alternate tracks, inspect it and change the map to the track you intend to use; do not assume the first audio stream is the right one.

#1 Best Overall
Sale
Lexar D40E 128GB Dual USB 3.2 Gen 1 Type-C Jump Drive, Champagne Silver
  • USB-C 2-in-1 storage OTG: The Lexar JumpDrive Dual Drive D40E features USB Type-A and Type-C connectors in a slim, portable form factor for easy device compatibility
  • Transfer speeds up to 100MB/s: Based on internal testing, performance may vary depending upon the host device, interface, and usage conditions. 1MB=1,000,000 bytes
  • Plug and Play: Widely compatible with USB Type-C smartphones, tablets, laptops, Macs, and traditional Type-A devices, no software installation required. The 360° swivel design allows for easy switching between connectors without the hassle of losing a cap
  • Durable & Compact: The Lexar D40E USB memory stick features a metal enclosure, withstands temperatures from 0° to 50° C (32°F to 122°F), and is lightweight at 26g with dimensions of 70.4 x 16.9 x 11.7mm
  • Security & Warranty: Securely protects files using an advanced security software solution with 256-bit AES encryption. Backed by a Lexar 3-year limited warranty

Choose stream copy or transcoding

The example transcodes video to H.264 and audio to AAC. That provides control over output format, but encoding uses compute and may change quality. If the file’s existing codecs and stream properties already suit YouTube and the output container, stream copy can avoid decoding and re-encoding. Copying cannot apply filters, resize or convert the media, and may fail when the source is incompatible with the target output.

Approach Use it when Trade-off
Stream copy The existing encoded audio and video are compatible with the output container and the settings accepted for your YouTube stream. Fast and preserves encoded media without another quality-loss generation, but offers no filtering or conversion and may be incompatible with the output.
Transcoding You need to convert codecs, adjust output properties, or apply filters. Offers more format control, but consumes processing capacity and can affect quality.

For a compatible source, a copy variant replaces the encoder options with -c:v copy -c:a copy while keeping the input, maps and output destination. Compatibility is not guaranteed by the filename or container alone; test the actual output and YouTube preview before using it for a long session.

Rank #2
SANDISK 128GB Ultra Flair, USB-A Flash Drive, Up to 150MB/s Read Speeds | USB Flash Drive, Up to 15x Faster than standard 2.0, Password Protection, Durable, Sleek Metal Casing, USB 3.0, Silver/Black
  • High-speed USB 3.0 performance of up to 150MB/s(1) [(1) Write to drive up to 15x faster than standard USB 2.0 drives (4MB/s); varies by drive capacity. Up to 150MB/s read speed. USB 3.0 port required. Based on internal testing; performance may be lower depending on host device, usage conditions, and other factors; 1MB=1,000,000 bytes]
  • Transfer a full-length movie in less than 30 seconds(2) [(2) Based on 1.2GB MPEG-4 video transfer with USB 3.0 host device. Results may vary based on host device, file attributes and other factors]
  • Transfer to drive up to 15 times faster than standard USB 2.0 drives(1)
  • Sleek, durable metal casing
  • Easy-to-use password protection for your private files(3) [(3)Password protection uses 128-bit AES encryption and is supported by Windows 7, Windows 8, Windows 10, and Mac OS X v10.9 plus; Software download required for Mac, visit the SanDisk SecureAccess support page]

Use a separate audio file with a visual

If your sleep sounds are in an audio-only file, YouTube’s live encoder guidance describes audio and video codecs, but the sources here do not establish a universal audio-only workflow or a universal requirement for silent audio. A practical setup is to pair the audio with a video file or a generated/static visual source, then map the chosen audio and video explicitly.

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

Audio file paired with a video file

When a video file supplies the visual, place the audio file as the second input and map its intended track. For example, the input and map portion can be:

Rank #3
2 Pack 64GB USB Flash Drive USB 2.0 Thumb Drives Jump Drive Fold Storage Memory Stick Swivel Design - Black
  • What You Get - 2 pack 64GB genuine USB 2.0 flash drives, 12-month warranty and lifetime friendly customer service
  • Great for All Ages and Purposes – the thumb drives are suitable for storing digital data for school, business or daily usage. Apply to data storage of music, photos, movies and other files
  • Easy to Use - Plug and play USB memory stick, no need to install any software. Support Windows 7 / 8 / 10 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, compatible with USB 2.0 and 1.1 ports
  • Convenient Design - 360°metal swivel cap with matt surface and ring designed zip drive can protect USB connector, avoid to leave your fingerprint and easily attach to your key chain to avoid from losing and for easy carrying
  • Brand Yourself - Brand the flash drive with your company's name and provide company's overview, policies, etc. to the newly joined employees or your customers
ffmpeg -stream_loop -1 -re -i "visual.mp4" 
  -stream_loop -1 -re -i "sleep-sounds.wav" 
  -map 0:v:0 -map 1:a:0 
  ...

The ellipsis is not a runnable command: append the encoder and RTMPS output options from the earlier example, adapting them to your files. Here the first input supplies video and the second supplies audio. Check that the two assets loop as intended and that audio remains present in YouTube’s preview.

Audio paired with a generated or static visual

A generated visual requires a video source or filter in addition to the audio input; the first example is not a complete audio-only-to-YouTube recipe. Choose a visual treatment and compatible video settings, then map that video and the intended audio. An FFmpeg-user discussion from 2020 describes one person’s approach to a static-image stream, but it is dated community advice, not proof of an official universal rule: the discussion.

Rank #4
Sale
SIMMAX 32GB Memory Stick USB 2.0 Flash Drives Swivel Thumb Drive Pen Drive (32GB Purple)
  • GOOD VALUE PACKAGE - 1 Pack 32GB Memory Stick USB 2.0 Flash Drives with great cost performance and high quality.
  • BIG CAPACITY - The available capacity: 29.10GB-29.8GB, You can save the data of movies, music, photos, designs, programs, manuals, handouts in a high speed.Good performance in digital data storing, transferring and sharing with families, friends, workmates, clients and machines.
  • EASY TO USE & PLUG AND WORK - Support windows 7 / 8 / 10 / Vista / XP / 2000 / ME / NT Linux and Mac OS, Compatible with USB2.0 and below.
  • TWISTTURN DESIGN & EASY CARRY - The metal clip rotates 360° round the ABS plastic body which with rubber oil skin feeling finish. The capless design can avoid lossing of cap, and providing efficient protection to the USB port.
  • WARRANTY & SUPPORT - SIMMAX logo is laser printed on the USB connector surface, our products are of good quality and we promise that any problem about the product within one year since you buy.

Match YouTube’s encoder settings

YouTube’s live encoder help page, accessed October 3, 2026, lists the following guidance. Its recommendations can change; check the current encoder settings, bitrates and resolutions page and the settings shown for your broadcast.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Setting Current guidance in YouTube Help
Ingest RTMP or RTMPS; YouTube recommends RTMPS for encrypted delivery into and through Google’s servers.
Video codecs H.264, H.265 (HEVC) or AV1.
Frame rate Up to 60 fps.
Keyframes Recommended interval of 2 seconds; do not exceed 4 seconds.
Audio codecs AAC or MP3; 5.1 audio over RTMP/RTMPS is supported only for AAC.
Bitrate mode CBR.
Audio sample rate 44.1 kHz stereo; 48 kHz for 5.1.
Stereo audio bitrate 128 Kbps.
Upload capacity Choose a quality that fits reliable available upload speed; use YouTube’s table for your codec, resolution and frame rate, then test your connection.

For H.264, the page currently lists 1080p30 at 5 Mbps minimum and 14 Mbps recommended, and 720p30 at 3 Mbps minimum and 8 Mbps recommended. These are YouTube ingestion recommendations, not a guarantee that a particular connection or setup will work. YouTube lists different bitrate values for AV1 and H.265. Check its table for the exact output you plan to send instead of treating one bitrate as universal.

Best Value
IMEASON Swivel Design 16GB USB Flash Drive with Keychain, USB 2.0 Portable Thumb Drive Memory Stick, FAT32 Format Flashdrive for Data Storage, Photos, Music, Files (Black, 16 GB)
  • 【16GB Flash Drive】USB flash drives with 16GB capacity, meet your needs of daily use on work, school, home and travelling for photos, music, videos, files storage and transfer. IMEASON thumb drives can be used to store different files, easy to data backup.
  • 【Metal Swivel Cap Design】USB thumb drive is metal swivel cover provides extra protection for the usb thumbdrive connector, no usb drive cap to lose; keychain design makes it easier to carry without worrying lose it.
  • 【Wide Compatibility】USB drive supports Windows 7/8/10/11 / Vista / XP / Unix / 2000 / ME / NT Linux and Mac OS, also Supports USB 2.0 and 1.1 ports. USB Stick support TV, desktop, notebook computer, car, audio and other device. The USB Memory Stick is your great data storage and transfer companion with traveling and working.
  • 【Easy to use】usb memory stick is plug and play without any software installation. Just simply plug the Flashdrive into the port of your USB-compatible devices such as computer, laptop to start data storage or transmission.
  • 【What You Get】16 GB USB Flash Drive Thumb Drive, The default format of the usb storage flash drive is FAT32.

Set the GOP for your actual frame rate

In the example, -g 60 makes a 60-frame GOP. It represents a two-second interval only at 30 fps; at 60 fps it spans one second. Set the GOP in relation to the actual output frame rate so the keyframe interval matches YouTube’s guidance. The example’s -pix_fmt yuv420p, AAC settings and GOP value are starting choices, not requirements for every configuration.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Test before leaving the stream unattended

  1. Run the command before the intended session and verify the YouTube preview shows the expected visual and audible content.
  2. Use a representative section of the audio and video, including a loop point, to check for glitches, gaps, abrupt transitions or an unintended track.
  3. Test upload speed and choose an output quality that leaves reliable headroom. YouTube recommends a preflight with representative audio and video movement, an upload-speed test, and monitoring stream health during the event.
  4. During the stream, watch YouTube’s stream-health diagnostics and FFmpeg’s logs. A local process continuing to run does not by itself prove that YouTube is receiving a healthy stream.

Troubleshoot common failures

Symptom Checks and fixes
YouTube does not receive the broadcast Check that the RTMPS endpoint and stream key are the current values for the intended broadcast, that the channel is eligible to stream, and that the network can reach the ingest service. Keep the key private.
Video appears, but there is no sound Confirm the input actually contains audio and that -map selects the intended audio stream. For a separate audio file, map its input index and audio stream, and confirm audio reaches the YouTube preview.
Sound plays, but the video is missing Confirm a video stream is mapped and present. An audio-only input does not supply a visual; pair it with video or a generated visual source and map that stream.
Stream health is poor or the output disconnects Check available upload capacity against the chosen codec, resolution and frame rate; inspect YouTube diagnostics and FFmpeg logs; check CPU headroom if transcoding; and review timestamps and behavior at the input loop point. These are practical diagnostic checks, not a guaranteed fix for every disconnect.
Copy mode fails or YouTube rejects the stream Check source codec and container compatibility and the current YouTube ingest settings. If conversion or filtering is needed, try transcoding and verify the output properties rather than assuming stream copy will adapt the source.
The loop runs too quickly or behaves unexpectedly Make sure -stream_loop -1 is before the input it should repeat and use -re for file input that must be paced in real time. Confirm option order, since FFmpeg options generally apply to the next input or output.

A 2022 FFmpeg-user post shows a looping YouTube example and describes CPU pressure and stream-health problems in that individual setup. It is an anecdote, not evidence that its flags are optimal or that the same issue is inevitable: read the post.

Or let it run in the cloud

If you would rather not keep a computer and home connection running, StreamNeo is a cloud service 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 the uploaded video; it does not broadcast from a camera.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Nothing has to stay on at home: the stream runs in the cloud.
  • Any quality up to 4K 60fps streams as uploaded 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.
  • Monthly billing is $9.99 per month.

To start, sign up for StreamNeo’s 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 *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair 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.