Run FFmpeg under systemd as a foreground process, then let systemd start it at boot and restart it after an unexpected exit. The exact FFmpeg command depends on your source, codecs, output protocol and destination; there is no universal bhajan-stream command. The example below assumes a local audio file and an RTMP-style destination, so adapt and test it before relying on it.
Before creating the service
First make the FFmpeg command work interactively under the same Ubuntu account that will run the service. That exposes problems with file permissions, paths, credentials, codecs and destination settings before systemd adds another layer.
-
Check the installed build with
ffmpeg -version. If an option in an example is unsupported, consult the help for your installed build rather than assuming current online documentation applies. FFmpeg notes that its online documentation is regenerated nightly and describes the newest revision, which may differ from an older Ubuntu package. See the FFmpeg command-line documentation. -
Test the source and destination with the command you plan to use, substituting the real paths and destination details. Confirm that the destination is receiving media, not merely that FFmpeg remains running.
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.
-
Decide whether the input is a local file, playlist, capture device or network stream, and whether the output protocol and destination accept the chosen codecs and container. These choices determine the command and any protocol-specific recovery settings.
Create a systemd service for a local file
This illustrative unit assumes a local file, AAC audio transcoding and an RTMP-style output. It is a template, not a tested universal configuration. Replace paths and the destination with values appropriate to your setup; do not use the placeholder destination literally.
[Unit]
Description=FFmpeg bhajan stream
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=stream
WorkingDirectory=/srv/bhajan
ExecStart=/usr/bin/ffmpeg -re -stream_loop -1 -i /srv/bhajan/source-file -c:a aac -b:a 128k -f flv rtmp://STREAM-DESTINATION/APP/STREAM-KEY
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
Adapt the input and encoding
-
-rereads a file at its native rate rather than as fast as possible.-stream_loop -1requests repeated looping of the input. Confirm the behavior for your input and installed FFmpeg build. -
-c:a aac -b:a 128ktranscodes the audio to AAC at the specified bitrate. This is only an example setting; the destination’s requirements and your source determine what is appropriate.Recommended: Crashes or Glitches? A Free Driver Scan Usually Finds the Culprit →Recommended: PC Feels Slow? A Free Scan Shows What's Dragging Windows Down →Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
If the media is already encoded suitably, stream-copy may avoid transcoding, but only when the destination accepts the existing codecs and container parameters. FFmpeg treats streamcopy and transcoding as distinct processing paths; see the command-line documentation.
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.
-
For a playlist, capture device or network input, replace the input and related options accordingly. Do not assume the local-file loop command handles a live input or every playlist format.
Keep FFmpeg in the foreground
Use the FFmpeg command directly in ExecStart=. Do not append & or place shell redirection or pipes there: Ubuntu Jammy’s systemd.service manual says those shell constructs are not supported in ExecStart=. systemd can collect output in its journal; use an explicitly configured wrapper if you need shell features. The Jammy manual corresponds to systemd 249.11-0ubuntu3.22; see Ubuntu’s systemd.service manual.
Protect the stream key
Do not put credentials in a unit file readable by everyone or expose them in logs. Restrict access to the service configuration and run the process as a dedicated account with only the file and system access it needs. The appropriate secret-handling method depends on the destination and local setup.
Enable, inspect and stop the service
-
Save the unit as
/etc/systemd/system/bhajan-stream.service, adjusting the paths, account and command first. -
Reload systemd’s unit definitions:
sudo systemctl daemon-reload.Rank #3
SaleAnker 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.
-
Enable the service at boot and start it now:
sudo systemctl enable --now bhajan-stream.service. -
Inspect its state and recent output:
systemctl status bhajan-stream.serviceandjournalctl -u bhajan-stream.service -f.Recommended Free Tools
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Stop it when needed:
sudo systemctl stop bhajan-stream.service. To change the unit, edit it, runsudo systemctl daemon-reload, then restart the service.
After starting, verify at the destination that audio is actually arriving. A running process alone does not establish that the remote stream is healthy.
Choose restart and reconnection behavior deliberately
Restart=on-failure is a reasonable starting policy for a long-running FFmpeg process: systemd can restart it after an unclean exit. RestartSec=5 adds a delay before restart; adjust it to suit the setup rather than allowing rapid repeated attempts. Restarting is subject to systemd unit start-rate limits, so repeated failures can leave the unit stopped until you inspect its state and rate-limit behavior. These semantics are documented in the Ubuntu Jammy systemd.service manual.
Rank #4
- 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
Systemd responds to process exits and timeouts; it does not inherently know that a process is still running while its output has stalled. FFmpeg’s recovery options are protocol-specific. Its HTTP reconnect options apply to HTTP input handling, while the FIFO muxer documentation gives an example of RTMP output recovery. They address different failure cases, so choose based on which side of which connection is failing rather than adding them indiscriminately. See the FFmpeg protocol documentation and FFmpeg all-components documentation.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesTroubleshoot common failures
-
The service fails immediately: inspect
systemctl status bhajan-stream.serviceandjournalctl -u bhajan-stream.service -f. Check the executable path, option support in the installed FFmpeg version, file paths, account permissions and destination configuration. -
It works in a terminal but not as a service: compare the interactive and service accounts, working directory and permissions. Use absolute paths and ensure the service account can read the source and access any required credentials.
-
It restarts repeatedly: read the journal for the original FFmpeg error, then fix that cause. A restart policy cannot correct a bad path, rejected stream key, unsupported codec or inaccessible input. Repeated start failures may also encounter systemd’s rate limits.
-
The process stays active but the destination stops receiving media: systemd may not restart a process that has not exited. Check FFmpeg’s output and the network path, then select a recovery mechanism suited to the actual input or output protocol.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →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.
-
A reconnect option is rejected or has no effect: verify the option against the installed FFmpeg build and confirm it applies to the protocol and direction in question. HTTP input reconnection and RTMP output recovery are not interchangeable.
-
The destination rejects the stream: verify its required protocol, codecs, container and credentials. The example’s RTMP-style URL and AAC settings are assumptions, not requirements shared by every destination.
Test recovery before leaving it unattended
Do a controlled check: stop and start the service, observe its journal, and verify that the destination resumes receiving media. Then test an expected failure mode if you can do so safely. Confirm both process recovery and actual media delivery; a successful systemd restart alone does not prove that the remote stream recovered.
Or let it run in the cloud
If your goal is a YouTube channel playing uploaded bhajans continuously, StreamNeo is an alternative to maintaining an Ubuntu host and FFmpeg service. Upload a recording or build a playlist, add your YouTube stream key once, and go live. StreamNeo loops the uploaded videos from the cloud, so no computer or home connection has to stay on. It is for YouTube and uploaded video playback, not a live camera feed.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →-
Each slot streams the uploaded media as made, up to 4K 60fps, at one flat price per slot with no quality tiers.
-
It includes 24/7 looping and playlists, 10 GB storage per slot pooled across active slots, automatic recovery if YouTube drops the stream, and support from the StreamNeo team.
-
The first day is free with no card, once per account. Billing options are a day, week, month, 6 months or year, and you can cancel any time. UPI and cards are available in India; card checkout is available worldwide. For 5 or more slots, contact support.
-
Monthly: $9.99 per month.
For details, visit StreamNeo, or start your free day.
Quick Recap
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.




