mbin icon indicating copy to clipboard operation
mbin copied to clipboard

Media preview attempting to load unsupported video format

Open ghost opened this issue 1 year ago • 3 comments

Describe the bug The thread media preview button (or auto media preview) is attempting to load a video that is unsupported causing the browser to prompt the user to download a file "master.m3u8"

On which Mbin instance did you find the bug? https://kbin.run/

To Reproduce Go to https://kbin.run/m/[email protected]/t/243728/Gen-Z-is-recording-themselves-getting-fired-in-growing-TikTok and click the media preview button (or have auto media preview enabled when viewing the thread).

Expected behavior Do not preview unsupported media formats

Screenshots

Enable:

image

or click

image

Results in:

image

Desktop (please complete the following information):

  • OS: Linux
  • Browser Firefox
  • Version 122.0.1

Additional context Impacts all Mbin instances

ghost avatar Feb 12 '24 20:02 ghost

Oopy indeed. It just download the file directly..

melroy89 avatar Feb 12 '24 21:02 melroy89

related kbin issue: https://codeberg.org/Kbin/kbin-core/issues/446

links to test with from OP and that bug are:

https://www.cbsnews.com/news/tiktok-videos-people-getting-fired-gen-z-trend/
https://www.cbsnews.com/news/missing-submarine-titanic-debris-field-oceangate-us-coast-guard/

I tried to track this down a while back and thought perhaps something like https://github.com/MbinOrg/mbin/blob/7d8c68ca854ef20f3f49807ed64d5d842684f0fb/src/Utils/Embed.php#L154-L157 was the cause being a bit too general with video detection but nothing I tried seemed to make a difference, so someone else might have a better idea

e-five256 avatar Feb 12 '24 21:02 e-five256

there seems to be a couple things going on here (also a bit of my own observation/thought nuggets):

  • the downloaded .m3u8 is for hls streaming, and from my experience you'll need something like hls.js or other supporting libraries/players in order to do hls playback on the browser. you can't just chuck this into a browser and expect it to start playing the video

  • the embed preview generator we have is essentially a wrapper around embed/embed library, and it looks like for this given url, this is what the library extracted for the html preview:

    # quick embed fetch test
    mbin % php psysh
    Psy Shell v0.12.0 (PHP 8.2.14 — cli) by Justin Hileman
    > use Embed\Embed;
    > $ef = new Embed()
    = Embed\Embed {#5245}
    
    > $e = $ef->get('https://www.cbsnews.com/news/tiktok-videos-people-getting-fired-gen-z-trend/')
    = Embed\Extractor {#5290}
    
    > $e->code->html
    = "<iframe src="https://prod.vodvideo.cbsnews.com/cbsnews/vr/hls/2024/01/31/2305225795952/2643805_hls/master.m3u8" frameborder="0" width="640" height="360" allowTransparency="true"></iframe>"
    
    <iframe src="https://prod.vodvideo.cbsnews.com/cbsnews/vr/hls/2024/01/31/2305225795952/2643805_hls/master.m3u8" frameborder="0" width="640" height="360" allowTransparency="true"></iframe>
    

    so I guess this is what cause the m3u8 to download when preview is being shown

  • looks like this currently affects cbsnews.com domain in particular, perhaps it's possible to hardcode it to make it return an empty preview, some dummy preview that return the description, or make it a playable video preview, using hls.js or whatever

asdfzdfj avatar Feb 13 '24 11:02 asdfzdfj