Html M4V Mimetype - 视频/mp4 或视频/m4v?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15277147/
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-08-29 06:13:45  来源:igfitidea点击:

M4V Mimetype - video/mp4 or video/m4v?

htmlvideomime-types

提问by Aidan Ryan

I am serving a video via the HTML5 videoelement. I'm finding conflicting information about the appropriate MIME type for m4vvideo. Most demos set the typeattribute to video/mp4in the sourcetag in the markup. Some articles I've read indicate video/m4vfor the web server Mimetype, while others indicate video/mp4. Which is correct?

我正在通过 HTML5video元素提供视频。我发现有关m4v视频的适当 MIME 类型的信息存在冲突。大多数演示在标记中的标记中设置type属性。我读过的一些文章指出Web 服务器 Mimetype,而其他文章指出. 哪个是正确的?video/mp4sourcevideo/m4vvideo/mp4

See for example, this article indicating video/m4vmimetype: http://html5center.sourceforge.net/make-your-html5-video-play-on-mobile-devices

例如,请参阅本文指示video/m4vmimetype:http: //html5center.sourceforge.net/make-your-html5-video-play-on-mobile-devices

And this article indicating video/mp4: http://www.coolestguyplanettech.com/use-html-5-video-on-all-browsers/

而这篇文章表明video/mp4http: //www.coolestguyplanettech.com/use-html-5-video-on-all-browsers/

回答by mark4o

The standard media type is video/mp4.

标准媒体类型是video/mp4.

The standard mp4 container format is commonly used for both AAC audio, and H.264 video + AAC audio. These have different media types, audio/mp4and video/mp4, however often you want different applications for audio and video and on some systems it is only possible to associate a default application with a file extension. Therefore it has become popular in some circles to use the extensions .m4aand .m4vfor audio and video(+audio), respectively, in an mp4 container. However this does not affect the media type, which already distinguishes these using the audio or video prefix.

标准 mp4 容器格式通常用于 AAC 音频和 H.264 视频 + AAC 音频。这些具有不同的媒体类型,audio/mp4video/mp4,但是经常要用于音频和视频不同的应用和在某些系统中,仅可能与一个文件扩展名的默认应用程序关联。因此,在某些圈子中,在 mp4 容器中分别使用扩展.m4a.m4v音频和视频(+音频)已经变得流行。然而,这不会影响媒体类型,媒体类型已经使用音频或视频前缀区分这些。

A twist, however, is that Apple started using their own media type, video/x-m4v, for videos from their store, which are in an mp4 container and use a .m4vextension. This is set to open the video in iTunes by default. Sometimes that is necessary because the video uses DRM, AC-3 Dolby Digital audio, or other capabilities that are not commonly supported in an mp4 container, but which are supported by iTunes for files with a .m4vextension. If you rely on such capabilities then you may want to use this media type instead of the standard one.

然而,一个转折点是 Apple 开始使用他们自己的媒体类型video/x-m4v, 来存储来自他们商店的视频,这些视频位于 mp4 容器中并使用.m4v扩展名。这被设置为默认在 iTunes 中打开视频。有时因为视频使用DRM,AC-3杜比数字音频,或不常用的MP4容器支持,但其他功能由iTunes支持是必要的一个文件.m4v扩展名。如果您依赖此类功能,那么您可能希望使用这种媒体类型而不是标准媒体类型。

Media types with no x-are standardized in an RFC and tracked by IANA. No media type with the name video/m4vhas been standardized. Non-standard media types have a x-prefix.

带有 no 的媒体类型x-在 RFC 中标准化并由 IANA 跟踪。没有video/m4v标准化同名的媒体类型。非标准媒体​​类型有一个x-前缀。

回答by user2993258

I only write HTML5 for special projects, but I've had a problem which I was able to solve quite by accident. In my blocks, I was writing the video code like this:

我只为特殊项目编写 HTML5,但我遇到了一个问题,我很偶然地解决了这个问题。在我的区块中,我正在编写这样的视频代码:

        <source src="Videos/myvideo.mp4" type="video/mp4">
        <source src="Videos/myvideo.webm" type="video/webm">

Here was my problem: If I put the mp4 line first, Google Chrome would play the video part, but there would be no sound. If I put the webm line first, Google Chrome would play the video and sound correctly, but Apple Safari would not detect the video at all. Even if I added the codec information in the type= statement, it had no effect.

这是我的问题:如果我先放 mp4 行,Google Chrome 会播放视频部分,但不会有声音。如果我将 webm 行放在首位,Google Chrome 会正确播放视频和声音,但 Apple Safari 根本不会检测到视频。即使我在 type= 语句中添加了编解码器信息,它也没有任何效果。

I was about to cave in and try to use Flash, but I happened on the solution, mostly by accident. In the line for mp4, I replaced the type="video/mp4" with type="video/m4v". It cured the problem completely! Note: I did not change the video file extentionsfrom mp4 to m4v -- I only used m4v in the type= statement.

我正要陷入困境并尝试使用 Flash,但我偶然发现了解决方案,这主要是偶然的。在 mp4 行中,我将 type="video/mp4" 替换为 type="video/m4v"。彻底解决了问题!注意:我没有将视频文件扩展名从 mp4更改为 m4v——我只在 type= 语句中使用了 m4v。

I couldn't find any documentation to tell me to do this, I just got interested in the difference between .mp4 and .m4v file extentions, and started playing around. I use Linux (Xubuntu) and I had created my videos as both webm and H.264 mp4 files, using Openshot Video Editor. Maybe the inner workings of Openshot caused this to be an issue, but anyway -- that's how I solved this problem. My mp4 videos play perfectly. I hope this helps somebody else -- MinnesotaJon

我找不到任何文档来告诉我这样做,我只是对 .mp4 和 .m4v 文件扩展名之间的区别感兴趣,并开始玩弄。我使用 Linux (Xubuntu),并使用 Openshot Video Editor 将视频创建为 webm 和 H.264 mp4 文件。也许 Openshot 的内部运作导致了这个问题,但无论如何——这就是我解决这个问题的方式。我的 mp4 视频播放完美。我希望这对其他人有帮助——MinnesotaJon

回答by JanTheHuman

Actually that totally depends on which video container you are using. Most browsers support the webm and/or mp4 file formats. Serving a combination of these two sourcefiles ensures browsers kan view the file. There's also the .ogg format if you wish to include it.

实际上,这完全取决于您使用的视频容器。大多数浏览器支持 webm 和/或 mp4 文件格式。提供这两个源文件的组合可确保浏览器可以查看文件。如果您希望包含它,还有 .ogg 格式。

Not so sure about the m4v format, but it sounds like it's not one commonly used on the web. Anyway, I'd say serve m4v with a video/m4v MimeType and mp4 as a video/mp4 MimeType.

不太确定 m4v 格式,但听起来它不是网络上常用的格式。无论如何,我会说为 m4v 提供视频/m4v MimeType 和 mp4 作为视频/mp4 MimeType。