Only I frames are correctly encoded during H264 video recording

I am recording video using a raspberry Pi 2 and a camera module in a Python script using a package picamera. See the Minimum Example below:

import picamera
import time

with picamera.PiCamera(resolution=(730, 1296), framerate=49) as camera:
    camera.rotation=270
    camera.start_preview()
    time.sleep(0.5)
    camera.start_recording('test.h264')
    time.sleep(3)
    camera.stop_recording()
    camera.stop_preview()

results

The result is a badly encoded video:

  • first frame ok
  • in the next 59 frames, the scene is barely noticeable, almost all are green or purple (it is not clear what makes the change between the two colors)
  • frame number 61 is ok

Basically, only I-frames are correctly encoded. This was clarified by experimenting with various values ​​of the intra_periodfunction parameter start_recording.

Notes and Attempts Already Taken

, , Pi . , , , ...

:

  • resolution ,
  • , OpenCV, .
  • mjpeg
  • : sensor_mode=5

, , . : , .

+4

Source: https://habr.com/ru/post/1620534/


All Articles