Giter Site home page Giter Site logo

Add preview for .mov files about zulip HOT 1 OPEN

varkor avatar varkor commented on June 2, 2024
Add preview for .mov files

from zulip.

Comments (1)

timabbott avatar timabbott commented on June 2, 2024

Here's the Zulip code around this:

    def is_video(self, url: str) -> bool:                                                                                                                                                                          
        if not self.zmd.image_preview_enabled:                                                                                                                                                                     
            return False                                                                                                                                                                                           
                                                                                                                                                                                                                   
        url_type = mimetypes.guess_type(url)[0]                                                                                                                                                                    
        # Support only video formats (containers) that are supported cross-browser and cross-device. As per                                                                                                        
        # https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#index_of_media_container_formats_file_types                                                                                        
        # MP4 and WebM are the only formats that are widely supported.                                                                                                                                             
        supported_mimetypes = ["video/mp4", "video/webm"]                                                                                                                                                          
        return url_type in supported_mimetypes                                                                                                                                                                     

As detailed in https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Containers#index_of_media_container_formats_file_types, the .mov format isn't supported in some major browsers, like Firefox. (I haven't found a good resource on why Firefox doesn't support it, but I'm guessing it relates to Quicktime's history as a proprietary Apple technology).

There are other ways we could handle this -- re-encoding videos is a lot of CPU and not likely a great plan, but we could consider rendering the preview elements and just hiding them on browsers that don't support codecs like this... with the downside being that it'd just fail to work for Firefox users, without much hint to the person posting the message. It's worth some testing on what firefox does with a player element for an unsupported format.

Another direction would be to just communicate when you upload a .mov that we're not generating a preview because that format isn't widely supported by all browsers.

from zulip.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.