vimeo.js
vimeo.js copied to clipboard
Is there any callback or web-hook when the processing is finished ?
I uploaded the video to Vimeo and it succeeds. but when I using the URL, It seems like the video still processing that video. So Is there any callback or web-hook to notified me back when it finished the processing.
Paying business user here and I definitely agree a webhook for when videos are done processing would be really, really helpful.
With the way the API works currently, I have to continually poll the Vimeo API until the video is done processing. I really don't think this is optimal.
same here... this is not cost effective even for vimeo. lots and lots of users pinging their server
any solution found on this?
@Tariqali13 what I suggest doing is as soon as video is uploaded create db entry for that uri with status of "in_progress"
then run a cronjob every minute what you do in cronjob is
check db for any videos which are of status "in_progress"
make get request to https://api.vimeo.com/me/videos?fields=uri,transcode.status
and map the response to object and update the "in_progress" docs with new status which might be "in_progress", "complete" or "error"
const unprocessedSnapshot = await admin
.firestore()
.collection('videos')
.where('status', '==', 'in_progress')
.get();
const unprocessedDocs = unprocessedSnapshot.docs;
if(!unprocessedDocs.length) return null;
const response = await axios(
'https://api.vimeo.com/me/videos?fields=uri,transcode.status',
{
headers: { Authorization: 'bearer 4e01e30bfyouraccesstokenhere7013642b6' },
}
);
interface MapInterface {
[key: string]: {
status: string,
}
}
const map: MapInterface = {};
for (const item of response.data.data) {
map[item.uri] = {
status: item.transcode.status,
};
}
for (const doc of unprocessedDocs) {
const video = doc.data();
await admin
.firestore()
.collection('videos')
.doc(doc.id)
.update({
...map[video.uri]
});
}
@pavanjadhaw thanks. that's a good solution but hope in future we will get a callback by vimeo
I bet that if Vimeo wants, a lot of coders would help to implement the webhook feature. I would. This is sooooo needed.
And again. Lots of “pinging” on the server versus one call to the webhook would unclutter services.
Can anyone from Vimeo comment on this? This feature would really be enormously helpful.
Hi, i have found that bit of undocumented useful code while browsing the repo examples:
client.upload(
filePath,
params,
function (uri) {
// UPLOAD SUCCESS but NOT TRANSCODED
// Get the metadata response from the upload and log out the Vimeo.com url
client.request(uri + '?fields=link', function (error, body, statusCode, headers) {
if (error) return console.error('There was an error making the request.')
console.log('"' + filePath + '" has been uploaded to ' + body.link)
// Make an API call to see if the video is finished transcoding.
client.request(
uri + '?fields=transcode.status',
function (error, body, statusCode, headers) {
if (error) return console.error('There was an error making the request.')
console.log('The transcode status for ' + uri + ' is: ' + body.transcode.status)
}
)
})
})
},
function (bytesUploaded, bytesTotal) { },
function (error) { }
)
You can start from this example to find a way to check for uploaded AND transcoded status for the video ^^
Hi, i have found that bit of undocumented useful code while browsing the repo examples:
client.upload( filePath, params, function (uri) { // UPLOAD SUCCESS but NOT TRANSCODED // Get the metadata response from the upload and log out the Vimeo.com url client.request(uri + '?fields=link', function (error, body, statusCode, headers) { if (error) return console.error('There was an error making the request.') console.log('"' + filePath + '" has been uploaded to ' + body.link) // Make an API call to see if the video is finished transcoding. client.request( uri + '?fields=transcode.status', function (error, body, statusCode, headers) { if (error) return console.error('There was an error making the request.') console.log('The transcode status for ' + uri + ' is: ' + body.transcode.status) } ) }) }) }, function (bytesUploaded, bytesTotal) { }, function (error) { } )
I found this could be useful ^^
Sorry to say, but you didn't understand the problem
Been a paying business user for about 2 years now and still no solution for this yet. I still have my polling solution in place but it would really be so much better if Vimeo implemented some sort webhook/callback feature here.
A webhook is available by default in a lot of services nowadays. It'd be very useful to be notified by Vimeo if a video was uploaded/changed. We could even pay a bit extra for this feature (although it should not put too much toll on their systems).
In my case I'd like to keep my custom apps and their service in sync. So, for example, whenever something happens to a video via Vimeo's UI my app would be notified so it could do additional processing.
Wondering if there is a way to make this more visible to Vimeo since it's not javascript specific.
Not sure but to be honest I am considering switching video hosting services. This library seems completely abandoned at this point and video uploads are an important feature for my business. It would be nice to know that the library I am using (as a paying customer) is at the very least being maintained.
2023 edit: Our business switched over to using Bunny.net which has a really easy to use API for video uploads and management. And as an added bonus, it’s 5 - 10x cheaper compared to the enterprise plan that Vimeo forced us onto a few years ago.
are there any updates on this? also what would be a good alternative to Vimeo? Dev support is more important than price EDIT: I'm using mux, it's great and does support webhooks
@rubenheymans Azure Media Services is a good product. It gives more control over the process but is more complex to setup. It also came out cheaper (for our project) than Vimeo. And Azure support is good. https://azure.microsoft.com/en-us/services/media-services/
Currently the only way to view when a video completes transcoding is by polling, i.e. GET /videos/{video_id}?fields=status
If you'd like to see a Webhook interface, please request it at:
https://vimeo.com/help/contact
Since this status
field appears to be undocumented (or hidden somewhere in the API docs that I could not find after looking for 10 minutes), here is the TypeScript type of the response body that you would get from there, scraped together from some 3rd-party Java docs:
// GET /videos/{video_id}?fields=status
type VimeoVideoStatusResponse = {
status:
| 'available'
| 'quota_exceeded'
| 'transcode_starting'
| 'transcoding'
| 'transcoding_error'
| 'uploading'
| 'uploading_error';
};
status
is documented here: https://developer.vimeo.com/api/reference/response/video, if you scroll down about half the page you'll see it / what each state means.
Workaround
In case this is useful for anyone else, polling using a recursive async function that calls GET /videos/{video_id}?fields=status
and then only resolves once an error occurs or the transcoding is done could be done like this (TypeScript):
// Docs: https://developer.vimeo.com/api/reference/response/video#:~:text=available%20%2D%20The%20video%20is%20available.,an%20error%20in%20uploading%20the%20video.
export type VimeoVideoStatus =
| 'available'
| 'quota_exceeded'
| 'total_cap_exceeded'
| 'transcode_starting'
| 'transcoding'
| 'transcoding_error'
| 'unavailable'
| 'uploading'
| 'uploading_error';
/**
* Get the transcode status of a Vimeo video
*/
export function getStatusByVideoIdRecursive(videoId: number): Promise<
| {
errors: Errors,
}
| {
status: VimeoVideoStatus,
},
> {
return new Promise((resolve, reject) => {
client.request(
`/videos/${videoId}?fields=status`,
(error, response: { status: VimeoVideoStatus }) => {
if (error) {
return reject(error);
}
if (['transcode_starting', 'transcoding'].includes(response.status)) {
return resolve(
new Promise((resolveInner) => {
setTimeout(
() => resolveInner(getStatusByVideoIdRecursive(videoId)),
1000,
);
}),
);
}
resolve({
status: response.status,
});
},
);
});
}
Here's an updated version of the script above, using @vimeo/[email protected]
with the promises API:
- https://github.com/vimeo/vimeo.js/issues/104#issuecomment-1658025556