October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Mountain View desk3 min

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

systemd process crash पर FFmpeg को फिर शुरू कर सकता है, लेकिन अटकी हुई YouTube stream के लिए अलग progress watchdog और Live Control Room verification चाहिए।
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Ubuntu/Linux Vultr VPS पर FFmpeg को systemd service के रूप में चलाएँ और Restart=always सेट करें। इससे FFmpeg process बंद या crash होने पर service उसे फिर शुरू कर सकती है। लेकिन अगर process चलता रहे और YouTube पर वीडियो अटक जाए, तो केवल यह restart policy पर्याप्त नहीं है—उसके लिए progress/health watchdog और YouTube Live Control Room में जाँच भी चाहिए।

यह तरीका क्या संभालता है—और क्या नहीं

Vultr VPS पर FFmpeg वीडियो को YouTube Live तक भेजता है; systemd उस process की निगरानी करके उसके exit होने पर उसे दोबारा शुरू करता है। Vultr का streaming-server संदर्भ Ubuntu पर streaming setup दिखाता है, जबकि FFmpeg की भूमिका media processing और output भेजना है (Vultr setup guide; FFmpeg documentation)।

As an Amazon Associate I earn from qualifying purchases.

  • Process exit या crash: systemd restart policy उपयोगी है।
  • Silent freeze: FFmpeg process जीवित हो सकता है, जबकि output आगे न बढ़े। इस स्थिति को पहचानने के लिए अलग progress/health check चाहिए।
  • YouTube ingest या network समस्या: service status से अकेले यह साबित नहीं होता कि दर्शकों को stream मिल रही है। Live Control Room के stream-health संकेत और watch page पर playback जाँचें।

systemd service और progress monitoring को अलग जिम्मेदारियाँ समझें; एक दूसरे का पूरा विकल्प नहीं है (FFmpeg systemd guide; YouTube encoder settings)।

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

पहले YouTube और VPS की तैयारी करें

Stream key को सुरक्षित रखें

YouTube stream key को password और address की तरह संवेदनशील मानता है (YouTube stream settings)। उसे public script या repository में न रखें और command में सीधे लिखने से बचें, क्योंकि command shell history या process विवरण में दिखाई दे सकती है। नीचे के उदाहरण में key restricted-permission environment file से ली जाती है। YouTube Live Control Room में key reset करने पर उस file में नई key डालकर service restart करनी होगी।

Encoder output को YouTube की settings से मिलाएँ

YouTube की encoder guidance RTMP/RTMPS, H.264/H.265/AV1 विकल्प, CBR और अधिकतम 60 fps तक frame rate बताती है। Keyframe interval 2 सेकंड सुझाया गया है और 4 सेकंड से अधिक न रखने की सलाह है। 720p30 H.264 के लिए YouTube की प्रकाशित सिफारिश 3–8 Mbps है; ये guidance values हैं, किसी खास VPS या source के लिए performance guarantee नहीं (YouTube encoder settings)।

उपलब्ध upload bandwidth stream के कुल bitrate से अधिक रखें। YouTube लगभग 20% headroom छोड़ने की सलाह देता है; network disruption stream तोड़ सकती है (YouTube streaming tips)।

systemd service बनाएँ

नीचे Ubuntu/Linux के लिए एक ढाँचा है। अपने distro, FFmpeg binary path, input file और YouTube ingest URL के अनुसार इसे जाँचें। यह किसी विशिष्ट Vultr VPS पर परीक्षण किया हुआ command set नहीं है। उदाहरण मानता है कि dedicated उपयोगकर्ता ffmpeg और directories पहले से बनाई गई हैं।

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Dedicated उपयोगकर्ता और config file तैयार करें

    अलग unprivileged account बनाएँ और उसे केवल आवश्यक media तथा config तक पहुँच दें। उदाहरण के लिए key file /etc/ffmpeg/youtube.env हो सकती है। उसे केवल service owner/root पढ़ सके, ऐसी permissions रखें।

    sudo install -d -m 0750 -o root -g ffmpeg /etc/ffmpeg
    sudo install -m 0640 -o root -g ffmpeg /dev/null /etc/ffmpeg/youtube.env
    sudoedit /etc/ffmpeg/youtube.env

    इस file में environment variable रखें, जैसे YOUTUBE_STREAM_KEY=...। वास्तविक key को साझा न करें। सिस्टम पर ffmpeg नाम का group/account न हो तो पहले अपने distro के अनुरूप बनाएँ; ownership उसी वास्तविक service account/group से मिलनी चाहिए।

  2. FFmpeg command तैयार करें

    एक उदाहरण invocation नीचे है। /usr/bin/ffmpeg, /srv/media/video.mp4, ingest hostname और encoding विकल्प अपने setup के अनुरूप बदलें। YouTube Live Control Room में दिखाया गया ingest URL इस्तेमाल करें।

    /usr/bin/ffmpeg -nostdin -re -stream_loop -1 -i /srv/media/video.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 -ar 44100 
      -f flv "rtmps://YOUR_INGEST_URL/live/${YOUTUBE_STREAM_KEY}"

    यह केवल उदाहरण है: 4500 kbps video bitrate और 30 fps को तभी रखें जब source, चुनी गई resolution, VPS क्षमता और उपलब्ध upload bandwidth के लिए वे उचित हों। 30 fps पर 60-frame GOP दो सेकंड का keyframe interval देता है। -nostdin background service में console-input checks से process suspend होने की संभावना से बचाता है, जैसा FFmpeg FAQ बताती है (FFmpeg FAQ)।

    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.

    आपके FFmpeg build और YouTube event configuration के अनुसार codec, audio तथा protocol विकल्प जाँचें। यदि पहले से तैयार input stream को बिना encode किए भेज रहे हैं, तो encoding flags का चुनाव अलग होगा; अनुमान से flags न जोड़ें।

  3. Service unit लिखें

    /etc/systemd/system/ffmpeg-youtube.service बनाएँ:

    [Unit]
    Description=FFmpeg YouTube Live stream
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    Type=simple
    User=ffmpeg
    Group=ffmpeg
    EnvironmentFile=/etc/ffmpeg/youtube.env
    ExecStart=/usr/bin/ffmpeg -nostdin -re -stream_loop -1 -i /srv/media/video.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 -ar 44100 -f flv rtmps://YOUR_INGEST_URL/live/${YOUTUBE_STREAM_KEY}
    Restart=always
    RestartSec=5
    
    [Install]
    WantedBy=multi-user.target

    अपनी unit में ingest URL और command को सही रूप में रखें; यदि URL में shell expansion की जरूरत है, तो systemd की ExecStart parsing के अनुरूप सावधानी से configure करें। एक सरल विकल्प एक executable wrapper script है जो restricted config पढ़कर FFmpeg शुरू करे। Secrets को unit file या public script में न रखें। RestartSec=5 restart से पहले पाँच सेकंड का विराम देता है; इसे अपने reconnect व्यवहार के अनुसार समायोजित किया जा सकता है।

  4. Unit लोड करके शुरू करें

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

    enable boot पर service शुरू करने के लिए सेट करता है; --now उसे अभी शुरू भी करता है।

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  5. Logs और YouTube पर परिणाम सत्यापित करें

    sudo journalctl -u ffmpeg-youtube.service -f

    Logs में FFmpeg errors, connection failures और restart attempts देखें। साथ में YouTube Live Control Room में stream-health messages देखें और public watch page पर playback जाँचें। YouTube स्वयं event के दौरान stream health monitor करने और messages देखने की सलाह देता है (YouTube encoder settings)।

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

