I'm using NodeJS to upload a directory of mp4s one-by-one to Azure. For some reason, the video indexing stalls about 20% of the time. I'm not clear as to why. There are no errors displayed by the API call. When trying to load data for the video, I just get the status "Processing", but it never ends. I have to manually delete the video and start over.
Logging into the videoindexer.ai website, I can see that the process is stalled indefinitely:
Here is my NodeJS for uploading an MP4. I'd greatly appreciate any advice if I'm doing something wrong here:
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