小编Mur*_*ran的帖子

猫鼬错误:检测到循环依赖

我编写了一项使用Google Cloud Video Intelligence分析视频的服务

\n

我用mongoose将分析结果保存到MongoDB中

\n

这是我使用的模型(我简化了一切以避免混淆):

\n
// Video.js\n\nconst mongoose = require(\'mongoose\');\n\nconst videoSchema = new mongoose.Schema({\n    analysis_progress: {\n        percent: { type: Number, required: true },\n        details: {}\n    },\n    status: {\n        type: String,\n        enum: [\'idle\', \'processing\', \'done\', \'failed\'],\n        default: \'idle\'\n    }\n});\n\nmodule.exports = mongoose.model(\'Video\', videoSchema);\n\n
Run Code Online (Sandbox Code Playgroud)\n

当分析操作结束时,我调用下面的函数并update像这样运行:

\n
\nfunction detectFaces(video, results) {\n   //Build query\n    let update = {\n        $set: {\n            \'analysis_results.face_annotations\': results.faceDetectionAnnotations // results is the the test result\n        }\n    };\n\n    Video.findOneAndUpdate({ _id: video._id }, update, { …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js video-intelligence-api

3
推荐指数
1
解决办法
4504
查看次数

如何同步执行ffmpeg命令?

我有一个视频处理 API,我想同步运行 ffmpeg 命令,否则处理的文件会损坏。

到目前为止,我尝试了以下步骤:

var execute = (command) => {
  const ffmpeg = spawn("./bin/ffmpeg/ffmpeg", command);
  ffmpeg.stderr.on("data", (data) => {
    debug(data.toString());
  });

  ffmpeg.on("close", () => {
    console.log('DONE');
  });
};

var sourceFilePath = '/tmp/test.mp4';
var outputPath = '/tmp/test_processed.mp4';
var ss = 5;
var t = 10;

execute([
  "-i",
  sourceFilePath,
  "-ss",
  ss,
  "-t",
  t,
  outputPath,
]);

await uploadTos3(outputPath); // Helper function to upload processed file to s3
Run Code Online (Sandbox Code Playgroud)

上传的文件无法工作..它已损坏。

注意:当我尝试上传工作视频时,它正在工作。所以问题出在 ffmpeg 辅助函数上。

ffmpeg node.js async-await

1
推荐指数
1
解决办法
1263
查看次数