【发布时间】:2020-08-01 04:54:43
【问题描述】:
我已经使用 react native 和 firebase 在我的应用中成功实现了视频共享,但我想确保存储的视频不超过 1080x1080(可能是 720,具体取决于它的外观)。
视频最长为 8 秒,如果可能,我会尽力将它们控制在 5MB 以下。我能够在客户端进行一些压缩(裁剪为正方形/修剪),但我希望能够通过云功能(存储触发器)进一步压缩视频而不会失去这种质量。
环顾四周,看起来Moviepy 是一个不错的选择,但它使用的是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")
我很想听听一些关于通过云功能压缩视频的建议,以及关于将上述脚本/模块与云功能结合使用的想法。
【问题讨论】:
-
你有什么问题?
-
@DougStevenson 谢谢道格,问题已编辑。
-
我也是这种情况,刚刚发现这个:stackoverflow.com/questions/57149078/…我还没试过。
标签: reactjs firebase react-native google-cloud-functions firebase-storage