mov 或 m4v 视频嵌入(通过 php 从 mysql 数据库检索数据)

发布于 2024-11-07 10:53:37 字数 986 浏览 2 评论 0原文

我正在为一家广告制作公司设计一个网站,该公司希望能够上传位置搜寻和投放视频。我已经弄清楚如何使用正确的标头将数据从 sql 中取出并放入浏览器中。

现在我的问题是 - 目前显示视频的最佳方式是什么。我需要它在 iPhone、iPad、Safari 和 Firefox 上运行。我根本不关心IE。

如果有帮助的话,我不介意限制他们只上传一种视频格式。意味着仅 Quicktime .mov 或仅 .m4v - 无论有效。无法使用 Flash,因为涉及 iPhone 和 iPad。

我也没有问题适应每个不同的浏览器与不同的代码。我只需要知道哪种方法最适合哪个平台/浏览器。

编辑:

我已经弄清楚如何在我关心的计算机浏览器(不包括 MSIE)中显示数据库中的视频。现在我需要弄清楚iPhone。为了进行测试,我将文件放入服务器的文件系统中,它们都通过 html5 视频标签从那里播放。因此 iPhone 能够播放剪辑的格式。问题显然是从 mySQL 将该数据传递到 iPhone...目前,我的 php 文件检索二进制数据并将其发送到浏览器指定以下标头:

header("Content-length: $audioLength");  
header('Content-Range: bytes 0-'.$audioLength.'/'.$audioLength);  
header("Content-type: ".$mimeType);

其中 $audioLength 是上传时捕获的文件大小(以字节为单位)
$mimeType 是浏览器在上传时报告的 mime 类型 - 两个值都与二进制数据一起从数据库传递到retrieve_audio.php 脚本。

可能还需要哪些其他标头?我如何找出从文件系统获取文件与从数据库获取文件之间的区别?

问题是否可能是 iPhone 在您按下播放按钮之前不会检索数据?作为最后的手段,我可​​以让 PHP 代码将文件写入文件系统,但这是我希望避免的数据重复,如果可能的话......

谢谢,

M

I am designing a site for an ad production company that want to be able to upload location scouting and casting videos. I have figured out how to get the data out of sql and into the browser with proper headers.

Now my issue is - what is the best way to display video at present. I need it to work on iPhones, iPads, Safari and Firefox. I don't care about IE at all.

I don't mind restricting them to uploading in only one video format if that helps. Meaning Quicktime .mov only or .m4v only - whatever works. Can't use Flash as iPhones and iPads are involved.

I also have no issue accommodating each different browser with different code. I just need to know which method is best for which platform/browser.

EDIT:

I have figured out how to display the video from the database in the computer browsers I care about (excludes MSIE). Now I need to figure out the iPhone. To test, I put the files into the server's files system and they all play from there via the html5 video tag. So the iPhone is capable of playing the clips' formats. The issue is apparently passing that data to the iPhone from mySQL... Currently, my php file that retrieves the binary data and sends it to the browser specifies the following headers:

header("Content-length: $audioLength");  
header('Content-Range: bytes 0-'.$audioLength.'/'.$audioLength);  
header("Content-type: ".$mimeType);

where $audioLength is the file size in bytes captured on upload
$mimeType is the mime type as reported by the browser at upload - both values are passed to the retrieve_audio.php script form the database along with the binary data.

What other headers may be necessary? How would I find out what the difference is between getting the file from the filesystem versus the database?

Is is possible the issue is that the iPhone doesn't retrieve the data until you press the play button? As a last resort, I could have the PHP code write the file(s) to the filesystem, but that is duplication of data that I would like to avoid, if possible...

Thanks,

M

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北方的韩爷 2024-11-14 10:53:37

查看 http://diveintohtml5.ep.io/video.html 了解有关 HTML5 视频的重要信息和不同的格式。

