7

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?

References:

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

4 Answers 4

7

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 \
   output.mp4

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.

References:

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

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.

source

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
2
  • 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, 2014 at 7:46
  • @LiveWireBT: That's cleaver!
    – Naveen
    Jun 4, 2014 at 12:03
3

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
0

Start VLC with the file you wish to convert, stop the video from playing, reset to start of file, then open the media menu, select the convert/save option, select H265 and MP3, then give the file a new name using the output file selection, and wait for the process to finish. There is no easier way.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .