Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3552

Beginners • no video using RPI5 and Bookworm

$
0
0
I am using a new RPI5 and bookworm with a motion detector and a V2 camera attached. The following code has two alternative lines, each beginning with "os.system." When I hash out the second one, the first one successfully takes a photo and stores it when motion is detected.

When I hash out the first one, the second one seems to be taking a video; when I move my fingers in front of the camera, I can see them moving on my screen. However, the video is not saved. I should say that a file is saved with the appropriate name, but when played in VLC, I see my hand for only a tiny fraction of a second and then I see the VLC blank screen.
********************

Code:

import gpiodfrom gpiozero import MotionSensor, LEDimport time, os, datetimectr=0LED_PIN = 2MOTION_PIN = 17chip = gpiod.Chip('gpiochip4')led_line = chip.get_line(LED_PIN)motion_line = chip.get_line(MOTION_PIN)led_line.request(consumer="LED", type=gpiod.LINE_REQ_DIR_OUT)motion_line.request(consumer="Motion", type=gpiod.LINE_REQ_DIR_IN)print("Waiting for motion...")try:   while True:       motion_state = motion_line.get_value()       if motion_state == 1:           print("Motion detected")           ctr+=1           trial="trial"+str(ctr)           led_line.set_value(1)           os.system("rpicam-still -o "+trial+".jpg")           #os.system("rpicam-vid -t 5000 --width 640 --height 480 --framerate 20 -o "+trial+".h264")           print("Image",ctr,"captured")                   else:           led_line.set_value(0)finally:   led_line.release()motion_line.release()
******************

Here is what is on the screen after running the video option:

pi@Raspi8:~/aPyProg $ python3 pic_or_vid_if_motion.py
Waiting for motion...
Motion detected
[25:00:36.312829155] [129404] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[25:00:36.320794605] [129407] INFO RPI pisp.cpp:662 libpisp version v1.0.4 6e3a53d137f4 14-02-2024 (14:00:12)
[25:00:36.338582942] [129407] INFO RPI pisp.cpp:1121 Registered camera /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 to CFE device /dev/media1 and ISP device /dev/media2 using PiSP variant BCM2712_C0
Made X/EGL preview window
Mode selection for 640:480:12:P(20)
SGBRG10_CSI2P,640x480/58.924 - Score: 1000
SGBRG10_CSI2P,1296x972/43.247 - Score: 1287
SGBRG10_CSI2P,1920x1080/30.6185 - Score: 1636.67
SGBRG10_CSI2P,2592x1944/15.6335 - Score: 10586.9
Stream configuration adjusted
[25:00:36.697874051] [129404] INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-YUV420 (1) 640x480-GBRG16_PISP_COMP1
[25:00:36.697919291] [129407] INFO RPI pisp.cpp:1405 Sensor: /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected CFE format: 640x480-PC1g
[libx264 @ 0x5555f67a3520] using cpu capabilities: ARMv8 NEON
[libx264 @ 0x5555f67a3520] profile High, level 3.0, 4:2:0, 8-bit
Output #0, h264, to 'trial1.h264':
Stream #0:0: Video: h264, yuv420p(tv, smpte170m/smpte170m/bt709), 640x480, q=2-31, 20 fps, 20 tbr, 1000k tbn
Halting: reached timeout of 5000 milliseconds.
[libx264 @ 0x5555f67a3520] frame I:6 Avg QP:18.30 size: 25514
[libx264 @ 0x5555f67a3520] frame P:53 Avg QP:20.30 size: 14605
[libx264 @ 0x5555f67a3520] frame B:47 Avg QP:22.88 size: 6324
[libx264 @ 0x5555f67a3520] consecutive B-frames: 11.3% 88.7%
[libx264 @ 0x5555f67a3520] mb I I16..4: 17.0% 61.9% 21.1%
[libx264 @ 0x5555f67a3520] mb P I16..4: 15.2% 48.1% 5.9% P16..4: 24.8% 0.0% 0.0% 0.0% 0.0% skip: 6.0%
[libx264 @ 0x5555f67a3520] mb B I16..4: 7.1% 18.8% 0.8% B16..8: 23.9% 0.0% 0.0% direct:22.8% skip:26.7% L0:37.9% L1:44.7% BI:17.4%
[libx264 @ 0x5555f67a3520] 8x8 transform intra:68.9% inter:44.7%
[libx264 @ 0x5555f67a3520] coded y,uvDC,uvAC intra: 89.2% 68.8% 32.0% inter: 25.0% 39.3% 3.0%
[libx264 @ 0x5555f67a3520] i16 v,h,dc,p: 14% 13% 47% 26%
[libx264 @ 0x5555f67a3520] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 19% 30% 4% 8% 5% 9% 4% 10%
[libx264 @ 0x5555f67a3520] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 25% 18% 3% 8% 4% 8% 4% 8%
[libx264 @ 0x5555f67a3520] i8c dc,h,v,p: 39% 30% 18% 13%
[libx264 @ 0x5555f67a3520] kb/s:2118.19
Image 1 captured
*******************
Here is what is on the screen after running the photo option:

pi@Raspi8:~/aPyProg $ python3 pic_or_vid_if_motion.py
Waiting for motion...
Motion detected
[25:37:19.503751896] [133604] INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[25:37:19.511752206] [133607] INFO RPI pisp.cpp:662 libpisp version v1.0.4 6e3a53d137f4 14-02-2024 (14:00:12)
[25:37:19.535396981] [133607] INFO RPI pisp.cpp:1121 Registered camera /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 to CFE device /dev/media1 and ISP device /dev/media2 using PiSP variant BCM2712_C0
Made X/EGL preview window
Mode selection for 1296:972:12:P
SGBRG10_CSI2P,640x480/0 - Score: 3296
SGBRG10_CSI2P,1296x972/0 - Score: 1000
SGBRG10_CSI2P,1920x1080/0 - Score: 1349.67
SGBRG10_CSI2P,2592x1944/0 - Score: 1567
Stream configuration adjusted
[25:37:19.921302456] [133604] INFO Camera camera.cpp:1183 configuring streams: (0) 1296x972-YUV420 (1) 1296x972-GBRG16_PISP_COMP1
[25:37:19.921507997] [133607] INFO RPI pisp.cpp:1405 Sensor: /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected CFE format: 1296x972-PC1g
Mode selection for 2592:1944:12:P
SGBRG10_CSI2P,640x480/0 - Score: 7832
SGBRG10_CSI2P,1296x972/0 - Score: 5536
SGBRG10_CSI2P,1920x1080/0 - Score: 4238.67
SGBRG10_CSI2P,2592x1944/0 - Score: 1000
Stream configuration adjusted
[25:37:25.097128286] [133604] INFO Camera camera.cpp:1183 configuring streams: (0) 2592x1944-YUV420 (1) 2592x1944-GBRG16_PISP_COMP1
[25:37:25.102065995] [133607] INFO RPI pisp.cpp:1405 Sensor: /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 - Selected sensor format: 2592x1944-SGBRG10_1X10 - Selected CFE format: 2592x1944-PC1g
Still capture image received
Image 1 captured
****************

I have tried several options given online for taking and saving a video with RPI5 and Bookworm, but nothing has succeeded for me. Here's hoping someone out there can help me.

Statistics: Posted by emeyeraway — Thu Apr 11, 2024 11:29 pm



Viewing all articles
Browse latest Browse all 3552

Trending Articles