I’m currently running through the example “mjpeg.py”.
I was able to save a 15 or so second mjpeg file and replay it in VLC (after resetting my camera).
If I try to run some modified code (below) so that I can save TWO videos … only the second video frames are “saved”.
Is there a way to have the camera save several short videos in a row without resetting?
I see the example “mjpeg_on_movement.py” seems to change the file names every time the program runs/ detects motion …
What am I missing in my code?
Do I need a ‘temp’ directory?
# MJPEG Video Recording Example
#
# Note: You will need an SD card to run this demo.
#
# You can use your OpenMV Cam to record mjpeg files. You can either feed the
# recorder object JPEG frames or RGB565/Grayscale frames. Once you've finished
# recording a Mjpeg file you can use VLC to play it. If you are on Ubuntu then
# the built-in video player will work too.
import sensor, image, time, mjpeg, pyb
RED_LED_PIN = 1
BLUE_LED_PIN = 3
sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QVGA) # or sensor.QQVGA (or others)
sensor.skip_frames(time = 2000) # Let new settings take affect.
clock = time.clock() # Tracks FPS.
pyb.LED(RED_LED_PIN).on()
sensor.skip_frames(time = 2000) # Give the user time to get ready.
pyb.LED(RED_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()
m = mjpeg.Mjpeg("example.mjpeg")
print("You're on camera!")
for i in range(200):
clock.tick()
m.add_frame(sensor.snapshot())
print(clock.fps())
pyb.LED(BLUE_LED_PIN).off()
pyb.LED(BLUE_LED_PIN).on()
m = mjpeg.Mjpeg("example2.mjpeg")
print("You're on camera!")
for i in range(200):
clock.tick()
m.add_frame(sensor.snapshot())
print(clock.fps())
m.close(clock.fps())
pyb.LED(BLUE_LED_PIN).off()
print("Done! Reset the camera to see the saved recording.")