I see that H.265/HEVC encoding is gathering momentum but under some versions of Ubuntu it is not all that easy to produce H.265 video streams.

How should I go about using x265, in a manner that integrates with Ubuntu (especially the LTS releases Trusty and Xenial), to produce HEVC video files under Ubuntu?


  1. x265 HEVC Encoder: The commandline encoder
  2. x265: Videolan site

The best solution so far on my system has been:

  1. For Trusty Tahr 14.04 LTS: use an up to date FFmpeg and the most recent x265, which necessitates some compiling and subsequent packaging
  2. For Xenial Xerus 16.04 LTS: simply run:

    sudo apt-get install ffmpeg  libavcodec-extra

With either of the previous methods then use the following:

ffmpeg -i input \
   -c:v libx265 -preset slow -x265-params crf=22 \
   -c:a libmp3lame -b:a 128k \

Note that this creates an mp3 audio stream as well as an h.265 video stream. To create an aac stream the line -c:a libmp3lame -b:a 128k could be replaced with the following:

-c:a aac -strict experimental -b:a 128k

The -strict experimental option will not be required if your copy of FFmpeg was released after December 2015 when development of the native aac encoder matured. Bear in mind that this option will still be required for the repository FFmpeg for Xenial Xerus 16.04 LTS.


  • 1
    That's pretty much what I did, except I used the experimental AAC encoder built-in to FFMpeg. Jan 12 '16 at 2:30
  • Interestingly enough the experimental aac encoder is no longer 'experimental' in git FFmpeg from December 2015.
    – andrew.46
    Jan 12 '16 at 2:46
  • Added in the option of using the FFmpeg native aac encoder...
    – andrew.46
    Jan 14 '16 at 21:23

Method 01

You can install Internet friendly media encoder:

enter image description here

Run these commands in your Terminal:

sudo add-apt-repository -y ppa:upubuntu-com/multimedia  
sudo apt-get update  
sudo apt-get install ifme

Now you can open the program ifme from Dash.


Method 02

Once you compiled the program following the instructions in here or here, first you have to encode the video into YUV format:

avconv -i MyVideo.mp4 MyVideo.yuv

Then you can convert YUV video into x265 format:

./x265 --input-res 640x360 --fps 24000/100 MyVideo.yuv -o MyVideo.h265
  • 6
    Or if you don't like big uncompressed files pipe the output of avconv against x265. (it looks like this for ffmpeg+x264: ffmpeg -i "INPUT" -pix_fmt yuv420p -f yuv4mpegpipe - | x264 --demuxer y4m - --profile High10 --preset slower --crf 20 --video-filter -o "OUTPUT" -)
    – LiveWireBT
    Jun 4 '14 at 7:46
  • @LiveWireBT: That's cleaver!
    – Naveen
    Jun 4 '14 at 12:03

This script worked for me:

ffmpeg -i input_file.mpg -pix_fmt yuv420p -f yuv4mpegpipe - |\
     x265-10bit --profile main10 --preset slower --crf 20 --input - --y4m -o output_file.mpg

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.