-
Notifications
You must be signed in to change notification settings - Fork 60
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
Download SD videos #4
Comments
Hello, I too would love this feature. Someone will need to discover a way how to get those videos from the camera and then I will add this to this lib. |
Ok here we go, huge amount of work went into this and we need more help. Thanks to a huge help from @depau who RE the camera and figured how the camera loads recording and also wrote a lot of code, we were able to get to an almost-there state. Almost is an important word here. So here is a summary of whats going on:
With the current code, we are able to get all the raw & decoded data for the whole day (currently its temporarily limited to 2000 sequences, gives around a minute or 2, for testing). However, when we convert the TS data into mp4, we get a video having around 1.3FPS which is terrible. Here is where we need help. There are 2 possibilities what is wrong here: 1.) We are missing something in the code. Currently we are getting all the binary data and decoding & connecting it together. It decodes fine and is also able to be converted, so I think this is not the case. After we resolve the low fps issue we can continue with the code and:
If you have the python / ffmpeg experience and wish to help: Download latest dev branch. Run file below. The file should use the downloaded library, not your installed one. Try to get a smooth video file from it... and please let us know if you have any success!
|
FYI people: An attacker who has a dump of the communication and your cloud password can still decrypt the video. Beware ;) Anyway I sent a TS video sample to a friend of mine who's into video codecs, he's gonna check it out. |
@depau would you be able to share it, I'd like to try it to if possible. I'm away from my cameras until next year, so it would be awesome if you can share that sample. |
@depau if its mine sample please do not share publicly |
Yeah I only have your sample, I'm not sending it around. I only showed it to my friend (i know him personally) and he said that to him it looks like the video is actually recorded at 1/2 fps, I have no idea why that would be. Maybe someone else can try to retrieve some samples and publish them so people can try to figure it out. |
I'm going to try when I'm back to my house Jan 20th. |
Same for me. |
My friend and I achieved similar results before when we are doing research on tapo C200, the low framerate issue is a real mystery :/ Here are what we did: https://drmnsamoliu.github.io/video.html And just FYI there is an auth bypass vulnerability in their implementation of RTSP protocol, but we failed to receive anything useful too. |
Any update on this? I also failed to fix the issue of low fps in my own research... ;/ |
i'm checking the ts files in order to see if we can fix this... it seems that there are two streams, video and i suposse an audio stream, but my ffmpeg doesn't recognice the second stream codec...
i think its a subtitle stream... i tried removing it (just in case the subtitles stream is forcing some kind of weird fps), with no luck. also, i've transformed each frame to jpg, and it seems that, even if the FPS are 15, the frames are repeated, so my guess is that the transceive method is making something wrong, or the json payload must have more params or some of the params must be changed in order to get the correct TS. |
Has there been any more progress? I was wondering if someone has compared the original file on the SD-card and the one captured from the stream? I.e. Size, if it is spesific framnes that are streamed etc. |
I have no idea if this could affect the dropping of frames, but when viewing in the app. It is possible to select different playback speeds. I guess having a faster playback speed means dropping frames. So maybe it is possible to experiment with different playback speeds to see if this affect the fps. |
Good idea, unfortunately already tried it when originally implementing. It is passed as a parameter |
i tried also modifying the scale param with every value I was capable of
thinking and the results remained the same: crappy video.
El mar, 25 ene 2022 a las 0:09, Juraj Nyíri ***@***.***>)
escribió:
… I have no idea if this could affect the dropping of frames, but when
viewing in the app. It is possible to select different playback speeds. I
guess having a faster playback speed means dropping frames. So maybe it is
possible to experiment with different playback speeds to see if this affect
the fps.
Good idea, unfortunately already tried it when originally implementing. It
is passed as a parameter "scale": "1/1",.
—
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACYUS6IRHP7S43H7ILD43QLUXXLZVANCNFSM4TXB6JQA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Ahh to bad. :( Whe Tapo care is activate, it says the videos is uploaded to the cloud, maybe by analyzing this traffic. Its possible to get more knowledge i to how videos are streamed/downloaded from the camera. Maybe this has already been drone. :/ |
A recent vulnerability was discovered where a reverse shell can be made by using post request (similar to what pytapo does). Maybe someone with version below 1.1.16 can utilize this to explore the inner workings of tapo C200. Unfortunately I have already updated my firmware to 1.1.18 before discovering this. https://www.hacefresko.com/posts/tp-link-tapo-c200-unauthenticated-rce |
One step forwards, one step back. Discovered a way how to "turn off" encryption of stream (and get state of the encryption). As I later found out this simply changes authorization to stream from using cloud password to using a hardcoded super secret password. After getting a recorded file with this way, I still get the same result as before after converting it with ffmpeg. I guess this at least confirms we are decoding the streamed data correctly. The changes are in dev branch as always. |
I analyzed chunks of data received when downloading the stream. There is always a bigger chunk, and 2 or 3 smaller chunks between the large ones. They always have length 376 decrypted, 384 encrypted but different content. I tried ignoring these chunks when building the file, and interestingly, it resulted into exactly the same result as before, with smaller file size (4mb vs 4.4mb). So it looks like these chunks can be ignored and we achieve the same result. Maybe it is sound or I was also thinking of the "difference" between the big chunks (that seems to be missing in our resulting file) but there is not more of them on motion in file, always just 2-3. After removing the small chunks, ffmpeg is still reporting 2 streams. |
Updated DEV branch with code changes adding ability to record live stream. It uses the same port and communication as recordings, with following differences:
How to run:
The resulting file is broken the same way as recordings are. Thanks to this we know:
With that, we can deduce that it can be an issue with:
|
This comment was marked as off-topic.
This comment was marked as off-topic.
@jepes1981 please come to discord to debug the issue with running this script. |
There has been progress on this made on go2rtc repository. I have spent a few hours on this comparing the code and have found that we need to be decoding the received payload. So here:
We need to be decoding I have verified that:
The difference between is that pytapo is not decoding the received packets, where as go2rtc is doing that and sending the decoded payload, which is significantly smaller. There is also something happening with tracks there, I am not sure what yet. I have tried following libraries in python to achieve the same with no success: |
DiscoveryModified go2rtc with following logs: This gives me following output: Notice the ImplementationNext, I have rewritten all the methods from go2rtc into pytapo (ouch) as described in above comment. File attached. I think they should be working as expected but have not tested them fully yet. ResultI have found that when using the functions that I wrote (if uncommented in code above/screenshot below), I land in a code branch where go2rtc never lands. The reason for that is that the chunks that I am receiving in pytapo do not have |
Simplifying debugging for aboveDownload: Just fill in ENV variables at the start of file or hardcode them, you can use the latest github main branch version. Go2RTC outputPyTapo outputNext action itemWe now have an easily debuggable scenario with comparison code and we need to make sure that the output of pytapo is the same as Go2RTC. |
SOLVED AFTER MORE THAN 2 YEARSAll we needed to do was refresh IV in crypto after every message.Also, all that code I rewrote from go to python for stream RTP was not needed in the end. |
Script to download all recordings have been added here.You can launch it like so:
Next taskWe need to figure out how to convert audio into the files. |
All needed functionality has been added. Recordings now also include audio converted into AAC. Instructions are in readme. |
Would be possible to download the contents of the SD card ? I'd like to have a script that automatically backups all cameras videos, thanks in advance.
The text was updated successfully, but these errors were encountered: