obsproject / obs-browser

CEF-based OBS Studio browser plugin
GNU General Public License v2.0
776 stars 220 forks source link

Video element has some issues loading and decoding video #316

Closed autotel closed 2 years ago

autotel commented 2 years ago

Operating System Info

Ubuntu 20.04

Other OS

Windows 10

OBS Studio Version

27.0.1

OBS Studio Version (Other)

No response

OBS Studio Log URL

https://obsproject.com/logs/X5CjMC4FEJQag265

OBS Studio Crash Log URL

No response

Expected Behavior

When adding an embedded video element in the browser, it plays normally like in a browser (firefox, chrome or chromium)

Current Behavior

For most video codecs I tried, video load is cancelled by the browser before it starts, or not loaded at all.

For mp4 in google-vp9 encoded video, it plays but without sound (the same player can play mp3 files successfully)

Steps to Reproduce

  1. get an mp4 video
  2. create an html file with the following content:

    
    <!DOCTYPE html>
    <html lang="en">
Document


3. add a video named "test-video.mp4" and place it on the same folder as the html file.
4. Create a browser source on obs pointing to this html file
5. Depending on the particular encoding of the video, it may play without sound or not play at all; while opening the same file on firefox or chrome would play the video correctly.
6. try mp4 encoded as h265 and google-vp9.

### Anything else we should know?

* If you find a way to get it working, I'd love to know! :) 
* Also tested on OBS on windows, and a remote computer whose hardware configuration I don't know for sure, the behavior is the same.
* I tried many other video formats (I didn't keep a list of which I tried) without success.
mihawk90 commented 2 years ago

This is an issue with CEF, not obs-browser.

CEF does not ship h.264 (or h.265) decoding, presumable due to patent/license issues.

MP3 patents expired so they can be shipped now, which is why it works.

The only way to get both Video and Audio properly is using free formats in a WebM container, e.g. VP9/Ogg Theora + Ogg Vorbis/Opus.

As for your MP4 test using VP9, you'd have to check which audio format was in use there (my guess is you were using AAC which has the same issue).

You can also add https://html5test.com in the browser source to see the same.

WizardCM commented 2 years ago

As mentioned above, it's by design on the CEF side. On our Windows and macOS builds, we do provide some proprietary codecs where we can, but not on Linux.

autotel commented 2 years ago

Thank you very much!

njutn95 commented 2 years ago

@WizardCM Do you not provide them on Linux due to licensing issues as well, or for some other reason? If it's a licensing issue, is there a way for us to embed the codecs in our custom obs-browser build?

WizardCM commented 2 years ago

@njutn95 Pretty much, yes. Unfortunately enabling them requires a full rebuild of CEF which takes ~3 hours or more, depending on the power of the machine building it.

mihawk90 commented 2 years ago

@WizardCM Do you not provide them on Linux due to licensing issues as well, or for some other reason?

As mentioned above it's not OBS that's not providing them, it is CEF.

If it's a licensing issue, is there a way for us to embed the codecs in our custom obs-browser build?

I am fairly certain that you can just drop in a libcef built with them enabled (provided it is the same version as used for when obs-browser was built), and it should work. That is a CEF-internal flag after all so the OBS side shouldn't matter.

njutn95 commented 2 years ago

Thanks for that! Any tips on how to do the above (in case you're doing a custom CEF build), or shall I ask/dig this elsewhere?

mihawk90 commented 2 years ago

Since you'd have to build CEF from scratch, the CEF Project Repo would probably be the best place to start, specifically the Branches and Building page.

Be warned though that building CEF from scratch can take some massive amounts of resources.

Edit: For some read up, here's an issue on the CEF tracker regarding this exact same issue (note that this issue is 6 years old so a lot has happened since then): https://bitbucket.org/chromiumembedded/cef/issues/1631/add-support-for-widevine-cdm Also some more reading

njutn95 commented 2 years ago

You're amazing, thanks a lot! I'll definitely check it out!

besweeet commented 2 years ago

Apologies for leaving a comment on this old post, but is Widevine DRM currently supported in the latest version of the plugin that's included with OBS Studio? A few websites are having issues with the browser source and it appears to be related to DRM.