Consider this Python code snippet using the picamera library to record a video for 5 seconds. What will be the output?
import time from picamera import PiCamera camera = PiCamera() camera.start_recording('test_video.h264') time.sleep(5) camera.stop_recording() print('Recording complete')
Think about what the print statement does after recording stops.
The code records a video for 5 seconds and then prints 'Recording complete'. No errors occur if the camera is connected properly.
In the picamera library, which parameter sets the resolution of the recorded video?
Resolution means width and height of the video.
The camera.resolution property sets the width and height of the video frames.
Look at this code snippet. It raises an error when run. What is the cause?
from picamera import PiCamera import time camera = PiCamera() camera.start_recording('video.h264') camera.wait_recording(5) camera.stop_recording() print('Done')
Check the official PiCamera documentation for method names.
The method wait_recording does not exist in PiCamera. The correct method to pause recording is time.sleep().
Choose the code snippet that correctly records a 10-second video using PiCamera.
Remember to use time.sleep() to pause the program.
Option B uses the correct method start_recording, then pauses with time.sleep(10), and stops recording properly.
You want to record a video and save it directly as an MP4 file using the Raspberry Pi camera. Which approach is correct?
Think about the default video format PiCamera records and how to convert it.
PiCamera records video in H264 format. To get MP4, you must convert the file using tools like ffmpeg after recording.
