1. Technology

How to Encode H.265 Video Using ffmpeg on Linux

h265-200pxAlmost all the video we watch, over digital terrestrial TV, over cable, from satellite, or over the Internet, is compressed. Raw, uncompressed video is just too big and would waste too much bandwidth. Way back before DVD and Blu-ray, there was the Video CD (VCD). It was the first format used to commercially distribute films on standard 120 mm (4.7 inch) optical discs. The video on the discs was encoded in MPEG-1, a lossy compression format designed for streaming video data at 1.5 Mbit/s. Probably the best known component of the MPEG-1 standard was its audio compression format. Officially called MPEG-1 Audio Layer III, you probably know it as MP3.

h265-and-other-video-logos

After MPEG-1 came MPEG-2, which was chosen as the video compression standard for DVD video. It was also used as the underlying video standard for digital satellite (DVB-S) and digital terrestrial TV (DVB-T). MPEG-2 was also ratified by the International Telecommunication Union (ITU) as H.262. After DVD came Blu-ray, which as well as supporting videos encoded in MPEG-2, also supported H.264 or MPEG-4 Part 10, Advanced Video Coding (MPEG-4 AVC) as it was officially known.

  • MPEG-1: Used for Video CDs
  • MP3: Part of the MPEG-1 standard, ubiquitous today
  • MPEG-2/H.262: Used for DVD and other digital mediums
  • MPEG-4 Part 10/H.264: Used in Blu-ray
  • MPEG-H/H.265: The next generation encoding format with support for 4K and 8K resolutions

After H.264 came H.265. It also has a few other names, most commonly High Efficiency Video Coding (HEVC) or MPEG-H. H.265 doubles the data compression ratio compared to H.264 and can support resolutions up to 8192×4320. This means that video at the same quality needs only half of the bandwidth (or file size). Alternately, it means that the quality of the video can be substantially improved at the same bit rate, something very important for very high definition (i.e. 4K and 8K) displays.

Ffmpeg-logo

The good news for Linux users is that the H.265 codec is available in the popular encoding suite “ffmpeg.” Although ffmpeg probably exists in your distro’s repositories, it might be out of date or it might not have support for H.265 compiled in. The easiest way to get the latest and most functional version of ffmpeg is to download the statically linked builds.

Download either the 32-bit or 64-bit .tar.xz file. If you are unsure which one to download, then use the 32-bit one. In the directory where you downloaded the file, run the following command to unpack the archive file:

tar xvf ffmpeg-2.4-32bit-static.tar.xz

Where “ffmpeg-2.4-32bit-static.tar.xz” is the name of the file you downloaded.

This will create a directory called something like “ffmpeg-2.4-32bit-static”. In that directory are the “ffmpeg” and “ffprobe” binaries (along with a couple of other binaries). To encode a video in H.265 format, use the following command:

./ffmpeg -i video.mp4 -c:a copy -c:v libx265 video-h265.mp4

The -i parameter specifies the input video file, in this case “video.mp4″. ffmpeg can decode a whole variety of video formats including .avi, .mp4 and .mov.

The -c:a copy parameter tells ffmpeg to copy the audio stream from the original file directly into the output file. While -c:v libx265 tells ffmpeg to encode the new video file in H.265 format.

The last parameter is the desired file name of the H.265 encoded output. ffmpeg can create .mp4, .mov and .mkv files with H.265 encoded video.

Once the encoding has finished, look at the file size of the two videos; you should see a significant decrease in the file size of the H.265 encoded video:

ls video.mp4 video-h265.mp4

To check to see that the file has been encoded correctly, use the ffprobe command like this:

ffprobe video-h265.mp4

ffprobe-h265

The output will show that the video stream (probably stream#0) is encoded using hvec, i.e. H.265. The audio stream will be encoded in whatever format was used in the original file as it was just copied across from one to the other.

If you have any questions about ffmpeg itself, there is a vibrant community with mailing lists, IRC channels and forums. If you have any questions about the examples given above, please use the comments section below and we will see if we can help.

The post How to Encode H.265 Video Using ffmpeg on Linux appeared first on Make Tech Easier.



No Comments
Comments to: How to Encode H.265 Video Using ffmpeg on Linux

Recent Articles

Good Reads

Sapphire Gemstones have captivated mankind since early times both for their beauty and special powers, but also as one of the most revered spiritual stones. In Indian astrology, sapphire is numbered among the most transformative stones that help change a person’s career, mindset and relationships as well as his destiny. Regardless of whether you pick a blue […]
The beauty, astrological power, and rarity of gemstones have always been recognized and appreciated. Among them, White Sapphire (Safed Pukhraj), Kashmir Blue Sapphire, and Zambian Emerald are most prized. Each one, with its characteristics and symbolisms, serves its unique purpose. A buyer with sufficient knowledge would be able to use them for astrological, healing, or […]

Worlwide

Overview VipsPM – Project Management Suite is a Powerful web-based Application. VipsPM is a perfect tool to fulfill all your project management needs like managing Projects, Tasks, Defects, Incidents, Timesheets, Meetings, Appointments, Files, Documents, Users, Clients, Departments, ToDos, Project Planning, Holidays and Reports. It has simple yet efficient layout will make managing projects easier than […]
Sapphire Gemstones have captivated mankind since early times both for their beauty and special powers, but also as one of the most revered spiritual stones. In Indian astrology, sapphire is numbered among the most transformative stones that help change a person’s career, mindset and relationships as well as his destiny. Regardless of whether you pick a blue […]
The beauty, astrological power, and rarity of gemstones have always been recognized and appreciated. Among them, White Sapphire (Safed Pukhraj), Kashmir Blue Sapphire, and Zambian Emerald are most prized. Each one, with its characteristics and symbolisms, serves its unique purpose. A buyer with sufficient knowledge would be able to use them for astrological, healing, or […]
When considering the ideal stone for astrology or jewelry, gemstone enthusiasts frequently discuss white sapphire and purple sapphire. Both hailing from the corundum family, they are celebrated for their luster, durability, and everlasting beauty. Nevertheless, the gemstones vary significantly in worth because the provenance determines the rarity, demand, and price of each stone. Let us […]

Trending

Turquoise Jewelry is one of the ancient healing stones used for personal adornment and astrological benefits. The rare greenish blue-colored pectolite is celebrated for its enchanting powers among many crystal lovers. It is a hydrated phosphate of copper and aluminum that ranks 5 to 6 on the Mohs hardness scale. It is deemed a protective […]
COVID-19 pandemic has affected Thailand’s economy and labor market. World Bank’s Thailand Economic Monitor predicted that it would take Thailand over two years to return to its pre-COVID-19 growth and domestic product output levels. Although the country has successfully curbed the pandemic tide over the last few months, the economy remains severely hit. Nevertheless, heavily […]