我已经在我的应用程序中成功地实现了视频共享,使用了react本机和firebase,但我希望确保存储的视频不超过1080x1080 (可能720取决于它的外观)。
视频最长为8秒,如果可能的话,我会尽我所能将它们保持在5MB以下。我能够在客户端做一些压缩(裁剪成正方形/修剪),但我希望能够更多地压缩视频,而不会因为云功能(存储触发器)而失去这种质量。
环顾四周之后,运动学看起来是个不错的选择,但它使用的是python,我不知道如何在云函数存储触发器中使用这个脚本。
如下所示:
//Not sure how this will import
import moviepy.editor as mp
//Can I get the video here from the bucket path in a cloud function?
clip = mp.VideoFileClip("video-stored.mp4")
clip_resized = clip.resize(height=1080) # make the height 1080px ( According to moviePy documenation The width is then computed so that the width/height ratio is conserved.)
//resize video, then we need to store it in the same location (same file path)
clip_resized.write_videofile("video-stored-resized.mp4")我想听听关于通过云功能进行视频压缩的一些建议,以及关于使用上面的脚本/模块和云功能的想法。
发布于 2020-07-07 20:33:45
此时,firebase函数不支持node.js以外的其他语言。因此,有两个解决方案。
顺便说一句,当我试图将vids合并到firebase函数中时,可能由于环境的限制,我无法做到这一点。因此,我个人推荐第一个解决方案: ofc,它取决于您的情况,如您的视频文件有多大。
https://stackoverflow.com/questions/61292799
复制相似问题