October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
DocumentaryTube
cron

How to Schedule an FFmpeg YouTube Stream with Cron on Linux

Use FFmpeg to send a Linux input to YouTube Live on a cron schedule. Learn how to choose encoder settings, protect the stream key, test the cron environment, and diagnose failures.

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

To start a YouTube Live encoder feed on a Linux schedule, get the stream URL and key from YouTube Live Control Room, build and test an FFmpeg command for your actual input, then add that command to the crontab of the Linux account that should run it. Cron starts commands; it does not supervise a stream, verify YouTube received it, or restart FFmpeg after a failure.

Before you configure FFmpeg

Check YouTube Live eligibility

YouTube says a channel must be verified, have no live-streaming restrictions in the previous 90 days, and meet the minimum age of 16 to enable live streaming. Check eligibility before troubleshooting your encoder: YouTube’s live-streaming overview.

Create or select the intended stream

In YouTube Studio, open Live Control Room and create a stream or select the scheduled stream you intend to use. Choose the encoder workflow, then copy the stream URL and stream key from that stream’s settings. Confirm the destination, privacy, and scheduling settings. Settings may be reusable, but the URL and key are tied to the stream configuration; verify them for the event you plan to run. See YouTube’s encoder setup instructions.

Treat the stream key as a password. Do not publish it in a script repository, screenshot, shell history, process listing visible to other users, or log. If it is exposed, reset it in Live Control Room and update the protected encoder configuration. YouTube explains key management at its stream-key help page.

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.

Choose YouTube-compatible output settings

Use YouTube’s current settings for the codec, resolution, and frame rate you select, rather than copying a bitrate from an unrelated setup. YouTube’s encoder guidance includes H.264, H.265, or AV1 video; AAC or MP3 audio; constant bitrate (CBR); frame rates up to 60 fps; and a recommended two-second keyframe interval that should not exceed four seconds. The examples below are H.264 recommendations from YouTube’s encoder settings page, accessed in 2026:

H.264 output YouTube recommended video bitrate
720p at 30 fps 5 Mbps
720p at 60 fps 8 Mbps
1080p at 30 fps 10 Mbps
1080p at 60 fps 17 Mbps

These are recommendations for the stated H.264 modes, not universal values for other codecs or frame rates. Consult YouTube’s encoder settings for the current table. Choose a quality your upload connection can sustain reliably; YouTube recommends checking upload speed and testing before an event.

Prefer RTMPS when supported

YouTube recommends RTMPS, which sends RTMP over TLS/SSL. In Live Control Room, reveal the RTMPS URL and use the exact endpoint shown for your stream. Confirm that your FFmpeg build supports the required protocol. YouTube documents the endpoint at its RTMPS setup instructions; FFmpeg’s protocol support depends on how it was built. If an SSL connection error persists, YouTube’s connection troubleshooting mentions port 443 as a possible setting.

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.

Build an FFmpeg command for your input

There is no single command that fits every source. A file, capture device, generated pattern, or network feed may require different input options. FFmpeg’s general structure is global options, input options and input, then output options and destination. This illustrative file-input pattern uses placeholders; replace every bracketed value and use the exact URL format YouTube gives you. Do not put a real key in a shared or public script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
/usr/bin/ffmpeg -nostdin -re -i /absolute/path/to/input 
  -c:v libx264 -preset veryfast -b:v VIDEO_BITRATE 
  -maxrate VIDEO_BITRATE -bufsize VIDEO_BUFFER 
  -g KEYFRAME_INTERVAL -keyint_min KEYFRAME_INTERVAL 
  -c:a aac -b:a AUDIO_BITRATE 
  -f flv 'rtmps://YOUTUBE_INGEST_URL/YOUR_STREAM_KEY'
  • /usr/bin/ffmpeg is an example executable path; find and use the path on your system.
  • /absolute/path/to/input is a placeholder for the actual file or input. -re reads a file at its native rate, which is generally appropriate when using a prerecorded file as a live feed; it is not a universal input setting.
  • VIDEO_BITRATE, VIDEO_BUFFER, and AUDIO_BITRATE are placeholders, not literal FFmpeg values. Select values appropriate to your chosen YouTube output settings and input.
  • KEYFRAME_INTERVAL must reflect your frame rate and the keyframe timing guidance. For example, keyframe interval is measured in frames, so calculate a two-second interval from the selected frame rate; do not paste a frame count without checking it.
  • rtmps://YOUTUBE_INGEST_URL/YOUR_STREAM_KEY illustrates the destination structure only. Replace it with the exact RTMPS endpoint and key supplied by Live Control Room; URL formats can vary.

This is not a verified copy-and-paste command for every FFmpeg build, input, bitrate, or YouTube configuration. Check the options against your local FFmpeg build and the current YouTube requirements. Transcoding with libx264 can establish the output codec and bitrate, but it uses CPU. Stream-copying avoids re-encoding only if the source streams already satisfy YouTube’s accepted settings. FFmpeg documentation is available at ffmpeg.org/ffmpeg.html.

For background execution, FFmpeg recommends -nostdin or redirecting standard input from /dev/null, so the process does not wait for console input. Keep credentials out of verbose output and logs.

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.

