Skip to content

How to convert MOV video to HLS format with ffmpeg: A step-by-step guide

Converting your videos from MOV format to HLS format has several benefits, including scalability and a better viewer experience—particularly for live streaming.

MOV format (noted with the .mov extension) was originally developed by Apple as a container file, similar to a MP4. Unlike MP4s, the MOV file type was created and optimized as the preferred file format for Apple QuickTime. HTTP live streaming, also known as HLS, is an adaptive bitrate streaming protocol—also created by Apple—which scales video quality up and down depending on the strength of the network connection.

Read this article to learn how to convert MOV files to a HLS format. In a hurry? Skip ahead to step-by-step instructions.

LinkTop 3 advantages to HLS format and adaptive bitrate streaming

There are many advantages to adaptive bitrate streaming, particularly HLS, but these are the top three reasons we suggest you use the HLS format over the MOV format:

  1. HLS players are available on major platforms: HLS is an industry-standard format and can play almost everywhere. Some examples of HLS web players are Mux video element, HLS.js, and Plyr.io.
  2. Uses common video formats: HLS uses existing video formats like MP4, TS, codecs like H.264, and AAC.
  3. More scalable than other protocols: HLS works over HTTP, which means no special servers are necessary.

Read more about mobile video streaming with HLS in this Mux resource guide.

LinkWhen to use HLS over MOV formats: What’s the difference?

MOV files are a container format that store multimedia information like audio, video, and text. Because they contain a lot of information, the file size is generally much larger than a MP4 file.

HLS format, on the other hand, is an adaptive bitrate streaming protocol. Instead of storing files in a container like an MOV file, HLS breaks down video files into many pieces. The video player can access these files throughout the duration of the video stream. Because of its scalability, the HLS format is popular for live streaming.

LinkWhen to use MOV files

MOV files are optimized for the Apple QuickTime application and often used for video editing purposes. Because the file type was created specifically for Apple applications, you’ll need to convert the file to another file type to open it in other applications outside the Apple universe. 

LinkUse cases for MOV files:

  • Video editing on Apple devices: MOV files are optimized for Apple QuickTime, so this format makes the most sense when you’re editing video on Apple devices. With less compression than MP4s, the video quality also tends to be slightly higher.

LinkWhen to use HLS

If you’re expecting high volumes of traffic to your video, like for a live stream or event, HLS is your best bet. HLS is the preferred format for live streaming because it can adapt the video quality to suit network conditions. For example, if someone was streaming video on their phone and their network connectivity was slower than usual, the video would continue to play uninterrupted, with a slight decrease in quality.

LinkUse cases for HLS:

  • Interactive video streams: HLS makes sense for interactive streaming use cases on community platforms like Twitch where there are a lot of people interacting with the video content. The Twitch developer team even wrote a blog post on this topic.
  • High-visibility streaming events: Use HLS for video streams where you expect a lot of viewers. This includes live streams for concerts or sporting events like the Rugby World Cup.
  • Streaming on Apple devices: All iOS devices require HLS for streaming. Android also now supports HLS for other mobile devices.

Active Theory used a HLS stream to create a digital auditorium for virtual concerts during the COVID-19 pandemic.

LinkWhat is ffmpeg?

The most popular way to convert MP4 files to HLS files is by using ffmpeg.

Ffmpeg is a piece of open source software used to modify media files. Officially, the ffmpeg website defines ffmpeg as “a complete, cross-platform solution to record, convert, and stream audio and video…able to decode, encode, transcode, mux, demux, stream, filter and play pretty much anything that humans and machines have created.“ In simple terms, ffmpeg helps you transcode media files into a simplified format, allowing for more efficient video streaming.

LinkA brief history of ffmpeg

The ffmpeg open source project was founded in the year 2000 by Fabrice Bellard and has continuously evolved over the years. Ffmpeg stands for “Fast Forward Moving Picture Experts Group.” Large organizations like Google use the ffmpeg project package in applications and open source libraries like Google Chrome, MPlayer, and VLC. In 2014, Google even conducted an internal fuzzing effort where they fixed over a thousand bugs in the ffmpeg project over the course of two years. Ffmpeg continues to be one of the most popular—if not the most popular—solution for processing media files.

LinkHow to convert MOV to HLS with ffmpeg: Step-by-step instructions

Link1. Install ffmpeg

See the download page for ffmpeg to install ffmpeg for your operating system.

Link2. Convert MP4 video file to HLS with ffmpeg

bash
ffmpeg -i filename.mov \ -codec: copy \ -hls_time 10 \ -hls_list_size 0 \ -f hls \ filename.m3u8

There's a number of ffmpeg settings and flags you can tweak here, let's break down what we have:

  • -i this is the input file, where you point to your mp4
  • -codec: copy will preserve the video & audio codecs of the original video. Which may or may not be what you need. The codec that you end up using will depend on which devices you want to support. Learn more about choosing the best video codec for your use case.
  • -hls_time 10 this is the target duration of each HLS segment
  • -f hls this tells ffmpeg to output the result in HLS format
  • filename.m3u8 this is the output file for the HLS playlist -- m3u8 is the extension for an HLS playlist

This command will output a single filename.m3u8 HLS playlist, along with video segment files ending with .ts. This particular output has only one quality level of HLS output. For a production use case you will likely want to create multiple quality levels of HLS output.

LinkHow to host and deploy your HLS stream

Now that you’ve converted your MP4 into a HLS file, you’ll need to host these new files. Hosting your HLS files, also known as deploying your HLS stream, requires a few steps.

The basic idea is that you'll need to put the HLS files onto a server that can deliver them to clients over HTTP. This can be as simple as an Amazon S3 bucket or your own static file server. One thing to keep in mind is that regardless of where you host the HLS files, you will likely need to put a CDN in front of it for caching which will give you better performance for users and lower costs.

LinkHow to play your HLS video

Once you’ve hosted your HLS stream, you need a way for people to view your video. HLS is supported by different media players for different applications.

LinkWeb

  • Safari on MacOS supports HLS natively in the HTML5 video tag without any extra code or configuration.
  • Other browsers including Chrome, Internet Explorer and Firefox require Javascript code with a library like Hls.js or http-streaming. These libraries use the browser's Media Source Extension API to add HLS support to the HTML5 video element.

LinkiOS apps

LinkAndroid apps

LinkWhat's next

After you get your HLS video set up and streaming make sure to monitor your users' quality of experience.

If you are looking for an API to convert MP4 videos or any other video type into HLS for streaming, see the getting started guide to start streaming video over HLS with Mux.

No credit card required to start using Mux.