Hi there! First-time Pi user here, I apologize if this is a very stupid issue.
I'm trying to use my Pi 5 (everything should be up to date) to record & save video using two IMX708 camera modules.
With the Picamera2 documentation (and admittedly a lot of help from ChatGPT), this is what I'm working with so far:
The code runs fine without any errors, but the output is very scuffed. All I get is a quick image, then the "video" (if you can even call it that) ends.
The .h264 files this creates (on 10s of video) are around 8MiB big, the corresponding .mp4 around 1MiB. At first, I thought the issue might be that VLC does not like .h264 files, which is why I'm converting to .mp4 in the first place. The conversion did not help.
What am I overlooking?
Any advice would be greatly appreciated.
All the best,
Diadormus
I'm trying to use my Pi 5 (everything should be up to date) to record & save video using two IMX708 camera modules.
With the Picamera2 documentation (and admittedly a lot of help from ChatGPT), this is what I'm working with so far:
Code:
import subprocessfrom picamera2 import Picamera2from picamera2.encoders import H264Encoder, Qualityimport timeoutput_file_a = 'video_camera_a.h264'output_file_b = 'video_camera_b.h264'output_file_a_mp4 = 'video_camera_a.mp4'output_file_b_mp4 = 'video_camera_b.mp4'picam2a = Picamera2(0)picam2b = Picamera2(1)try:video_config_a = picam2a.create_video_configuration()picam2a.configure(video_config_a)video_config_b = picam2b.create_video_configuration()picam2b.configure(video_config_b)encoder_a = H264Encoder()encoder_b = H264Encoder()picam2a.start_recording(encoder_a, output_file_a, quality=Quality.HIGH)picam2b.start_recording(encoder_b, output_file_b, quality=Quality.HIGH)duration = 10start_time = time.time()while time.time() - start_time < duration:time.sleep(1)picam2a.stop_recording()picam2b.stop_recording()subprocess.run(['ffmpeg', '-i', output_file_a, output_file_a_mp4])subprocess.run(['ffmpeg', '-i', output_file_b, output_file_b_mp4])print("Recording completed successfully!")except Exception as e:print(f"Error occurred: {e}")finally:picam2a.close()picam2b.close()
The .h264 files this creates (on 10s of video) are around 8MiB big, the corresponding .mp4 around 1MiB. At first, I thought the issue might be that VLC does not like .h264 files, which is why I'm converting to .mp4 in the first place. The conversion did not help.
What am I overlooking?
Any advice would be greatly appreciated.
All the best,
Diadormus
Statistics: Posted by diadormus — Mon Apr 22, 2024 7:18 pm — Replies 0 — Views 9