英文:
Is there a file size limit to play a video using <video> tag?
问题
我一直在使用Google Apps Script部署一个Web应用程序,它在侧边栏上播放视频。视频链接来自Google表格。一切都正常,直到我有两个大约500MB的文件。视频根本无法播放。当我手动减小文件大小时,它可以播放。但每次这样做都很不方便。所以我想知道是否有更好的方法?谢谢!
Html:
<video id="vid" controls autoplay muted>
<source src="" type="video/MP4">
</video>
JavaScript(部分):
let source = document.querySelector('#vid > source');
source.src = e.target.options.vidID;
source.parentNode.load();
vidID保存在Google表格列中单元格的内容,该列包含指向Drive上视频的链接。它是代码的一部分,其中表格中的每一行都被记录为一个标记,并用于生成交互地图。
英文:
I've been using Google Apps Script to deploy a web app, which plays videos on the side bar. The video links are from the Google Sheet. It worked until I have two files about 500mb each. The videos couldn't play at all. When I manually reduced the file size, it worked. But it's inconvenient to do so everytime. So I was wondering if there's a better way out? Thanks!
Html:
> <video id="vid" controls autoplay muted>
> <source src="" type="video/MP4">
> </video>
JavaScript (partial):
let source=document.querySelector('#vid > source');
source.src=e.target.options.vidID;
source.parentNode.load();
vidID holds the content of a cell in a Google Sheet column that holds the links to the videos in Drive. It is part of the codes where each row in the Sheet is recorded as a marker and used to produce an interactive map.
答案1
得分: 2
是的,使用HTML5的<video>标签播放视频时,有文件大小限制。确切的限制取决于几个因素,如使用的浏览器、设备的可用内存和所使用的视频编解码器。
一般而言,大多数现代Web浏览器可以处理大小达数GB的视频文件。例如,Google Chrome通常可以播放高达2GB大小的视频,而Mozilla Firefox可以处理高达512MB的视频。然而,需要注意的是,播放大型视频文件可能会对用户的设备造成压力,可能导致性能问题甚至崩溃。
文件大小限制可能会根据浏览器、设备和网络条件而有所不同:
网络: 文件大小会影响视频加载和播放所需的时间。如果网络带宽有限,大型视频文件可能需要更长时间来加载,导致更长的缓冲时间和中断。
设备: 在处理能力或内存有限的设备上播放大文件可能会导致性能问题,如冻结或崩溃。
浏览器: 一些较旧的浏览器可能对可以使用<video>标签播放的视频文件的最大大小有限制。现代浏览器通常支持播放大型视频文件。
最后, 最好使用经过优化以适合Web播放的视频文件,如带有H.264视频编解码器的MP4文件,并将视频压缩到合理的大小,以确保在不同设备和网络条件下平稳播放。
规范建议将属性preload
设置为metadata
,这表示仅获取视频元数据(例如长度),从而提高性能。
英文:
Yes, there is a limit to the file size of a video that can be played using the HTML5 <video>
tag. The exact limit will depend on several factors, such as the browser being used, the available memory of the device, and the video codec being used.
However, in general, most modern web browsers can handle video files up to a few gigabytes in size. For example, Google Chrome can typically play videos up to 2 GB in size, while Mozilla Firefox can handle videos up to 512 MB. However, it's important to note that playing large video files can put a strain on the user's device, potentially causing performance issues or even crashes.
The size limit may vary depending on the browser, device,
and network conditions:
Network: File size have an impact the time it takes for the video to load and start playing.
If the network bandwidth is limited, a large video file may take longer to load, resulting in longer buffering times,
interruptions.
Device: Playing large files on devices with limited processing power or memory may result in performance issues, such as freezing or crashing.
Browser: Some older browsers may have limitations on the maximum size of a video file that can be played
using the <video> tag. Modern browsers generally have support for playing large video files.
Finally, it is best to use video files that are optimized for web playback, such as MP4 files with H.264 video codec and to compress the video to a reasonable size to ensure smooth playback on different devices and network conditions.
The spec advises the attribute preload
to be set to metadata
which indicates that only video metadata (e.g. length) is fetched hence better in performance.
答案2
得分: 0
"看起来这取决于您用什么来托管您的网站/应用程序
。这是Google Studio 帮助
关于文件大小限制
的说法:
文件大小限制:大多数创意资产(图像、音频、HTML、CSS、数据文件、JavaScript等)的文件大小限制为10 MB。
视频文件的上传限制为100 MB,提供限制为60 MB(OGV文件除外,限制为10 MB)。如果您的资产超过此限制,请联系支持以获取帮助,否则您的视频可能无法提供服务。较大的视频文件可能需要以不同方式托管,以确保最佳性能。"
英文:
It seems that it varies depending on what you are using to host your website/app
. This is what Google Studio Help
has to say about file size limits
:
> File size limits The file size limit for most creative assets (images,
> audio, HTML, CSS, data files, JavaScript, etc.) is 10 MB.
>
> Video files are limited to 100 MB for upload and 60 MB for serving
> (except OGV files, which are limited to 10 MB). If your assets are
> larger than this limit, contact support for help, or your videos may
> not serve. Large video files may need to be hosted differently to
> ensure optimal performance.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论