noirotm / flvmeta

FLV Metadata Editor
https://flvmeta.com/
GNU General Public License v2.0
121 stars 35 forks source link

First attempt to parse video dimensions for HEVC encoding #22

Open rogerhu opened 9 months ago

rogerhu commented 9 months ago

Depends on https://github.com/noirotm/flvmeta/pull/21

I spent the last month studying how ffmpeg code handles parsing HVEC NALU's. =)

It turns out that most of the information I need has to be retrieved from the hvcc atom that's included as part of the HEVCDecoderConfigurationRecord.

A new Video Parameter Set (VPS) is added, but it contains no useful information about the video dimensions from what I can tell. The SPS needs to be parsed, but there is an emulation prevention byte 0x00003 that has to be replaced. The ffmpeg code has a lot of special ways of looking for it (including this crazy way of check for zero bytes - https://graphics.stanford.edu/~seander/bithacks.html#ZeroInWord), but I chose to extract the the least common denominator to parse it.

I implemented the logic from FFMPEG based on decode_profile_tier_level and parse_ptl.

noirotm commented 9 months ago

Hi Roger, it seems this PR contains the changes from #21. Is this expected?

rogerhu commented 9 months ago

Hi Roger, it seems this PR contains the changes from #21. Is this expected?

I just rebased! I squashed all the commits which included those PR changes.