How to play html5 video? When the file is file.m4v?

后端 未结 4 1910
走了就别回头了
走了就别回头了 2021-02-08 19:06

I have tried several methods but none is playing the file2.m4v using html5 see screen shot.

But if i use that same file using VLC/Mplayer it play the film nicely (no pr

相关标签:
4条回答
  • 2021-02-08 19:17

    HTML5 is a web standard (in other words, a specification), not a technology, so the phrase "html5 cant play it" implies a bit of misunderstanding on your part. The file is decoded by the browser according to the settings you specify in the <video> tag. It is worth noting that not every browser and/or operating system has the same codecs available, so first verify that you can play the video natively.

    Firefox, for one, cannot decode anything encoded with the H.264 codec, which I believe is used in .m4v files (anyone who knows better, please correct me).

    Lastly, as someone else pointed out, your path is likely wrong. Remove the 'var' and 'www' portions of the path.

    0 讨论(0)
  • 2021-02-08 19:20

    Try:

    <video id="myVideo" width="300" height="200" preload="auto" src="/var/www/html/video/file2.m4v" type="video/mp4" autoplay controls></video>
    

    Also try renaming the file to file2.mp4

    0 讨论(0)
  • 2021-02-08 19:20

    Your html is correct, so either the path is incorrect, the file is invalid, or the browser doesn't support m4v.

    1. /var/www/ is highly suspicious, but as you say it works with a avi file, so that is not it

    2. Try using the file: http://ade.apple.com/movies/institute2011/hotel.m4v in the src. If it is playing, then your m4v is probably not correctly encoded.

    3. If you are using Firefox or Opera then the movie will never play, as they don't support anything other than WebM and OGG

    0 讨论(0)
  • 2021-02-08 19:41

    HTML5 Video is just a convention to play a certain video formats with a new element for which browsers will implement an own player. HTML5 won’t provide players or something like that.

    You have to look for the codecs and contained supported by most browsers, which, if I remember well, are mostly Theora for Video and Vorbis for audio, in an OGG container.

    Then I remember that Webkit browsers will support Matroska (MKV) containers using V8 as video codec and Vorbis for audio.

    My recommendation: provide an OGG file with Theora and Vorbis as video and audio codecs respectively. Inside provide a fallback using an MKV file with V8 and Vorbis and then, if you can, inside an MPG video file using Mpeg2 and MP2 (couldn’t think on something better) as video and audio codecs, fallback. Then as the last fallback, a Flash player playing a FLV video file.

    Example for how your HTML should look like:

    <video src="thevideo.ogg">
        <video src="firstFallback.mkv">
            <object type="video/mpeg" src="secondFallback.mpeg">
                <object
                    type="application/x-shockwave-flash"
                    src="player.swf?etc...">
                    <p>Download <a href="videourl">the video etc...</a><br />
                    or use a more modern browser to watch online, etc...</p>
                </object>
            </object>
        </video>
    </video>
    

    Etc... ;-)

    With this configuration, most (if not all) browsers should be able to play your video, preferring the most supported (and most modern) format. “Fallbacking” until they find a Flash Player.

    For hints on what formats to support: take a look at the HTML5 Video part in Wikipedia.

    Important: In your code you are refering to an absolute filesystem path, which is totally not-accesible for a web visitor. Maybe in the src you meant /video/file2.m4v.

    0 讨论(0)
提交回复
热议问题