B4x4
Posts: 2
Joined: Mon Jan 14, 2019 6:41 pm

Insert date and time in filname on camera.split_recording

Mon Jan 14, 2019 6:47 pm

Hello all. First question here.
How can I insert tame and date in the filname when i do a split_recording?
I have defined tid as time, and if i insert it as camera.start_recording('1.' + tid + '.h264') it works only for the first file.
As it is under, it does not work.


import picamera
import time

tid = time.strftime("%Y%m%d%H%M%S")

camera = picamera.PiCamera(resolution=(640, 480))
camera.start_recording('1.h264')
camera.wait_recording(5)
for i in range(2, 11):
camera.split_recording('%d.' + tid +'.h264' % i)
camera.wait_recording(5)
camera.stop_recording()

The one over gives error:
Traceback (most recent call last):
File "./recording.py", line 17, in <module>
camera.split_recording('%d.' + tid +'.h264' % i)
TypeError: not all arguments converted during string formatting
sys.excepthook is missing
lost sys.stderr

pcmanbob
Posts: 6655
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Insert date and time in filname on camera.split_recording

Mon Jan 14, 2019 8:11 pm

Hi.

You need to update the time/date for each recording, at the moment you have it only updating once at the start of the program.

You need to make it the first line after the for statement.

And please when posting code use code tags as python relies on indentation to work correctly.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported


Return to “Python”