Closed denven closed 3 weeks ago
This is very very strange. But I don't understand what I'm looking at. Is it a frame of the mp4 or the related jpg. Because the timestamp shouldn't appear in the video.
Another question: which version are you using?
This is very very strange. But I don't understand what I'm looking at. Is it a frame of the mp4 or the related jpg. Because the timestamp shouldn't appear in the video.
Another question: which version are you using?
It's a jpg file, you can see the red border marked filename
not sure if you can get some clue by checking imggrabber.c
and thumb.sh
You are right. The thumbnail is created from the mp4 file but the watermark is added with the wrong time. Is the time when imggrabber is executed and not the time related to the content of the video file. To fix this problem, I need to change imggrabber.
@roleoroleo some ideas about the thumb.sh
and imggrabber
performance:
it seems this thumbnail feature is cpu expensive, on my camera, it costs about 10% cpu usage
thumb.sh
will run every minute, and imggrabber
has delay in grab frame to generate jpg file (like about 8 minutes in this bug)
what's the most time cost for imggrabber
? why there is too much delay when grabbing the thumbnail file?
probably it is caused by the checkFiles()
in thumb.sh
: echo "${L_FILE_LIST}" | while read file; do
imggrabber
process time and tune SLEEP_CYCLE_SECONDS
to ensure imggrabber
can be called every minute,by doing this, the delay is only 1 minute or none.
I already trying to change the code. The solution I'm trying is very simple. imggrabber accepts a new option useful to pass the timestamp manually. So the script thumb.sh can call imggrabber and pass the value derived from the file name. https://github.com/roleoroleo/yi-hack-MStar/commit/040c90af1e069d0b4b21082b7880ada2a064e718
If you want to test it: thumb.sh.gz imggrabber.gz
I replaced the two files and rebooted the camera, which resulted in the camera running into an infinite reboot loop. perhaps the cause is I didn't change the overwritten files permission. Then I hacked the camera with version 0.54 firmware, I previously used 0.49.
have to find another time to test again.
tested, the time minute is close to the jpg filename, but it is always a little greater (no more than 2 minutes) than it.
Update: Not true, the above is the previous grabber
created time which has delay.
The new grabber has the right time, however it doesn't show the local time, uses UTC time instead.
I have setup the time zone string, however the folders are still organized with UTC time.
Yes. The last version fixes a very old bug related to the time. Now the cam uses the correct timezone (localtime). But I changed all other pages and features related to the time, so the only difference is the time of the folder structure in /tmp/sd/record. I hope...
Yes. The last version fixes a very old bug related to the time. Now the cam uses the correct timezone (localtime). But I changed all other pages and features related to the time, so the only difference is the time of the folder structure in /tmp/sd/record. I hope...
By adding and using get_timestamp
function (convert UTC time to local time), we can put local time into the thumbnail file.
Or if possible, use the function to generate the video folder names by using local datetime, then no need to change thumb.sh
.
# input sample: /tmp/sd/record/2024Y01M24D09H/24M00S60
# will output: 2024-01-24 09:24:00
get_timestamp() {
local_time=$(date +"%Y-%m-%d %H:%M:%S")
utc_time=$(date -u +"%Y-%m-%d %H:%M:%S")
local_ts=$(date -d "$local_time" +%s)
utc_ts=$(date -d "$utc_time" +%s)
local_utc_offset=$((local_ts-utc_ts)) # seconds
# get utc time path without minute: 2024Y01M24D09H
# utc_path=$(echo $1 | grep -oE "[0-9]{4}Y[0-9]{2}M[0-9]{2}D[0-9]{2}H")
# utc_path_ts=$(date -d "${utc_path:0:4}-${utc_path:5:2}-${utc_path:8:2} ${utc_path:11:2}:00:00" +%s)
# local_path_ts=$((utc_path_ts+local_utc_offset))
# output local date path: 2024Y01M24D01H
# echo $(date -d "@$local_path_ts" +"%YY%mM%dD%HH")
# get utc time path with minute and second: 2024Y01M24D09H24M00S
utc_path=$(echo $1 | grep -oE "[0-9]{4}Y[0-9]{2}M[0-9]{2}D[0-9]{2}H/[0-9]{2}M[0-9]{2}S" | tr -d "/")
utc_path_ts=$(date -d "${utc_path:0:4}-${utc_path:5:2}-${utc_path:8:2} ${utc_path:11:2}:${utc_path:14:2}:${utc_path:17:2}" +%s)
local_path_ts=$((utc_path_ts+local_utc_offset))
# output local time: 2024-01-24 09:24:00
echo $(date -d "@$local_path_ts" +"%Y-%m-%d %H:%M:%S")
}
checkFiles ()
{
....
# TIME_STAMP="${file:15:4}-${file:20:2}-${file:23:2} ${file:26:2}:${file:30:2}:${file:33:2}"
TIME_STAMP=$(get_timestamp "$file")
....
}
By adding and using get_timestamp function (convert UTC time to local time), we can put local time into the thumbnail file.
Sorry but I don't understand. The time in the thumbnail jpeg should already be localtime. Is it in UTC for your cam?
Could you try to switch on the option "Enable/disable time OSD" and check the time in the upper left corner?
A little fix here: imggrabber.gz Not related to the timezone.
By adding and using get_timestamp function (convert UTC time to local time), we can put local time into the thumbnail file.
Sorry but I don't understand. The time in the thumbnail jpeg should already be localtime. Is it in UTC for your cam?
Could you try to switch on the option "Enable/disable time OSD" and check the time in the upper left corner?
Running the latest imggrabber
and turn on OSD option:
The delay is likely caused by the cron job of thumb.sh
execution every minute, and it loops and check all mp4 files which will cost more cpu time. there is already a while true loop in thumb.sh
, and it will keeps 2 processes running thumb.sh
, maybe keeping one is enough, and do not need to start it as cron job. I change thumb.sh
with above code I pasted here and I change only to check the latest 2 mp4 files, there is no delay of thumbnail files generation after mp4 files created (although 2 thumb.sh
processes are still running).
How is the time in the snapshot (from web gui for example)?
The delay is likely caused by the cron job of thumb.sh execution every minute
thumb.sh is executed with a delay, but, if you are using the version I posted above, when it runs imggrabber it passes the timestamp as an argument:
...
TIME_STAMP="${file:15:4}-${file:20:2}-${file:23:2} ${file:26:2}:${file:30:2}:${file:33:2}"
imggrabber -f $BASE_NAME.h26x -r low -w -t "$TIME_STAMP" > $BASE_NAME.jpg
...
thumb.sh reads the time from the name of the file (and the dir) and passes it to imggrabber. Imggrabber uses this time to print the watermark. Since the image is extracted from the first frame, the time of this frame is the same as the time extracted from the name of the file.
How is the time in the snapshot (from web gui for example)?
The delay is likely caused by the cron job of thumb.sh execution every minute
thumb.sh is executed with a delay, but, if you are using the version I posted above, when it runs imggrabber it passes the timestamp as an argument:
... TIME_STAMP="${file:15:4}-${file:20:2}-${file:23:2} ${file:26:2}:${file:30:2}:${file:33:2}" imggrabber -f $BASE_NAME.h26x -r low -w -t "$TIME_STAMP" > $BASE_NAME.jpg ...
thumb.sh reads the time from the name of the file (and the dir) and passes it to imggrabber.
Imggrabber uses this time to print the watermark.
Since the image is extracted from the first frame, the time of this frame is the same as the time extracted from the name of the file.
currently, the time in thumbnail is correct after using your new imggrabber. However, it is still in UTC time. z The video records directories are orgnized in UTC date hour time. do you convert the time to local timezone in imggrabber?
Something is wrong, I don't understand. With the last release, the file/folder structure in /tmp/sd/record should be oganized in local time. Not in UTC.
I will send a whole image to test.
Something is wrong, I don't understand. With the last release, the file/folder structure in /tmp/sd/record should be oganized in local time. Not in UTC.
I will send a whole image to test.
I noticed that the record folders' naming was changed to UTC since version 0.49 or earlier. I thought it was a universal change since that version, so that's why I had to write the time conversion code to handle this.
I am not sure which setup of mine is not correct or if some other thing is wrong at my end because you've already adjusted this.
This commit (included in 0.5.4) changes the behavior of the cam. The cam should work in localtime and save the files/folders in localtime. I don't understand why your cam works in UTC...
A question. What time does the cam use when cloud is on?
from the Yi App stream, the OSD time is local. I think I never turned off the official cloud feature, although I don't use their cloud storage plans.
@roleoroleo I've mentioned that the camera stops to record video files in the previous issue discussion as well.
And it is not true, it is recording files, and using the local time to do it, the files in utc-time directories are overwritten by the new files.
So now the issue is when OSD is disabled, the camera still uses UTC time to organize folders.
Another issue found after OSD is enabled, it still has a chance to create folders in UTC time., I found this in the noon a several hours later folder was created of a sudden, and confirmed it existed on SD card from that time.
after several days of use the latest version, the timestamp on thumbnail file still doesn't match the osd time,delayed by hours.
Check this issue: https://github.com/roleoroleo/yi-hack-MStar/issues/436
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.
The bug appears in the bottom right corner of the thumbnail, the timestamp is not the correct time from its original video file. The camera time is 20:29 (the minute time is from its filename
29M04S56.jpg
grabbed from video file29M04S56.mp4
) while this timestamp put in the screenshot shows 20:37. The time difference is around 8 minutes.BTW: I take the thumbnail jpg file as a screenshot since it is picked from the recorded video file by the Yi-hacked integrated program
imggrabber
, and the timestamp is added to the file by this program.