How To Make Iptv Server In Ubuntu

How To Make Iptv Server In Ubuntu

Reading time1 min
#Streaming#Ubuntu#IPTV#FFmpeg#Linux

Building a Robust IPTV Server on Ubuntu: Step-by-Step Guide to Streaming Mastery

Forget getting locked into expensive commercial IPTV services. Here’s how you can own your streaming pipeline using Ubuntu — with greater flexibility, security, and control than most do-it-yourself tutorials suggest.

Setting up your own IPTV server on Ubuntu empowers you to control content distribution, reduce costs, and customize streaming solutions without relying on third-party providers. This is crucial for anyone looking to scale personalized streaming services or simply want full ownership of their IPTV ecosystem.

In this post, I’ll walk you through everything you need to build a reliable, scalable IPTV server running on Ubuntu—from preparing the environment to serving live streams or Video On Demand (VOD) content. Whether you are a technical professional or enthusiast eager to learn, this practical guide will get you streaming like a pro.


What You’ll Need Before Starting

  • A machine running Ubuntu (18.04/20.04/22.04 LTS recommended). This can be physical hardware or a VPS.
  • Basic Linux command-line knowledge.
  • A stable internet connection with appropriate bandwidth for your number of viewers.
  • Multimedia source files or live broadcast input (IP camera feed, tuner card, etc.).

Step 1: Update and Prepare Your Ubuntu Server

Start by ensuring your system is updated:

sudo apt update && sudo apt upgrade -y

Install essential tools:

sudo apt install -y software-properties-common curl ffmpeg nginx

ffmpeg is key for transcoding or packaging video streams while nginx will serve as our HTTP server.


Step 2: Understand Core IPTV Components

An IPTV solution mainly consists of:

  • Source Input: Live broadcast feed or video files.
  • Encoder/Packager: Processes and converts the input into streaming-friendly formats.
  • Streaming Server: Delivers the video streams over protocols like HLS (HTTP Live Streaming) to client devices.
  • Playlist Management: M3U playlists help clients know available channels.

We’ll build a simple HLS streaming server using ffmpeg and nginx.


Step 3: Set Up the Streaming Directory Structure

Create folders where your live chunks and playlists will reside:

sudo mkdir -p /var/www/html/iptv/live
sudo chown -R $USER:$USER /var/www/html/iptv

This path /var/www/html/iptv/live will host our .m3u8 playlist and .ts segments created by ffmpeg.


Step 4: Streaming a Video File as an HLS Stream

To test your setup, start by streaming a pre-recorded video file (e.g., sample.mp4) as an HLS stream.

Place your sample video somewhere accessible, e.g., /home/user/videos/sample.mp4.

Run this command to convert it into an HLS stream:

ffmpeg -re -i /home/user/videos/sample.mp4 \
  -c:v libx264 -preset veryfast -crf 20 \
  -c:a aac -b:a 128k \
  -hls_time 6 \
  -hls_list_size 5 \
  -hls_flags delete_segments+append_list \
  /var/www/html/iptv/live/stream.m3u8

Explanation:

  • -re: Read input at native frame rate (real-time).
  • -hls_time 6: Splits stream into ~6-second chunks.
  • -hls_list_size 5: Playlist contains last 5 segments.
  • delete_segments: Removes old segments to save space.

Leave this command running while you test playback.


Step 5: Configure Nginx to Serve Your Streams

By default, Nginx serves files from /var/www/html. Verify it’s running using:

systemctl status nginx

If not active:

sudo systemctl start nginx

Make sure port 80 is open in your firewall (ufw example):

sudo ufw allow 'Nginx HTTP'

Your stream URL will now be accessible via:

http://your_server_ip/iptv/live/stream.m3u8

Test playing it in VLC or any HLS-compatible player:

  1. Open VLC Media Player.
  2. Go to Media > Open Network Stream.
  3. Enter the URL above.
  4. Hit Play.

You should see your sample video playing as an HTTP Live Stream!


Step 6: Streaming Live Input (Optional)

For live broadcasting from a DVB tuner card or IP camera (RTSP), adjust the ffmpeg input accordingly.

Example with IP camera RTSP feed:

ffmpeg -i rtsp://username:password@camera_ip:554/stream1 \
-c:v libx264 -preset veryfast -crf 20 \
-c:a aac -b:a 128k \
-hls_time 6 \
-hls_list_size 5 \
-hls_flags delete_segments+append_list \
/var/www/html/iptv/live/live.m3u8

This command extracts your live feed and streams it out over HTTP as HLS segments you can consume instantly via compatible devices.


Step 7: Creating an M3U Playlist for Multiple Channels

To add multiple channels—for example multiple live streams—you want a master .m3u playlist that points to each channel’s .m3u8.

Sample /var/www/html/iptv/channels.m3u file content:

#EXTM3U

#EXTINF:-1 tvg-id="channel1" tvg-name="Channel One" tvg-logo="http://example.com/logos/ch1.png",Channel One
http://your_server_ip/iptv/live/channel1.m3u8

#EXTINF:-1 tvg-id="channel2" tvg-name="Channel Two" tvg-logo="http://example.com/logos/ch2.png",Channel Two
http://your_server_ip/iptv/live/channel2.m3u8

Clients load this playlist file to browse available streams easily.


Additional Tips for Robustness & Scaling

  • Automate startup of FFmpeg streams with systemd service files.
  • Use SSL/TLS certificates with Nginx for secure HTTPS streaming.
  • Monitor streaming server performance with tools like htop, netstat.
  • Optimize transcoding parameters based on target device compatibility.
  • Consider load balancing if scaling beyond a single server.

Conclusion

Building your own IPTV server on Ubuntu may seem daunting at first, but once broken down into manageable steps—installing Nginx, using FFmpeg for encoding, and creating playlists—it becomes straightforward and incredibly powerful. You gain total control over your media distribution without expensive commercial dependencies.

With customization possibilities spanning from codec settings to security policies, mastering these building blocks sets you up for scalable personalized IPTV delivery tuned exactly how you want it.

Try out these techniques today and unlock true streaming mastery on your own terms!


If you found this guide useful, feel free to share it or ask questions below!