1.) Giving you the binaries:
Just recently I tried to give the x265 H.265/HEVC video encoder another chance to prove itself, because so far I’ve been using x264, so H.264/AVC. x264 does a really good job, but given that the marketing guys are talking about colossal efficiency/quality gains with H.265, I thought I’d put that to the test once again. It was quite easy to compile the software on my CentOS 6.7 Linux, but my old XP x64 machine proved to be a bit tricky.
But, after a bit of trial and error and getting used to the build toolchain, I managed to compile a seemingly stable version from the latest snapshot:
Update 2: And here comes my first attempt to build an x86_64 multilib binary, that can encode H.265 at 8-bit, 10-bit and 12-bit per pixel color depths. You may wish to use this if you need more flexibility (like using 12-bit for PC only and 8- or 10-bit for a broader array of target systems like TVs, cellphones etc.). It’s currently still being tested for a short encoding run. You can specify the desired color depth with the parameter
-D 10 or
- [x265 1.9+15-425b583f25db 8-, 10- & 12-bit, VC10 x86_64 multilib build for Windows XP x64+]
Update: And here are the newer 1.9 versions, built from source code directly from the [MulticoreWare] (=the developers) servers. I haven’t tested these yet, but given that I configured & compiled them in the same way as before, they “should work™”:
- [x265 1.9+15-425b583f25db 8-bit, VC10 x86_32 build for Windows XP+]
- [x265 1.9+15-425b583f25db 8-bit, VC10 x86_64 build for Windows XP x64+]
- [x265 1.9+15-425b583f25db 10-bit, VC10 x86_64 build for Windows XP x64+]
- [x265 1.9+15-425b583f25db 12-bit, VC10 x86_64 build for Windows XP x64+]
And the old 1.7 versions from the Videolan servers:
- [x265 v1.7+512-f8b8ebdc5457 8-bit, VC10 x86_32 build for Windows XP+]
- [x265 v1.7+512-f8b8ebdc5457 8-bit, VC10 x86_64 build for Windows XP x64+]
- [x265 v1.7+512-f8b8ebdc5457 10-bit, VC10 x86_64 build for Windows XP x64+]
- [x265 v1.7+512-f8b8ebdc5457 12-bit, VC10 x86_64 build for Windows XP x64+]
So this has been built with MSVC10 and yasm 1.3.0 on Windows XP Pro x64 SP2, meaning this needs the Microsoft Visual C++ 2010 runtime. You can get it from Microsoft if you don’t have it yet: [32-bit version], [64-bit version]. v1.7 tested for basic functionality on XP 32-bit and tested for encoding on XP x64. The 32-bit version only supports 8-bit per pixel, which is default for x264 as well. The 64-bit versions support either 8-, 10- or 12 bits per pixel. Typically, higher internal precision per pixel results in finer gradients and less banding. 8-/10-bit is default for H.265/HEVC. 12-bit will likely not be supported by any hardware players, just as it was with 10-bit H.264/AVC before.
You may or may not know it, but as of now, x265 cannot be linked against either ffmpeg or libav, so it can only read raw input. To “feed” it properly you need either a frame server like [AviSynth] in combination with the pipe tool [Avs4x265], or a decoder that can pipe raw YUV to x265. I went for the latter version, because I already have libav+fdkaac compiled for Windows to get the avconv.exe binary. It’s quite similar to ffmpeg.
This I can only provide as a 64-bit binary, as I’m not going to build it for 32-bit Windows anytime soon I guess, so here you go:
- [avconv 11.4, GCC 4.9.2 64-bit build for Windows XP x64+]
This was compiled with GCC 4.9.2 and yasm 1.3.0 on CygWin x64. To use the two together, add the locations of your EXE files (avconv.exe and x265.exe) to your search path. Then, you can feed arbitrary video (VC1, H.264/AVC, MPEG-2, whatever) to x265. An example for a raw H.264/AVC input stream using the 64-bit versions of the software:
avconv -r 24000/1001 -i video-input.h264 -f yuv4mpegpipe -pix_fmt yuv420p - 2>NUL |^ x265 - --wpp --y4m -D 12 -p slower --bframes 16 --bitrate 2000 --crf 18 --sar 1^ --range full -o video-output.h265
Or another, reading some video stream from an MKV container, disabling audio and subtitles:
avconv -r 24000/1001 -i video-input.mkv -f yuv4mpegpipe -pix_fmt yuv420p -an -sn^ - 2>NUL | x265 - --wpp --y4m -D 12 -p slower --bframes 16 --bitrate 2000 --crf 18^ --sar 1 --range full -o video-output.h265
Just remove the carets and line breaks to make single-line commands out of those if preferred. To understand all the options, make yourself some readmes like this:
avconv -h full > avconv-readme.txt and
x265 --log-level full --help > x265-readme.txt or read the documentation online.
2.) How to compile by yourself:
I won’t describe how to build libav here, but just the x265 part. First of all, you need some software to be able to do this, some of it free, other not so much (unless you can swap MSVC with MSYS, I didn’t try that):
- [cmake] (I used version 2.8.12 because that’s roughly what I have on Linux.)
- [Mercurial] (Needed to fetch the latest version from x265′ versioning system. I used the latest Inno Setup installer.)
- [yasm] (Put yasm.exe in your search path and you’re fine. This is optional, but you really want this for speed reasons.)
- [Microsoft Visual Studio] (Use 2010 if you’re on Windows XP. Supported versions: 2008/VC9, 2010/VC10, 2012/VC11 & 2013/VC12)
- [x265 source code] (Enter a target download path and use Mercurials hg.exe like
hg clone https://bitbucket.org/multicoreware/x265to fetch it)
2b.) Preparation of the solution:
Usually, you would use cmake to have it compile your entire project, but in this case it’ll build Visual Studio project files and a solution file for us. To do this, enter the proper build path. In my case I’m using Visual Studio 2010, so VC10, and I’d like to build the 64-bit version, so with the unpacked x265 source, I’d enter its subdirectory build\vc10-x86_64\ and then run the generation script:
There are several things you need to make sure here: First, if you’re on Windows XP or Windows Vista, you need to toggle the
WINXP_SUPPORT flag. Also, if you’re compiling for a 64-bit target, you may wish to enable
HIGH_BIT_DEPTH as well to get to either 10-bit or even 12-bit per pixel other than just 8. The 32-bit code doesn’t seem to support high bit dephts right now.
Then there is one more important thing; With
CMAKE_CONFIGURATION_TYPES set to
Debug;Release;MinSizeRel;RelWithDebInfo, my build was unstable, throwing errors during encoding, like
x265 [error]: scaleChromaDist wrap detected dist: -2029735662 lambda: 256. Setting
CMAKE_CONFIGURATION_TYPES to just
Release solved that problem! So you may wish to do the same.
ENABLE_ASSEMBLY are checked as well, then click Configure. If you’re building with high bit depth support, you’ll be presented with another option,
MAIN12. You should enable this to get Main12 profile support in case you’re planning to build a 12-bit encoder. If you don’t pick it, you’ll get a 10-bit version instead, staying within Blu-Ray 4K specifications. After that, click Configure again. Generally, you need to click Configure unless no more red stuff pops up, then click Generate.
2c.) Compiling and installing the solution:
Load the resulting solution file x265.sln into Microsoft Visual Studio, then right click ALL_BUILD and pick Build. This will compile x265. If you want to install it from the IDE as well, right click INSTALL and select Build. This will install x265 in %PROGRAMFILES%\x265\ with the binary sitting in %PROGRAMFILES%\x265\bin\:
3.) Running it:
Now we can feed x265 some raw YUV files like this, after adding x265.exe to the search path:
Or we can use a decoder to feed it arbitrary video formats, even from MKV containers, like shown in the beginning. ffmpeg or avconv can decode pretty much anything, and then pipe it into x265 as raw YUV 4:2:0:
And that’s it! Now all I need is some 18-core beast processor to handle the extreme slowness of the encoder at such crazy settings. When going almost all-out, it’s easily 10 times as slow as x264 (at equally insane settings)! Or maybe I can get access to some rack server with tons of cores or something…
Update: All x265 releases have now been consolidated on [this page]! All future XP- and XP x64-compatible releases of x265 plus a relatively recent version of avconv to act as a decoder for feeding x265 with any kind of input video streams will be posted there as well.