Hello everyone,
I'm working on a project with my Raspberry Pi, and I've hit a snag when trying to record a video using the `picamera2` library. I would appreciate any help or guidance you can give me.
Description of the problem:
I am trying to record a video by specifying the encoder and output file destination. However, I have encountered several error messages when trying to use the `start_recording` method of the `picamera2` library. Below, I describe the steps I followed and the corresponding errors:
Errors Received:
Any help or suggestions would be greatly appreciated. Thanks in advance!.
I'm working on a project with my Raspberry Pi, and I've hit a snag when trying to record a video using the `picamera2` library. I would appreciate any help or guidance you can give me.
Description of the problem:
I am trying to record a video by specifying the encoder and output file destination. However, I have encountered several error messages when trying to use the `start_recording` method of the `picamera2` library. Below, I describe the steps I followed and the corresponding errors:
- 1. Initially, I received an error stating that a required positional argument called `output` was missing when calling `start_recording`.
2. After adjusting my code to include this argument, I ran into a new error saying that the `str` object does not have the `output` attribute, leading me to believe that there is a misunderstanding in how the encoder and the output to the method.
Code:
from picamera2 import Picamera2, Previewfrom picamera2.outputs import FileOutputimport timedef main(): picam2 = Picamera2() preview_config = picam2.create_preview_configuration() picam2.configure(preview_config) picam2.start_preview(Preview.QTGL) picam2.start() video_output = FileOutput("/home/pi/video.mp4") print("Starting video recording.") picam2.start_recording(output=video_output) time.sleep(5) # Recording duration in seconds picam2.stop_recording() print("Recording finished.") picam2.stop()if __name__ == '__main__': main()
- TypeError: Picamera2.start_recording() missing 1 required positional argument: 'output'`
After adjusting the code: `AttributeError: 'str' object has no attribute 'output'`
Any help or suggestions would be greatly appreciated. Thanks in advance!.
Statistics: Posted by Baladier — Tue Apr 09, 2024 12:15 am