简体   繁体   English

有没有办法为基于浏览器的视频上传者设置最长持续时间?

[英]Is there a way to set maximum duration for browser-based video uploaders?

Vine.co allows videos at most 6 seconds. Vine.co最多允许视频6秒。 But users only upload from phones. 但是用户只能从手机上传。 I wonder if this can be done with browsers. 我想知道这是否可以通过浏览器完成。 Thanks. 谢谢。

(I rely on node.js) (我依靠node.js)

It depends how you want to perform the upload. 这取决于您要如何执行上传。

Option 1 - If the movie is uploaded by streaming it to the server in, for example, RTSP or RTMP, then the server can elect to drop the movie based on its duration, as determined during the upload. 选项1-如果通过将影片流传输到服务器(例如,RTSP或RTMP)来上传影片,则服务器可以根据影片的持续时间来选择放下影片,如在上传过程中确定的那样。 This is the most accurate and efficient option but it requires the uploader to be able to stream the file and the server to accept the stream by a media server. 这是最准确,最有效的选项,但是它要求上传者能够流传输文件,并且服务器必须接受媒体服务器的流。

Option 2 - If the movie is uploaded by file transfer then the easiest is to limit the movie file size. 选项2-如果影片是通过文件传输上传的,那么最简单的方法就是限制影片文件的大小。 The size can be determined by heuristics if you know its bit rate. 如果您知道比特率,则可以通过试探法确定大小。 For example, at 500Kbps you'd expect a 6 second movie to weigh approximately 375KB, so you might limit the uploads to 450KB and figure the exact boundary while inspecting the file on the server side. 例如,以500Kbps的速度播放6秒的电影大约需要375KB,因此您可以将上传的文件限制为450KB,并在检查服务器端的文件时确定确切的边界。 For this to actually work you must know in advance the movie's average bit rate. 为了使此功能真正起作用,您必须事先知道电影的平均比特率。

Option 3 - Yet another option, based on the movie metadata: Depending on the movie format you might be able to determine upfront the movie's duration by just inspecting the file headers. 选项3-另一个选项,基于电影元数据:根据电影格式,您可以仅检查文件头就可以确定电影的前期时间。 In mp4, for example, if the MOV atom is at the beginning of the file you can tell upfront what's the movie's duration. 例如,在mp4中,如果MOV原子位于文件的开头,则可以提前告知电影的持续时间。 However, if the MOV atom is at the end of the file or if the H.264 stream is muxed for live streaming as MPEG-TS then there is no way to tell upfront the movie's duration. 但是,如果MOV原子位于文件的末尾,或者如果将H.264流作为MPEG-TS进行流式传输复用,则无法预告电影的持续时间。 Note that the header info is in any case just metadata, so a non-conforming client (whether accidentally or maliciously) might fool the server by posting incorrect duration metadata. 请注意,标头信息在任何情况下都只是元数据,因此,不合格的客户端(无论是偶然还是恶意)都可能通过发布不正确的持续时间元数据来欺骗服务器。 In other words - this method is not reliable. 换句话说-此方法不可靠。

Option 4 - The more accurate method in case you use only HTTP/FTP, though probably the most labor intensive programming-wise, is to analyze the movie during upload. 选项4-如果仅使用HTTP / FTP(虽然可能是最费力的编程方式),则更准确的方法是在上传过程中分析影片。 This method is highly dependent on the movie format and upload method. 此方法高度依赖于电影格式和上载方法。 And it is still less accurate and responsive than the first option (upstreaming the files). 而且它仍然不如第一个选项(上游文件)准确和响应。

To summarize, if you can compromise on the upfront accuracy of the quota assertion and wait for the file to be on the server before accepting or rejecting it then the simplest and recommended solution would be Option 2. 总而言之,如果您可以在配额声明的前期准确性上做出妥协,并在接受或拒绝文件之前等待文件在服务器上,则最简单和建议的解决方案是选项2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM