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

Vultr VPS पर FFmpeg YouTube स्ट्रीम अपने आप कैसे रीस्टार्ट करें

Vultr VPS पर FFmpeg को systemd service में चलाकर process crash के बाद restart करें—और जानें कि YouTube पर अटकी stream को अलग watchdog से कैसे पहचानना है।

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

Vultr के Ubuntu/Linux VPS पर FFmpeg को systemd service के रूप में चलाएँ। Restart=always से service FFmpeg के बंद होने पर उसे फिर शुरू कर सकती है; पर अगर FFmpeg चलता रहे और YouTube पर वीडियो रुक जाए, तो केवल यह setting काफी नहीं है। उसके लिए अलग health check और YouTube Live Control Room में निगरानी चाहिए।

क्या चाहिए और यह तरीका क्या संभालता है

इस सेटअप में Vultr VPS पर FFmpeg वीडियो को YouTube Live तक भेजता है और systemd FFmpeg process को service की तरह चलाता है। Vultr का [streaming server guide](https://docs.vultr.com/public/doc-assets/pdfs/article/create-a-streaming-server-with-obs-and-ubuntu.pdf) Ubuntu पर streaming server की पृष्ठभूमि देता है; FFmpeg की भूमिका और विकल्प उसके [आधिकारिक documentation](https://www.ffmpeg.org/ffmpeg.html) में हैं। यह उदाहरण Ubuntu/Linux और systemd मानता है। अपने distro, FFmpeg के installed path, वीडियो फ़ाइल और YouTube event के अनुसार paths तथा settings जाँचें।

  • यह तरीका FFmpeg के crash या exit होने पर process को फिर शुरू करने के लिए है।
  • यह अपने आप प्रमाणित नहीं करता कि YouTube दर्शकों को वीडियो दिखा रहा है। Network, YouTube ingest या अटके output के लिए अलग जाँच आवश्यक है।
  • उदाहरण में वीडियो को लगातार loop किया जाता है। आपका स्रोत playlist या अलग input हो तो FFmpeg command उसी के अनुसार बदलें।

यहाँ दिए गए commands किसी विशेष Vultr VPS पर परीक्षण किए हुए होने का दावा नहीं हैं। उन्हें अपने server पर चलाने से पहले paths और YouTube stream setup से मिलाएँ।

FFmpeg के लिए सुरक्षित user और stream key तैयार करें

अलग user बनाएँ

SSH से VPS में लॉगिन कर एक dedicated, unprivileged user बनाएँ। नीचे ffmpeg नाम उदाहरण के लिए है:

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.
sudo adduser --system --group --home /var/lib/ffmpeg ffmpeg
sudo install -d -o ffmpeg -g ffmpeg /srv/stream
sudo install -d -o root -g ffmpeg -m 750 /etc/ffmpeg

अपनी वीडियो फ़ाइल /srv/stream/video.mp4 पर रखें और सुनिश्चित करें कि ffmpeg user उसे पढ़ सकता है। यदि फ़ाइल किसी अन्य directory में है, तो आगे के command में उसका वास्तविक path लिखें।

YouTube stream key को config file में रखें

YouTube stream key को password की तरह सुरक्षित रखें। YouTube कहता है, “Stream keys are like your YouTube stream’s password and address.” इसे सार्वजनिक script या repository में न डालें और command line पर सीधे न लिखें। Live Control Room में key reset करने पर इस config file में नई key दर्ज करें। विवरण [YouTube stream settings](https://support.google.com/youtube/answer/9854503?hl=en) में हैं।

Root के रूप में नीचे की file बनाएँ। REPLACE_WITH_YOUR_STREAM_KEY को अपनी key से बदलें:

sudo sh -c 'printf "%sn" "STREAM_KEY=REPLACE_WITH_YOUR_STREAM_KEY" > /etc/ffmpeg/youtube.env'
sudo chown root:ffmpeg /etc/ffmpeg/youtube.env
sudo chmod 640 /etc/ffmpeg/youtube.env

Key में shell या URL के विशेष अक्षर हों तो साधारण environment-file assignment उन्हें हर परिस्थिति में सुरक्षित ढंग से संभाले, यह मानकर न चलें। अपनी key के characters के अनुसार file का quoting तरीका जाँचें; key को सार्वजनिक जगह पर दिखाए बिना permissions भी सत्यापित करें।

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

FFmpeg चलाने का script बनाएँ

एक script में environment file पढ़ें और stream key को input से जोड़ें। इस तरह key FFmpeg command की unit file में खुली हुई नहीं रहती। Root के रूप में /usr/local/bin/youtube-ffmpeg.sh बनाएँ:

sudo tee /usr/local/bin/youtube-ffmpeg.sh > /dev/null <<'EOF'
#!/bin/bash
set -euo pipefail

source /etc/ffmpeg/youtube.env
: "${STREAM_KEY:?STREAM_KEY is not set}"

exec /usr/bin/ffmpeg 
  -nostdin 
  -re -stream_loop -1 -i /srv/stream/video.mp4 
  -c:v libx264 -preset veryfast -pix_fmt yuv420p 
  -r 30 -g 60 -keyint_min 60 -sc_threshold 0 
  -b:v 4500k -maxrate 4500k -bufsize 9000k 
  -c:a aac -b:a 128k -ar 44100 
  -f flv "rtmp://a.rtmp.youtube.com/live2/${STREAM_KEY}"
EOF
sudo chown root:root /usr/local/bin/youtube-ffmpeg.sh
sudo chmod 755 /usr/local/bin/youtube-ffmpeg.sh

/usr/bin/ffmpeg इस उदाहरण का path है; command -v ffmpeg से अपने server पर binary का path देखें और script में बदलें। यदि FFmpeg अलग जगह installed है, पुराना path रखने पर service शुरू नहीं होगी। -nostdin background task में FFmpeg को console input जाँचने से रोकता है; यही विकल्प [FFmpeg FAQ](https://ffmpeg.org/faq.html) सुझाती है।

यह encoding command एक उदाहरण है, सार्वभौमिक preset नहीं। -re फ़ाइल को लगभग वास्तविक समय की गति से पढ़ता है; -stream_loop -1 इसे दोहराता है। वीडियो codec, audio, frame rate, bitrate और GOP को source तथा YouTube event के अनुकूल रखें। यदि upload किया जा रहा वीडियो पहले से सही codec और stream settings में है, तो re-encoding के बजाय stream copy संभव हो सकती है, लेकिन तभी जब source YouTube की आवश्यकताओं से मेल खाता हो।

systemd service बनाएँ और चालू करें

/etc/systemd/system/youtube-ffmpeg.service नाम से unit file बनाएँ:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 tee /etc/systemd/system/youtube-ffmpeg.service > /dev/null <<'EOF'
[Unit]
Description=FFmpeg YouTube Live stream
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=ffmpeg
Group=ffmpeg
ExecStart=/usr/local/bin/youtube-ffmpeg.sh
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

Restart=always process समाप्त होने पर उसे फिर शुरू करने की policy है; RestartSec=10 restart से पहले दस सेकंड रुकता है। यह delay तेज़ restart loop से बचाता है, पर स्थायी गलत config या invalid key को ठीक नहीं करता। बदलाव लागू कर service enable और start करें:

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

Logs देखने के लिए journalctl उपयोग करें:

sudo journalctl -u youtube-ffmpeg.service -f

बाहर निकलने के लिए Ctrl+C दबाएँ; इससे log देखने की command बंद होगी, service नहीं। Configuration बदलने के बाद, जैसे stream key update करने पर, service restart करें:

sudo systemctl restart youtube-ffmpeg.service

YouTube के encoder settings से output मिलाएँ

YouTube की प्रकाशित encoder guidance के अनुसार RTMP/RTMPS ingest उपलब्ध है; codec विकल्पों में H.264, H.265 और AV1 बताए गए हैं। वह CBR की सलाह देती है, frame rate 60 fps तक बताती है और keyframe frequency 2 सेकंड सुझाती है—4 सेकंड से अधिक नहीं। नीचे के उदाहरण में 30 fps और 2-second GOP के लिए -g 60 रखा गया है। अपने चुने हुए frame rate के अनुसार GOP बदलें; सामान्य गणना frame rate × 2 है।

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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

YouTube की 2026-10-03 को देखी गई encoder guidance में 720p, 30 fps H.264 के लिए 3–8 Mbps bitrate range दी गई है। ऊपर का -b:v 4500k इस range के भीतर का उदाहरण है, performance guarantee नहीं। Resolution, frame rate और codec के लिए वर्तमान मान तथा अन्य presets YouTube की [encoder settings](https://support.google.com/youtube/answer/2853702?hl=en) में देखें।

आउटबाउंड upload bandwidth में पर्याप्त margin रखें। YouTube लगभग 20% headroom छोड़ने की सलाह देता है और कहता है कि कुल stream bitrate उपलब्ध upload bandwidth से अधिक नहीं होना चाहिए। मसलन, ऊपर के video और audio bitrate का कुल जोड़ ही network पर भेजे जाने वाले data का पूरा हिसाब नहीं है; overhead के लिए भी जगह रखें। YouTube की [streaming tips](https://support.google.com/youtube/answer/2853856?hl=en) network disruption को stream की समस्या का एक कारण बताती हैं।

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

Restart हुआ है या YouTube पर stream भी चल रही है?

systemctl status में active (running) का अर्थ केवल यह है कि service का process चल रहा है। FFmpeg अटक जाए, output packets आगे न बढ़ें, network टूट जाए या YouTube ingest पर समस्या हो, तो service फिर भी चलती दिख सकती है। Process-exit recovery और silent-freeze detection अलग समस्याएँ हैं।

तीन जगह पर जाँचें

  1. systemd status: sudo systemctl status youtube-ffmpeg.service से active state और हालिया exit/restart देखें। बार-बार restart होने पर logs में error का कारण ढूँढें।
  2. FFmpeg logs/progress: sudo journalctl -u youtube-ffmpeg.service -f में input, encoder, network और output संबंधी errors देखें। Progress counter या health watchdog से जाँचें कि frame/time/output आगे बढ़ रहे हैं। Watchdog को सिर्फ PID के जीवित होने पर निर्भर न करें।
  3. YouTube: Live Control Room में ingest status और stream health देखें, फिर public watch page पर playback सत्यापित करें। YouTube event के दौरान stream health की निगरानी की सलाह देता है; देखें [encoder settings](https://support.google.com/youtube/answer/2853702?hl=en)।

Progress watchdog को अलग से बनाना और संचालित करना होगा; ऊपर की systemd unit में ऐसा watchdog शामिल नहीं है। वह निर्धारित समय तक progress न मिलने पर alert दे सकता है या service को पुनः शुरू करा सकता है, लेकिन गलत threshold network jitter या धीमे input को freeze समझ सकता है। पहले logs और YouTube health संकेतों के साथ व्यवहार जाँचें; बिना परीक्षण के आक्रामक auto-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.

YouTube stream की lifecycle, key और नियम जाँचें

Restart policy YouTube Live event की lifecycle को नियंत्रित नहीं करती। YouTube encoder instructions के अनुसार 12 घंटे से छोटी streams स्वतः archive होंगी। लगातार चलने वाली stream और archive व्यवहार अपने channel तथा event setup में सत्यापित करें; इसे हर stream के लिए एक जैसी lifecycle या restart schedule न मानें। देखें [YouTube encoder instructions](https://support.google.com/youtube/answer/2907883?hl=en-EN)।

Stream key को किसी अनधिकृत व्यक्ति को मिल जाने का संदेह हो तो Live Control Room में reset करें, फिर restricted config file में नई key डालें और service restart करें। साथ ही सुनिश्चित करें कि upload की गई सामग्री के लिए आवश्यक अधिकार आपके पास हैं और stream YouTube के copyright तथा monetization/reused-content नियमों के अनुरूप है। Live eligibility या content policy के बारे में अनुमान न लगाएँ; अपने channel पर लागू YouTube की मौजूदा शर्तें जाँचें।

आम समस्याएँ और उनके समाधान

लक्षण संभावित कारण क्या करें
Service शुरू होते ही fail होती है गलत FFmpeg binary path, script permission या वीडियो path command -v ffmpeg से binary path मिलाएँ; script executable है और ffmpeg user input file पढ़ सकता है, यह जाँचें। फिर journalctl -u youtube-ffmpeg.service -n 100 देखें।
Service बार-बार restart होती है FFmpeg लगातार exit कर रहा है—मसलन invalid input, key या encoder option Logs में पहली FFmpeg error ढूँढें और root cause ठीक करें; केवल restart delay बढ़ाने से error नहीं सुधरेगा।
FFmpeg चल रहा है, पर YouTube पर stream नहीं दिखती गलत या reset हुई key, ingest/network समस्या, या output रुकना Key की config और Live Control Room event मिलाएँ; logs, progress और YouTube stream health को साथ देखकर कारण अलग करें।
Service active है पर playback freeze है Process जीवित है लेकिन output progress नहीं कर रहा इसे process-exit restart policy का काम न समझें। Progress/health watchdog और YouTube health संकेत जाँचें; आवश्यक हो तो समस्या पहचानकर service restart करें।
Stream health खराब या connection अस्थिर है Upload bandwidth अपर्याप्त या network disruption कुल bitrate घटाएँ या resolution/frame rate समायोजित करें और उपलब्ध upload में YouTube की सुझाई लगभग 20% headroom रखें।
Key बदलने के बाद stream नहीं जुड़ती पुरानी key config में है या नई file service user के लिए पढ़ने योग्य नहीं /etc/ffmpeg/youtube.env अपडेट करें, owner/mode जाँचें और sudo systemctl restart youtube-ffmpeg.service चलाएँ।

Or let it run in the cloud

यदि VPS पर FFmpeg, systemd और health checks खुद बनाए रखना आपका लक्ष्य नहीं है, StreamNeo YouTube पर uploaded videos से 24/7 stream चलाने का cloud विकल्प है। वीडियो upload करें, YouTube stream key जोड़ें और go live करें; laptop या home connection चालू रखने की जरूरत नहीं।

  • कंप्यूटर बंद होने पर भी stream cloud से चलती है।
  • हर slot का एक flat price है; upload जैसा है वैसा ही stream होता है, 4K 60fps तक, बिना re-encode और quality tiers के।
  • YouTube stream गिरने पर automatic recovery शामिल है।
  • पहला दिन बिना card के free है।

Monthly: $9.99 per month. StreamNeo केवल YouTube पर stream करता है और uploaded video चलाता है—camera से live नहीं जाता। [StreamNeo](https://streamneo.com) पर विवरण देखें या [बिना card के free day शुरू करें](https://app.streamneo.com/register)।

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 Patch Notes

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
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.