javascript 如何将 m4v 视频文件嵌入到我的 html 网页中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17045961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 06:53:47  来源:igfitidea点击:

How to embed an m4v video file to my html webpage?

javascriptjquery-mobilevideo-streamingjwplayerm4v

提问by NJInamdar

I am currently trying to embed the m4v videos in my html webpage. using the following code

我目前正在尝试将 m4v 视频嵌入到我的 html 网页中。使用以下代码

<video controls="" height="360" width="480">
<source src="path/to/my/m4v/video" type="video/mp4"> 
<source     src="path/to/my/m4v/video" type="video/ogg"> 
</source></source></video>

its working perfectly in google chrome.and it demands for an ogv video for mozillabrowser.as we cant get an ogv video from our client.Also I am using it in hero framework. I also tried to use the iframe tag used by youtube embed code.that works with webkit browser(google chrome). but not able to play in mozilla firefox browser.I need to play m4v video in cross browsers.Is there any way or any html tag I am missing here?I explored alot but couldn't find an efficient solution.

它在 . 中完美运行,google chrome并且需要ogv video for mozilla浏览器。因为我们无法从客户端获取 ogv 视频。此外,我在英雄框架中使用它。我还尝试使用iframe tag used by youtube embed code.与 webkit 浏览器(谷歌浏览器)配合使用的。但无法在 mozilla firefox 浏览器中播放。我需要在跨浏览器中播放 m4v 视频。有什么方法或我在这里缺少任何 html 标签吗?我探索了很多,但找不到有效的解决方案。

采纳答案by NJInamdar

  • If you're not forced to use Quicktime, the Flash based JW PlayerNOT free
  • can do Quicktime encoded MV4 if the client has Flash 10 installed.

  • Hence tried using the JWPlayerfrom the official site of jwplayer.

  • Will have to purchase it to get a licence key.
  • Enables to play .m4vvideo on cross browsers.
  • Works perfectly.
  • 如果您不是被迫使用 Quicktime,基于 Flash 的JW Player不是免费的
  • 如果客户端安装了 Flash 10,则可以执行 Quicktime 编码的 MV4。

  • 因此尝试使用jwplayer官方网站上的JWPlayer

  • 必须购买它才能获得许可证密钥。
  • 允许在跨浏览器上播放.m4v视频。
  • 完美运行。

回答by veeru

m4v format files are not supporting by browsers, these format need player support. these files directly cannot run in browser. like chrome, firefox, ie...etc.

浏览器不支持 m4v 格式的文件,这些格式需要播放器支持。这些文件不能直接在浏览器中运行。像铬,火狐,即...等。

Because these file format belongs to iOS operating system, developed by apple. Read the instructions given by below link Wikipedia. http://en.wikipedia.org/wiki/M4V

因为这些文件格式属于苹果开发的iOS操作系统。阅读以下链接维基百科给出的说明。 http://en.wikipedia.org/wiki/M4V

M4V - Video Supporting Features these are the possibilities to

M4V - 视频支持功能这些是

  1. upload m4v files in the you tube that link we can use.
  2. need to convert in to mp4 format all files and use in server.
  3. need to write any script that converts the m4v files to mp4 fomat from server side.
  4. need any builder that directly converts that m4v to mp4 formats files but it may be payable it.
  1. 在 You Tube 中上传我们可以使用的链接的 m4v 文件。
  2. 需要将所有文件转换为 mp4 格式并在服务器中使用。
  3. 需要编写从服务器端将 m4v 文件转换为 mp4 格式的任何脚本。
  4. 需要任何直接将该 m4v 转换为 mp4 格式文件的构建器,但可能需要付费。

回答by Xaviju

You will probably need some external plugin or servcice support for your codec (m4v) since is not supported by all the browsers out there.

您的编解码器 (m4v) 可能需要一些外部插件或服务支持,因为并非所有浏览器都支持。

For a list of supported cross-browser video and audio formats I suggest you to check this documentation by MDN

有关支持的跨浏览器视频和音频格式的列表,我建议您查看 MDN 的此文档

Media formats supported by the HTML audio and video elements

HTML 音频和视频元素支持的媒体格式

In just a few Words, the formats you need to be 99% bross-browser are:

简而言之您需要成为 99% 浏览器的格式是

  • H.264 and AAC in MP4
  • Theora and Vorbis in Ogg
  • VP8 and Vorbis in WebM
  • MP4 中的 H.264 和 AAC
  • 奥格中的 Theora 和 Vorbis
  • WebM 中的 VP8 和 Vorbis

回答by Ankit Aranya

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.

HTML5 Video 只是一种使用新元素播放特定视频格式的约定,浏览器将为其实现自己的播放器。HTML5 不会提供播放器或类似的东西。

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.

您必须在 OGG 容器中查找大多数浏览器支持的编解码器和包含的编解码器,如果我没记错的话,主要是用于视频的 Theora 和用于音频的 Vorbis。

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

然后我记得 Webkit 浏览器将支持使用 V8 作为视频编解码器和 Vorbis 作为音频的 Matroska (MKV) 容器。

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.

我的建议:分别提供一个带有 Theora 和 Vorbis 作为视频和音频编解码器的 OGG 文件。内部使用带有 V8 和 Vorbis 的 MKV 文件提供后备,然后,如果可以,在使用 Mpeg2 和 MP2(想不出更好的东西)作为视频和音频编解码器的 MPG 视频文件中,后备。然后作为最后一个后备,Flash 播放器播放 FLV 视频文件。

<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.

使用此配置,大多数(如果不是全部)浏览器应该能够播放您的视频,更喜欢最受支持(和最现代)的格式。“后备”直到他们找到 Flash Player。

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

有关支持哪些格式的提示:请查看维基百科中的 HTML5 视频部分。

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.

重要提示:在您的代码中,您指的是绝对文件系统路径,网络访问者完全无法访问该路径。也许在 src 中你的意思是 /video/file2.m4v。

回答by VishalDream

You can use HTML5 video tag. or jplayer.org

您可以使用 HTML5 视频标签。或 jplayer.org

or https://github.com/html5-ninja/Bootstrap-video-player-jQuery-plugin/blob/master/index.htmlview about url you got complete reference .

https://github.com/html5-ninja/Bootstrap-video-player-jQuery-plugin/blob/master/index.html查看有关 url 的完整参考。