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
DocumentaryTube
FFmpeg

How to Keep FFmpeg Streaming to YouTube After an SSH Session Ends

Use a named tmux session to keep remote FFmpeg running after you close SSH, and understand what tmux cannot recover if the host or stream fails.

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

Run FFmpeg inside a named tmux session on the remote host, then detach from tmux before closing SSH. The FFmpeg process stays attached to the remote tmux session rather than your local terminal, so an SSH disconnect alone will not stop it. This protects against a lost terminal connection—not a reboot, host failure, FFmpeg crash, or every interruption between the host and YouTube.

Keep FFmpeg running when SSH disconnects

The key is to start FFmpeg on the remote machine from inside tmux. The tmux project describes this use as protecting remote programs from connection drops: tmux Getting Started. If you start FFmpeg in an ordinary SSH shell instead, ending that shell may end the process.

1. Check the remote host and YouTube stream

SSH into the machine that will run FFmpeg. Confirm that both ffmpeg and tmux are available there, and that the host can reach the internet and has enough CPU, memory, storage, and network capacity for the source and output you intend to use. A tmux session cannot keep a machine running if it shuts down or loses connectivity.

Set up the live stream in YouTube Live Control Room and obtain its current server URL and stream key. YouTube’s encoder workflow requires both: the URL is the ingest destination, and the key identifies the stream. See YouTube’s encoder setup instructions. Treat the key like a password: do not show it in screenshots or public logs, and avoid putting it in commands that will remain in shared shell history.

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.
#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.

2. Create or reattach to a named tmux session

From the remote SSH shell, run:

tmux new-session -A -s youtube-live

This creates a session named youtube-live, or attaches to it if that session already exists. Run the command on the remote host, not on your local computer.

3. Start FFmpeg inside tmux

Run your FFmpeg command from the tmux window. For a file sent in real time, FFmpeg documents this general shape:

ffmpeg -re -i myfile -f flv rtmp://myserver/live/mystream

This is an illustrative FFmpeg example, not a ready-to-use YouTube command. Replace the input, encoding options, and destination with the values appropriate to your source and the current ingest details shown for your YouTube stream. Do not paste a real stream key into a public example. FFmpeg’s protocol documentation explains the example’s real-time input option and RTMP output pattern.

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.

YouTube recommends RTMPS for Live ingestion, describing it as a secure extension to RTMP. Use the current server URL and settings presented in your Live Control Room; consult YouTube’s encoder settings guidance for its resolution-, frame-rate-, and codec-specific recommendations. For example, that guidance lists recommended H.264 video bitrates of 14 Mbps for 2160p at 60 fps and 17 Mbps for 1080p at 60 fps. These are YouTube recommendations for those settings, not universal minimum internet speeds; allow for audio and network overhead as well.

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

4. Detach, then close SSH

Leave FFmpeg running. Press Ctrl+b, release the keys, then press d. This is tmux’s default detach sequence. You should return to the ordinary remote shell while the tmux session remains on the host. You can then exit SSH or close your local terminal.

5. Reconnect and inspect the session

SSH back into the same host as the same account, then run:

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.
tmux attach-session -t youtube-live

You will re-enter the session and see its terminal. If FFmpeg is still running, its process and output will be there; if it has exited, inspect the displayed error or logs available from your setup before restarting it. To leave it running again, detach with Ctrl+b, then d.

What tmux does—and what it does not

tmux separates a program’s terminal from the SSH client window, allowing you to detach and later reattach. It does not supervise FFmpeg or make the remote machine resilient to every failure. If the host reboots, loses power or network access, or FFmpeg exits, tmux cannot keep the stream alive by itself. A process manager or service manager may be appropriate when you also need restart-on-failure or start-at-boot behavior; choose and configure that separately, including safe handling of the stream key.

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

SSH persistence is also different from recovering an output connection to YouTube. You can lose SSH while FFmpeg continues normally; conversely, SSH may remain open while FFmpeg’s connection to YouTube fails.

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

Handle a temporary network outage separately

For an output-side interruption, FFmpeg’s FIFO muxer documentation shows a recovery pattern using -f fifo, -fifo_format flv, -attempt_recovery 1, and -recovery_wait_time 1. Its example is:

ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv 
  -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 
  -map 0:v -map 0:a rtmp://example.com/live/stream_name

The manual describes this pattern as continuing real-time processing during a temporary network outage and attempting recovery every second indefinitely. The example destination is not a YouTube ingest address. Adapt the input, codecs, stream mapping, and output to your actual setup, and test it with your FFmpeg build and YouTube endpoint; the documented behavior is not a guarantee for every failure or server. See the FFmpeg documentation for the FIFO muxer options.

YouTube limits and archive behavior to account for

  • YouTube’s current guidance says streams under 12 hours are automatically archived. Do not assume the same archive behavior for a stream that runs 12 hours or longer; see YouTube’s encoder instructions.
  • YouTube states a limit of 10 active streams per channel and 3 active streams per stream key. These are separate limits; see YouTube’s live-streaming eligibility guidance.
  • Use video and audio you have the rights to stream. A long-running stream is still subject to YouTube’s copyright rules and platform policies. Check the current YouTube guidance for your content and channel rather than assuming that looping or using FFmpeg changes those obligations.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

FFmpeg stops when you close SSH

It may have been started in the normal SSH shell instead of inside tmux. Reconnect, create or attach to the named tmux session, and start FFmpeg from there. Confirm the process remains visible after detaching before closing SSH.

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.

The tmux session is not found after reconnecting

Check that you connected to the same remote host and account where you created it, then try tmux ls to list available sessions. If the host rebooted or the session ended, it will not be recoverable by attaching; start a new session and investigate why the machine or process stopped.

FFmpeg is present, but YouTube is not receiving the stream

Check the FFmpeg output for connection or authentication errors, then verify the current server URL and stream key in YouTube Live Control Room. Confirm the key has not been mistyped or replaced, and that the host still has outbound network access. Keep the key private when sharing terminal output.

The stream drops during a network interruption

tmux only addresses SSH-client disconnection. Review FFmpeg’s output and consider testing the FIFO recovery pattern above against the actual source and ingest destination. Recovery depends on the failure, configuration, and FFmpeg build; test rather than assuming a reconnect will succeed.

The stream looks soft, stutters, or fails to meet the target

Compare the configured resolution, frame rate, codec, and bitrate with YouTube’s current recommendations at Choose live encoder settings, bitrates, and resolutions. Also check that the remote host can encode and upload at the selected settings without exhausting CPU or network capacity.

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

Or let it run in the cloud

If your goal is a YouTube channel that keeps looping uploaded videos without maintaining an FFmpeg process on your own server, StreamNeo is a separate cloud option: upload a recording or build a playlist, add your YouTube stream key, and go live. It runs on StreamNeo’s cloud, so nothing has to stay on at home. It plays uploaded videos rather than broadcasting a live camera feed, and it streams to YouTube only.

  • One flat price per slot for any uploaded quality up to 4K 60fps, with no re-encode or quality tiers.
  • 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. See StreamNeo for the service, then start your free 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 Screening Room

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.