-
Notifications
You must be signed in to change notification settings - Fork 662
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
Milliseconds support for time overlay (recording and streaming) #2130
Comments
The overlay comes from Motion (which your script reconfigures over the webcontrol interface), but I have to ask what's the camera frame rate you're using? Asking for 10 ms refresh interval for the overlay would also mean having 1/0,01=100 frames/sec since the overlay is written on the video frames. Recording 720p at 100 fps using a Raspberry Pi sounds quite a challenge, too, even without any motion detection (which I assume you're not using), is that even feasible? What I see in Motion docs is that Anyway, if it really is so that the timestamp in the overlay doesn't change even though there are multiple video frames per second, I think that must be some sort of optimization (or just a side-effect of something else which has gone unnoticed) in Motion. I also took a quick look at where As for changing the code, did you restart MotionEye service after recompiling (might be a stupid question but asking just to make sure 😃 )? |
Hey, thx for the reply. :-)
Of course you are right, I`m only running it 720p with 25fps. So I get a new frame every 40ms. The ideal sleep would be 0.040 s in the bash script if it would synchronize exactly at every new frame.
Ok and my values if I use the config path with "text_right %Y-%m-%d %T.%3N" are always between 1-255 which corresponds to your explanation.
Yes,I just redid the whole setting Default_INTERVAL=2 and still get the overlay refreshed every second instead of every 2 seconds.
To alter the monitor.py I used: And I even rebooted the rpi. Btw, I actually do the scheduled constant recording with 10 minute files via starting and stopping the motion sever via crontab with the start and stopserver commands. Below all the camera settings (I might turn off more to see whether I can save more cpu): |
With some digging and luck I found the concept the Anyway, if you want to experiment with that, it seems like it might be possible to make it run on nanosecond precision by changing As for the way of recompiling ME, I run ME with modifications only in my local development environment, I don't touch my production setup other that my upgrading it with |
I meant to reply way earlier but was carried away configuring manual ntp sync from a local windows 10 notebook for the same setup when deploying the cameras without any internet connection. Since I need the timestamp burned into the video and I need to leave for fieldwork to deploy the cameras in 5 days I will stick with the curl version for now. Thx again for the helpful input. :-) |
I would like to add a "+1" for this too. I am trying to measure the speed of cars passing pas my door and the variable framerate video is doing my head in. A ms timestamp would be a great help. |
Hi,
Great piece of software. I modified it to use without wifi to constantly monitor bat flights on a raspberry pi 3B simultaneous to audio recordings (no detection trigger used). (I use a local hotspot on my smartphone to setup the camera and check the stream).
However I need now higher precision and implemented a milisecond overlay.
In the camera-x.conf file it accepts miliseconds and also displays them in the overlay:
text_right %Y-%m-%d %T.%3N
However the overlay seems to be refreshed only every second so that I don`t really gain anything from the miliseconds since they show always the same 3 digits every second.
Therefore I used the bash script below which gets started and killed with motioneye server (c is a correction due to processing time):
#!/bin/bash
#for recording correction (s)
#c=-0.2
#for stream correction (s)
c=+0.3
NOW=$( date '+%Y-%m-%d_%H:%M:%S.%3N' )
while :
do
curl "http://localhost:7999/1/config/set?text_right=`LANG=C date '+%Y-%m-%d %H:%M:%S.%3N' --date "NOW $c sec"`"
sleep 0.01
done
exit
This unfortunately uses 20% more cpu and I`m off by about +-50ms of real time (https://time.curby.net/clock)
and it uses more energy. Since my devices are car battery powered and temperature in warm attics can play a role I would rather stay with 50% cpu usage while recording 10 minute 720p files instead of 70-80%.
See the timing in the attached picture:
Is there a way to change the overlay refresh interval to 10ms or 100ms in more efficient and precise way than using the above curl?
So I could use it in combination with the normal "text_right %Y-%m-%d %T.%3N" in the config file.
I saw in the monitor.py file an interesting variable:
DEFAULT_INTERVAL = 1 # seconds
I changed it to 0.1 and 2 directly in the install folder and compiled it, unfortunately without any effect. Or do I have to take additional steps beside changing the variable, compile it to a .pyc and reboot raspberry pi that the new values take effect?
Maybe my bash script can still be of use for some people if efficiency is not that important. :-)
Thanks for your help in advance.
The text was updated successfully, but these errors were encountered: