Skip to content

Commit b799330

Browse files
committed
Update profile handling in codecs to latest version of PyAV
Signed-off-by: David Plowman <[email protected]>
1 parent acba763 commit b799330

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

picamera2/encoders/libav_h264_encoder.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,17 @@ def _start(self):
8181
if self.profile is not None:
8282
if not isinstance(self.profile, str):
8383
raise RuntimeError("Profile should be a string value")
84-
# Much more helpful to compare profile names case insensitively!
85-
available_profiles = {k.lower(): v for k, v in self._stream.codec.profiles.items()}
86-
profile = self.profile.lower()
87-
if profile not in available_profiles:
84+
# Find the right profile name, ignoring case.
85+
profile = None
86+
for available_profile in self._stream.profiles:
87+
if self.profile.lower() == available_profile.lower():
88+
profile = available_profile
89+
break
90+
if not profile:
8891
raise RuntimeError("Profile " + self.profile + " not recognised")
89-
self._stream.codec_context.profile = available_profiles[profile]
92+
self._stream.profile = profile
9093
# The "ultrafast" preset always produces baseline, so:
91-
if "baseline" not in profile:
94+
if "baseline" not in profile.lower():
9295
preset = "superfast"
9396

9497
if self.bitrate is not None:

0 commit comments

Comments
 (0)