secure-video-specification icon indicating copy to clipboard operation
secure-video-specification copied to clipboard

Is there documentation on when HomeKit will re-encode streams?

Open Botts85 opened this issue 3 years ago • 1 comments

I am trying to determine what stream parameters cause HomeKit to re-encode video before uploading to iCloud.

A raw stream off my camera is not re-encoded prior to uploading to iCloud. However, if I run it through FFmpeg, it'll record, but it is being compressed prior to upload.

The stream directly off the camera is: Stream #0:0[0x1e0]: Video: h264 (High), yuvj420p(pc, bt709, progressive), 1280x720, 20 fps, 20 tbr, 90k tbn, 40 tbc

This is what I was using for export settings in FFmpeg: -c:v libx264 -pix_fmt yuvj420p -bf 0 -vf scale=1280:720,fps=30 -preset ultrafast -b:v 1500k -minrate 1500k -maxrate 1500k -g 120 -r 30 -video_track_timescale 90k -profile:v main -movflags frag_keyframe+empty_moov+default_base_moof

If anyone happens to know where the line is between compatible with HomeKit, and compatible with HomeKit after the AppleTV re-encodes it, that would be awesome.

Perhaps most strangely, is the awful quality that the AppleTV creates on re-encode. Presumably it should have the same H264 encode blocks as an A12 powered iPhone which'll do awesome looking H264 video faster than real time. Attached is two screenshots, one straight from FFMpeg, and one after the AppleTV re-encodes it.

Recorded Streamed

Botts85 avatar Feb 11 '22 06:02 Botts85

I'd be interested to know you have gotten on with this? Seem something similar with one I developed for older Nest cameras (More specifically, the Nest Hello) Have an ffmpeg command string that take the raw h264 frames and allows them to be recorded (seems HomeKit is picky with what it gets to allow a recording to be stored (still have to get audio encoding working as there are split streams to be mux'd together)

n0rt0nthec4t avatar Apr 28 '22 01:04 n0rt0nthec4t