Skip to content
Launch offer: Free installation on every Extended license this month! Shop now
  1. Home
  2. Blog
  3. HLS Video Streaming in Laravel: A Practical Setup Guide

HLS Video Streaming in Laravel: A Practical Setup Guide

A beginner-friendly guide to adding HLS video streaming to your Laravel app, from converting videos with FFmpeg to serving playlists and playing them in the browser.

November 01, 2026 7 min read Tutorials
HLS Video Streaming in Laravel: A Practical Setup Guide

If you want videos on your website to start quickly and play smoothly on any connection, hls video streaming laravel is one of the most practical setups you can choose. Instead of sending one huge MP4 file, HLS breaks the video into small pieces that load one after another. In this guide, we will walk through how it works and how to set it up in a Laravel project, step by step.

You do not need to be a video expert. If you know the basics of Laravel, you can follow along. And if you would rather have someone build it for you, we will point you to the right help at the end.

What Is HLS and Why Use It?

HLS stands for HTTP Live Streaming. Apple created it, and today almost every device and browser can play it, either natively or with a small JavaScript library.

Here is the basic idea. Your video is converted into many short segments, usually a few seconds each. A text file called a playlist (with the .m3u8 extension) tells the player which segments to load and in what order.

Benefits for small businesses

  • Faster start: viewers do not wait for a full file to download.
  • Adaptive quality: you can offer several resolutions, and the player switches based on the viewer's internet speed.
  • Works over normal HTTP: no special streaming server is required to deliver the files.
  • Harder to download casually: the video is split into many pieces, which discourages simple right-click saving. It is not full protection, though.

For course platforms, membership sites, product demos or movie portals, this makes a real difference to the viewer experience.

What You Need Before You Start

Before writing any code, check that your environment is ready. Many problems with hls video streaming laravel projects come from the server, not the code.

  1. A Laravel project running on a recent PHP version.
  2. FFmpeg installed on the server. This is the tool that converts videos into HLS segments.
  3. A queue system (database or Redis driver) so conversions run in the background.
  4. Enough storage and CPU. Video conversion is heavy work, and HLS files take space, especially with multiple resolutions.

Not every hosting plan allows FFmpeg or long-running background jobs. Before you commit, ask your host directly. You can compare options on our web hosting plans page and contact us to confirm what fits your project.

Step-by-Step: Converting Videos to HLS in Laravel

The most common approach is to let users or admins upload a normal MP4 file, then convert it to HLS in the background.

Step 1: Install an FFmpeg package

Popular community packages like pbmedia/laravel-ffmpeg wrap FFmpeg in a clean Laravel-style API. You install it with Composer and set the paths to your FFmpeg and FFprobe binaries in the config or .env file.

Step 2: Store the uploaded video

Save the original upload to a private disk, for example storage/app/uploads. Create a database record for the video with a status field such as pending, processing, ready or failed. This lets you show progress to users.

Step 3: Create a queued job

Never convert a video during the web request. It can take minutes and will time out. Instead, create a job (for example ConvertVideoToHls) and dispatch it after the upload is saved.

Inside the job, you typically:

  • Open the original file from your disk.
  • Define one or more quality levels, such as 360p, 720p and 1080p, each with its own bitrate.
  • Export to HLS with a segment length, often around 6 to 10 seconds.
  • Save the playlist and segments to a folder named after the video ID.
  • Update the video status to ready, or failed if something goes wrong.

Step 4: Run the queue worker

Start a worker with php artisan queue:work. On a live server, use a process manager such as Supervisor so the worker keeps running after restarts. Increase the job timeout, because long videos need more time.

Serving and Playing Your HLS Streams

Once conversion is done, you have a master playlist that points to the different quality playlists and their segments. Now you need to deliver them to viewers.

Public vs. protected delivery

For free public videos, you can place HLS files on a public disk and link straight to the master .m3u8 file. This is the simplest and fastest option.

For paid or member-only content, keep files private and serve them through a Laravel route that checks if the user is logged in or subscribed. Some setups also encrypt segments with AES-128 keys, which FFmpeg packages can generate, and serve the key only to authorised users.

Playing the video in the browser

Safari on Mac and iPhone plays HLS directly in a normal video tag. Chrome, Firefox and Edge on desktop usually need a library such as hls.js, or a full player like Video.js or Plyr. The player loads the master playlist and handles quality switching automatically.

Make sure your server sends the correct MIME types: application/vnd.apple.mpegurl for .m3u8 files and video/mp2t for .ts segments. If you use a CDN or separate storage domain, set up CORS headers too, or the player will refuse to load the files.

Common Mistakes to Avoid

Even a simple hls video streaming laravel setup can trip you up. Watch out for these issues:

  • Converting inside the controller: always use queues.
  • Too many quality levels: each level adds processing time and storage. Start with two or three.
  • Wrong file paths in playlists: relative paths break when you move files. Test playback after deployment.
  • Forgetting cleanup: delete original uploads or old segments you no longer need, or your disk will fill up.
  • No error handling: log FFmpeg failures and mark videos as failed so admins can retry.

Build It Yourself or Use a Ready-Made Script?

Building your own streaming system is a great learning project. But if your goal is to launch a video business quickly, a ready-made solution can save weeks of work.

For example, CineVault is a Netflix-style OTT script built with Laravel 13. It covers movies, series, live TV with EPG and subscriptions, so you can focus on content and marketing instead of building the platform from zero.

If you need something unique, such as a course platform or a custom video portal, our web development service builds Laravel applications tailored to your business. We can plan the right mix of features, storage and hosting for hls video streaming laravel projects of any size.

Final Thoughts

HLS gives your viewers faster starts and smoother playback, and Laravel makes it manageable with queues, storage disks and solid FFmpeg packages. Start small: one or two quality levels, a reliable queue worker and a tested player. Then add protection and extra resolutions as your audience grows.

Ready to launch your video platform? Tell us what you want to build and get a free quote from our team today.

Frequently asked questions

What is HLS streaming?

HLS (HTTP Live Streaming) splits a video into small chunks and lists them in an .m3u8 playlist. Players download the chunks one by one, which lets videos start fast and adapt to the viewer's internet speed.

Do I need FFmpeg for HLS in Laravel?

In most setups, yes. FFmpeg converts your uploaded MP4 files into HLS segments and playlists. Laravel packages usually call FFmpeg behind the scenes.

Can I run HLS video streaming on shared hosting?

Serving ready-made HLS files can work on many hosts, but converting videos needs FFmpeg and enough CPU. Check with your host whether FFmpeg and background jobs are allowed before you start.

Does Safari play HLS without extra code?

Yes, Safari on Mac and iPhone supports HLS natively. Browsers like Chrome and Firefox usually need a JavaScript library such as hls.js.

Is there a ready-made Laravel streaming platform?

Yes. CineVault is a Netflix-style OTT script built with Laravel 13 for movies, series and live TV, which can save you building everything from scratch.

#Laravel#HLS#Video Streaming#FFmpeg#Web Development#OTT
Share:

More articles