roleoroleo / yi-hack-MStar

Custom firmware for Yi 1080p camera based on MStar platform
GNU General Public License v3.0
835 stars 110 forks source link

Incorrect video filename (doesn't match time) #436

Closed phoenix1887 closed 2 weeks ago

phoenix1887 commented 2 years ago

Hi, I've been using this software (and other versions allwinner etc) for over a year across many cams and have continually been updating every once in awhile when new versions come out. However I just updated one camera that has the mStar software on it to the latest version of the software and discovered a bug where it's saving the video file with a filename that doesn't match the time. This is causing problems in software I've written that syncs video files from various times across cameras as it's not grabbing the right files that coordinate with the times gathered from other cameras as it once did.

For example I'm using all my cameras with Los Angeles time zone string specified PST8PDT,M3.2.0,M11.1.0

The video file which corresponds to 4-12 at 11:09am is: http://rear:8080/record/2022Y04M12D18H/09M00S60.mp4 (Note the hour is 18 not 11, 7 hours off from what it should be)

The correct filename for this time should be: http://rear:8080/record/2022Y04M12D11H/09M00S60.mp4

Please note that in the UI it correctly shows that this incorrect filename is associated with 11:00 a.m. it's just that the filename itself is incorrect and doesn't match the time. Therefore it doesn't match the filename for this time gathered on other cameras that i have. Therefore it has been causing problems with the wrong files being synced for this camera in scripts that I have to back up files for the cameras.

I haven't noticed any of these incorrect filename problems with any of the other cameras using the various kinds of software and various versions of this mstar software. Therefore I believe this bug is coming from either the most recent version or within the last 2-4 updates.

Hope this issue can be fixed as right now the only solution I have is to downgrade to a previous version of the software. I'll have to figure out which is the last version that works. Let me know if you know what version I should downgrade to.

Best,

roleoroleo commented 2 years ago

I played a lot with timezone in the last versions and I'm working on it in these days. But I don't understand the current state. Please explain me better how it was before and how it is now.

rathaROG commented 1 year ago

Edit: I guess it's not the same problem. I checked the folder names, and they were correct. The problem is that I can't seek the timeline on the Yi Home app to the exact time I want.

I think mine has the same problem. It's 1 hour different, and I guess it's related to the folder name? I have to seek the timeline on app 1 hour later; for example, if I want to see the recorded footage at 10:00 AM, I must seek to 11:00 AM.

roleoroleo commented 1 year ago

Did you set time zone both in the app and in the web page?

rathaROG commented 1 year ago

Did you set time zone both in the app and in the web page?

Yes both app and webpage have the exact same time zone, and there's nothing wrong on the event webpage /?page=eventsdir. The names of the dir or folder are correct. I have no idea why the app can't seek the time correctly.

Mine is "9FUS", came with firmware 4.2.0. I used the latest MStar 0.4.8, tried both (4.2.0 y25) and (4.5.0 y203c), but no luck.

I also have a newer 9FUS with firmware 8.3.0, and there is no such problem with your Allwinner 0.3.2. Everything just works perfectly.

roleoroleo commented 1 year ago

Do you remember if the problem already existed before installing the hack?

rathaROG commented 1 year ago

Do you remember if the problem already existed before installing the hack?

No there was no such problem before. I used the stock firmware for years, and this issue only presents after I installed the hack last week.

roleoroleo commented 1 year ago

Are you using continuous recording or just events?

roleoroleo commented 1 year ago

I checked the problem and it has always existed. I will fix it in the next release. But this fix will introduce a "problem": the cam will save date/time in UTC (as original fw does).

rathaROG commented 1 year ago

I checked the problem and it has always existed. I will fix it in the next release. But this fix will introduce a "problem": the cam will save date/time in UTC (as original fw does).

Yes, continuous recording. I'm glad you identified bug. I'm looking forwards to the next release. Thanks!

smithumble commented 5 months ago

I will fix it in the next release.

Wasn't this behavior changed? I have the same problem in 0.5.4

roleoroleo commented 5 months ago

The last release changes completely this behavior. So, please, describe the problem again. What's the local time shown in Status page? What's the "Date & time" column in Events page? Local time? GMT? Other? What's the name of the file/folder structure in/tmp/sd/record? Local time? GMT? Other?

smithumble commented 5 months ago

I set timezone in settings like this

image

In status page there is local time

image

Also local time in in Events page

image image

Here is file/folder structure. It's also local time.

Screenshot 2024-02-08 at 10 46 05

The red one is with configured timezone The greens is when timezone is not set (blank on settings page)

When timezone is set I can't seek in app timeline properly.

In app timezone is configured 2024-02-08 10 56 39

Here is how the app behaviors with timezone set

https://github.com/roleoroleo/yi-hack-MStar/assets/33865176/1c4dfd72-8158-4b54-9459-f1ab1ded5243

Without timezone set in yi-hack settings it works just fine.

smithumble commented 5 months ago

So as I understand the app requires GMT time in file structure

roleoroleo commented 5 months ago

Please, overwrite syste.sh with this one: system.sh.gz

smithumble commented 5 months ago

Looks like it did nothing

Check that I did it right

Screenshot 2024-02-10 at 00 34 33

md5 of original and replaced

Screenshot 2024-02-10 at 00 42 26
smithumble commented 5 months ago

oh, sorry, I was wrong

it did something

image

looks like strait after reboot it saves first file to folder with GMT time and next files to folder with local time

smithumble commented 5 months ago

BTW maybe it makes sense to make a switch for the time zone in the saved files/folders?

Something like "Force GMT for saved video directory tree"

So that those who need the app can enable it and those who don't can have the correct local date/time

roleoroleo commented 5 months ago

Mmmmmmmhhh The problem is not yet fixed. I need to check again.

roleoroleo commented 5 months ago

After many days of analysis, I understand that this problem is very complex.

If you use the cam with the factory firmware, it works in GMT: the file/folder structure is saved in GMT and the software translates the time for you (with the timezone that you configure in the app). The cam knows the timezone because cloudAPI gets this value from the cloud and sets it in memory, but the cam continues to work in GMT.

When you switch off the cloud, cloudAPI_fake replies to the cam with the same configuration sent by the cloud, so there shouldn't be any differences.

Other elements impact this behavior: ntpd, timezone, set_tz_offset_osd. ntpd: if you use ntpd, the time comes from an internet server, but it's the same time sent from the cloud (tested). timezone: if you set timezone in the webgui, /etc/TZ is filled and all the processes can read the file (to check again). I could remove the file and use TZ just for my processes. set_tz_offset_osd: if you enable time osd in the webgui, the cam changes the time used to save the file. If you don't use the cloud it's not a problem, if you use the cloud you will experiment the problem reported in the video above.

I didn't finish the test because it's very difficult and time expensive. But I will do...

roleoroleo commented 5 months ago

I finished to test all options (updated post above). ntpd and timezone don't change the time behavior. The problem is the option "Time OSD". When I check this option the cam changes the date/time of the folder structure. And unfortunately I can't do anything about it.

If you use the app and you don't want to have problems with the timeline you have to switch off the OSD. I will send a beta image to test, if you agree.

EDIT

Maybe I found a way. I will let you know.

roleoroleo commented 4 months ago

I did all the tests I could and there is no full solution. I managed to fix the problem about folder structure but I didn't find a solution for the timeline in the app. When I switch on the the "Time OSD" flag the timeline is wrong. Please, try this beta: h201c_0.5.4.tar.gz

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.