Compiling X265 under MSYS2 environment

Source: Internet
Author: User
Tags mercurial

HEVC (High efficiency video Coding), is a new video compression standard. Can replace H.264/AVC encoding, so that the same quality of the case, the volume is reduced by about 40%. There are many implementations now, and x265 is one of them. Popular websites:

X265 official website http://www.x265.org/code hosting https://bitbucket.org/multicoreware/x265/code mirroring http://www.videolan.org/developers/x265.html. Compiled executable file http://x265.ru/en/

This article provides a way to compile x265 the MSYS2 environment under the Windows platform.

MSYS2 Download installation , and need to use the software installation, please refer to the blog http://www.cnblogs.com/eudiwffe/p/6249630.html

Software Prerequisites:

Makemsys2-base comes with CMake 2.8 or above version https://cmake.org/(Please install Windows edition) Yasm 1.2 and above HTTP://YASM.TORTALL.NET/MINGW-GCC More than 4.8 recommended to use Http://xhmikosr.1f0.de/tools/msys

Note: Make is included in MSYS2, no installation is required, CMake download the Windows version installation, do not use MSYS2 version, Yasm is used to generate assembly files and can be manually downloaded and copied to/usr/bin/ Yasm.exe can also be installed online using Pacman in Msys2, MINGW-GCC recommended for manual download and overwrite. Where Windows edition CMake is installed, it may not be found in the MSYS2 environment and needs to be manually added to the PATH, specifically to perform "Export path=/cmake-winverion/: $PATH" in bash.

x265 Source Download , you can download the latest release version from two code hosting, you can also use HG to clone the software warehouse, the specific method in Msys2 execution:

Pacman-s mercurial# Installation Mercurial HG distributed software Warehouse management HG clone https://bitbucket.org/multicoreware/x265# clone software warehouse CD x265# Go to x265 HG update stable# switch to stable version

Can. If you have cloned the repository, you can perform the "HG pull && Hg update Stable" in the x265 directory to update to the latest version.

If TORTOISEHG is already installed in Windows and you do not want to install the MSYS2 version of Hg in Msys2, you can Do "Export path=/yourhgpath/: $PATH" To add it to the environment variable.

Compile

Before compiling, be sure to check:

$ echo $PATH.:/ C/program Files (x86)/cmake/bin:/mingw32/bin:/usr/local/bin:/usr/bin:/bin:/c/windows/system32:/c/windows:/c/ Windows/system32/wbem:/c/windows/system32/windowspowershell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr /bin/core_perl$ which make/usr/bin/make$ which Cmake/c/program Files (x86)/cmake/bin/cmake$ which yasm/usr/bin/yasm$ Which HG/USR/BIN/HG

If the software is not found or the path is incorrect, you can fix it manually.

After entering Build/msys, execute "./make-makefiles.sh" to generate a build makefile, the CMake dialog box pops up, you can generally click "Configure" and then "generate" to generate makefile, Finally execute make to compile.

Execute./make-x86_64-w64-mingw32-makefiles.sh can generate a makefile that compiles a 64-bit version of x265, before you clean up the compiled intermediate file, otherwise cmake will not generate a new makefile.

HG problem under MSYS2 :

If you are using the HG clone repositories source code compilation, the following error may occur:

--Found yasm:c:/msys2x86/usr/bin/yasm.exe (Found version "1.3.0")--Found Yasm 1.3.0 to build assembly primitives--Hg found at c:/msys2x86/usr/bin/hg--x265 version +---the Asm_yasm compiler identifi cation is unknown--Found assembler:c:/msys2x86/usr/bin/yasm.exe--looking for strtok_r--looking for Strtok_r-not Foun Dcmake error at cmakelists.txt:529 (list): List get given empty Listcmake Error at cmakelists.txt:530 (list): List get G Iven empty list--Looking for include file getopt.h--looking for include file getopt.h-found--configuring incomplete, Errors occurred! See also "C:/msys2x86/home/user/x265/build/msys/cmakefiles/cmakeoutput.log". See also "C:/msys2x86/home/user/x265/build/msys/cmakefiles/cmakeerror.log". 

This is because CMake will automatically get the current code version based on the HG software before generating makefile. If you are using TORTOISEHG and adding it to path, then there is no problem, and if you are using MSYS2-HG (that is, using Pacman to install mercurial online), CMake will not get the version number correctly. Because Source/cmake/version.cmake uses "execute_process" to get the version, and the Windows version of CMake can only call the native win execution file, msys2 version of Hg is built with Python2, So "execute_process" cannot be executed properly, so you need to manually get the current version of x265 and save it in X265/.hg_archival.txt, as well as in x265/source/cmake/ The last part of Version.cmake adds some code, specifically as follows:

HG Log-r.--template {node}hg log-r.--template {node}hg log-r.--template {branch}hg log-r.--template {LATESTTAG}HG Log-r.--template {latesttagdistance}## X265/.hg_archival.txtrepo:6dd8f6a41db17a30b5dc14218acc4065dee7f465node: be14a7e9755e54f0fd34911c72bdfa66981220bcbranch:stabletag:2.2distance:1## X265/source/cmake/version.cmake last added: # Msys HG cannot get correct version infoset (x265_latest_tag "2.2") Set (x265_tag_distance "1") Set (x265_revision_id " BE14A7E9755E ") Set (x265_version" 2.2+1-be14a7e9755e ") message (STATUS" Msys Hg x265 VERSION ${x265_version} ")

Because each compilation requires the above action, you can write a script in x265/build/msys/make-version.sh:

#!/bin/sh## MSYS HG cannot get repo version, so read info## from. Hgtags and save to. hg_archivalhg_tags= ". /.. /.hgtags "Hg_archival=". /.. /.hg_archival.txt "cmake_version=". /.. /source/cmake/version.cmake "Patch=" # Msys HG cannot get correct version info "repo= ' hg log-r.--template {node} ' node= ' HG l Og-r.--template {node} ' branch= ' hg log-r.--template {BRANCH} ' tag= ' hg log-r.--template {latesttag} ' distance= ' HG Log-r . --template {latesttagdistance} ' # # Find current branch node and Tagcat $HG _tags > $HG _archivalwhile read onelinedoif [" ${oneline#*} "=" $TAG "]thennode=${oneline% *}breakfidone < $HG _archival## for mercurial## find current Version.cmake ENDRM-RF $CMAKE _version.bakcat $CMAKE _version > $HG _archivalwhile read onelinedoif ["$oneline" = "$PATCH"]thenbreakf Iecho "$oneline" >> $CMAKE _version.bakdone < $HG _archivalecho "$PATCH" >> $CMAKE _version.bakecho "Set ( X265_latest_tag \ "$TAG \") ">> $CMAKE _version.bakecho" set (x265_tag_distance \ "$DISTANCE \") ">> $CMAKE _version.bakecho" set (x265_revision_id \ "${node:0:12}\") ">> $CMAKE _version.bakecho" Set (X265 _version \ "$TAG + $DISTANCE-${node:0:12}\") ">> $CMAKE _version.bakecho" message (STATUS \ "Msys Hg x265 VERSION \${ X265_version}\ ")" >> $CMAKE _version.bakrm-rf $CMAKE _versionmv $CMAKE _version.bak $CMAKE _version## for release echo Repo: $REPO > $HG _archivalecho node: $NODE >> $HG _archivalecho Branch: $BRANCH >> $HG _archivalecho Tag : $TAG >> $HG _archivalecho Distance: $DISTANCE >> $HG _archival

Later when the source code is updated, compile again, first execute the./make-version.sh, generate patches, and then compile.

Compiling X265 under MSYS2 environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.