View Single Post
Old 2nd April 2016, 20:47   #218  |  Link
Mosu
MKVToolNix author
 
Mosu's Avatar
 
Join Date: Sep 2002
Location: Braunschweig, Germany
Posts: 4,278
About the CodecPrivate thingy. mkvinfo outputs profile information for two codecs: AVC/h.265 and HEVC/h.265. Those can be easily gathered yourself by parsing the "codec_private" attributes mkvmerge outputs. Here's how.

AVC/h.264: trivial. Connvert the first four pair of hex numbers to four bytes. Then you get the following variables:

Code:
// bytes[0] is always 1 and can be ignored.
profile_idc    = bytes[1];
profile_compat = bytes[2];
level_idc      = bytes[3];
Then you can determine the profile and level strings like mkvinfo does.

For HEVC/h.265 is a bit more complicated, but not by much. Convert the codec private hex numbers to bytes. Then you'll need some specific bits. I'll write some pseudo code; see here for the code mkvinfo uses:

Code:
// Start reading at the start of the codec private bytes.
skip 8 bits (version number)
skip 2 bits (profile space)
skip 1 bit (tier flag)
profile_idc = read 5 bits
skip 32 bits (profile compatibility flags)
skip 1 bit (progressive source flag)
skip 1 bit (interlace source flag)
skip 1 bit (nonpacked constraint flag)
skip 1 bit (frame only constraint flag)
skip 44 bits (reserved)
level_idc = read 8 bits
And here's how those numbers translate into the profile strings.

That way you don't even need to execute mkvinfo.
__________________
Latest MKVToolNix is v83.0

If I ever ask you to upload something, please use my file server.
Mosu is online now   Reply With Quote