Bird
0
0

Identify the error in this code snippet for recording video on Raspberry Pi:

medium📝 Debug Q14 of 15
Raspberry Pi - Camera Module
Identify the error in this code snippet for recording video on Raspberry Pi:
from picamera import PiCamera
import time
camera = PiCamera()
camera.start_recording('video.h264')
time.wait(3)
camera.stop_recording()
Astop_recording() should be called before start_recording()
BMissing camera initialization
CFile name must be .mp4 not .h264
DIncorrect method name 'time.wait' instead of 'time.sleep'
Step-by-Step Solution
Solution:
  1. Step 1: Check the time delay function

    The code uses time.wait(3), but the correct function to pause is time.sleep(3).
  2. Step 2: Confirm other parts are correct

    Camera is initialized, start and stop recording are in correct order, and .h264 is a valid format.
  3. Final Answer:

    Incorrect method name 'time.wait' instead of 'time.sleep' -> Option D
  4. Quick Check:

    Use sleep() to pause, not wait() [OK]
Quick Trick: Use time.sleep() to pause, not time.wait() [OK]
Common Mistakes:
MISTAKES
  • Using time.wait() instead of time.sleep()
  • Thinking .h264 is invalid file extension
  • Calling stop_recording() before start_recording()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes