Treasured's Movie Repair Guide -- H265


H.265 or High Efficiency Video Coding (HEVC) is a modern standard for video compression.

The successor of H.264, H.265 claims to achieve the same level of quality with only half the bitrate.
Cameras with HEVC video encoding have started shipping in 2015 (Samsung NX1, Samsung NX500, Samsung Gear) and in last years, as H.265 encoding chips are becoming mainstream, the HEVC codec is used by many cameras, ranging from low-end to production:

Samsung Gear 360, featuring H.265 recording

Detection

Starting with Treasured 4.0, damaged files containing H.265 format are now supported. Treasured will detect presence of H.265 media inside the corrupted video and show a preview (if encoding profile is supported).

Repair

At bitstream level, H.265 is structured similarly as H.264. Therefore, repair techniques for HEVC are not very different from what we have been doing with H.264 for over 8 years. In other words, all our experience in delivering high-quality, affordable repairs will be immediately available for new H.265 videos.

To fix a corrupt video containing H265, it is sometimes necessary, and always helpful, to have a good file similarly encoded. Even if the good file contains only a few frames, the fact that it was encoded with the exact settings of the damaged clip will provide useful information:

This information can be guessed from a broken H265 file, but through a very lengthy trial-and-error iterative process.

Anatomy of a H265 movie

H.265/HEVC format can be found in a variety of containers, for example .MOV, .MP4, .MXF or .TS (transport stream).

Inside a MP4 container, H.265 has the following characteristics:

Header


0000000: 0000 0030 6674 7970 6d70 3432 0000 0000  ...0ftypmp42....
0000010: 7174 2020 6973 6f6d 6876 6331 0000 0000  qt  isomhvc1....
0000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................

where mp42 indicates MP4 container and hvc1 indicates H.265/HEVC encoding.

Frames


0000040: 000b dd6c 2601 ac6e 4939 bd6c c7f1 da20  ...l&..nI9.l... 
         +++++++++ xxxx
0000050: 4a68 0c7c c8c2 9c5d 6612 eaad d3b7 daf9  Jh.|...]f.......
0000060: eb92 2ca1 b0c2 4f8a 1ede 0541 c938 c684  ..,...O....A.8..

where +++++++++ value 0xbdd6c corresponds to the length of this frame
and xxxx value 0x2601 corresponds to a keyframe.

Other values are possible for xxxx, for example 0x0201 stands for a (P)rogressive frame.

Sample Description

Deep inside the moov atom found either at the beginning of at the end of the .MP4 file, the stsd atom contains the H.265 encoding settings necessary to decode the video.

bbf4fd3: 0000 00ed 7374 7364 0000 0000 0000 0001  ....stsd........
bbf4fe3: 0000 00dd 6876 6331 0000 0000 0000 0001  ....hvc1........
bbf4ff3: 0000 0000 0000 0000 0000 0000 0000 0000  ................
bbf5003: 0f00 0870 0048 0000 0048 0000 0000 0000  ...p.H...H......
         wwww hhhh
bbf5013: 0001 1f44 5249 4d65 5620 4845 5643 2045  ...DRIMeV HEVC E
bbf5023: 6e63 6f64 6572 0000 0000 0000 0000 0000  ncoder..........
bbf5033: 0000 0018 ffff 0000 0074 6876 6343 0101  .........thvcC..
                               ++                           xxxx 
bbf5043: 0000 0006 0000 0000 0000 99f0 00fc fdf8  ................
bbf5053: f800 004f 0320 0001 0018 4001 0c01 ffff  ...O. ....@.....
bbf5063: 0160 0000 0300 0003 0000 0300 0003 0099  .`..............
bbf5073: ac09 2100 0100 2542 0101 0160 0000 0300  ..!...%B...`....
bbf5083: 0003 0000 0300 0003 0099 a001 e020 0220  ............. . 
bbf5093: 7c4e 5ae4 bc12 ea6e 0202 0201 2200 0100  |NZ....n...."...
bbf50a3: 0944 01c0 7292 030c 4190 0000 0013 636f  .D..r...A.....co
bbf50b3: 6c72 6e63 6c78 0001 0001 0001 00         lrnclx.......

where hvc1 indicates the codec used, wwww with value of 0x0f00 (3840) is the picture width, and hhhh with value of 0x0870 (2160) the picture height.
and where hvcC structure (length ++ 0x74) contains encoding settings, formatted in according to "Annex-B"

Free Preview of corrupt H.265 videos with: