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
24/7 streaming

Vultr VPS पर FFmpeg से YouTube Stream अपने आप Restart कैसे करें

systemd FFmpeg के crash को restart कर सकता है, लेकिन silent freeze के लिए progress watchdog और YouTube Live Control Room की जाँच भी जरूरी है।

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

Vultr के Ubuntu/Linux VPS पर FFmpeg से YouTube Live stream भेजते समय process के crash होने पर उसे फिर चलाने का व्यावहारिक तरीका systemd service है। लेकिन यह केवल FFmpeg process के बंद होने पर प्रतिक्रिया देता है; process चलता रहे और वीडियो रुक जाए तो अलग progress या stream-health watchdog चाहिए। नीचे दोनों स्थितियों को अलग-अलग संभालने और YouTube पर वास्तविक stream की पुष्टि करने का तरीका है।

पहले समझें: restart किस समस्या को हल करता है?

FFmpeg वीडियो को encode या remux करके YouTube तक भेजता है। Vultr का streaming-server guide Ubuntu पर streaming setup का संदर्भ देता है; FFmpeg का काम media processing है। Vultr streaming-server guide और FFmpeg documentation देखें।

स्थिति उपयुक्त उपाय सीमा
FFmpeg process exit या crash हो गया systemd की restart policy केवल process के बंद होने पर काम करती है।
FFmpeg जीवित है, लेकिन output रुक गया या YouTube को वीडियो नहीं मिल रहा Progress counter या stream-health watchdog, साथ में YouTube health जाँच साधारण service restart policy silent freeze पहचानने की गारंटी नहीं देती।

इसलिए सेवा का active दिखना इस बात का प्रमाण नहीं कि YouTube पर वीडियो चल रहा है। StreamNeo की FFmpeg systemd guide भी process restart और स्वास्थ्य-जाँच को अलग समस्याएँ मानती है।

Stream key और encoder settings तैयार करें

Stream key को पासवर्ड की तरह सुरक्षित रखें

YouTube के अनुसार, “Stream keys are like your YouTube stream’s password and address.” इसे सार्वजनिक script या repository में न रखें और shell history में खुला छोड़ने से बचें। YouTube Live Control Room में key reset की जा सकती है; reset करने पर config में नई key डालकर सेवा restart करें। विवरण: YouTube stream settings.

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

Output को YouTube की guidance से मिलाएँ

YouTube की encoder guidance RTMP/RTMPS और H.264, H.265 या AV1 विकल्पों का उल्लेख करती है; CBR इस्तेमाल करें, 60 fps तक frame rate रखें और keyframe interval 2 सेकंड रखें—4 सेकंड से अधिक नहीं। उदाहरण के लिए, YouTube 720p30 H.264 के लिए 3–8 Mbps सुझाता है। ये YouTube की प्रकाशित सिफारिशें हैं, किसी खास source, VPS या नेटवर्क पर performance guarantee नहीं। मौजूदा विवरण: YouTube encoder settings.

YouTube के अनुसार कुल stream bitrate उपलब्ध upload bandwidth से अधिक नहीं होना चाहिए और करीब 20% headroom रखना चाहिए। Network disruption stream को बाधित कर सकता है। यह क्षमता अपने VPS के वास्तविक network path के लिए जाँचें; YouTube की सलाह streaming tips में है।

Ubuntu/Linux पर FFmpeg को systemd service बनाएँ

यह नमूना एक dedicated, unprivileged account से FFmpeg चलाता है, key को अलग restricted-permission environment file में रखता है और process exit होने पर restart करता है। इसे ज्यों का त्यों लागू करने से पहले अपने distro, FFmpeg के वास्तविक path, input file और stream protocol के अनुसार जाँचें। उपलब्ध guidance किसी खास Vultr VPS पर इस उदाहरण के चलने की पुष्टि नहीं करती।

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.

1. Dedicated service user और सुरक्षित key file बनाएँ

