Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any callback or web-hook when the processing is finished ? #120

Open
shammi-hak opened this issue Oct 28, 2019 · 22 comments
Open

Comments

@shammi-hak
Copy link

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.

@unicornsoftwareinc
Copy link

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.

@fweffort
Copy link

same here... this is not cost effective even for vimeo. lots and lots of users pinging their server

@Tariqali13
Copy link

any solution found on this?

@pavanjadhaw
Copy link

pavanjadhaw commented Apr 12, 2020

@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]
		});
}

@Tariqali13
Copy link

@pavanjadhaw thanks. that's a good solution but hope in future we will get a callback by vimeo

@fweffort
Copy link

fweffort commented Jul 4, 2020

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.

@unicornsoftwareinc
Copy link

Can anyone from Vimeo comment on this? This feature would really be enormously helpful.

@top-kat
Copy link

top-kat commented Nov 18, 2020

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 ^^

@algosoftbd
Copy link

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

@unicornsoftwareinc
Copy link

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.

@iSeiryu
Copy link

iSeiryu commented Aug 27, 2021

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.

@unicornsoftwareinc
Copy link

unicornsoftwareinc commented Oct 1, 2021

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.

@rubenheymans
Copy link

rubenheymans commented Jun 25, 2022

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

@iSeiryu
Copy link

iSeiryu commented Jul 7, 2022

@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/

@aaronm67
Copy link

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

@karlhorky
Copy link
Contributor

karlhorky commented Jul 21, 2022

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';
};

@aaronm67
Copy link

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.

@karlhorky
Copy link
Contributor

karlhorky commented Jul 21, 2022

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,
        });
      },
    );
  });
}

@karlhorky
Copy link
Contributor

karlhorky commented Jul 31, 2023

Here's an updated version of the script above, using @vimeo/[email protected] with the promises API:

@fweffort
Copy link

fweffort commented Nov 4, 2024

My opinion:
We have been asking for this webhook for ages... AGES!
We have several people willing to do this for free for vimeo... including me...

We KNOW this is better for VIMEO and for us.

The issue here is: It is not an issue for vimeo! Why? Because we are too kind!
If every single person using this api would poll non stop for transcoding status instead of waiting 1-3 or even 5 seconds, then, and only then, there is a problem for them to fix and work on, otherwise, it's not a problem and it's not priority(clearly)!

C'mon devs @ vimeo...

@aaronm67
Copy link

aaronm67 commented Nov 4, 2024

@fweffort If you reach out to support (https://vimeo.com/help/contact) you can be opted in to the webhooks beta.

@karlhorky
Copy link
Contributor

@aaronm67 thanks for the tip! Wasn't aware there was a webhooks beta.

Here's how I submitted the form, not sure if you would suggest doing it differently:

Screenshot 2024-11-08 at 22 48 28

Instructions:

  1. Go to https://vimeo.com/help/contact
  2. Log in to your account if necessary
  3. Select the product "vimeo.com"
  4. Select the feature "Uploading and conversion"
  5. Select the feature "Uploading from another website or program"
  6. Select the severity "Minor issue"
  7. Fill in the text fields as follows

Subject:

Opt in to webhooks beta

Description:

Hello,

As Aaron Marasco mentioned on https://github.com/vimeo/vimeo.js/issues/120#issuecomment-2455175223 , I would like to opt our account into the webhooks beta.

Cheers, Karl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants