Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
FREEDOM251

Freedom251 › Blog › 24/7 Livestream

How to Set Up a 24/7 YouTube Sleep Music Radio Channel with FFmpeg

By Freedom251 Team · · 6 min read

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

You can run a 24/7 sleep-music radio channel by sending a looping audio or video file from FFmpeg to a YouTube Live encoder stream. First enable live streaming on your channel, confirm that you have the rights to broadcast and archive the music, then configure FFmpeg and plan how you will monitor and restart it. A continuous stream is an operating goal, not a guarantee that one process or YouTube event will never disconnect.

What you need before starting

  • A verified YouTube channel with live streaming enabled and no live-streaming restrictions in the previous 90 days. First-time activation may take up to 24 hours, so enable it before your planned launch.
  • An audio file, or a video file that contains the music. For an audio-only track, prepare a still image to display during the broadcast.
  • FFmpeg installed on a computer or server that can remain online and has enough outbound upload capacity.
  • A YouTube encoder stream’s stream URL and private stream key.
  • Permission to use the music for the live broadcast and, if you want a replay, for the archived material too.

The exact FFmpeg options available depend on your installed build and its codec support. Test the command against your actual media before relying on it overnight.

As an Amazon Associate I earn from qualifying purchases.

Enable YouTube Live and create an encoder stream

  1. Enable live streaming. Complete YouTube’s channel verification and check that there are no live-streaming restrictions in the previous 90 days. Allow up to 24 hours for first-time activation.
  2. Open YouTube Studio’s Live Control Room. Create or schedule a stream and choose the encoder workflow.
  3. Copy the ingest details. Put the stream URL and stream key into your FFmpeg setup. The stream key is a credential: keep it private, and reset it in YouTube Studio if it is exposed.
  4. Preview before going live. Start FFmpeg and confirm that YouTube receives the expected picture and sound before you make the broadcast public.

Prepare FFmpeg to loop sleep music

Audio file with a still image

This example repeats an MP3 while showing a JPEG as a static 1280×720 image. It encodes H.264 video and AAC audio, sends a constant video bitrate, and sets a two-second keyframe interval for a 30 fps output. Replace the file paths and bitrate with values suitable for your content and connection. The bitrate shown is an example, not a YouTube-prescribed rate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
ffmpeg -loop 1 -framerate 30 -i /path/to/cover.jpg -stream_loop -1 -re -i /path/to/sleep-music.mp3 
  -vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2" 
  -c:v libx264 -preset veryfast -tune stillimage -pix_fmt yuv420p 
  -r 30 -g 60 -keyint_min 60 -sc_threshold 0 
  -b:v 3000k -minrate 3000k -maxrate 3000k -bufsize 6000k 
  -c:a aac -b:a 128k -ar 44100 
  -f flv "$YOUTUBE_RTMPS_URL/$YOUTUBE_STREAM_KEY"

Set YOUTUBE_RTMPS_URL to the RTMPS stream URL shown for your encoder stream in YouTube Studio, and YOUTUBE_STREAM_KEY to that stream’s key. Keep the key out of public scripts, source control, screenshots, and shared logs. The final output argument combines the URL and key; confirm that this matches the URL/key format shown in your Studio setup.

#1 Best Overall
Focusrite Scarlett Solo 3rd Gen USB-C Audio Interface | 1 XLR Mic Preamp, 1 Hi-Z Instrument Input, 24-Bit/192kHz, 56dB Gain Range, Air Mode, macOS/Windows/iPadOS Compatible
  • Pro performance with great pre-amps - Achieve a brighter recording thanks to the high performing mic pre-amps of the Scarlett 3rd Gen. A switchable Air mode will add extra clarity to your acoustic instruments when recording with your Solo 3rd Gen
  • Get the perfect guitar and vocal take with - With two high-headroom instrument inputs to plug in your guitar or bass so that they shine through. Capture your voice and instruments without any unwanted clipping or distortion thanks to our Gain Halos
  • Studio quality recording for your music & podcasts - Achieve pro sounding recordings with Scarlett 3rd Gen’s high-performance converters enabling you to record and mix at up to 24-bit/192kHz. Your recordings will retain all of their sonic qualities
  • Low-noise for crystal clear listening - 2 low-noise balanced outputs provide clean audio playback with 3rd Gen. Hear all the nuances of your tracks or music from Spotify, Apple & Amazon Music. Plug-in headphones for private listening in high-fidelity
  • Everything in the box: Includes Pro Tools Intro+, Ableton Live Lite, Cubase LE, and Hitmaker Expansion: a suite of essential effects, powerful software instruments, and easy-to-use mastering tools

Video file that already contains audio

If you have a prepared video with the sleep music already in it, use one looping input instead. This example transcodes it to H.264/AAC; it uses a 30 fps output and a two-second keyframe interval. Adjust the example video bitrate to suit the output resolution and your available upload bandwidth.

ffmpeg -stream_loop -1 -re -i /path/to/sleep-video.mp4 
  -c:v libx264 -preset veryfast -pix_fmt yuv420p 
  -r 30 -g 60 -keyint_min 60 -sc_threshold 0 
  -b:v 4500k -minrate 4500k -maxrate 4500k -bufsize 9000k 
  -c:a aac -b:a 128k -ar 44100 
  -f flv "$YOUTUBE_RTMPS_URL/$YOUTUBE_STREAM_KEY"

These are starting-point examples, not verified production configurations. Check that your FFmpeg build supports the selected codecs, that the media loops cleanly, and that the output appears and sounds right in YouTube’s preview. If your source has a different frame rate or resolution, choose output settings deliberately rather than assuming the example values are ideal.

Rank #2
Focusrite Scarlett Solo 4th Gen USB-C Audio Interface | 1 XLR Mic Preamp, 1 Hi-Z Instrument Input, 24-Bit/192kHz, 120dB Dynamic Range, Air Modes, PC/Mac/iPad Compatible
  • The new generation of the songwriter's interface: Plug in your mic and guitar and let Scarlett Solo 4th Gen bring big studio sound to wherever you make music
  • Studio-quality sound: With a huge 120dB dynamic range, the newest generation of Scarlett uses the same converters as Focusrite’s flagship interfaces, found in the world's biggest studios
  • Find your signature sound: Scarlett 4th Gen's improved Air mode lifts vocals and guitars to the front of the mix, adding musical presence and rich harmonic drive to your recordings
  • All you need to record, mix and master your music: Includes industry-leading recording software and a full collection of record-making plugins
  • Everything in the box: Includes Pro Tools Intro+, Ableton Live Lite, Cubase LE, and Hitmaker Expansion: a suite of essential effects, powerful software instruments, and easy-to-use mastering tools

Set output and network settings for YouTube

  • Use RTMPS. YouTube recommends encrypted RTMPS ingest. Use the stream URL provided in Studio rather than guessing an endpoint.
  • Use a constant bitrate. The examples set matching minimum, target, and maximum video bitrates. Choose a rate appropriate to your resolution and the actual upload capacity of the host.
  • Keep keyframes two seconds apart. YouTube recommends a two-second interval and says not to exceed four seconds. At 30 fps, a GOP of 60 frames corresponds to two seconds.
  • Check upload capacity, not just download speed. YouTube recommends 20% upload-bandwidth headroom above the stream’s bitrate. Leave room for normal network variation and other traffic.
  • Watch YouTube’s stream-health feedback. Preview the feed and monitor its quality after launch; a successful FFmpeg process alone does not prove YouTube is receiving a healthy stream.

Video resolution and bitrate should match the source and the connection. The settings above show usable command structure, not a universal bitrate recommendation for every resolution.

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

Keep the channel running through interruptions

A process that runs indefinitely can still lose its network connection, stop after a host restart, or be disconnected on YouTube’s side. FFmpeg documents an RTMP FIFO approach with recovery attempts for temporary network failures, but reconnect options do not guarantee continuity on YouTube. For a basic setup:

Rank #3
SABRENT USB External Stereo Sound Card Adapter, Plug & Play (AU-MMSA) | USB audio adapter; no drivers needed; for Windows & Mac; 3.5mm headphone & mic jacks; usb to 3.5mm jack audio adapter
  • PLUG IN AND HEAR SOUND IN SECONDS - USB Type-A connector with a 3.5mm stereo headphone output and a separate 3.5mm mono microphone input. No drivers, no software, no external power - the adapter is USB bus-powered and is recognized as a standard USB audio device.
  • WORKS ON WINDOWS, MAC AND LINUX - Driverless on Windows 98SE/ME/2000/XP/Server 2003/Vista/7/8, Linux and Mac OSX, and compliant with the USB Audio Device Class 1.0 specification, so any system that supports class-compliant USB audio will see it. Select it as the sound output and input device after plugging it in.
  • TWO JACKS, TWO JOBS - The green jack is stereo OUT for headphones or powered speakers; the pink jack is mono microphone IN for a 3.5mm mic. It does NOT support 4-pole headsets on a single combo plug, it does NOT power passive speakers, and it does NOT add surround sound - it is a stereo 2-channel adapter.
  • FOR LAPTOPS AND DESKTOPS THAT NEED AN AUDIO PORT BACK - Adds a headphone and mic port to a laptop, desktop, or mini PC whose onboard jack has failed or was never there. Managed and work-issued computers can block new USB audio devices by policy - check with your IT department before ordering for a company machine.
  • SABRENT SUPPORT AND WARRANTY - What is in the box: one USB audio sound adapter. Backed by a 1-year limited warranty, extended to 2 years when you register within 90 days on the manufacturer's website.
  1. Run FFmpeg on a host that will remain powered and connected for the period you need.
  2. Use process supervision or another restart mechanism appropriate to that host, and test what happens if FFmpeg exits or the host reboots.
  3. Monitor the stream in YouTube Studio and arrange an alert or regular check so you can spot a failed broadcast.
  4. Keep a tested restart procedure that uses the current stream URL and key. If the key is exposed, reset it in Studio and update your configuration.

A separate encoder or network can add another recovery option, but it is not required by the cited YouTube guidance. No single FFmpeg reconnect setting can promise that a 24/7 broadcast will never go offline.

Plan around YouTube’s archive limit

YouTube says streams under 12 hours are automatically archived. Its guidance does not promise a complete replay for a continuous broadcast that exceeds 12 hours. If a replay matters, plan and test separate broadcasts under that threshold, and check the current archive behavior in YouTube Studio. A single always-on radio stream and a dependable full-length replay are not the same requirement.

Rank #4
M-AUDIO M-Track Duo USB Audio Interface | Dual XLR, Line and DI Inputs, Professional Software Suite for Recording, Streaming, and Podcasting
  • Podcast, Record, Live Stream, This Portable Audio Interface Covers it All - USB sound card for Mac or PC delivers 48kHz audio resolution for pristine recording every time
  • Be ready for anything with this versatile M-AUDIO interface - Record guitar, vocals or line input signals with two combo XLR / Line / Instrument Inputs with phantom power
  • Everything you Demand from an Audio Interface for Fuss-Free Monitoring - 1/4" headphone output and stereo 1/4" outputs for total monitoring flexibility; USB/Direct switch for zero latency monitoring
  • Get the best out of your Microphones - M-Track Duo’s transparent Crystal Preamps guarantee optimal sound from all your microphones including condenser mics
  • The MPC Production Experience - Includes MPC Beats Software complete with the essential production tools from Akai Professional

Confirm music rights before you go live

YouTube’s terms place responsibility on the creator to have the necessary rights for live content worldwide, including music licensing rights; archived material is also subject to the applicable agreement. A “royalty-free” label by itself does not establish that a track’s license covers this particular live broadcast, territories, duration, monetization, or archive. Check the license for the exact uses you intend, and retain the terms or permissions that support your use.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common problems and fixes

Symptom Likely cause What to check
YouTube receives no signal Incorrect stream URL or key, live streaming not active yet, or an FFmpeg output error Confirm the encoder details in Studio, check first-time activation, and read FFmpeg’s error output. Reset an exposed key and update the configuration.
Stream starts but drops or buffers Unstable upload, insufficient upload headroom, or a host/network interruption Measure upload capacity, leave the recommended 20% headroom, reduce the output bitrate if needed, and monitor YouTube’s stream-health feedback.
Video is black, frozen, or incorrectly framed Unexpected source layout, unsupported media, or unsuitable scaling/output settings Test the file locally, confirm FFmpeg can decode it, and inspect the YouTube preview before launching publicly.
Audio is silent, distorted, or stops at a loop boundary Wrong input selection, unsupported audio encoding, or a problematic source-file transition Listen to the source, check the FFmpeg input and audio settings, and test the loop end-to-start transition before broadcasting.
FFmpeg exits and the stream ends Process or host failure; reconnect handling may not cover the failure Inspect the exit log, restart the process using a tested procedure, and add host-appropriate supervision and monitoring.
The full 24-hour broadcast is not available as a replay The broadcast exceeded YouTube’s stated under-12-hour automatic-archive threshold If a full archive is important, test discrete broadcasts under 12 hours and verify the resulting replays in Studio.

Or let it run in the cloud

If you do not want a computer or home connection to carry the broadcast, StreamNeo runs an uploaded-video YouTube stream from the cloud. Upload a recording or build a playlist, add your YouTube stream key once, and go live. It loops the upload from the cloud, so nothing has to stay on at home. Every slot streams the uploaded quality up to 4K 60fps at one flat price per slot; there are no quality tiers or re-encoding. StreamNeo also attempts automatic recovery 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. StreamNeo plays uploaded videos and streams to YouTube; it is not a camera broadcast. Start your free day with StreamNeo.

Best Value
Focusrite Scarlett 2i2 4th Gen USB-C Audio Interface | 2 Mic Preamps, 2 Hi-Z Instrument Inputs, 24-Bit/192kHz, 120dB Dynamic Range, Auto Gain, Clip Safe, Air Modes
  • The new generation of the artist's interface: Connect your mic to Scarlett's 4th Gen mic pres. Plug in your guitar. Fire up the included software. Start making your first big hit
  • Studio-quality sound: With a huge 120dB dynamic range, the newest generation of Scarlett uses the same converters as Focusrite’s flagship interfaces, found in the world's biggest studios
  • Never lose a great take: Scarlett 4th Gen's Auto Gain sets the perfect level for your mic or guitar, and Clip Safe prevents clipping, so you can focus on the music
  • Find your signature sound: Air mode lifts vocals and guitars to the front of the mix, adding musical presence and rich harmonic drive to your recordings
  • With Scarlett 4th Gen, you have all you need to record, mix and master your music: Includes industry-leading recording software and a full collection of record-making plugins

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.

24/7 LivestreamFFmpegSleep MusicStreaming setupYouTube Live

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.

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.