This article shows how to encode your video with HM (HEVC Test Model (HM)), the reference implementation developed by the standard organizations.
HM is provided as a source code so that we can build on various platforms. But let’s focus on Windows and Microsoft Visual Studio tool chain for now.
Step 0: Prerequisite
- Microsofot Visual Studio 2008 or later. Express version should work. [Download]
- Your favorite YUV viewer such as YUV Player [Download]
- Subversion client such as Sliksvn [Download]
- Sample YUV file such as this [Download]
Step 1: Download the source tree
Get the latest version of HM.
% svn co https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/trunk
Step 2: Build it!
Start Visual Studio command line prompt and build HM_vc9.sln located in trunk/build directory.
% msbuild /p:Configuration=Release HM_vc9.sln
Step 3: Encode it!
Open a notepad and make a configuration text file as shown at the bottom of this article. Save it as test.config. The encoder tool is called TAppEncoder.exe which should be located in trunk/bin/vc9/win32/release.
% TAppEncoder.exe -c test.cfg -i mobile_cif.yuv
Step 4: Check the output
The step above encodes the first 10 frames at 100kbps and creates mobile.hevc, which is your first HEVC stream. Congratulations!
The encoding tool also conveniently made YUV file which was decoded from the HEVC stream. You can compare the original (mobile_cif.yuv) and encoded file (mobile_out.yuv).
Do you see the difference? It’s doing pretty good job for 100kbps – but you can see some compression artifact here.
Configuration file
Here is the configuration file I used. Hover the mouse to right-top area to copy it.
Update: The config file was updated to the latest HM (Feb 6, 2013)
#======== File I/O =====================
BitstreamFile : mobile.hevc
ReconFile : mobile_out.yuv
FrameRate : 24 # Frame Rate per second
FrameSkip : 0 # Number of frames to be skipped in input
SourceWidth : 352 # Input frame width
SourceHeight : 288 # Input frame height
FramesToBeEncoded : 10 # Number of frames to be coded
#======== Unit definition ================
MaxCUWidth : 64 # Maximum coding unit width in pixel
MaxCUHeight : 64 # Maximum coding unit height in pixel
MaxPartitionDepth : 4 # Maximum coding unit depth
QuadtreeTULog2MaxSize : 5 # Log2 of maximum transform size for
# quadtree-based TU coding (2...6)
QuadtreeTULog2MinSize : 2 # Log2 of minimum transform size for
# quadtree-based TU coding (2...6)
QuadtreeTUMaxDepthInter : 3
QuadtreeTUMaxDepthIntra : 3
#======== Coding Structure =============
IntraPeriod : -1 # Period of I-Frame ( -1 = only first)
DecodingRefreshType : 0 # Random Accesss 0:none, 1:CDR, 2:IDR
GOPSize : 4 # GOP Size (number of B slice = GOPSize-1)
# Type POC QPoffset QPfactor tcOffsetDiv2 betaOffsetDiv2 temporal_id #ref_pics_active #ref_pics reference pictures predict deltaRPS #ref_idcs reference idcs
Frame1: B 1 3 0.4624 0 0 0 4 4 -1 -5 -9 -13 0
Frame2: B 2 2 0.4624 0 0 0 4 4 -1 -2 -6 -10 1 -1 5 1 1 1 0 1
Frame3: B 3 3 0.4624 0 0 0 4 4 -1 -3 -7 -11 1 -1 5 0 1 1 1 1
Frame4: B 4 1 0.578 0 0 0 4 4 -1 -4 -8 -12 1 -1 5 0 1 1 1 1
ListCombination : 1 # Use combined list for uni-prediction in B-slices
#=========== Motion Search =============
FastSearch : 1 # 0:Full search 1:TZ search
SearchRange : 64 # (0: Search range is a Full frame)
BipredSearchRange : 4 # Search range for bi-prediction refinement
HadamardME : 1 # Use of hadamard measure for fractional ME
FEN : 1 # Fast encoder decision
FDM : 1 # Fast Decision for Merge RD cost
#======== Quantization =============
QP : 32 # Quantization parameter(0-51)
MaxDeltaQP : 0 # CU-based multi-QP optimization
MaxCuDQPDepth : 0 # Max depth of a minimum CuDQP for sub-LCU-level delta QP
DeltaQpRD : 0 # Slice-based multi-QP optimization
RDOQ : 1 # RDOQ
RDOQTS : 1 # RDOQ for transform skip
#=========== Deblock Filter ============
DeblockingFilterControlPresent: 0 # Dbl control params present (0=not present, 1=present)
LoopFilterOffsetInPPS : 0 # Dbl params: 0=varying params in SliceHeader, param = base_param + GOP_offset_param; 1=constant params in PPS, param = base_param)
LoopFilterDisable : 0 # Disable deblocking filter (0=Filter, 1=No Filter)
LoopFilterBetaOffset_div2 : 0 # base_param: -13 ~ 13
LoopFilterTcOffset_div2 : 0 # base_param: -13 ~ 13
#=========== Misc. ============
InternalBitDepth : 8 # codec operating bit-depth
#=========== Coding Tools =================
SAO : 1 # Sample adaptive offset (0: OFF, 1: ON)
AMP : 1 # Asymmetric motion partitions (0: OFF, 1: ON)
TransformSkip : 1 # Transform skipping (0: OFF, 1: ON)
TransformSkipFast : 1 # Fast Transform skipping (0: OFF, 1: ON)
SAOLcuBoundary : 0 # SAOLcuBoundary using non-deblocked pixels (0: OFF, 1: ON)
#============ Slices ================
SliceMode : 0 # 0: Disable all slice options.
# 1: Enforce maximum number of LCU in an slice,
# 2: Enforce maximum number of bytes in an 'slice'
# 3: Enforce maximum number of tiles in a slice
SliceArgument : 1500 # Argument for 'SliceMode'.
# If SliceMode==1 it represents max. SliceGranularity-sized blocks per slice.
# If SliceMode==2 it represents max. bytes per slice.
# If SliceMode==3 it represents max. tiles per slice.
LFCrossSliceBoundaryFlag : 1 # In-loop filtering, including ALF and DB, is across or not across slice boundary.
# 0:not across, 1: across
#============ PCM ================
PCMEnabledFlag : 0 # 0: No PCM mode
PCMLog2MaxSize : 5 # Log2 of maximum PCM block size.
PCMLog2MinSize : 3 # Log2 of minimum PCM block size.
PCMInputBitDepthFlag : 1 # 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
PCMFilterDisableFlag : 0 # 0: Enable loop filtering on I_PCM samples. 1: Disable loop filtering on I_PCM samples.
#============ Tiles ================
UniformSpacingIdc : 0 # 0: the column boundaries are indicated by ColumnWidth array, the row boundaries are indicated by RowHeight array
# 1: the column and row boundaries are distributed uniformly
NumTileColumnsMinus1 : 0 # Number of columns in a picture minus 1
ColumnWidthArray : 2 3 # Array containing ColumnWidth values in units of LCU (from left to right in picture)
NumTileRowsMinus1 : 0 # Number of rows in a picture minus 1
RowHeightArray : 2 # Array containing RowHeight values in units of LCU (from top to bottom in picture)
LFCrossTileBoundaryFlag : 1 # In-loop filtering is across or not across tile boundary.
# 0:not across, 1: across
#============ WaveFront ================
WaveFrontSynchro : 0 # 0: No WaveFront synchronisation (WaveFrontSubstreams must be 1 in this case).
# >0: WaveFront synchronises with the LCU above and to the right by this many LCUs.
#=========== Quantization Matrix =================
ScalingList : 0 # ScalingList 0 : off, 1 : default, 2 : file read
ScalingListFile : scaling_list.txt # Scaling List file name. If file is not exist, use Default Matrix.
#============ Lossless ================
TransquantBypassEnableFlag: 0 # Value of PPS flag.
CUTransquantBypassFlagValue: 0 # Constant lossless-value signaling per CU, if TransquantBypassEnableFlag is 1.
#============ Rate Control ======================
RateControl : 0 # Rate control: enable rate control
TargetBitrate : 1000000 # Rate control: target bitrate, in bps
KeepHierarchicalBit : 1 # Rate control: keep hierarchical bit allocation in rate control algorithm
LCULevelRateControl : 1 # Rate control: 1: LCU level RC; 0: picture level RC
RCLCUSeparateModel : 1 # Rate control: use LCU level separate R-lambda model
InitialQP : 0 # Rate control: initial QP
RCForceIntraQP : 0 # Rate control: force intra QP to be equal to initial QP
### DO NOT ADD ANYTHING BELOW THIS LINE ###
### DO NOT DELETE THE EMPTY LINE BELOW ###



