On 16/06/18 14:58, RobH wrote:
> On 16/06/18 13:59, Dennis Lee Bieber wrote:
>> On Sat, 16 Jun 2018 12:49:30 +0100, RobH declaimed
>> the
>> following:
>>
>>
>>> from os.path import join < I added this
>>>
>> Why? Was typing os.path.join too much effort?
>
> No it wasn't actually, as I said in another reply on here, I have been
> reading up on the shutil module, and I thought to try some of the
> examples I looked at.
>
>>
>>> src = ("RAMname")< and this
>>> dst = ("NASname")< this
>>
>> These lines do nothing useful since you never use the names src
>> and dst
>> later (except to replace the contents and again not use them)
>
> No I have removed them now
>>
>>
>>> while True:
>>> # Wait for motion being detected
>>> pir.wait_for_motion()
>>> triggerTime = time.time()
>>>
>>> #create base filename at time of motion trigger
>>> fname = time.strftime("%Y-%m-%d_%H.%M.%S.h264",
>>> time.localtime(triggerTime))
>>>
>>> RAMname = os.path.join("/run/shm", fname)
>>> NASname = os.path.join("/mnt/CCTV/PiZero" , fname)
>>>
>>> camera.start_preview()
>>>
>>> #capture video to RAM device first
>>> camera.start_recording(RAMname)
>>
>> I suggested trying NASname in that call, to directly capture to
>> the end
>> device rather than buffering in RAM first and then copying. If that
>> fails,
>> then the problem is not inherent to the script but is something wrong in
>> the environment. RAMname (and later the shutil copyfile) was proposed to
>> let the RPi capture to RAM without the overhead of network traffic (given
>> that the network interface of an RPi is via the USB system)
>>
>>> camera.wait_recording(10)
>>> camera.stop_recording()
>>> camera.stop_preview()
>>>
>>> #copy from RAM device to NAS device
>>> #shutil.copyfile(RAMname, NASname)
>>> src = join('/', RAMname) #new lines here < I added this
>>> dst = join('/', NASname) < and this
>>
>> Similarly, these do nothing useful since "src" and "dst" are never
>> referenced in the code... And what they are doing is just trying to add
>> another / to the front of the names generated earlier. But since / is the
>> path separator in Linux, and .join() puts the components together by
>> putting a path separator between them...
>
> Ok , I've removed them
>>
>> -=-=-=-=-
>>>>> import os.path
>>>>> import time
>>>>> fname = time.strftime("%Y-%m-%d_%H.%M.%S.h264", time.localtime())
>>>>> fname
>> '2018-06-16_08.45.24.h264'
>>>>> nname = os.path.join("/mnt/CCTV/PiZero", fname)
>>>>> nname
>> '/mnt/CCTV/PiZero/2018-06-16_08.45.24.h264'
>>>>> dst = os.path.join("/", nname)
>>>>> dst
>> '/mnt/CCTV/PiZero/2018-06-16_08.45.24.h264'
>>>>> dst == nname
>> True
>>>>>
>> -=-=-=-=-
>>
>> ... there is no effect
>>
>>>
>>>
>>> #delete file from RAM device
>>> os.unlink(RAMname) #os.remove() is same function
>>
>> I also asked you to comment that out... Since if the capture is
going
>> to NASname, there is no file in RAMname to be deleted
>
> Yes I did do that last night, but there was some sort of error. I can't
> recall it now as it was late.
>>
>>>
>>> #set up next check time
>>> time.sleep((triggerTime + 20.0) - time.time())
>>>
>>
>> While picking up that beginners book on Linux, pick up a book on
>> Python
>> also...
>>
>>
>
> I have now commented out what you asked me to and also:
>
> camera.start_recording(NASname)
>
> The script is running without errors, and producing video files of
> around 5 or 6MiB on the PiZero, but nothing of todays date on the NAS box.
> So the script is producing the files but not moving/copying them accross
> to the NAS box
No the script didn't run very long, as it produced this error which I
now recall from last night.
pi@raspberrypi:~/Downloads $ python intruder.py
Traceback (most recent call last):
File "intruder.py", line 36, in
camera.start_recording(NASname)
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line
1049, in start_recording
encoder.start(output, options.get('motion_output'))
File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line
812, in start
super(PiVideoEncoder, self).start(output)
File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line
375, in start
self._open_output(output)
File "/usr/lib/python2.7/dist-packages/picamera/encoders.py", line
331, in _open_output
self.outputs[key] = mo.open_stream(output)
File "/usr/lib/python2.7/dist-packages/picamera/mmalobj.py", line
344, in open_stream
stream = io.open(stream, 'wb' if output else 'rb', buffering)
IOError: [Errno 13] Permission denied:
'/mnt/CCTV/PiZero/2018-06-16_15.03.02.h264'
I have just checked all the mounted directories, and they are all owned
by pi:pi and have appropriate permissions.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|