I am using a Raspberry Pi 3B and Camera Module 3 to capture wildlife. The H264 files created by my script are often missing huge chunks of footage.
My script is based on the capture_circular_stream.py example (a combination of mjpeg_server.py and capture_circular.py), but with a hardcoded capturing delay instead of being based on motion detection.
The encoder is set up like so:
The data is encoded manually:
The code to save the circular buffer is this:
I have confirmed that the time between circ.start() and circ.stop() is always 60 seconds.
How can I get consistent results?
Python console output:Also, this is probably an unrelated issue, but when I later create an MP4 from the H264 the framerate/playback speed is always slightly faster than real time (roughly +20%).
My script is based on the capture_circular_stream.py example (a combination of mjpeg_server.py and capture_circular.py), but with a hardcoded capturing delay instead of being based on motion detection.
The encoder is set up like so:
Code:
file_encoder = H264Encoder()file_encoder.framerate = 30file_encoder.size = config["lores"]["size"]file_encoder.format = config["lores"]["format"]file_encoder.bitrate = 5000000circ = CircularOutput(buffersize=30*60)file_encoder.output = circfile_encoder.start()
Code:
try: while True: request = picam2.capture_request() file_encoder.encode(lores_stream, request) request.release()finally: file_encoder.stop()
I would expect the resulting video to be two minutes long. Instead it is shorter, sometimes much shorter. For example, it might have the first 36 seconds from the circular buffer, but is missing the rest, including the moment when circ.start() is called. Other times it is missing only 20 seconds or so. The start of the video can also be a little bit longer ago than one minute, like 77 seconds before circ.start() was called for example.circ.start()
time.sleep(60)
circ.stop()
I have confirmed that the time between circ.start() and circ.stop() is always 60 seconds.
How can I get consistent results?
Python console output:
Code:
[57:22:54.300443257] [8433] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e[57:22:54.396359723] [8436] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise[57:22:54.402158595] [8436] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media3 and ISP device /dev/media0[57:22:54.402287188] [8436] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'[57:22:54.409744800] [8433] INFO Camera camera_manager.cpp:284 libcamera v0.1.0+118-563cd78e[57:22:54.495533929] [8439] WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise[57:22:54.501070303] [8439] INFO RPI vc4.cpp:444 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media3 and ISP device /dev/media0[57:22:54.501205614] [8439] INFO RPI pipeline_base.cpp:1142 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'[57:22:54.518723428] [8433] INFO Camera camera.cpp:1183 configuring streams: (0) 1920x1440-XBGR8888 (1) 1280x960-YUV420 (2) 2304x1296-SBGGR10_CSI2P[57:22:54.519588058] [8439] INFO RPI vc4.cpp:608 Sensor: /base/soc/i2c0mux/i2c@1/imx708@1a - Selected sensor format: 2304x1296-SBGGR10_1X10 - Selected unicam format: 2304x1296-pBAA/home/tem/Videos/camera-mjpeg-server/run.py:246: DeprecationWarning: setDaemon() is deprecated, set the daemon attribute instead t.setDaemon(True)
Statistics: Posted by tem — Tue Feb 27, 2024 4:11 pm — Replies 1 — Views 21