Skip to content

enumerate_input_devices doesn't work #2264

Closed

Description

@kazuki

I installed PyAV from a PyPI binary wheel on both Windows and Linux (Ubuntu).

In windows 11

> python
Python 3.13.13 (tags/v3.13.13:01104ce, Apr  7 2026, 19:25:48) [MSC v.1944 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import av
>>> av.__version__
'17.0.1'
>>> av.enumerate_input_devices('dshow')
Traceback (most recent call last):
  File "<python-input-2>", line 1, in <module>
    av.enumerate_input_devices('dshow')
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "av/device.py", line 153, in av.device.enumerate_input_devices
    return _build_device_list(device_list)
    ^^^
  File "av/device.py", line 58, in av.device._build_device_list
    media_types.append(s.decode())

AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

In Ubuntu 24.04

$ python
Python 3.12.3 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import av
>>> av.__version__
'17.0.1'
>>> av.enumerate_input_devices('v4l2')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "av/device.py", line 153, in av.device.enumerate_input_devices
  File "av/device.py", line 62, in av.device._build_device_list
AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

s is is already str type. .decode is not necessary.
https://github.com/PyAV-Org/PyAV/blob/v17.0.1/av/device.py#L58

53 |        media_types: list = []
54 |         for j in range(device_info.nb_media_types):
55 |             mt = device_info.media_types[j]
56 |             s = lib.av_get_media_type_string(mt)
57 |             if s:
58 |                 media_types.append(s.decode())    <= AttributeError

Activity

  1. added a commit that references this issue on May 31, 2026
    2474f35
  2. added a commit that references this issue on Jun 7, 2026
    9d15953
  3. added a commit that references this issue on Jun 7, 2026
    1940fd4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions