obs-studio icon indicating copy to clipboard operation
obs-studio copied to clipboard

linux-pipewire: Support MJPEG and H264 devices

Open dimtpap opened this issue 1 year ago • 0 comments

Description

With https://github.com/obsproject/obs-studio/pull/9771, support was added for the Camera portal. However, code to support MJPEG and H264 devices didn't make it. This PR is basically the code that didn't land + some more to finish it up.

Similarly to the v4l2 plugin, it uses ffmpeg to decode the encoded streams.

TODO

  • I tried to integrate the encoded format with the existing supported formats code, but that code identifies each format by enum spa_video_format. For encoded formats there is only one value of that enum, SPA_VIDEO_FORMAT_ENCODED and the codec is distinguished using enum spa_media_subtype. As of writing the PR actually adds support for just MJPEG because only one EnumFormat is added. I'm unsure as to what is the best approach here. Tried something out here bit it's pretty ugly
  • From my understanding there is some incorrect code that compares different kinds of enums with each other (OBS enum video_format with SPA enum spa_video_format), ~~this caused the formats not to show up in the user selection~~, but I'm probably wrong since I'm assuming this code worked for as long as it's there? 1, 2. Unfortunately I only have an MJPEG webcam so I couldn't see if it broke other devices. Edit: Tested with a GStreamer pipeline exposing the camera's feed but converted to a raw format. After some more reading it seems this made YUYV422 the only format that resolution and FPS can be selected by the user because the enum values are the same. I don't know if this is intentional or not.

Motivation and Context

MJPEG and H264 devices exist

Fixes https://github.com/obsproject/obs-studio/issues/10180 Fixes https://github.com/obsproject/obs-studio/issues/10994

How Has This Been Tested?

Connected an MJPEG webcam, added the source, video was coming through.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist:

  • [x] My code has been run through clang-format.
  • [x] I have read the contributing document.
  • [x] My code is not on the master branch.
  • [x] The code has been tested.
  • [x] All commit messages are properly formatted and commits squashed where appropriate.
  • [x] I have included updates to all appropriate documentation.

dimtpap avatar Oct 08 '24 18:10 dimtpap