FFmpeg HLS Conversion to HEVC in fMP4: A Comprehensive Guide
In this article, we will discuss how to convert an .mkv file containing AVC video to HLS with HEVC codec in fMP4 format, while also creating two streams for 1080p and 720p quality. The user trying to accomplish this has mentioned that they "tried everything and can't get it to work." We will provide a detailed guide to help them and others who may encounter similar issues.
Introduction to FFmpeg and HLS Conversion
FFmpeg is a powerful, open-source tool used for handling multimedia files, including audio, video, and images. It can convert, stream, and record multimedia files, making it an essential tool for media professionals and enthusiasts alike. HLS (HTTP Live Streaming) is an HTTP-based media streaming communications protocol developed by Apple Inc.
HEVC and fMP4: Key Concepts
HEVC (High Efficiency Video Coding) is a video compression standard that offers improved compression efficiency compared to its predecessor, AVC (Advanced Video Coding). fMP4 (fragmented MP4) is a format that stores media data in an MP4 container, allowing for adaptive bitrate streaming (ABS) in HTTP-based environments.
Why Convert AVC to HEVC in fMP4 for HLS?
Converting AVC to HEVC in fMP4 for HLS streaming offers several benefits, including improved compression efficiency, reduced storage and bandwidth requirements, and better overall streaming quality.
Preparing for the Conversion
Before we start the conversion process, make sure you have the latest version of FFmpeg installed. You can download it from the official website: https://ffmpeg.org/download.html
Converting AVC to HLS HEVC in fMP4: Step-by-Step Guide
To convert an .mkv file containing AVC video to HLS with HEVC codec in fMP4 format, use the following command:
ffmpeg -i input.mkv -c:v libx265 -crf 28 -c:a aac -b:a 128k -map 0 -var_stream_map "v:0,a:0 v:1,a:1" -f hls_time -hls_time 10 -hls_playlist_type event -hls_flags independent_segments+delete_segments+discont_start+program_date_time+start_number out_%03d.m3u8
This command will create two streams for 1080p and 720p quality. The CRF (Constant Rate Factor) value of 28 ensures a good balance between compression efficiency and quality. Adjust the value to suit your needs.
In this article, we provided a detailed guide on converting an .mkv file containing AVC video to HLS with HEVC codec in fMP4 format, creating two streams for 1080p and 720p quality. Users experiencing difficulties with this process can now successfully accomplish it by following the steps outlined in this guide.
References
-
FFmpeg: https://ffmpeg.org/
-
HLS (HTTP Live Streaming): https://developer.apple.com/documentation/http_live_streaming
-
HEVC (High Efficiency Video Coding): https://en.wikipedia.org/wiki/High Efficiency Video Coding
-
fMP4 (fragmented MP4): https://en.wikipedia.org/wiki/ISO Base Media File Format#Fragmented MP4