使用 NodeJS API 调用上传 MP4 时,Azure 视频索引器停顿

问题描述

我正在使用 NodeJS 将 mp4 目录一一上传到 Azure。出于某种原因,视频索引大约有 20% 的时间会停止。我不清楚为什么。 API 调用没有显示错误。尝试为视频加载数据时,我只获得“正在处理”状态,但它永远不会结束。我必须手动删除视频并重新开始。

登录videoindexer.ai网站,可以看到进程无限期地停滞:

video indexer stalling at 30% and 90%

这是我上传 MP4 的 NodeJS。如果我在这里做错了什么,我将不胜感激:

const fs = require('fs');
const path = require('path');
const fetch = require('node-fetch');
const FormData = require('form-data');

const uploadVideo = async (filePath) => {
  const fileName = path.parse(filePath).name;

  const url = `https://api.videoindexer.ai/${LOCATION}/Accounts/${ACCOUNTID}/Videos?accesstoken=${TOKEN}&name=${fileName}&description=TEST&privacy=private&partition=some_partition`;

  const fileBase = path.parse(filePath).base; // e.g. "video1.mp4"
  const formData = new FormData();
  formData.append('file',fs.createReadStream(filePath),{ filename: fileBase });

  const headers = {
    'x-ms-client-request-id': '','Ocp-Apim-Subscription-Key': APIKEY,...formData.getHeaders()
  };

  const response = await fetch(url,{
    cache: 'no-cache',headers,method: 'POST',body: formData
  });
  const json = await response.json();
  if (json.ErrorType && json.Message) {
    throw new Error(`${json.ErrorType} - ${json.Message}`);
  }
  console.log('Successfully uploaded video');
  console.log(json);
  return json.id;
};
uploadVideo('./video1.mp4').then((videoId) => console.log('result: ' + videoId)) // <- returns the correct videoId even when process stalls

解决方法

请添加标题 'Content-Type': 'multipart/form-data'. 您可以删除 ...formData.getHeaders() 并请提供您的帐户 ID 和/或暂停的视频 ID,以便我们进行内部检查

谢谢, 视频索引器团队