Is there a way to mux the HEVC stream within a MPEG-2 Transport stream?
I am not aware of existing solutions yet. The stream syntax of HEVC is similar to H.264 (NAL + byte stream format) so I would expect TS multiplexers for HEVC to be simple extension to existing ones.
Maybe Mainconcept SDK would include TS multiplexer with HEVC support. According to the press release below, it should be available in “early 2013″
http://www.rovicorp.com/company/news-center/pressreleases/1434_17072.htm
I’m also searching…
How can the 3D extension for HEVC be applied? I cannot seem to find a similar tutorial to this one. There are some examples in the README, however I keep getting an error for the input YUV file. Is the 3D extension a full encoder in itself, or does it need to be built with the HEVC base encoder?
Hi Codey, sorry I am not informed enough to answer the questions. Interesting questions, though.
Thanks for this tutorial.
I tried to do the same, without building the sources (I haven’t Visual Studio). I’m using this release (HM9.2 and HM10Rc) :
http://x264.fushizen.eu/builds/hevc-hm/
But I can’t encode your video example, I try to give you the snapshot of the errors
https://docs.google.com/file/d/0B5K_ZbDKhOviUkRJQ05EN1RsOWs/edit?usp=sharing
So is it a problem from my release or a “option” who has changed ?
Hi Nelson,
Yes, the configuration syntax has been changed. I just updated the example configuration above to match the latest HM. Hope it works!
Thank you so much

