Gary Littlemore
Posts: 327
Joined: Thu Oct 11, 2012 11:52 am
Location: Cheshire, UK

Re: RPi Cam Web Interface

Fri Mar 02, 2018 9:50 am

Robert,

I have this problem that keeps happening for time to time every few days. I have 'Motion Detect' on and it'll keep turning itself off, the last recorded video was 2018-03-01 19:49:28 31214 Kb 24s. Sometimes, but not all the time when it happens the video are showing busy and there can be 2 or 3 showing busy, I have to delete them to get rid of them. This time the process has completed and it's showing busy.

Below is the log file from when the 19:49:28 file has been picked up.

Code: Select all

{2018/03/01 19:49:22} Add /var/www/html/media/vi_3017_20180301_194904.mp4 to Box Queue at pos 13
{2018/03/01 19:49:23} Start boxing /var/www/html/media/vi_3017_20180301_194904.h264 to /var/www/html/media/vi_3017_20180301_194904.mp4 Queue pos 13
{2018/03/01 19:49:23} DEBUG 3
{2018/03/01 19:49:39} Watchdog detected problem. Stopping{2018/03/01 19:49:42} SIGINT/SIGTERM received, stopping
{2018/03/01 19:49:42} Executing macro /var/www/html/macros/startstop.sh "stop" 
{2018/03/01 19:49:47} RaspiMJPEG Version 5.8.06
{2018/03/01 19:49:47} Executing macro /var/www/html/macros/startstop.sh "start" 
{2018/03/01 19:49:47} recommended video buffer size 65536
{2018/03/01 19:49:47} h264 size set to 131072
{2018/03/01 19:49:47} recommended video buffers 1
{2018/03/01 19:49:47} h264 buffers set to recommended 1
{2018/03/01 19:49:48} Set up internal detect width=121 height=68
{2018/03/01 19:49:48} Opening FIFO 0 /var/www/html/FIFO 7
{2018/03/01 19:49:48} Opening FIFO 1 /var/www/html/FIFO11 8
{2018/03/01 19:49:48} MJPEG streaming, ready to receive commands
{2018/03/01 19:49:48} send smd 9
{2018/03/01 19:49:48} Starting command loop
[2018/03/01 19:49:48] Reload parameters command requested
[2018/03/01 19:49:48] Scheduler loop is started
{2018/03/01 19:49:48} DEBUG 3
[2018/03/01 19:49:49] New period detected 0
[2018/03/01 19:49:49] Scheduled management tasks. Next at 1519935589
[2018/03/01 19:49:49] Purged 3 Files
3b+, 2b, b+, b, Zero & Zero-W

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 02, 2018 12:17 pm

Gary Littlemore wrote:
Fri Mar 02, 2018 9:50 am
Robert,

I have this problem that keeps happening for time to time every few days. I have 'Motion Detect' on and it'll keep turning itself off, the last recorded video was 2018-03-01 19:49:28 31214 Kb 24s. Sometimes, but not all the time when it happens the video are showing busy and there can be 2 or 3 showing busy, I have to delete them to get rid of them. This time the process has completed and it's showing busy.

Below is the log file from when the 19:49:28 file has been picked up.
The log shows a watchdog reset. This happens when there is no response from camera supplying preview image updates.

Unreliability here is often due to either marginal power supply or camera cabling. The power must be both from a decent 5V supply and connected via a low resistance USB cable. Many USB cables have a significant resistance and can drop the voltage at the Raspberry. The camera cable should be re-seated at both ends and also it is worth pressing down on the little cable on board the camera module itself as that can sometimes be a bit loose.

hwissing
Posts: 10
Joined: Wed Jan 31, 2018 4:08 pm

Re: RPi Cam Web Interface

Sat Mar 03, 2018 1:23 pm

Thanks for the fast reply. Up to now I stuck to the information given on the elinux page. These restrictions are not explained there or I missed it. I just had 127 characters in mind, as also referenced in the settings page. All installation was made on Rasbian stretch.

But today a more severe problem occured. I enabled USB boot to use an old SSD instead of microSD A new system was installed, updated, upgraded and worked. When doing sudo apt-get dist-upgrade an update of the Linux kernel was offered and performed. Its now a 4.14.xx.
After that, installation of RPi Cam Web Interface failed. I tryed this an that, also an uninstall and reinstall without success. Latest error log shows:



03-Mär-2018-12-26 File does not exist!
03-Mär-2018-12-26 File /etc/apache2/apache2.conf does not exist!
03-Mär-2018-12-26 File /etc/apache2/ports.conf does not exist!
03-Mär-2018-12-26 File /etc/motion/motion.conf does not exist!
03-Mär-2018-12-29 File does not exist!
03-Mär-2018-12-29 File /etc/apache2/apache2.conf does not exist!
03-Mär-2018-12-29 File /etc/apache2/ports.conf does not exist!
03-Mär-2018-12-29 File /etc/motion/motion.conf does not exist!
03-Mär-2018-12-56 File does not exist!
03-Mär-2018-12-56 File /etc/apache2/apache2.conf does not exist!
03-Mär-2018-12-56 File /etc/apache2/ports.conf does not exist!
03-Mär-2018-12-56 File /etc/motion/motion.conf does not exist!
03-Mär-2018-12-59 File does not exist!
03-Mär-2018-12-59 File /etc/apache2/apache2.conf does not exist!
03-Mär-2018-12-59 File /etc/apache2/ports.conf does not exist!
03-Mär-2018-12-59 File /etc/motion/motion.conf does not exist!

Has anyone a similar problem?

Thanks
Heimo

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Sat Mar 03, 2018 2:10 pm

hwissing wrote:
Sat Mar 03, 2018 1:23 pm
Thanks for the fast reply. Up to now I stuck to the information given on the elinux page. These restrictions are not explained there or I missed it. I just had 127 characters in mind, as also referenced in the settings page. All installation was made on Rasbian stretch.

But today a more severe problem occured. I enabled USB boot to use an old SSD instead of microSD A new system was installed, updated, upgraded and worked. When doing sudo apt-get dist-upgrade an update of the Linux kernel was offered and performed. Its now a 4.14.xx.
After that, installation of RPi Cam Web Interface failed. I tryed this an that, also an uninstall and reinstall without success. Latest error log shows:

Has anyone a similar problem?

Thanks
Heimo
I haven't tried direct USB boot on my cameras but it sounds like something has gone drastically wrong with the install. Were there any errors during that? Also worth looking at install.txt in the installer folder to see what steps it did.

If you just want to exploit the space of the SSD you could also contemplate booting from microSD as normal and linking the SSD to the media folder

hwissing
Posts: 10
Joined: Wed Jan 31, 2018 4:08 pm

Re: RPi Cam Web Interface

Sat Mar 03, 2018 3:46 pm

Hello,

I've solved the problem by going back to the old system. I formatted the SSD and put a new Rasbian on it. I did all the update and upgrade procedures but remained on the old kernel 4.9.59 -V7+.
With the new kernel 4.14.22 after reboot display settings were changed. During installation of RPi Cam Web Interface the graphical help boxes were no displayed correctly. Some content could not be read. I always proceeded without change. PHP5 was referenced, whereas 7 is installed by default on stretch.
Anyway, now I have a working system again.

Heimo

ksdehoff
Posts: 8
Joined: Fri Apr 12, 2013 2:26 am

Re: RPi Cam Web Interface

Wed Mar 07, 2018 1:41 pm

I am trying to use the new Delay Frames on motion detection. I am using this to avoid the initial camera changes under night mode (the previously proposed FIFO commands didn't work for me). The problem I am having with Delay Frames - it doesn't appear to do anything and in the UI it gets reset to 0 regardless of what I set it to. I am wondering if there are other parameters that need to be set to get it to work correctly? Also is there a FIFO command to set this value or alternately should I put it a config file directly?

sarasaurus
Posts: 2
Joined: Mon Feb 26, 2018 7:03 pm

Re: RPi Cam Web Interface

Thu Mar 08, 2018 9:40 pm

btidey wrote:
Tue Nov 14, 2017 11:22 am
yassermohamed wrote:
Tue Nov 14, 2017 10:06 am
Every thing works fine with me but i can't play my recorded videos it shows me the file "Busy" i don't know what to do any help ??
When a video is recorded a raw h264 stream is captured from the camera. This is then normally converted to mp4 which can be viewed in the browser after the video is finished by a MP4Box process which is kicked off after each video finishes.

A busy status on those thumbnails indicates that it can't find a corresponding mp4 file. Normally it should show the file size.

This indicates that either the MP4Box process is not being started or something is going wrong with it.

Check first of all that it is configured to do the conversion. Under camera settings look for MP4 Boxing mode. This should be on 'background' (default). Off should only be used when h264 files are needed for some reason.

If it is set OK then check the media folder (e.g. ls -l /var/www/html/media) Does this have h264 files (as well as jpg thumbnails) and are they a decent filesize, e.g. several MB. If so this indicates the h264 recordings are being made but not being converted.

Check the log (under scheduler settings). This should show the MP4Box process being initiated and completed like

Code: Select all

{2017/11/14 11:21:51} Capturing started
{2017/11/14 11:21:55} Capturing stopped
{2017/11/14 11:21:55} Add /var/www/media/vi_0002_20171114_112151.mp4 to Box Queue at pos 0
{2017/11/14 11:21:56} Start boxing /var/www/media/vi_0002_20171114_112151.h264 to /var/www/media/vi_0002_20171114_112151.mp4 Queue pos 0
{2017/11/14 11:21:57} Finished boxing /var/www/media/vi_0002_20171114_112151.mp4 from Box Queue at pos 0
{2017/11/14 11:21:57} Removed item from Box Queue

I am also having this issue. The boxing process is shown as being initiated and completed, but videos still show as busy. What would be the next step to fix this?

RDPUser
Posts: 142
Joined: Tue Jan 30, 2018 12:18 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 1:26 pm

I really like PI Camera, because it can record and stream at the same time.
I've problems with video compression paramters.
https://www.raspberrypi.org/documentati ... /camera.md
Sets the intra refresh period (GoP) rate for the recorded video. H264 video uses a complete frame (I-frame) every intra refresh period, from which subsequent frames are based. This option specifies the number of frames between each I-frame. Larger numbers here will reduce the size of the resulting video, and smaller numbers make the stream less error-prone.

--qp, -qp Set quantisation parameter

Sets the initial quantisation parameter for the stream. Varies from approximately 10 to 40, and will greatly affect the quality of the recording. Higher values reduce quality and decrease file size. Combine this setting with a bitrate of 0 to set a completely variable bitrate.

--profile, -pf Specify H264 profile to use for encoding

Sets the H264 profile to be used for the encoding. Options are:

baseline
main
high
So how can I set the -qp parameter to make the video size much more dynamic better adopting the actual filmed scene?

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 2:32 pm

ksdehoff wrote:
Wed Mar 07, 2018 1:41 pm
I am trying to use the new Delay Frames on motion detection. I am using this to avoid the initial camera changes under night mode (the previously proposed FIFO commands didn't work for me). The problem I am having with Delay Frames - it doesn't appear to do anything and in the UI it gets reset to 0 regardless of what I set it to. I am wondering if there are other parameters that need to be set to get it to work correctly? Also is there a FIFO command to set this value or alternately should I put it a config file directly?
The command to set the delay is ms n where n is the number of frames. This is in the wiki and the scheduler web page reference.

One needs the default value in /etc/raspimjpeg for values to change properly so if you used a previous raspimjpec config without the motion_initframes value that would cause a problem.

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 2:41 pm

sarasaurus wrote:
Thu Mar 08, 2018 9:40 pm

If it is set OK then check the media folder (e.g. ls -l /var/www/html/media) Does this have h264 files (as well as jpg thumbnails) and are they a decent filesize, e.g. several MB. If so this indicates the h264 recordings are being made but not being converted.

Check the log (under scheduler settings). This should show the MP4Box process being initiated and completed like

Code: Select all

{2017/11/14 11:21:51} Capturing started
{2017/11/14 11:21:55} Capturing stopped
{2017/11/14 11:21:55} Add /var/www/media/vi_0002_20171114_112151.mp4 to Box Queue at pos 0
{2017/11/14 11:21:56} Start boxing /var/www/media/vi_0002_20171114_112151.h264 to /var/www/media/vi_0002_20171114_112151.mp4 Queue pos 0
{2017/11/14 11:21:57} Finished boxing /var/www/media/vi_0002_20171114_112151.mp4 from Box Queue at pos 0
{2017/11/14 11:21:57} Removed item from Box Queue
Although the Mp4Box may show as completed it is possible that it is failing for some reason. You need to check for the mp4 file in the media folder. The web page looks for this and show busy if its not there OR if its size is 0. These indicate that the Mp4Box is not running properly for some reason.

One way to debug is to turn boxing off so you get .h264 files and then manually run the Mp4Box process from a command line.

This should be MP4Box -fps 25 -add sourcefile.h264 output.mp4

Substitute the sourcefile with one of the .h264 files


I am also having this issue. The boxing process is shown as being initiated and completed, but videos still show as busy. What would be the next step to fix this?
[/quote]

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 2:41 pm

btidey wrote:
Fri Mar 09, 2018 2:41 pm
sarasaurus wrote:
Thu Mar 08, 2018 9:40 pm

If it is set OK then check the media folder (e.g. ls -l /var/www/html/media) Does this have h264 files (as well as jpg thumbnails) and are they a decent filesize, e.g. several MB. If so this indicates the h264 recordings are being made but not being converted.

Check the log (under scheduler settings). This should show the MP4Box process being initiated and completed like

Code: Select all

{2017/11/14 11:21:51} Capturing started
{2017/11/14 11:21:55} Capturing stopped
{2017/11/14 11:21:55} Add /var/www/media/vi_0002_20171114_112151.mp4 to Box Queue at pos 0
{2017/11/14 11:21:56} Start boxing /var/www/media/vi_0002_20171114_112151.h264 to /var/www/media/vi_0002_20171114_112151.mp4 Queue pos 0
{2017/11/14 11:21:57} Finished boxing /var/www/media/vi_0002_20171114_112151.mp4 from Box Queue at pos 0
{2017/11/14 11:21:57} Removed item from Box Queue


I am also having this issue. The boxing process is shown as being initiated and completed, but videos still show as busy. What would be the next step to fix this?
Although the Mp4Box may show as completed it is possible that it is failing for some reason. You need to check for the mp4 file in the media folder. The web page looks for this and show busy if its not there OR if its size is 0. These indicate that the Mp4Box is not running properly for some reason.

One way to debug is to turn boxing off so you get .h264 files and then manually run the Mp4Box process from a command line.

This should be MP4Box -fps 25 -add sourcefile.h264 output.mp4

Substitute the sourcefile with one of the .h264 files

[/quote]

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 2:49 pm

RDPUser wrote:
Fri Mar 09, 2018 1:26 pm
I really like PI Camera, because it can record and stream at the same time.
I've problems with video compression paramters.

So how can I set the -qp parameter to make the video size much more dynamic better adopting the actual filmed scene?
Currently raspimjpeg uses a fixed value for that parameter. I'll look at making it variable.

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 4:05 pm

btidey wrote:
Fri Mar 09, 2018 2:49 pm
RDPUser wrote:
Fri Mar 09, 2018 1:26 pm
I really like PI Camera, because it can record and stream at the same time.
I've problems with video compression paramters.

So how can I set the -qp parameter to make the video size much more dynamic better adopting the actual filmed scene?
Currently raspimjpeg uses a fixed value for that parameter. I'll look at making it variable.
Latest version has 2 new /etc/raspimjpeg settings initial_quant and encode_qp to control MMAL h264 encoding parameters

A pipe command qp allows setting minimise_frag, initial_quant and encode_qp

This is added to web camera settings to allow these to be changed

Wiki updated

RDPUser
Posts: 142
Joined: Tue Jan 30, 2018 12:18 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 4:16 pm

Wow man, youre extremly fast, thanks a lot!

Another problem with /dev/shm/mjpeg/user_annotate.txt
It takes out only 97 Charakters (there is one "\n" char in the string), Rest is not shown in the video. According to https://picamera.readthedocs.io/en/rele ... amera.html
annotate_text

Retrieves or sets a text annotation for all output.

When queried, the annotate_text property returns the current annotation (if no annotation has been set, this is simply a blank string).

When set, the property immediately applies the annotation to the preview (if it is running) and to any future captures or video recording. Strings longer than 255 characters, or strings containing non-ASCII characters will raise a PiCameraValueError. The default value is ''.

Changed in version 1.8: Text annotations can now be 255 characters long. The prior limit was 32 characters.
255 characters should be possible. Is there any setting to show more characters from the file?

RDPUser
Posts: 142
Joined: Tue Jan 30, 2018 12:18 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 5:46 pm

Beside the problem of the annotation length, see above, which encoding must be the file? I struggle with "°" char and German Umlaute like "äöü".

Code: Select all

cat /dev/shm/mjpeg/user_annotate.txt
shows them correct

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 5:50 pm

RDPUser wrote:
Fri Mar 09, 2018 4:16 pm
Wow man, youre extremly fast, thanks a lot!

Another problem with /dev/shm/mjpeg/user_annotate.txt
It takes out only 97 Charakters (there is one "\n" char in the string), Rest is not shown in the video. According to https://picamera.readthedocs.io/en/rele ... amera.html
annotate_text

Retrieves or sets a text annotation for all output.

When queried, the annotate_text property returns the current annotation (if no annotation has been set, this is simply a blank string).

When set, the property immediately applies the annotation to the preview (if it is running) and to any future captures or video recording. Strings longer than 255 characters, or strings containing non-ASCII characters will raise a PiCameraValueError. The default value is ''.

Changed in version 1.8: Text annotations can now be 255 characters long. The prior limit was 32 characters.
255 characters should be possible. Is there any setting to show more characters from the file?
In the latest version I did increase the limit for an individual parameter including the %a file to 150. It would be possible to increase a bit more. The issue was I don't want to get into complex checking of all the permutations of other things that can be added to the string that might exceed the overall 255 character limit imposed by the MMAL system.

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Fri Mar 09, 2018 5:51 pm

RDPUser wrote:
Fri Mar 09, 2018 5:46 pm
Beside the problem of the annotation length, see above, which encoding must be the file? I struggle with "°" char and German Umlaute like "äöü".

Code: Select all

cat /dev/shm/mjpeg/user_annotate.txt
shows them correct
That is a limitation of the MMAL implementation of adding annotation into the video frames. It only supports base ASCII

RDPUser
Posts: 142
Joined: Tue Jan 30, 2018 12:18 pm

Re: RPi Cam Web Interface

Sat Mar 10, 2018 7:44 pm

Thanks, youre the best.
I'd like to use RPi-Cam as Dashcam, so I've written a little python script, that writes out 10 times each seconds (or should, currently there is a gps problem, see here viewtopic.php?f=29&t=207396&p=1283088#p1283088 so that position is only written about 3 times each seconds) the current position. Sometimes both get a race condition, RPi-Cam is reading while the script is wrting out, leading to an empty annotation user string.
Then following error is shown (script continues running), or could also be when starting and stopping video.

Code: Select all

sh: 0: getcwd() failed: No such file or directory
You've an idea how to avoid?

Heres the code for the GPS/Dashcam usage, feel free to do withit what you want.

Code: Select all

#!/usr/bin/env python3

from time import sleep

import time
import gpsd #https://pypi.python.org/pypi/gpsd-py3/0.2.0

# Connect to the local gpsd
gpsd.connect()

updaterate = 10 #Anzahl der Updates pro Sekunde

# Get gps position

packet = gpsd.get_current()
gpsZeit = packet.time
# See the inline docs for GpsResponse for the available data

print("GPS-Einblendung läuft...")

while True:

    zeitstart=int(round(time.time() * 1000))
    packet = gpsd.get_current()
    gpsZeitZuvor=gpsZeit
    gpsZeit=packet.time

    if(not(gpsZeitZuvor == gpsZeit)): #nur wenn neue Daten vorliegen

        GPS = "UTC: " + gpsZeit + " Lat: " + ((str)(packet.lat)).ljust(12,'0')+ " Long: " + ((str)(packet.lon)).ljust(12,'0') + " Hoehe: " + (str)(packet.alt) + " \nGes. " \
              + ((str)(round(packet.hspeed,1))).rjust(5,'0') + " km/h Richtung: " + (str)(round(packet.track)).rjust(3,'0') + " Grad Climb: " \
              + (str)(round(packet.climb,1)) + " Sats: " + (str)(packet.sats_valid).rjust(2,'0')+ " / " + (str)(packet.sats).rjust(2,'0') + "\n"

        gpsTextDatei = open('/dev/shm/mjpeg/user_annotate.txt', 'w', encoding='iso-8859-1')
        gpsTextDatei.write(GPS)
        gpsTextDatei.close()

        #print(GPS) 

    zeitende=int(round(time.time() * 1000))
    sleepzeit=(1000/updaterate)-(zeitende-zeitstart)-1 #;Minus Konstante um Zeit zu geben
    #print(sleepzeit) #Genau die Zeit schlafen, sodass 100 ms pause sind
    time.sleep(sleepzeit / 1000.0)


#

RDPUser
Posts: 142
Joined: Tue Jan 30, 2018 12:18 pm

Re: RPi Cam Web Interface

Sat Mar 10, 2018 8:04 pm

In the latest version I did increase the limit for an individual parameter including the %a file to 150. It would be possible to increase a bit more. The issue was I don't want to get into complex checking of all the permutations of other things that can be added to the string that might exceed the overall 255 character limit imposed by the MMAL system.
Could you just truncate the string to 255 before passing it to MMAL? Then maximum can be used and no errors can occur. However now there are now enough chars for the dashcam, thanks a lot again.

I've noticed a strange behaviour. Swichting between default stream and MJPG works fine when no video is recorded (tested with Firefox on PC and Chrome on Android). Now when running MJPG Stream and Recording everything is fine. However if you're in default stream, start recording and then want to switch to MJPG Stream it always shows "Loading" and no video is show. Neither on PC-Firefox nor Android Chrome. Stopping Video and MJPEG-Stream comes back. Starting Video Recording then, and you can record and see MJPEG-Stream.
Any technical explanation? Its not very important for me, just good to now. So don't hurry if you like to fix it.

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Sun Mar 11, 2018 8:51 pm

RDPUser wrote:
Sat Mar 10, 2018 8:04 pm
In the latest version I did increase the limit for an individual parameter including the %a file to 150. It would be possible to increase a bit more. The issue was I don't want to get into complex checking of all the permutations of other things that can be added to the string that might exceed the overall 255 character limit imposed by the MMAL system.
Could you just truncate the string to 255 before passing it to MMAL? Then maximum can be used and no errors can occur. However now there are now enough chars for the dashcam, thanks a lot again.

I've noticed a strange behaviour. Swichting between default stream and MJPG works fine when no video is recorded (tested with Firefox on PC and Chrome on Android). Now when running MJPG Stream and Recording everything is fine. However if you're in default stream, start recording and then want to switch to MJPG Stream it always shows "Loading" and no video is show. Neither on PC-Firefox nor Android Chrome. Stopping Video and MJPEG-Stream comes back. Starting Video Recording then, and you can record and see MJPEG-Stream.
Any technical explanation? Its not very important for me, just good to now. So don't hurry if you like to fix it.
Yes. It is easy to handle the max length for annotation. The way it is coded means allocating the maximum length space for all parameters in the annotation template, so I was trying to avoid increasing it too much to avoid wasting memory unnecessarily. It is not a large amount in the grand scheme so I might increase it further, or I might recode it a bit differently to make it more efficient.

On the MJPEG default stream switch I can reproduce that. I haven't noticed it before as it is intended that this switch is just a set up thing and not really changed. Mjpeg is the preferred setting to lower network traffic a bit, but default is retained to work with some browsers where mjpeg streaming doesn't work. The setting is retained on a per browser basis, so individual clients can have different modes without disturbing the settings of other clients.

I am investigating why the switch from default to mjpeg doesn't work if recording is in progress.

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Sun Mar 11, 2018 9:09 pm

RDPUser wrote:
Sat Mar 10, 2018 7:44 pm
Thanks, youre the best.
I'd like to use RPi-Cam as Dashcam, so I've written a little python script, that writes out 10 times each seconds (or should, currently there is a gps problem, see here viewtopic.php?f=29&t=207396&p=1283088#p1283088 so that position is only written about 3 times each seconds) the current position. Sometimes both get a race condition, RPi-Cam is reading while the script is wrting out, leading to an empty annotation user string.
Then following error is shown (script continues running), or could also be when starting and stopping video.

Code: Select all

sh: 0: getcwd() failed: No such file or directory
You've an idea how to avoid?
One can probably minimise the risk of this occurring by writing to a tmp file first and then moving it to the final file name.

Currently, if the raspimjpeg fails to successfully open and read the contents of the user_annotate file then a null string is used. This would normally be fixed on the next frame call when it does successfully read the file providing the script is continuing to try and write the fail even if it has failed to do so.

When I next do an update then I could change the behaviour so that it repeats the last user_annotate if it fails to read the file, This would avoid any flashing to an empty string but would not solve any issue if the script stalls updating the file.

One easy way to check the script behaviour is just to cat the user_annotate.txt file and make sure its contents are still changing.

RDPUser
Posts: 142
Joined: Tue Jan 30, 2018 12:18 pm

Re: RPi Cam Web Interface

Sun Mar 11, 2018 9:35 pm

One can probably minimise the risk of this occurring by writing to a tmp file first and then moving it to the final file name.
Thanks, I'll try that. Plus the script needs an update, it just exits, if connection to GPS-Dongle gets lost at some point. I'll post the new code here for everyone who is interested in the dashcam solution.
When I next do an update then I could change the behaviour so that it repeats the last user_annotate if it fails to read the file, This would avoid any flashing to an empty string but would not solve any issue if the script stalls updating the file.
Thanks for the offer. However if it flashes user sees directly that the data is not present, otherwise user would not notice that GPS-Data is from the past. I'll try with the tmp file and report.

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Sun Mar 11, 2018 9:41 pm

btidey wrote:
Sun Mar 11, 2018 8:51 pm

On the MJPEG default stream switch I can reproduce that. I haven't noticed it before as it is intended that this switch is just a set up thing and not really changed. Mjpeg is the preferred setting to lower network traffic a bit, but default is retained to work with some browsers where mjpeg streaming doesn't work. The setting is retained on a per browser basis, so individual clients can have different modes without disturbing the settings of other clients.

I am investigating why the switch from default to mjpeg doesn't work if recording is in progress.
This is not to directly do with switching to mjpeg stream whilst recording. Rather it it is to do with the browser web page opening when in mjpeg stream mode whilst it is recording. So one can reproduce it by starting a recording, closing the web page and then re-opening the page. If it is in mjpeg stream mode then it doesn't kick off the stream until the recording is stopped.

Latest version should fix this by starting the stream no matter what the state. I haven't seen any side effects from this so far.

btidey
Posts: 1632
Joined: Sun Feb 17, 2013 6:51 pm

Re: RPi Cam Web Interface

Mon Mar 12, 2018 4:21 pm

RDPUser wrote:
Sat Mar 10, 2018 8:04 pm
In the latest version I did increase the limit for an individual parameter including the %a file to 150. It would be possible to increase a bit more. The issue was I don't want to get into complex checking of all the permutations of other things that can be added to the string that might exceed the overall 255 character limit imposed by the MMAL system.
Could you just truncate the string to 255 before passing it to MMAL? Then maximum can be used and no errors can occur. However now there are now enough chars for the dashcam, thanks a lot again.
I have now reworked the naming code so it should allow maximum lengths.

This also fixes a bug in the PIPE command processing. The bug should not affect users but did occasionally cause bad compiles.

RDPUser
Posts: 142
Joined: Tue Jan 30, 2018 12:18 pm

Re: RPi Cam Web Interface

Mon Mar 12, 2018 11:59 pm

Thank you very much for all your help.

I tried to work with tempfile as you said.

Code: Select all

#!/usr/bin/env python3

from time import sleep

import time
import tempfile
import shutil

i = 0

while True:

        i = i + 1
        tempDatei = tempfile.NamedTemporaryFile(mode='w',delete=False,encoding='iso-8859-1')
        tempDatei.write( str(i) )
        print(tempDatei.name)
        tempDatei.close()

        shutil.move(tempDatei.name,'/dev/shm/mjpeg/user_annotate.txt')
        time.sleep(1)    
This code kills user annotation. As soon as this script is started user annotation text disappears and even after stopping and putting something else inside it, it won't come back. You have to reboot PI to get it back to work. What am I doing wrong?

Return to “Camera board”