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

-stream_loop -1 makes FFmpeg repeat an input; it does not restart FFmpeg when a local file error stops the process. To recover, identify the failure, handle damage that can be skipped where appropriate, and supervise FFmpeg with a bounded restart policy that can validate the file or switch to a known-good fallback. HTTP reconnect options are for HTTP input connections, not local-file errors or a guarantee that YouTube publishing will resume.

First identify what failed

“File error” can describe several different events, and each needs a different response. Check FFmpeg’s last log lines and exit status before changing options.

  • Normal end of file: the input finished normally. Use -stream_loop -1 to repeat it.
  • Corrupt packets, but FFmpeg continues: the input may be partially readable. The discardcorrupt flag can discard corrupted packets in supported formats.
  • File cannot be opened, demuxed, or decoded: looping cannot fix an input FFmpeg cannot use. Validate or replace it, or select a fallback.
  • HTTP source disconnect: HTTP protocol reconnect options may apply, depending on the failure and configured retry conditions.
  • Output or YouTube publishing failure: investigate the destination connection and stream health separately. Input-looping and HTTP input flags do not guarantee recovery of an RTMP/RTMPS output.

Keep the log and exit status together: a restart without diagnosing the cause can turn one failure into a rapid, repeated restart cycle.

Loop a readable local file

For a single local input, place -stream_loop -1 before the input it controls. FFmpeg defines -1 as an infinite loop; it is an input option, not a process supervisor.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
ffmpeg -nostdin -stream_loop -1 -re -i input.mp4 
  -c:v libx264 -c:a aac -f flv "$YOUTUBE_RTMP_URL"

This is an illustrative command shape, not a tested end-to-end configuration. Supply the actual YouTube server URL and stream key securely. Choose codec, bitrate, resolution, frame rate, and keyframe interval to match YouTube’s current encoder guidance and your source. -re reads the file at its native rate rather than as fast as possible; -nostdin avoids terminal input handling for a background job. Neither option restarts FFmpeg.

FFmpeg options generally apply to the next input or output, so option placement matters when a command has multiple inputs. Check the documentation for your installed build: FFmpeg’s online nightly documentation tracks the newest revision and options may differ by version.

Rank #2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
  • Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
  • Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
  • Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
  • Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
  • From Sandisk, a brand professional photographers trust to take on assignments.

Handle damaged packets without mistaking it for recovery

For an input with some damaged packets, you can try the input flag -fflags +discardcorrupt, placed before the relevant -i:

ffmpeg -nostdin -stream_loop -1 -fflags +discardcorrupt -re 
  -i input.mp4 -c:v libx264 -c:a aac -f flv "$YOUTUBE_RTMP_URL"

FFmpeg documents this flag as discarding corrupted packets. It may let processing continue past some damage, but it does not repair a container, guarantee every error is recoverable, or make an unreadable file usable. Test against a copy of the media before relying on it for an unattended stream. See FFmpeg’s component and protocol documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
SSK Portable SSD 500GB External Solid State Hard Drive USB C Up to 1050MB/s
  • Capacity Display Variance: 500GB external ssd often appears as around 465GB on Windows. MacOS can show full 500 GB capacity. This is binary calculation difference and doesn’t affect SSD hard drive actual physical storage
  • 1050 MB/s Speed: Instantly access to your files with blazing-fast 10Gbps external SSD read up to 1050MB/s and write up to 1000MB/s. LED Light indicates USB SSD instant activity
  • Data Security: Solid state drives S.M.A.R.T. health diagnostics​ and adaptive TRIM optimizing data block management ensures consistent write speeds and extends the longevity of the portable SSD
  • USB-C & USB-A Cable: Both cables featuring rapid USB 3.2 Gen2, this USB SSD effortlessly bridges devices, enabling seamless cross-platform file transfers and backup between computers, smartphones, tablets and iPhone
  • Always Fast: No slowdowns for large file transfers. With SLC caching (25% of current available capacity allocated as high-speed cache), this external SSD delivers steady 10Gbps for transfers within the cache capacity

Restart FFmpeg with a supervisor and fallback

If FFmpeg exits on a persistent local-file failure, recovery requires something outside that FFmpeg process: a service manager or wrapper that notices the exit and launches a new process. A robust design validates the intended file, waits a bounded interval, and chooses a known-good fallback or stops and alerts you if the input remains bad. There is no universal restart command: exact syntax depends on your operating system and supervisor.

  1. Capture diagnostics: record stderr, exit status, input path, and restart time so repeated failures can be distinguished from transient ones.
  2. Wait before relaunching: use a bounded delay and avoid a tight restart loop that repeatedly opens the same bad file.
  3. Check the input: confirm it exists and can be read or probed before restarting the same playlist item.
  4. Choose a recovery action: retry a transient problem, switch to a known-good fallback file, alert an operator, or stop after a configured number of failures.
  5. Verify the new output: confirm FFmpeg is publishing and check YouTube’s stream health; a successful process launch alone does not prove that viewers are receiving a healthy stream.

-xerror tells FFmpeg to stop and exit on an error, while -max_error_rate affects the exit-code threshold for decoding failures; crossing that threshold does not terminate processing. Neither option launches another process. See FFmpeg’s command-line documentation and its FAQ for background-job guidance.

Rank #4
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Use reconnect flags only for the matching HTTP input

FFmpeg documents HTTP-specific reconnect behavior, including retries for disconnects, EOF, network errors, and selected HTTP status codes, with retry limits. These options address HTTP input protocol events. They do not retry a local file that fails to open or decode, and they do not establish that a YouTube RTMP/RTMPS publishing connection will resume.

Keep recovery paths separate: validate or replace a local file; configure HTTP reconnect behavior for an HTTP source; and troubleshoot the output connection when publishing fails. FFmpeg documents RTMP separately from HTTP in its protocol documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Samsung T7 Portable SSD 1TB Titan Gray, USB 3.2 Gen 2, Up to 1,050MB/s
  • MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
  • SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
  • ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
  • ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
  • HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check YouTube’s encoder and stream health separately

A healthy input loop does not ensure a healthy YouTube stream. YouTube’s current guidance lists RTMP/RTMPS ingestion and CBR, recommends a two-second keyframe interval that does not exceed four seconds, and provides bitrate guidance by resolution and other settings. Use the current table rather than applying one bitrate to every stream. YouTube also recommends testing before going live and monitoring stream health. Its streaming tips recommend about 20% upload bandwidth headroom and testing encoder failover. These are YouTube’s operational recommendations, not guarantees that a local file or connection will recover.

Protect the stream key as you would a password: YouTube says it tells the encoder where to send the feed and allows YouTube to accept it. Find current guidance in YouTube’s stream settings, encoder settings, and streaming tips.

Choose the response that matches the failure

Situation Suitable response What it does not do
Readable file reaches EOF -stream_loop -1 before -i Recover an unreadable file or restart an exited process
Some damaged packets in a supported input -fflags +discardcorrupt Repair the whole file or guarantee continued decoding
FFmpeg exits after a persistent local-file failure External supervisor, validation, and a fallback or stop condition Provide automatic recovery through FFmpeg alone
HTTP input disconnect or retryable HTTP response Applicable HTTP reconnect options and retry limits Recover a local file or guarantee RTMP output recovery
YouTube stream is unstable Check encoder settings, upload headroom, stream health, and failover Fix a broken input file

Or let it run in the cloud

If the goal is to keep uploaded videos looping on YouTube without keeping a computer running, StreamNeo runs the stream in the cloud. Upload a recording or build a playlist, add your YouTube stream key, and go live. Nothing has to stay on at home; it streams the uploaded quality up to 4K 60fps at one price per slot, and automatically recovers if YouTube drops the stream. The first day is free with no card. Monthly is $9.99 per month. It streams to YouTube only and plays uploaded videos, not a live camera feed. Start your free first day with StreamNeo.

Frequently Asked Questions

Does -stream_loop -1 restart FFmpeg after a file error?

No. It repeats a readable input indefinitely; an external supervisor is needed to relaunch FFmpeg after the process exits.

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

Will FFmpeg’s HTTP reconnect options fix a local MP4 error?

No. Those options apply to HTTP input connections and retry conditions, not local-file decoding or opening failures.

Quick Recap

Bestseller No. 2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model)
From Sandisk, a brand professional photographers trust to take on assignments.
$165.70
SaleBestseller No. 4
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99

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.