我正在尝试使用 Google 云功能将视频从存储桶转码,并使用在线发布的代码输出到另一个存储桶,但进行了一些调整。
但我收到以下错误:
类型错误:无法读取在 transcodeVideo (/srv/index.js:17:56) at /worker/worker.js:825:24 at at process._tickDomainCallback (internal/process/next_tick.js:229) 处未定义的属性“名称” :7)
索引.js
const {Storage} = require('@google-cloud/storage');
const projectId = 'cc18-223318';
const storage = new Storage({
projectId: projectId,
});
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path;
const ffmpeg = require('fluent-ffmpeg');
const transcodedBucket = storage.bucket('2400p');
const uploadBucket = storage.bucket('inpuut');
ffmpeg.setFfmpegPath(ffmpegPath);
exports.transcodeVideo = function transcodeVideo(event, callback) {
const file = event.data;
// Ensure that you only proceed if the file is newly created, and exists.
if (file.metageneration !== '1' || file.resourceState !== 'exists') {
callback();
return;
}
// Open write stream to new bucket, modify the filename as needed.
const remoteWriteStream = transcodedBucket.file(file.name.replace('.webm', '.mp4'))
.createWriteStream({
metadata: {
metadata: file.metadata, // You may not need this, my uploads have associated metadata
contentType: 'video/mp4', // This could be whatever else you are transcoding to
},
});
// Open read stream to our uploaded file
const remoteReadStream = uploadBucket.file(file.name).createReadStream();
繁星coding
相关分类