mnakada / atomcam_tools

Hack tool for atomcam and wyzecam.
Other
183 stars 22 forks source link

h265 1080p channel 2? #43

Closed gtxaspec closed 1 year ago

gtxaspec commented 2 years ago

@mnakada, i discovered in atomcam, there is channel 2 which outputs 1080p @h265, do you know what this is used for? I don't believe it's used in the atom app

CHANNEL 0    1920x 1080     START H264
CHANNEL 4    1920x 1080      STOP JPEG
CHANNEL 2    1920x 1080     START H265
CHANNEL 1     640x  360     START H265
CHANNEL 5     640x  360      STOP JPEG
mnakada commented 2 years ago

@gtxaspec , I don't know. The video_callback registration occurs on Channel0, 1, and 5, but only 0 and 1 actually receive the stream.

gtxaspec commented 2 years ago

do you think it would be possible to switch channel 0 to h265, or somehow enable channel 2 ? I've checked sample_encoder_init in liblocalsdk.so, I think that where the IMPEncoderProfile video profile is set.

I think h265 has better bandwidth savings compared to h264, maybe approaching 50% bandwidth savings in h265 from what I've read. This could benefit storage space on the sd card / nas storage and rtsp server too.

mnakada commented 2 years ago

@gtxaspec , The following is my guess as I have not tried it.

The T31 has 2 Encoders, one is used for 1080p, the other for 360p. So I believe that if you are running these, you cannot run ch2.

Also, if ch0 could be switched from H264 to H265, I think it would now be inconsistent with the iCamera_app side.

gtxaspec commented 2 years ago

I did succeed in switching ch0 and ch1 in wyze from h264 to h265, and the rtsp server works, but the phone app breaks obviously.

mnakada commented 2 years ago

@gtxaspec , How much data volume changes between H264 and H265? Can you measure the number of bytes per minute for the two types of encoding on the same scenery?

gtxaspec commented 2 years ago

tested on one minute of video, similar scenery.

HEVC (360kbps target bitrate, 960kpbs max bitrate): 2841397 bytes per minute MP4 (720kbps target bitrate, 960kbps max bitrate): 6767493 bytes per minute

@mnakada I lowered the target bitrate of the HEVC video until I could not distinguish the difference between HEVC and MP4 for an indoor type of scenery

mnakada commented 2 years ago

@gtxaspec . Thanks! That's quite a difference.

How do we handle the mobile app? For H265, do we make ch1 360p flow to the mobile app so we can switch between H264 and H265?

gtxaspec commented 2 years ago

Hmm... I'm really not sure how to handle with the mobile app.

just thinking out loud, the wyze app system does not seem to support h265 at all. Probably does not have the libraries built in...but maybe the atom app does? Perhaps just switching the 1080p stream to h265 will work with atom, it's just a wild guess for now.

mnakada commented 2 years ago

@gtxaspec , I replaced IMP_Encoder_CreateChn in atomcam and checked the content of attr.

ch0 eProfile: AVC IDC_MAIN width: 1920 height: 1080 pixFormat 0188
attrRcMode: 08 targetBitRate 1440 MaxBitRate 1920 

ch1 eProfile: HEVC IDC_MAIN width: 640 height: 360 pixFormat 0188
attrRcMode: 08 targetBitRate 480 MaxBitRate 640

ch2 eProfile: HEVC IDC_MAIN width: 1920 height: 1080 pixFormat 0188
attrRcMode: 08 targetBitRate 1440 MaxBitRate 1920 

ch4 eProfile:JPEG width: 1920 height: 1080 pixFormat 0188
attrRcMode: 00 

ch5 eProfile:JPEG width: 640 height: 360 pixFormat 0188
attrRcMode: 00 

It seems that ch2 comes as ch3 in video_callback. By outputting ch3 to /dev/video0, I was able to receive the video in VLC as 1080p HEVC. It seems to be able to encode 3 streams at the same time. This is different from the documentation.

mnakada commented 2 years ago

@gtxaspec , I have not changed ch0, so of course the mobile application looks fine.

However, when I add /dev/video2 to the three v4l2loopback streams, the iCamera_app is unusually overloaded. Maybe there is not enough memory.

mnakada commented 2 years ago

I have switched to HEVC but it may be a little unstable. After watching rtsp for a while, sometimes the picture looks like the I-picture is missing. Sometimes it gets disconnected.

gtxaspec commented 2 years ago

@mnakada I just saw your latest release with H265, very impressive!

I wonder if I can do the same to the wyze system to create an additional output for h265 as in atomcam.

Regarding stability, I noticed that the tx-isp-t31 module is loaded with a lower isp_clk frequency on atomcam, and on wyze it is higher. Could adjusting this maybe help stability?

insmod /system/driver/tx-isp-t31.ko isp_clk=220000000

mnakada commented 2 years ago

I wonder if I can do the same to the wyze system to create an additional output for h265 as in atomcam.

Since the hardware is the same, it should be possible. It may work if you initialize HEVC ch2 together when initializing ch0.

Regarding stability, I noticed that the tx-isp-t31 module is loaded with a lower isp_clk frequency on atomcam, and on wyze it is higher. Could adjusting this maybe help stability?

Thanks! I tried it, but it still rarely causes symptoms like I-Picture reading failure. (Only the moving parts are shown in the full gray screen)

mnakada commented 1 year ago

close this issue.