简单简短的回答:Firefox 4 支持 Ogg (Theora/Vorbis) 和 WebM; Safari(桌面版和移动版)支持 MP4 (H.264/AAC)。尝试使用 HTML5 标签,如下所示:(

<video width="320" height="240" controls>
    <source src="pr6.mp4"  type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
    <source src="pr6.webm" type='video/webm; codecs="vp8, vorbis"'>
    <source src="pr6.ogv"  type='video/ogg; codecs="theora, vorbis"'>
</video>

示例来自上面链接的网站。说真的,这是一本非常好的读物,它还会告诉您如何确保您的视频 在 IE、Chrome 等中工作。)

编辑如果您绝对需要只使用一种视频格式,那么您最好的选择可能是带有 H.264 视频和 AAC 音频的 MP4/M4V。 Safari(桌面版和移动版)可以在 标签中播放它,Firefox 将能够在 Flash 容器中播放它。这并不理想,因为我认为你必须进行一些浏览器嗅探以确保 iOS 不会获取 Flash 而 Firefox 会获取 Flash,但你会想要这样的东西:

<!-- Safari and iOS -->
<video width="320" height="240" poster="poster.jpg" controls>
    <source src="video.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
</video>

<!-- Firefox / other -->
<object width="320" height="240" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
    <param value="player.swf">
    <param value="true" name="allowfullscreen">
    <param value="always" name="allowscriptaccess">
    <param value="file=video.mp4&image=poster.jpg" name="flashvars">
    <embed
        width="320"
        height="240"
        flashvars="file=video.mp4&image=poster.jpg"
        allowfullscreen="true"
        allowscriptaccess="always"
        src="player.swf"
        type="application/x-shockwave-flash"
    >
</object>

即使你走这条路,但是,我会仍请阅读深入 HTML5 页面,了解有关要使用的适当编解码器、如何对视频进行编码以及需要注意的各种问题的更多信息。

Check out http://diveintohtml5.ep.io/video.html for great info on HTML5 video and different formats.

Simplified short answer: Firefox 4 supports Ogg (Theora/Vorbis) and WebM; Safari (desktop and mobile) supports MP4 (H.264/AAC). Try using the HTML5 <video> tag like this:

<video width="320" height="240" controls>
    <source src="pr6.mp4"  type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
    <source src="pr6.webm" type='video/webm; codecs="vp8, vorbis"'>
    <source src="pr6.ogv"  type='video/ogg; codecs="theora, vorbis"'>
</video>

(Example from site linked above. Seriously, it's a really good read, and it will also tell you how to make sure your video does work in IE, Chrome, etc.)

EDIT If you absolutely need to only use one video format, your best bet is probably MP4/M4V with H.264 video and AAC audio. Safari (desktop and mobile) can play it in the <video> tag, and Firefox will be able to play it in a Flash container. It's not ideal, because I think you'll have to do some browser sniffing to make sure iOS doesn't get Flash and Firefox does, but you'll want something like this:

<!-- Safari and iOS -->
<video width="320" height="240" poster="poster.jpg" controls>
    <source src="video.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
</video>

<!-- Firefox / other -->
<object width="320" height="240" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
    <param value="player.swf">
    <param value="true" name="allowfullscreen">
    <param value="always" name="allowscriptaccess">
    <param value="file=video.mp4&image=poster.jpg" name="flashvars">
    <embed
        width="320"
        height="240"
        flashvars="file=video.mp4&image=poster.jpg"
        allowfullscreen="true"
        allowscriptaccess="always"
        src="player.swf"
        type="application/x-shockwave-flash"
    >
</object>

Even if you go this route, though, I'd still read the Dive Into HTML5 page for more info about the appropriate codecs to use, how to encode the video, and various problems to look out for.

℡寂寞咖啡 2024-11-14 10:53:37

不幸的是,没有一种格式可以在如此广泛的设备上运行良好。您需要采用上传的任何格式并将其转换为多种不同的格式。您可能需要研究像 http://www.livetranscoding.com/ 这样的服务来完成繁重的工作(注意,我没有使用过他们的服务,我不知道是否有办法让它与非直播流一起工作)。

Unfortunately there is no single format that works well on such a wide variety of devices. You'll need to take whatever format is uploaded and convert it into a number of different formats. You might want to look into a service like http://www.livetranscoding.com/ to do the heavy lifting (note, I've not used their services and I don't know if there's a way to get it to work with non-live streams).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文