अटकने वाली stream के लिए progress watchdog जोड़ें

Restart=always तभी काम आता है जब process exit करे। अगर FFmpeg जीवित है पर media timestamp या output progress नहीं बढ़ रहा, तो systemd इसे अपने-आप crash नहीं मानेगा। FFmpeg का progress output किसी file/pipe में लिखवाएँ और अलग watchdog से जाँचें कि हाल की अवधि में progress बदला है या नहीं। पुराना progress मिलने पर watchdog service restart करा सकता है।

Watchdog बनाते समय timeout को source के स्वभाव, reconnect की अवधि और नेटवर्क में सामान्य उतार-चढ़ाव से बड़ा रखें, ताकि अस्थायी रुकावट पर अनावश्यक restart न हो। FFmpeg log activity को अकेले progress न मानें: लगातार messages आना यह प्रमाण नहीं कि YouTube तक उपयोगी frames पहुँच रहे हैं। Watchdog के बाद भी Live Control Room और watch page से पुष्टि करें।

आम समस्याएँ और सुधार

  • Service शुरू होते ही बार-बार restart होती है: systemctl status और journalctl में file path, permissions, FFmpeg arguments और ingest URL की त्रुटि देखें। पहले command को service user के रूप में जाँचें।
  • FFmpeg चलता है, लेकिन YouTube पर stream नहीं दिखती: stream key और ingest URL की पुष्टि करें, Live Control Room के health संकेत पढ़ें, और outbound connectivity तथा bitrate जाँचें। Process का active दिखना YouTube ingest का प्रमाण नहीं है।
  • Key reset के बाद connection विफल: restricted config file में नई key डालें और service restart करें: sudo systemctl restart ffmpeg-youtube.service।
  • दर्शकों को frozen video दिखता है, service active है: यह process-exit recovery से अलग silent-freeze मामला है। Progress watchdog और YouTube stream-health जाँच लागू करें।
  • बार-बार network disconnect: bitrate को उपलब्ध upload capacity के अनुरूप रखें और headroom दें; नेटवर्क बाधा से भेजना टूट सकता है (YouTube streaming tips)।
  • पुनः शुरू होने पर YouTube event अपेक्षा से अलग व्यवहार करता है: YouTube के अनुसार 12 घंटे से छोटी streams स्वतः archive होंगी। लगातार stream और archive व्यवहार अपने channel/event setup में सत्यापित करें; हर stream के लिए एक सार्वभौमिक lifecycle या restart schedule स्थापित नहीं है (YouTube encoder instructions)।

Or let it run in the cloud

अगर VPS पर FFmpeg, systemd और watchdog बनाए रखना नहीं चाहते, तो StreamNeo YouTube के लिए cloud service है: वीडियो upload करें, YouTube stream key जोड़ें और go live करें। यह uploaded video को 24/7 loop करता है—घर का computer या internet connection चालू रखने की जरूरत नहीं।

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • आपका video जिस quality में बना है, उसी में stream होता है, 4K 60fps तक; हर quality के लिए एक ही price per slot है।
  • YouTube stream गिरने पर automatic recovery है।
  • पहला दिन बिना card के free है।

Monthly plan: $9.99 per month. StreamNeo पर पहला दिन मुफ्त शुरू करें।

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 Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
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.