ThisCalculator

Everyday

How to Stream Church Sermons 24/7 with FFmpeg

Updated · Standard formula, shown below

This guide shows you how to set up a continuous 24/7 live stream of your church sermons using FFmpeg, a free and open-source tool. You’ll learn to loop pre-recorded sermon videos, add a static overlay, and push the stream to platforms like YouTube or Facebook Live. By the end, you’ll have a reliable, automated stream that runs without manual intervention.

What You’ll Need

  • A computer that can stay on 24/7 (a small PC, laptop, or even a Raspberry Pi 4 or newer).
  • FFmpeg installed on that computer. Download from ffmpeg.org or use your package manager (e.g., apt install ffmpeg on Debian/Ubuntu).
  • Pre-recorded sermon videos in a common format (MP4, MKV, etc.). They should be encoded with H.264 video and AAC audio for best compatibility.
  • A streaming platform account (YouTube, Facebook Live, Twitch) that provides a stream URL and stream key.
  • Optional: A static image (PNG or JPG) to use as a “now playing” or logo overlay.

Step-by-Step

  1. Prepare your video files. Place all sermon videos in a single folder. Name them in the order you want them to play (e.g., 01-sermon.mp4, 02-sermon.mp4). Ensure they all have the same resolution and frame rate to avoid glitches. If they differ, use a tool like HandBrake to normalize them to, say, 1920×1080 at 30fps.
  2. Get your stream URL and key. In your streaming platform’s live dashboard, create a new live stream. Copy the RTMP URL (e.g., rtmp://a.rtmp.youtube.com/live2) and the stream key (a long alphanumeric string). Keep these private—anyone with them can stream to your channel.
  3. Create a playlist file. In the folder with your videos, create a text file named playlist.txt (or any name). List each video file with a full path, one per line. For example:
    file '/home/user/sermons/01-sermon.mp4'
    file '/home/user/sermons/02-sermon.mp4'

    Save the file. FFmpeg will loop through these in order.

  4. Test your FFmpeg command locally. Before going live, test the stream to a local file to verify the command works. Use the following command (replace paths and keys):
    ffmpeg -re -f concat -safe 0 -i playlist.txt -c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k -pix_fmt yuv420p -g 60 -c:a aac -b:a 128k -f flv test.flv

    Run this for a few seconds, then stop it. Check the output file plays correctly.

  5. Add looping and overlay (optional). To loop the playlist indefinitely, add the -stream_loop -1 option before the input. To overlay a static image (e.g., a logo in the corner), use the overlay filter. Here’s a full command with looping and overlay:
    ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt -i logo.png -filter_complex "[0:v][1:v]overlay=10:10" -c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k -pix_fmt yuv420p -g 60 -c:a aac -b:a 128k -f flv rtmp://your-stream-url/your-stream-key

    Adjust the overlay position (10:10 is 10 pixels from top-left).

  6. Go live. Replace the output URL and key in the command above. Run the command. You should see FFmpeg output showing encoding progress. Go to your streaming platform’s dashboard to confirm the stream is live.
  7. Keep it running. To run this 24/7, you’ll want to start the command automatically. On Linux, use systemd or cron with @reboot. On Windows, use Task Scheduler. Create a script that runs the FFmpeg command and restarts it if it crashes. For example, a simple bash loop:
    #!/bin/bash
    while true; do
      ffmpeg -re -stream_loop -1 -f concat -safe 0 -i playlist.txt -c:v libx264 -preset veryfast -b:v 2500k -maxrate 2500k -bufsize 5000k -pix_fmt yuv420p -g 60 -c:a aac -b:a 128k -f flv rtmp://your-url/your-key
      sleep 5
    done

    Make it executable and add it to your startup.

Common Mistakes

  • Using a stream key as the URL. The URL and key are separate. The full RTMP URL includes the key at the end, but many platforms provide them separately. Don’t mix them up.
  • Videos with different resolutions or frame rates. This causes the stream to stutter or drop. Normalize all videos to the same settings.
  • Forgetting the -re flag. Without it, FFmpeg sends frames as fast as possible, overloading the network and causing the stream to fail.
  • Not using -stream_loop -1 correctly. The -stream_loop option must come before the input file. Placing it after the input will cause an error.
  • Using a low bitrate for high-resolution video. This leads to blurry, pixelated video. For 1080p, use at least 2500kbps; for 720p, 1500kbps is acceptable.

Tips

  • Use a hardware encoder if available. If your CPU supports Intel Quick Sync or you have an NVIDIA GPU, use -c:v h264_qsv or -c:v nvenc_h264 to reduce CPU load.
  • Test with a private stream. Most platforms allow you to set a stream as “unlisted” or “private” for testing. Use that to verify everything works before going public.
  • Monitor your stream. Use a tool like ffmpeg logs or a simple script that checks if the process is running. If it stops, restart it.
  • Keep your playlist file updated. When adding new sermons, just add a line to the playlist file. The stream will pick it up on the next loop.
  • Use a static IP or a dynamic DNS service. If you’re hosting the stream from home, a dynamic DNS service helps you reconnect if your IP changes.

Troubleshooting

  • Stream goes live but shows a black screen. Check that your videos have video streams. Use ffprobe video.mp4 to inspect. If the video is corrupt, re-encode it.
  • Audio is out of sync. This often happens when videos have different audio sample rates. Normalize all audio to 44.1kHz or 48kHz.
  • FFmpeg crashes after a few minutes. Look at the error message. Common causes: invalid playlist entries (check paths), unsupported codecs (re-encode), or network issues (lower bitrate).
  • The stream disconnects periodically. This is often due to network instability. Reduce the bitrate, or use a wired Ethernet connection instead of Wi-Fi.
  • FFmpeg says “Unknown encoder ‘libx264′”. Your FFmpeg build doesn’t include libx264. Install the full version or use a different encoder like mpeg4 (but that’s less compatible).

Frequently Asked Questions

Can I stream live sermons instead of pre-recorded ones?

Yes, but this guide is for looping pre-recorded content. For live streaming, you’d use a capture device or screen capture. FFmpeg can do that too, but the setup is different.

Do I need a powerful computer?

Not really. Encoding 1080p with software encoding requires a decent CPU, but a modern quad-core is usually enough. Using hardware encoding reduces the load significantly.

Can I use a Raspberry Pi?

Yes, a Raspberry Pi 4 can handle 720p streaming with hardware encoding (h264_v4l2m2m). It’s a low-power, reliable option.

How do I add a “live” indicator or countdown?

You can create a video with a countdown timer using tools like OBS or FFmpeg’s drawtext filter, then include it in the playlist. For a simple static overlay, use the overlay filter as shown.

What if my internet upload speed is low?

Lower the resolution and bitrate. For example, 480p at 800kbps is watchable and requires less bandwidth. Test with a speed test to see your upload capacity.

Can I stream to multiple platforms at once?

Yes, you can use FFmpeg to output to multiple RTMP URLs by adding multiple output options, or use a service like Restream. However, that increases bandwidth usage.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.