gpt4 book ai didi

javascript - HTML 视频播放器对于某些文件出现故障

转载 作者:太空宇宙 更新时间:2023-11-04 15:47:22 25 4
gpt4 key购买 nike

Browser errors

从上图中,我在尝试检索视频时有一个视频文件 -> 这些问题仅针对特定文件发生 ->可能是可能的问题..?

我正在使用 jquery ajax 响应附加视频数据:

$("#videoData").append('<video width="75%" class="center-block" 
controls autoplay style="max-width: 60em;">
<source style="max-width: 60em;" src="'+path+'" type="video/mp4">
'+response["videoName"]+'</video>');

路径内的视频位置将从头开始。(http://website.com/uploads/file.mp4)

我的html是这样的:

<div id="videoData">     </div> 

我的 php 存储文件是这样的:

$videoPath      = '../uploads/course_videos/'.$coursename;
for ($i = 0; $i < count($_FILES['course_video']['name']); $i++) {
$videofilename = $_FILES["course_video"]["name"][$i];
$videofilename = mysqli_real_escape_string($conn,$videofilename);
$targetVideo = $videoPath ."/". $videofilename;
move_uploaded_file($_FILES["course_video"]["tmp_name"][$i], $targetVideo)
}

文件夹中的所有文件都正确上传,但我不知道为什么很少有视频没有出现

我认为该文件可能已损坏,但是当我从服务器再次下载相同的文件并在我的计算机中播放该文件时,它工作正常。!

感谢帮助..

最佳答案

如果您只是直接上传视频文件而不进行转换或检查,则可能会面临安全问题。

同时,由于编解码器的不同,不能保证所有上传的文件都能播放。我建议对上传的文件进行检查,将其验证为视频,然后进行转换。

<小时/>

发生这种情况的另一个可能原因是,正如您提到的,在某些文件上,您没有正确转义 URL。

尝试在返回的 URL 上使用 encodeURIComponent(path)

encodeURIComponent() - The encodeURIComponent() function encodes a Uniform Resource Identifier (URI) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character (will only be four escape sequences for characters composed of two "surrogate" characters).

<小时/>

另外,也可能是服务器端的问题。在服务器端正确转义文件名也很重要。

文件上传和播放视频时可能会出现许多问题。

关于javascript - HTML 视频播放器对于某些文件出现故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43450638/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com