It works well
I’ve done my first HEVC file
I’ve to study the config file now !!!
Hi
Only directories, obj files, idb file…
I tried to follows your tutoriel but can’t build encoder
With the reposity of Fraunhofer need a password, so I went on this one :
http://hevc.kw.bbc.co.uk/git/w/jctvc-hm.git
With the HM9, It build sucessfully BUT there’s no EXE file in the release directory
With the HM10, build failed with the 7 following errors…
I really want to try this encoder, could you help me ?
Build started 06/02/2013 09:45:25.
Project “M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” on node 0 (default targets).
Building solution configuration “Release|Win32″.
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TAppDecoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TAppEncoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TAppCommon_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibCommon_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibDecoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibEncoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibVideoIO_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
Done Building Project “M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default targets) — FAILED.
Build FAILED.
“M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default target) (1) ->
(TAppDecoder target) ->
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TAppDecoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
“M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default target) (1) ->
(TAppEncoder target) ->
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TAppEncoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
“M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default target) (1) ->
(TAppCommon target) ->
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TAppCommon_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
“M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default target) (1) ->
(TLibCommon target) ->
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibCommon_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
“M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default target) (1) ->
(TLibDecoder target) ->
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibDecoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
“M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default target) (1) ->
(TLibEncoder target) ->
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibEncoder_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
“M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\HM_vc10.sln” (default target) (1) ->
(TLibVideoIO target) ->
M:\Logiciels\HEVC-H265\Sources\jctvc-hm\build\vc10\TLibVideoIO_vc10.vcxproj(3,14): error MSB4066: L’attribut “Label” de l”l’ment n’est pas reconnu.
0 Warning(s)
7 Error(s)
Hi Nelson,
Could you double check a few points:
1. Fraunhofer subversion doesn’t require a password. It may ask if you want to accept their public certificate for the first time, though.
2. The built binary should be in bin\vc9\Win32\Release folder.
3. To build VC10 solution, you need to use Visual Studio 2010 command line prompt. If you are in Visual Studio 2008 command line prompt, error MSB4066 happens.
Hope it helps!
Thanks for help, here my answers :
1) turtoiseSVN ask for a password. When I access directly by web, no need. But it’s complicated to download
2) Thanks, you’re right I have searched in \build\vc9\Win32\Release. Sorry
3) I didn’t know that I’ll maybe try to find the Visual Studio 2010
So thanks a lot for your answer.
But it’s not finished
With the VC9 release, I’ve tried again and i’ve got this error “The last frame in each GOP must have temporal ID = 0 ”
If you have a start of answer
Hi Moto,
Could we use Visual Studio 2012 to build VC10 solution?
Thank you for this post!
Yes. I have successfully built with VS2012 with the following command line:
% msbuild /p:Configuration=Release HM_vc10.sln
Please make sure to run it from “Developer Command Prompt for vs2012″.
can somebody help me please. I am doing a masters diploma about comparison about H.264 and H.265 codecs. Can somebody pls give me some pointers. pls send me an e-mail to damjan.jarc@hotmail.com pleaseee. I would we very happy of your help
Probably you have read thisalready but the overview written by Gary Sullivan is always a good start: http://iphome.hhi.de/wiegand/assets/pdfs/2012_12_IEEE-HEVC-Overview.pdf
Thank you moto i have already read this yes it’s a good article.
Here is the thing :
I will make a video of my own. I will convert this video with H.264 codec ( with AVS video converter program ). For converting a video with HEVC H.265 there is no program yet. So i need some program to convert my video with HEVC H.265 codec. Can anyone pls advise me how to do it ? Then when i will have a video of boath as H.264 and H.265 coded then i need some program which will evaluate each of videos and let me know the possible differents about those two videos such as size of video, bit rate, FPS etc….
any ideas ?
The best way is (I gess) convert your video in YUV (non compress)
From this new source, make your h264 and your h265 (follow this post). Take care to keep some comparaison element (exemple same Bitrate)
After that, do the reverse operation and make 2 new yuv files (the yuv form h264, and the yuv from h265). It’s uncompressed but you keep the artefacts of compression.
To compare the two quality of images use MSU quality measurement it’s free for non commercial use.
Hope I help you
Hello thanks for you quick reply. But does YUV offers a convert with HEVC ( H.265 ) codec ?
Where could I find the file that contains the statistics for the last encoded sequence? Just like in JM Reference Software wherein it has a stats.dat
Sorry, I don’t know. The encoder prints out PSNR of each plane (Luma, Cb, Cr) to the console but I guess you are looking for more than that.
Hi Moto
Another question. Do you know how to change the quality of the encoding ? I tried to activated the rate controle and change the bitrate (in the config file) : no change
I also tried to change the QP in the quantification part of the config file : no change
So if you’ve a clue, I really appreciate
See you.
I made two configurations based on the example in the post.
# 100 kbps configuration
RateControl : 1 # Rate control: enable rate control
TargetBitrate : 100000 # Rate control: target bitrate, in bps
# 1000 kbps configuration
RateControl : 1 # Rate control: enable rate control
TargetBitrate : 1000000 # Rate control: target bitrate, in bps
With the source file in the post, I could tell the difference by looking at the decoded frame image. For PSNR wise, in 100kbps configuration, the luma PSNR of the first frame was 28.8dB while it was 33.5 dB in 1000kbps configuration.
So, I could not recreate your problem.
So thank you… I will retry very much for your time
does anyone during building in CMD gets MSB 3411error ? does anyone know what it would mean ?
HI, is there an equivalent way to get the baseline profile with the HEVC reference software? It seems that Main, Main10 and Main Still are the chosen HEVC profiles, but I would like an I-P-P-P-P .. output. Any ideas please?
Thanks
Hi Codey, would the a configuration file below work to make I-P-P-… sequence? It’s a part of HM package:
trunk\cfg\encoder_lowdelay_P_main.cfg
I was able to encode the video. How to interpret the results. What does bitrate mean( in results).
Bitrate shown in the console output of TAppEncoder.exe is the number of bits produced divided by the duration in seconds.
Do you have a tutorial on how to convert a JPEG to a HEVC encoded image? I’ve seen articles on this, but no one has ever explained how they did it. Thank you in advance.
No, but I am curious why you would want to do that. JPEG is designed for still image while HEVC is for video. As HEVC is the latest and greatest standard, do you expect intra frame compression algorithm of HEVC to beat JPEG compression? I don’t know but it might. Why don’t you decode JPEG to uncompressed single frame YUV file and feed it to HM encoder?
There are articles and papers about how HEVC is better than both JPEG and JPEG 2000 in terms of compression. (Here’s a link to one of the articles if you are interested:
http://forum.doom9.org/showthread.php?t=167235
I also have a few papers; here’s a link to one:
https://ieeexplore.ieee.org/xpl/login.jsp?tp=&arnumber=6411873&url=http%3A%2F%2Fieeexplore.ieee.org%2Fxpls%2Fabs_all.jsp%3Farnumber%3D6411873)
Thank you for the suggestion. I’ll look into that; I didn’t know the HM encoder would accept a single frame. If you have any suggestions/tips on how to do that, it’d be greatly appreciated.
Hi,
I’m new to svn commands, and I’m stuck at Step 1 with the following message:
C:\Program Files\SlikSvn\bin>svn co https://hevc.hhi.fraunhofer.de/svn/svn_HEVCS
oftware/trunk
svn: E720005: Can’t create directory ‘C:\Program Files\SlikSvn\bin\trunk\.svn’:
Access is denied.
Could anyone please assist me in this matter?
Hi, it’s probably because you do not have write access permission to C:\Program Files. How about making a new directory at C: drive root and check out the source code there?
Try:
C:\Program Files\SlikSvn\bin>cd C:\
C:> mkdir hevc
C:> cd hevc
C:\hevc> PATH %PATH%;‘C:\Program Files\SlikSvn\bin\
C:\hevc> svn co https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/trunk
Hi Moto, cool it solves my previous problem. Thanx man. But now I have the following error message:
C:\hevc>svn co https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/trunk
svn: E175002: Unable to connect to a repository at URL ‘https://hevc.hhi.fraunho
fer.de/svn/svn_HEVCSoftware/trunk’
svn: E175002: OPTIONS of ‘https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/tr
unk’: SSL handshake failed: A connection attempt failed because the connected pa
rty did not properly respond after a period of time, or established connection f
ailed because connected host has failed to respond.
(https://hevc.hhi.fraunhofer.de)
I think it’s because of the weekend, and any attempt to the HHI server is temporarily blocked. I will try again on Monday/Tuesday and hopefully be able to code my first hevc stream…
@nelson: I was reading your comments and it seems that you able to run your first HEVC stream. i am also working on this on a semester project but i am not able to make it yet …i am really confused and need some help as i don’t have much time to submit my output results….can you send me your files as well as your outputs results to me ASAP please….
I will be very thankful to you,
My email id is jawad@jawadnaqvi.com
Sorry I was on Holidays. I don’t know if my answer come to late. Let me know if you already needs my files
thanks for your reply,yes i need your files as i am still not successful.If I will have your files and you can briefly guide me through this, that will be highly appreciated. please send asap Nelson, Thanks.
jawad@jawadnaqvi.com
Hi NELSON
I need your YUV output file and configuration file.if you send me that.it would be helpful for me.
thanks imtiaz and Jawad
Jawad@jawadnaqvi.com
imtiazmcs@hotmail.com usaks.ca
Hi,
Do you know if there is a way to config the HM encoder for integer ME, half pel ME and quarter-pel ME separately?
Hello,
Your article was a great help. Can you please let me know which parameters in the config file will affect:
1. PSNR
2. Bit-rate
3. Total Time consumed.
Thanks.