Skip to content

Commit

Permalink
Update profile handling in codecs to latest version of PyAV
Browse files Browse the repository at this point in the history
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
  • Loading branch information
davidplowman committed Jan 8, 2025
1 parent acba763 commit e7c0daa
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions picamera2/encoders/libav_h264_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,17 @@ def _start(self):
if self.profile is not None:
if not isinstance(self.profile, str):
raise RuntimeError("Profile should be a string value")
# Much more helpful to compare profile names case insensitively!
available_profiles = {k.lower(): v for k, v in self._stream.codec.profiles.items()}
profile = self.profile.lower()
if profile not in available_profiles:
# Find the right profile name, ignoring case.
profile = None
for available_profile in self._stream.profiles:
if self.profile.lower() == available_profile.lower():
profile = available_profile
break
if not profile:
raise RuntimeError("Profile " + self.profile + " not recognised")
self._stream.codec_context.profile = available_profiles[profile]
self._stream.profile = profile
# The "ultrafast" preset always produces baseline, so:
if "baseline" not in profile:
if "baseline" not in profile.lower():
preset = "superfast"

if self.bitrate is not None:
Expand Down

0 comments on commit e7c0daa

Please sign in to comment.