2

Well I guess the title sums it up pretty good. I know I can do annotations but they're just strings which can't be altered or am I wrong? Is it possible to always have the time in the video recording? I'm trying this with python if this is possible I would appreciate a little hint

Clarification: I want to overlay the current time of the day (year/month/day /hours/minutes/seconds) not the runtime of the video

  • Could you edit your question to clarify whether you'd like to overlay the current time of day, or the current run-time of the video? – goobering Sep 14 '16 at 13:32
2

The picamera documentation page includes a basic recipe for a timestamp overlay, which I've just tested, which puts a second-accurate timestamp (yyyy-MM-dd HH:mm:ss) at the top of the video.

import picamera
import datetime as dt

with picamera.PiCamera() as camera:
    camera.resolution = (1280, 720)
    camera.framerate = 24
    camera.start_preview()
    camera.annotate_background = picamera.Color('black')
    camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    camera.start_recording('timestamped.h264')
    start = dt.datetime.now()
    while (dt.datetime.now() - start).seconds < 30:
        camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        camera.wait_recording(0.2)
    camera.stop_recording()
  • In answer to @goobering The issue with this solution, is that each time you need to stop&start the camera, which can be problematic in the solutions where you use split_recording. For example when you create security camera, than you cannot use stop&start many time as that will cut the videos. – haykp Jan 13 '18 at 7:34
  • do you have any idea/solution to this issue? – con Jun 3 '18 at 19:06
  • In response to haykp, where do you see the camera starting and stopping? It is only starting once, and stopping once. It is waiting (see here) frequently, but this does not cause the recording to stop. wait_recording also accepts a splitter_port argument, to handle split recordings. – Lorenz Forvang Mar 5 at 6:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.