Merge Video and Audio Streams into a Single HEVC Output File
In this article, we will discuss the process of merging video and audio streams into a single file with HEVC (High Efficiency Video Coding) output. Specifically, we will address a situation where the audio streams are wrongly chosen during the initial encoding process and need to be corrected.
What is HEVC (High Efficiency Video Coding)?
HEVC, also known as H.265, is a video compression standard that offers up to 50% better data compression than its predecessor, H.264. HEVC is widely used for recording, compressing, and distributing video content, particularly for high-definition video.
Why Merge Video and Audio Streams?
When working with video files, audio and video streams are often encoded separately, resulting in multiple files for a single video. Merging them into a single file can simplify file management and improve compatibility with different media players and devices.
Situation: Wrong Audio Streams Selected for HEVC Output
Suppose you have an input file, original.mkv, encoded in H.264 format, and you've made an error during the encoding process for the HEVC output file, hevc.mkv, by choosing the wrong audio streams. Now you need to generate a new output file, hevc_2.mkv, with the correct audio streams.
Tools Required
To merge video and audio streams, you will need a video editing tool that supports HEVC encoding and multiple audio stream selection. Examples of such tools include:
- FFmpeg: A free, open-source tool for handling multimedia data.
- HandBrake: A popular, open-source video transcoder.
Merging Video and Audio Streams with FFmpeg
Assuming you have FFmpeg installed, you can merge the desired video and audio streams into a single HEVC file with the following command:
ffmpeg -i original.mkv -i audio.aac -c:v libx265 -crf 28 -c:a aac -strict experimental -map 0:v:0 -map 1:a:0 hevc_2.mkvThis command uses two inputs: the original video file (original.mkv) and a separate audio file (audio.aac). The resulting output file is hevc_2.mkv. The command uses FFmpeg's libx265 encoder for HEVC video, with CRF (Constant Rate Factor) set to 28 for a good balance between file size and quality. The audio stream is encoded with AAC codec.
Merging Video and Audio Streams with HandBrake
HandBrake provides a graphical user interface, making it more accessible for users unfamiliar with command-line tools. Here’s how to merge the desired video and audio streams into a single HEVC file using HandBrake:
- Launch HandBrake and open the input file (
original.mkv) by clicking "Open Source." - In the "Summary" tab, select the destination file (
hevc_2.mkv) by clicking "Browse." - Switch to the "Audio" tab and choose the correct audio track from the available list.
- Switch to the "Video" tab and ensure H.265 is selected in the "Video Codec" dropdown menu.
- Click "Start" to begin the encoding process.
To merge video and audio streams into a single HEVC output file, use a video editing tool that supports HEVC encoding and multiple audio stream selection. Popular tools for this task include FFmpeg and HandBrake. FFmpeg commands can be complex, but HandBrake offers a user-friendly graphical interface for those who prefer a point-and-click experience.