在 drupal 7 中更改 CDN 中的视频内容类型(mime 类型) [英] Changing video content type (mime type) in CDN in drupal 7

查看:42
本文介绍了在 drupal 7 中更改 CDN 中的视频内容类型(mime 类型)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用媒体模块将媒体保存在 CDN 中.要播放视频,我们在 Drupal 7 中使用 jwplayer.Jwplayer 在 IE 中抛出错误,如果视频不是 content type [mime type] *video/mp4*.我已将现有的 CDN 视频 mime 类型从 application/octet-stream 更改为 video/mp4.

I am using media module to save media in CDN. To play videos, we are using jwplayer in Drupal 7. Jwplayer throws error in IE, If video is not of content type [mime type] *video/mp4*. I have changed the existing CDN videos mime type from application/octet-stream to video/mp4.

现在上传/保存到 CDN 的任何 mp4 视频都应该只是 video/mp4 mime 类型,但是当我在媒体模块中上传 mp4 视频时,它会以 mime 类型 application/octet 保存在 CDN 中-stream,如何将上传的mime type [content type]改为video/mp4.

Now whatever mp4 videos are being uploaded/saved to cdn should only be of video/mp4 mime type but when I upload mp4 videos in media module it is saved in CDN with mime type application/octet-stream, How do I change the uploaded mime type [content type] to video/mp4.

CDN module code 

function CDNtransfer_content($source,$destination)  {

        $s3=_CDN_transfer_load();

        $up_bucket="cdn.example.com";

        $uploadOk=null;

        $expires=date('D, d M Y H:i:s O', strtotime('+10 year'));

        $headers=array('Content-Type' => 'video/mp4', 'Expires' => $expires);

        if($destination)
        {
                        $up_state=$s3->putObject($up_bucket, $destination, $source, 'true', $headers);

                        if($s3->objectExists($up_bucket, $destination)) {
                            $uploadOk =1;
                        }
                        else {
                            $uploadOk ="Error: File Not Uploaded Correctly. Please try again.";
                        }
        }
        return $uploadOk;
}

即使设置上面的标题似乎也不起作用!!!不知道为什么??

Even setting the above header does not seem to work !!! not sure why ??

我们正在使用 s3 php sdk 2 aws 独立类和我们的自定义drupal 中的模块.

We are using s3 php sdk 2 aws stand alone class with our custom module in drupal.

在上传 mp4 视频时,如何在 Drupal 7 媒体模块中将 mime type[content type] 更改为 video/mp4.

How do I change mime type[content type] to video/mp4 in media module, Drupal 7, when mp4 video are being uploaded.

推荐答案

MIME-TYPE 是服务器端设置.您可以要求您的托管服务提供商为您添加 MP4 MIME-TYPE.

A MIME-TYPE is a server side setting. You can ask your hosting provider to add the MP4 MIME-TYPE for you.

或者,您可以将 .htaccess 文件添加到您上传的存储目录中.

Or, you can add a .htaccess file to the directory where you uploads are stored.

添加 MP4 MIME-TYPE 的示例 .htaccess 文件是:

A sample .htaccess file that adds the MP4 MIME-TYPE is:

<IfModule mod_rewrite.c>
  AddType video/mp4 .mp4
</IfModule>

如果您无法正确添加 MIME TYPE,您可以使用的一种解决方法是强制 JW 播放器作为 Flash 运行,这对 MIME-TYPE 不那么严格,通过将此行添加到播放器的嵌入代码:

If you are not able to add the MIME TYPE properly, one work around you can use is to force the JW Player to run as Flash, which is less strict about MIME-TYPEs, by adding this line, to your player's embed code:

primary: 'flash',

如果这有帮助,请告诉我!

Let me know if this helps!

这篇关于在 drupal 7 中更改 CDN 中的视频内容类型(mime 类型)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