Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for H265 HEVC Encoding #43

Open
mattreidy opened this issue May 28, 2024 · 6 comments
Open

Add Support for H265 HEVC Encoding #43

mattreidy opened this issue May 28, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@mattreidy
Copy link

UniFi Protect Application 4.0.21 now adds H265 HEVC as an option for newer cameras and is used when "Enhanced" encoding is selected in the camera recording settings. ("Standard" encoding continues to be H.264).

It would be great if this utility could support both types of encoding.

https://community.ui.com/releases/UniFi-Protect-Application-4-0-21/6890a055-2a90-4011-a3e6-18f8e290244f

@mattreidy
Copy link
Author

I'm unsure of the actual format of the UBV file when Enhanced encoding is used, but the remux utility does not work with it.

@petergeneric
Copy link
Owner

It's likely a simple matter of changing how the bitstream is processed, or reading from a different track - do you have a sample .ubv that you are able to share without any identifying information that I could use for development purposes?

@mattreidy
Copy link
Author

Here's a file wit the enhanced encoding - it would be ideal if the program could determine which encoding was used and automatically handle it vs. needing to pass in a flag etc. Thanks for responding and taking a look! I use the program to snatch a clip from a specific camera every 5 minutes and make it available as a "live" video on a web page - www.keuka.org

https://drive.google.com/file/d/1gIkG3MATIBWWOpDzRPCsJ2Xwg_fAnJQg/view?usp=sharing

@petergeneric
Copy link
Owner

petergeneric commented Jun 2, 2024

Thanks for the sample file - I'll have a look to see what's different in the structure. I would also hope to have it natively detect and extract H264/H265 depending on what is in the file.

FYI if you haven't already tried it, give Ubiquiti's native tool a go - it is available at /usr/share/unifi-protect/app/node_modules/.bin/ubnt_ubvexport (at least on my cloudkey). I built this tool before Ubiquiti provided that, and while I still think my tool is able to recover more from corrupted files ubnt_ubvexport seems to work well on normal files.

@petergeneric petergeneric added the enhancement New feature or request label Jun 2, 2024
@petergeneric
Copy link
Owner

Hi, took me a while to get around to this but I looked at the supplied sample... it appears to contain H264, not HEVC. Could you check that you've provided the right sample?

@petergeneric
Copy link
Owner

Ok, I switched one of my cameras to HEVC to test and I think the issue preventing you here is the same as in #44 (HEVC video is written to a different Track Number in the .ubv, track 1003).

If using an older version of ubnt_ubvinfo, I get the following error (running ubnt_ubvinfo -P -f test.ubv):

Type   TID  KF           OFFSET     SIZE          DTS   CTS              WC     CR
----------- PARTITION START -----------
:0 Invalid track detected: 0x03eb
/home/shiretu/jenkins/workspace/EMS_tag_v2/label/debian_9.2.1_64_machine_1/sources/ubnt_ubvinfo/src/ubvobserver.cpp:41:SignalPayloadRaw
:0  not yet implemented
:0 Error occurred while parsing the file: (-2146697195)
Stats
Audio: frames: 0; bytes: 0; minTs: -1; maxTs: -1; bitrate: 0.00kbps; mbday: 0.00 MB/day
Video: frames: 0; bytes: 0; minTs: -1; maxTs: -1; bitrate: 0.00kbps; mbday: 0.00 MB/day
:0 Shutting down the logger leaving you in the dark. Bye bye... :(

I need to update my test env with a more recent ubnt_ubvinfo, but I suspect the development code will now be able to extract HEVC tracks if the -track-number 1003 arg is added to the remux commandline. Once I have tested with a more up-to-date version of ubnt_ubvinfo I'll look at cutting a release for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants