How to Encode Videos Using the x265 Codec

We all are very familiar with the very popular video codec x264 used extensively online to play videos on sites like Youtube, Vimeo, Dailymotion and more. Now they have developed a newer codec called x265 that promises superior quality video at a much reduced file size compared to the x264 codec. The latest versions of the popular media player VLC support playing of the videos encoded using this new x265 codec. If you want to encode your existing videos using the x265 codec then you can use the following two methods:

1. Using FFmpeg
FFmpeg is the leading media encoding, recording, playback and streaming library under the open source GPL license. You can use the following FFmpeg command line for encoding videos using the x265 codec:

ffmpeg -i input.mp4 -c:v libx265 -c:a aac -strict experimental output.mp4

Here input.mp4 is the source video that you want to encode and the output.mp4 is the output video file that would be encoded using the x265 codec.

x265 Video Encoding

The process is extremely slow and will take a longer time if you try to encode a longer duration video. But in the end a smaller size x265 encoded video file is created.

2. Using VideoLAN x265 Encoder
While FFmpeg works perfectly well, there is another command line tool created for the the sole purpose of encoding video files using the x265 codec by the VideoLAN developers (the people who also make the VLC media player). You can give the following command for using this tool:

x265-64bit-8bit-2016-04-11.exe input.mp4 –fps 30 –input-res 640×386 -o output.mp4

Here input.mp4 is the source video that you want to encode and the output.mp4 is the output video file that would be encoded using the x265 codec. In this tool, you also have to specify the frame rate and the resolution of the source video for the encoding process to work.

x265 Video Encoding

As with the FFmpeg, this tool also may take a longer time if the video file has a considerable long playback time duration. But in several of my attempts, this tool failed to properly encode the files unlike FFmpeg that worked flawlessly all the time.

You can download FFmpeg from https://ffmpeg.org/ and VideoLAN x265 encoder from https://builds.x265.eu/.