Convert HLS M3U8 videos to MP4
  • Convert HLS M3U8 to MP4 or vice-versa without quality loss.
  • Lossless conversion technology, GPU Acceleration, and Multi-core Processor optimization.
  • Convert HLS M3U8 videos to 1000+ audio/video formats at a 30X faster speed.
  • Compress HD videos of 1080p without losing quality.

As a rule of thumb, a file with an M3U8 extension is not a real media file but an audio playlist encoded in UTF-8. You need a devoted media player to read the M3U8 file. The alternative solution is to change it over to a standard multi-media format, such as MP4. Thus, we will look into FFMPEG MP4 to HLS M3U8 conversions here.

What is HTTP Live Streaming (HLS)?

HTTP Live Streaming (known as HLS) is an HTTP-based adaptive bitrate streaming communications protocol released by Apple in 2009. This protocol has widespread support in media players, internet browsers, cell phones, and streaming media servers. This format usually contains H.264 encoded content and AAC encoded video packed through the RTMP protocol and sent to the media server. Then re-packed as HLS playlists so that they can get distributed faster to any players.

What is FFMPEG?

FFMPEG is the leading media framework capable of decoding, encoding, transcoding, mux, demux, stream, filter, and play pretty much anything that people and machines have made. It supports the most obscure. Regardless, designed by a standards committee, a community, or an organization. It is likewise exceptionally versatile: FFmpeg compiles, runs, and passes across Linux, Mac OS X, Microsoft Windows, the BSDs, Solaris, and so on under a wide assortment of environments, machine architecture, and configurations.

Part 1. How to create .mpd or .m3u8 video file using ffmpeg?

Need to know how to create an .MPD or .M3U8 video file suing FFMPEG? Follow the steps below.

Note: Android Exoplayer supports.MPD/.M3U8 for versatile streaming.

1. Install XAMPP/LAMP/WAMP on your local or dedicated server like AWS.

2. Install the FFMPEG library on your server. (To introduce FFMPEG on the server, follow the link: https://www.FFMPEG.org/download.html)

3. After installation, execute the commands to process MP4 video files and produce TS records for the M3U8 record.

4. Once using the commands, all M3U8 files are produced for various resolutions, add them into one primary document by reference, and make the main M3U8 file.

5. Finally,you will have the server path for theparticular M3U8 file only, and the Exoplayerwill create a link to that file.

FFMPEG Commands to process MP4 videoare:

Step 1: Make one folder/index with the name of the video.

Step 2: Put the MP4 video in that folder.

Step 3: Begin performing the commands or operation.

Once you are over with performing the four commands,it will produce four distinct .M3U8 files.

You can make one .M3U8 file with a playlist manually or by programming.

Part 2. How to create an HLS master playlist with ffmpeg?

Fragmented MP4 (FMP4) can be an alternative to MPEG-TS. As the resultant FMP4 is compatible with MPEG-DASH, it can be an alternative to HLS, and you can use the same files. To create an HLS master playlist with FFMPEG, you need to follow the below steps:

Step 1: Download a relatively recent version of FFMPEG that supports FMP4- I version 4.1.1 to create the files.

Step 2: Take the original video, and re-encode it.

Step 3: Whatever the video size could be, alter it to 1280*720, reduce the video bitrate, and make sure that the audio is left as it is.

Step 4: Now, open the terminal, and execute the command.

Step 5: You need to set the segment type to fmp4 to skip the default MPEG-TS and generate FMP4 files.

Step 6: You will now get a playlist file, files with .m4s extension, and a file with init.mp4., keep them safe as you will need them to play the video.

Step 7: As the final step, play the video in the browser. You can try it in Chrome 72, Firefox 65.0 on Ubuntu.

Part 3. How to download and combine m3u8 video file using ffmpeg?

As you are aware, HLS came from Apple, and it stands for "HTTP Live Streaming" used for the playback. Here, we would like to share how we can download and combine chunks of media with an HLS stream variant.

Download TS Segments

Step 1: Ensure or install a local FFMPEG. (For Linux: use https://johnvansickle.com/ffmpeg/ for the FFmpeg installation)

Step 2: By running the “ffmpeg” command on your terminal, verify the Ffmpeg installation. On successful accomplishment, you will receive the message like the below interface.
Step 3: Finally, to generate media segments on your current working directory, you can complete the task by executing the below command:

Doing so will generate TS segment chunks about 3 seconds within the current directory.

Convert TS Segments to MP4                                         

1. From the above generated .ts files, combine them into a single .mp4 file.

2. Execute the command:

Command: {“ffmpeg -f concat -safe 0 -i<(for f in ./*.ts; doecho"file '$PWD/$f'"; done) -c copy playlist.mp4”}

You will get a playlist.mp4 file, resulting in the same directory that can play on any media player.

Part 4. How to Convert MP4 to HLS M3U8 using ffmpeg?

  1. As the first step, you need to install FFMPEG on Ubuntu from a suitable source.
  2. Keep the .ts files ready for processing.

3. Now, execute the two below commands to convert MP4 VOD files to HLS segment M3U8/TS files.

Command 1: # FFMPEG -i filename.MP4 -codec: copy -bsf:v h264_mp4toannexb -start_number 0 -HLS_time 10 -HLS_list_size 0 -f HLS filename.M3U8

Command 2: # FFMPEG -i filename.MP4 -profile:v baseline -strict -2 -level 3.0 -start_number 0 -HLS_time 10 -HLS_list_size 0 -f HLS filename.M3U8

You will then have HLS M3U8 Stream Link from HTTP or HTTPS.

Part 5. How to convert m3u8 stream to mp4 using ffmpeg?

Here is another way to convert the M3U8 stream to MP4 using FFMPEG that requires only two steps for execution.

1. Copy M3U8 link

Copy the M3U8 link from the directory or location.

2. Run command

On the terminal, execute the following command:

Command: {echo "Enter m3u8 link:";readlink;echo "Enter output filename:";read filename;ffmpeg -i "$link" -bsf:aaac_adtstoasc -vcodec copy -c copy -crf 50 $filename.mp4}

Part 6. Easy way to extract mp4 from HTTP live streaming m3u8 file

Aicoosoft Video Converter

Aicoosoft Video Converter Ultimate is one of the most popular additions to video converter options and has become a significant hit with users today. What makes Aicoosoft Video Converter unique from the others is its unmatchable functionality, video, and audio presets for mobile phones, desktops, gaming devices, electronic book readers, among others. It is the best video converter with 30X faster speed, high-quality, lossless conversion technology, and optimization techniques with unique converting technology. It is not just a converter but is a compressor, downloader, and screen recorder as well. Used for FFMPEG HLS live streaming M3U8 videos in just simple steps without a terminal or any other complicated process like the strategies mentioned earlier.

Features

1. Convert FFMPEG or MP4 to 1000+ reliable format like HLS M3U8 at 30X faster conversion speed without quality loss.

2. If you are wondering what the secret behind such accomplishment is, it is the GPU-Acceleration, Multi-core Processor Optimization, and AI technology.

3. Edit your videos effectively without the need of any other third-party application s Aicoosoft offers an all-in-one video editor toolbox too.

4. With the help of a professional compressor, compress videos at high flexibility, including HD videos of resolution till 1080P and 4K videos.

Conclusion

Though seemingly a little bit too technical, the conversion of FFMPEG MP4 to HLS M3U8 would need you to do a little bit of work to get the final result. We detailed some of the ways to achieve this format for you above. However, one easy and sure way to convert M3U8 files to MP4 and vice versa, using FFMPEG, is through the fabled Aicoosoft Video Converter.

All Topic

Hot Articles


Cron Job Starts