Python Forum
Split recording with Picamera
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Split recording with Picamera
#1
Looking to achieve two things with a raspberry pi and pi cam but can't work out the best way to approach it.

I have the camera working using the record. sequence code from the pi website. I would like to spilt recording into a new file on a keypress.

I would also like to add a text annotation based on a different keypress. I currently have annotation showing current time which works I want a separate counter annotation showing the count from the keypress.

Sorry feel like both should be simple and asked before but can't seem to find the answers.

Thanks in advance

[Edit to add a bit more context] - I am trying to record a video split into separate files with each video a set length. say 2 mins, This bit I understand. I want to have a counter displayed on the screen which increments with a key press (probably spacebar). I also want to display current time. I can put both bits of information using annotate.text but would rather have 2 distinct boxes.
import picamera
import datetime as dt
import functools
import operator 
##initialise camera
print('running')

def convertTuple(tup):
    str = functools.reduce(operator.add, (tup))
    return str

with picamera.PiCamera() as camera:
    camera.resolution = (1280, 720)
    camera.framerate = 24
    camera.start_preview(fullscreen=False, window = (100, 20, 640, 480))
    camera.annotate_background = picamera.Color('black')
    text = ('finish',dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
    text = convertTuple(text)
    camera.annotate_text = text
    start = dt.datetime.now()
    sheetcount = 0

    while (dt.datetime.now() - start).seconds < 30:
        for filename in camera.record_sequence(
                '%d.h264' % i for i in range(1, 11)):
            currentfile = dt.datetime.now()
            sheetcount +=1
            while (dt.datetime.now() - currentfile).seconds < 10:
                text = ('Finish Sheet ',str(sheetcount),' ',dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
                text = convertTuple(text)
                camera.annotate_text = text
                camera.wait_recording(0.2)
 

    camera.stop_recording()
    print('stopped')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Video recording with Raspberry Pi - What´s wrong with my python code? Montezuma1502 3 1,264 Feb-24-2023, 06:14 PM
Last Post: deanhystad
  PiCamera - print exceptions? korenron 2 836 Dec-15-2022, 10:48 PM
Last Post: Larz60+
Smile How we can prevent screen recording murad_ali 3 1,839 Jul-29-2022, 10:29 AM
Last Post: DeaD_EyE
  How to decrease latency while recording streaming video. unicorn2019 0 1,261 Nov-15-2021, 02:12 PM
Last Post: unicorn2019
  Help with storing temp data for each day then recording min/max in app. trthskr4 3 2,415 Sep-10-2021, 10:51 PM
Last Post: trthskr4
  Using pyaudio to stop recording under certain sound threshold Twanski94 2 6,467 Jun-13-2020, 11:35 AM
Last Post: Twanski94
  recording a translation table into a file arbiel 0 1,450 Mar-31-2020, 02:33 PM
Last Post: arbiel
  Recording audio to file until no dialogue. diffLocks16 1 2,329 Aug-14-2019, 04:37 PM
Last Post: Larz60+
  picamera not working on premade script georgeaura 1 2,530 Jul-24-2019, 10:11 AM
Last Post: gontajones
  Computationally efficient recording + searching? IAMK 1 2,356 Apr-30-2018, 01:23 AM
Last Post: IAMK

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020