You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to set profile="high" for H264Encoder causes the following:
Traceback (most recent call last):
File "/home/pi/test.py", line 24, in <module>
picam2.start_encoder(encoder, output, quality=Quality.HIGH)
File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 1712, in start_encoder
_encoder.start(quality=quality)
File "/usr/lib/python3/dist-packages/picamera2/encoders/encoder.py", line 231, in start
self._start()
File "/usr/lib/python3/dist-packages/picamera2/encoders/h264_encoder.py", line 87, in _start
super()._start()
File "/usr/lib/python3/dist-packages/picamera2/encoders/v4l2_encoder.py", line 111, in _start
fcntl.ioctl(self.vd, VIDIOC_S_EXT_CTRLS, ext)
OSError: [Errno 22] Invalid argument
baseline and main work properly, only high causes the exception.
Hi, thanks for reporting this. Yes, it does indeed seem to be broken.
The problem is that the value of V4L2_MPEG_VIDEO_H264_PROFILE_HIGH is incorrect in the python-v4l2 package. I'll make up a PR and ask the repository owner to merge the fix. Then we'll have to make up an updated package, so it may all take a few days.
If you want a fix in the meantime, I might check out git clone https://github.com/RaspberryPiFoundation/python-v4l2 and then add the folder where you put it to your PYTHONPATH environment variable. Then, look in the file v4l2.py in there, and find V4L2_MPEG_VIDEO_H264_PROFILE_HIGH. Just above that add the following new line:
V4L2_MPEG_VIDEO_H264_PROFILE_EXTENDED,
Also change the range(4) below it to range(5). Then things should work.
@davidplowman Thanks for the workaround, one semi-related question: I was not able to find anything about the "default" profile when not specifying the profile parameter. What does it default to?
High! So it looks like leaving it out altogether would also be a workaround. Obviously would be worth checking in practice. Oh well.
The patch has also been merged now, so just waiting for a new apt package to be made up. (You could install it with pip too, but mixing pip and apt packages often seems to lead me to a dark place.)
Trying to set profile="high" for H264Encoder causes the following:
baseline
andmain
work properly, onlyhigh
causes the exception.Example code :
Using Pi4 with HQ camera, Python 3.11.2, picamera2 0.3.19, libcamera v0.3.0+65-6ddd79b5, Linux 6.6.31+rpt-rpi-v8
The text was updated successfully, but these errors were encountered: