可以在Firebase Cloud功能中调用FFMPEG [英] Can you call out to FFMPEG in a Firebase Cloud Function

查看:142
本文介绍了可以在Firebase Cloud功能中调用FFMPEG的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Firebase Cloud Functions文档,您可以从云功能中利用ImageMagick: https://firebase.google.com/docs/functions/use-cases

Per the Firebase Cloud Functions documentation, you can leverage ImageMagick from within a cloud function: https://firebase.google.com/docs/functions/use-cases

是否可以做类似的事情,但是调用FFMPEG而不是ImageMagick ?虽然缩略图是伟大的,我也希望将传入的图像附加到存储在Firebase存储中的视频文件。

Is it possible do something similar but call out to FFMPEG instead of ImageMagick? While thumbnailing images is great, I'd also like the capability to append incoming images to a video file stored out on Firebase Storage.

推荐答案

p> ffmpeg 不预装(几乎只是ImageMagick);看看在这里安装的Dockerfile是什么? https:// github的.com / GoogleCloudPlatform /的NodeJS-搬运工/斑点/主/运行时图像/ Dockerfile

ffmpeg is not preinstalled (pretty much just ImageMagick); to see exactly what's installed check out the Dockerfile here: https://github.com/GoogleCloudPlatform/nodejs-docker/blob/master/runtime-image/Dockerfile.

但是,当您使用 gcloud beta功能部署上传代码时,可以上传任意二进制文件,因为当前的所有内容目录( node_modules 除外)

However, you can upload arbitrary binaries when you upload your code using gcloud beta functions deploy because everything in the current directory (except node_modules) is uploaded.

您可以将ffmpeg二进制文件作为上传的一部分,然后运行使用类似 child_process.exec 的shell命令。您将需要为目标平台(Debian / jessie)编译的ffmpeg二进制文件。

You could include an ffmpeg binary as part of the upload and then run a shell command using something like child_process.exec. You'll need the ffmpeg binary that's compiled for the target platform (Debian/jessie).

./
../
index.js
ffmpeg

然后运行例如 gcloud beta函数部署myFunc --stage-bucket = YOUR_BUCKET --trigger-http

var exec = require('child_process').exec;
var cmd = 'ffmpeg -i myvideo.mp4 image-%d.jpg';

exec(cmd, function(error, stdout, stderr) {
  // command output is in stdout
});

这篇关于可以在Firebase Cloud功能中调用FFMPEG的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