नीचे के आदेश Ubuntu/Debian-जैसे systemd सिस्टम के लिए उदाहरण हैं। अगर आपका distro अलग है, तो user-management और package संबंधी आदेश बदल सकते हैं।

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo useradd --system --create-home --shell /usr/sbin/nologin ffmpegstream
sudo install -o root -g root -m 600 /dev/null /etc/ffmpegstream.env
sudoedit /etc/ffmpegstream.env

/etc/ffmpegstream.env में एक environment variable रखें, उदाहरण के लिए:

YOUTUBE_STREAM_KEY=अपनी_निजी_stream_key

Environment file को केवल root पढ़ सके, इसका mode जाँचें:

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.
sudo chmod 600 /etc/ffmpegstream.env
sudo chown root:root /etc/ffmpegstream.env

अपनी input recording को उस स्थान पर रखें जहाँ ffmpegstream user उसे पढ़ सके। उदाहरण के लिए, एक अलग directory बनाकर ownership या read permission उसी आवश्यकता के अनुसार दें; stream key को वीडियो directory में न रखें।

2. Service unit लिखें

/etc/systemd/system/youtube-ffmpeg.service बनाएँ। नीचे /usr/bin/ffmpeg path, /srv/video/recording.mp4, resolution और bitrate उदाहरण हैं—अपने installed binary तथा source के अनुरूप بدلें। ExecStart में shell variable expansion नहीं होती; इसलिए key को FFmpeg URL में systemd के ${YOUTUBE_STREAM_KEY} रूप में दें।

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudoedit /etc/systemd/system/youtube-ffmpeg.service
[Unit]
Description=FFmpeg YouTube Live stream
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=ffmpegstream
Group=ffmpegstream
EnvironmentFile=/etc/ffmpegstream.env
WorkingDirectory=/srv/video
ExecStart=/usr/bin/ffmpeg -nostdin -re -stream_loop -1 -i /srv/video/recording.mp4 -c:v libx264 -preset veryfast -b:v 4500k -maxrate 4500k -bufsize 9000k -r 30 -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -b:a 128k -f flv "rtmp://a.rtmp.youtube.com/live2/${YOUTUBE_STREAM_KEY}"
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

यह एक संभावित H.264/AAC loop उदाहरण है, YouTube की हर stream के लिए सार्वभौमिक command नहीं। -re file input को उसकी सामान्य playback गति पर पढ़ता है; -stream_loop -1 input को दोहराता है। अगर आपकी source पहले से live या real-time है, तो file-loop विकल्प नकल न करें। -g 60 और -keyint_min 60 30 fps पर 2-सेकंड GOP के उदाहरण हैं। Codec, bitrate, frame rate और keyframe interval को अपने source तथा YouTube Live Control Room की चुनी हुई settings से मिलाएँ।

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

Background invocation में -nostdin उपयोगी है: FFmpeg FAQ बताती है कि इससे console-input checks के कारण background task के suspend होने से बचा जा सकता है। FFmpeg FAQ.

3. Service load, start और enable करें

sudo systemctl daemon-reload
sudo systemctl enable --now youtube-ffmpeg.service
sudo systemctl status youtube-ffmpeg.service --no-pager

enable --now सेवा अभी शुरू करता है और boot पर शुरू होने के लिए enable करता है। Status में active (running) दिखना process की स्थिति बताता है, YouTube पर stream की नहीं।

4. Logs دیکھें اور restart کو محفوظ طریقے سے آزمائیں

sudo journalctl -u youtube-ffmpeg.service -f

Logs में input file न मिलने، permission، codec یا YouTube connection جیسے errors دیکھیں۔ Process-exit recovery کا آزمائشی طریقہ یہ ہے کہ stream کے دوران service کو جان بوجھ کر stop/start کریں، پھر status اور logs دیکھیں؛ live channel پر ایسا کرنے سے مختصر interruption ہو سکتا ہے۔ معمول کے restart کے لیے:

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.
sudo systemctl restart youtube-ffmpeg.service

اگر stream key reset کی ہو تو پہلے /etc/ffmpegstream.env کو نئی key سے محفوظ طریقے سے اپ ڈیٹ کریں، پھر service restart کریں۔

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

Silent freeze के लिए progress और YouTube health जाँचें

FFmpeg process के साथ output progress देखें

