Skip to content

Commit edb89d1

Browse files
naushirdavidplowman
authored andcommitted
encoders: Fix for typo in videodev2 import
This typo was missed by the tests as the __init__ function for the encoder module was also incorrect. Use the get_platform() function to correctly retrieve the running platform. Signed-off-by: Naushir Patuck <[email protected]>
1 parent 471d497 commit edb89d1

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

picamera2/encoders/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@
22

33
import videodev2
44

5+
from picamera2.platform import Platform, get_platform
6+
57
from .encoder import Encoder, Quality
68
from .jpeg_encoder import JpegEncoder
79
from .libav_h264_encoder import LibavH264Encoder
810
from .libav_mjpeg_encoder import LibavMjpegEncoder
911
from .multi_encoder import MultiEncoder
1012

11-
_hw_encoder_available = False
12-
try:
13-
with open('/dev/video11', 'rb', buffering=0) as fd:
14-
caps = videodev2.v4l2_capability()
15-
fcntl.ioctl(fd, videodev2.VIDIOC_QUERYCAP, caps)
16-
_hw_encoder_available = (caps.card.decode('utf-8') == "bcm2835-codec-encode")
17-
except Exception:
18-
pass
13+
_hw_encoder_available = get_platform() == Platform.VC4
1914

2015
if _hw_encoder_available:
2116
from .h264_encoder import H264Encoder

picamera2/encoders/v4l2_encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import select
88
import threading
99

10-
from vidoedev2 import *
10+
from videodev2 import *
1111

1212
from picamera2.encoders.encoder import Encoder
1313

tests/test_list.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ tests/display_transform_null.py
7474
tests/display_transform_qt.py
7575
tests/easy_video2.py
7676
tests/egl_leak.py
77+
tests/encoder_import.py
7778
tests/encoder_start_stop.py
7879
tests/ffmpeg_abort.py
7980
tests/grey_world.py

0 commit comments

Comments
 (0)