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

Camera board • Re: Problem Using `start_recording` with Picamera2 on Raspberry Pi

$
0
0
You should specify an encoding method to use, eg H264Encoder, and, as you have specified an mp4 output, you should also use FfmpegOutput to package the h264 file as an mp4.

Something like the following.

Code:

from picamera2 import Picamera2, Previewfrom picamera2.encoders import H264Encoderfrom picamera2.outputs import FfmpegOutputimport timedef main():     picam2 = Picamera2()     preview_config = picam2.create_preview_configuration()     picam2.configure(preview_config)     picam2.start_preview(Preview.QTGL)     encoder = H264Encoder(10000000)     picam2.start()         video_output = FfmpegOutput("/home/pi/video.mp4")     print("Starting video recording.")     picam2.start_recording(encoder,output=video_output)     time.sleep(5) # Recording duration in seconds     picam2.stop_recording()     print("Recording finished.")     picam2.stop()if __name__ == '__main__':     main()     
Thank you for your answer

Statistics: Posted by Baladier — Wed Apr 10, 2024 3:59 am



Viewing all articles
Browse latest Browse all 4832

Trending Articles