प्रक्रिया running हो सकती है जबकि frames या output आगे न बढ़ रहे हों। FFmpeg का -progress विकल्प progress records stdout पर देता है; इसे जोड़ना तभी उपयोगी है जब आप उन records को किसी monitor तक पहुँचाकर stale progress पर कार्रवाई भी करें। केवल service में Restart=always जोड़ना ऐसे अटके process को नहीं पहचानता। अपने input और FFmpeg build के अनुसार progress reporting तथा monitoring लागू करें; एक watchdog को लंबे समय तक progress न मिलने पर alert या service restart करना चाहिए, और लगातार restart loop से बचने के लिए सीमाएँ रखें।

YouTube पर वास्तविक stream की पुष्टि करें

Live Control Room में stream health और messages देखें, फिर public watch page पर playback जाँचें। YouTube कहता है, “During the event, monitor the stream health and review messages.” आधिकारिक मार्गदर्शन: encoder settings और stream health.

FFmpeg का log साफ दिखना, service का active होना और YouTube पर दर्शक को वीडियो मिलना तीन अलग संकेत हैं। समस्या की जगह पहचानने के लिए इन्हें साथ देखें: process/log, बढ़ता हुआ output progress, और YouTube health/watch page।

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.

YouTube stream lifecycle और archive का ध्यान रखें

YouTube के encoder instructions के अनुसार 12 घंटे से छोटी streams अपने आप archive होंगी। इससे यह निष्कर्ष नहीं निकलता कि हर लगातार चलने वाली stream का lifecycle या archive व्यवहार समान होगा। अपने channel और event setup में live stream तथा archive व्यवहार की पुष्टि करें: YouTube encoder instructions.

समस्या आए तो क्या जाँचें

लक्षण संभावित कारण जाँच या सुधार
Service तुरंत exit होकर बार-बार restart होती है गलत FFmpeg path, input path या permissions; invalid arguments; अनुपलब्ध key systemctl status और journalctl देखें। उसी user और input के साथ command की paths तथा options जाँचें; key को logs या सार्वजनिक रूप से न दिखाएँ।
Service active है, लेकिन वीडियो आगे नहीं बढ़ता Silent freeze या input/output progress रुकना Progress counter/monitor और YouTube Live Control Room health देखें। आवश्यक हो तो अलग watchdog से stale progress पर कार्रवाई कराएँ।
YouTube stream स्वीकार नहीं करता या बंद हो जाती है Key गलत/reset हो चुकी है, protocol या output settings मेल नहीं खाते, अथवा network बाधित है Control Room के संदेश देखें, सही key को restricted config में डालें और codec, bitrate व keyframe settings मिलाएँ। नेटवर्क क्षमता में headroom रखें।
Boot के बाद service नहीं चलती Unit enable नहीं، network/input उपलब्ध नहीं، या systemd configuration में त्रुटि systemctl is-enabled youtube-ffmpeg.service और boot के बाद journalctl -u youtube-ffmpeg.service देखें; unit बदलने पर daemon-reload चलाएँ।
कई बार restart के बाद भी YouTube पर stream नहीं आती Restart केवल process को दोहरा रहा है; मूल key، input، settings या network कारण باقی ہے Restart loop को असली recovery न मानें। Logs तथा YouTube health संदेश से मूल कारण ठीक करें।

Or let it run in the cloud

अगर आप खुद VPS, FFmpeg service और watchdog चलाने के बजाय uploaded video को 24/7 YouTube पर loop करना चाहते हैं, तो StreamNeo एक cloud विकल्प है: वीडियो upload करें, YouTube stream key जोड़ें और go live करें। घर का computer या connection चालू रखने की जरूरत नहीं; upload किया हुआ video जैसा है वैसा ही, 4K 60fps तक, एक flat slot price पर stream होता है। YouTube stream drop होने पर automatic recovery होती है। हर slot में 10 GB storage है, active slots में pooled; एक free day बिना card के मिलता है। Monthly plan: $9.99 per month. यह YouTube के लिए uploaded videos चलाता है, camera से live नहीं करता। StreamNeo पर 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
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.