Schedule the stream with cron

Install the job for the right Linux account

Use the account that should own the process and have permission to read the input and write its logs. Edit that user’s crontab with crontab -e. A user crontab schedule line has five time/date fields followed by the command. For example, a weekday launch at 18:30 uses:

30 18 * * 1-5 /absolute/path/to/start-stream.sh

That schedule only launches the script at the specified local system time; it does not define the stream’s duration or stop it automatically. Confirm the host’s timezone and choose a lifecycle plan if the broadcast should end at a particular time.

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

Make the cron environment explicit

Cron runs commands as the crontab owner. The cited Linux cron documentation specifies /bin/sh as the default shell; do not assume an interactive login shell, GUI, current working directory, or your usual PATH. Use absolute paths for FFmpeg, the script, inputs, and logs. Set any required environment variables explicitly and test them under the target distribution’s cron implementation. See the Linux crontab manual.

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

A small wrapper script is easier to inspect than a long crontab line. Protect it and any configuration containing the key with file permissions appropriate to the account. Avoid passing a secret in a way that exposes it to other users through process listings; keep access restricted and do not log the full destination URL.

Capture output and avoid duplicate launches

Send stdout and stderr to a protected log, or configure cron mail handling so failures are visible. Cron may mail command output to the owner or a configured MAILTO recipient; an explicit log path makes diagnosis more predictable. Ensure a previous long-running process cannot overlap with the next scheduled invocation. Cron does not provide a general duplicate-instance lock or stream supervisor.

30 18 * * 1-5 /absolute/path/to/start-stream.sh >> /absolute/path/to/stream.log 2>&1

Whether to append or rotate logs depends on your retention needs; do not let logs grow without limit, and ensure permissions prevent unintended access.

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

Test the scheduled path before relying on it

  1. Run the command manually as the intended account. Confirm the input opens, FFmpeg starts, and no permission or missing-library error appears.
  2. Test using cron’s actual environment. Trigger a test schedule or use a temporary near-future entry, then inspect the protected log. This catches PATH, shell, working-directory, and permission differences that an interactive test may miss.
  3. Check Live Control Room. Confirm the preview appears and review YouTube’s stream-health messages. Test audio and moving video representative of the actual program.
  4. Verify the public outcome and lifecycle. A cron launch, zero exit status, or running FFmpeg process does not prove YouTube accepted a healthy public stream. Confirm the intended privacy and scheduling state and observe the stream itself.

YouTube recommends testing before going live and checking the Live Control Room preview and health: encoder settings and stream testing.

What cron can—and cannot—do

Cron is a scheduler for fixed-time launches, not a process manager. It will not, by itself, keep FFmpeg healthy after a crash, restart it, verify ingest status, or stop it at a planned duration. If you need restart policy, dependency ordering, continuous supervision, or controlled shutdown, use an appropriate service manager or wrapper and configure its lifecycle explicitly. FFmpeg’s FIFO muxer documentation includes an example intended to attempt recovery after temporary network failure, but that is one component, not a complete system-level supervisor: FFmpeg format and muxer documentation.

Troubleshoot common cron and YouTube failures

Symptom Likely cause What to check
Works in a terminal but not from cron Different shell, PATH, working directory, environment, or account permissions. Use absolute paths, set required environment explicitly, check file access as the crontab owner, and inspect the cron log.
FFmpeg waits or behaves oddly in the background It is attempting to read from an unavailable terminal. Use -nostdin or redirect stdin from /dev/null; capture stderr for diagnosis.
YouTube does not show an incoming preview Incorrect/stale URL or key, unsupported RTMPS build, network/firewall issue, or stream configuration mismatch. Recheck the exact endpoint and stream’s key in Live Control Room, verify FFmpeg protocol support and network access, and inspect stream health. Never print the key while troubleshooting.
Connection reports an SSL error RTMPS/TLS connection or network configuration problem. Confirm the endpoint begins with rtmps://, the build supports it, and check YouTube’s connection guidance, including its mention of port 443.
Video is choppy or YouTube reports poor health Upload capacity may be insufficient or unstable for the chosen output, or the encoder may not be sustaining it. Lower the selected quality if needed, compare against YouTube’s recommendation for the codec and frame rate, measure upload capacity, and test again.
Audio or video is missing Input stream mapping, source content, or chosen output settings may not match the media. Inspect the input’s streams and FFmpeg errors; test representative audio and movement in Live Control Room before the scheduled event.
A leaked key or unexpected destination Credential exposure or wrong stream configuration. Reset the key in Live Control Room, update the protected configuration, and confirm the scheduled stream’s destination and privacy settings.

Or let it run in the cloud

If the goal is a scheduled or always-on YouTube channel playing uploaded recordings, StreamNeo is a cloud alternative to maintaining a Linux host and cron job. Upload a recording or build a playlist, add your YouTube stream key, and go live. Nothing has to stay on at home; it plays uploaded videos rather than broadcasting a live camera. StreamNeo automatically recovers if YouTube drops the stream, supports any uploaded quality up to 4K 60fps at one flat price per slot, and gives the first day free with no card. Monthly pricing is $9.99 per month. It is YouTube-only. 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.

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

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 Screening Room

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
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.