Video uploading - Straas/Straas-web-document GitHub Wiki
By using Straas to accelerate your online business, you might want to upload your existing videos. Besides our CMS had already provided UI for you to achieve it. For the following extra needs, video upload API is the way to go:
- You want to integrate video upload function into your own system
- You got lots of videos along with its metadata to upload
Here are the steps to upload videos through API.
- Create a video ingestion
- Upload the video
- Transcode the video
- Check if the video is ready
Note that, the uploading process should be implemented on server side. For security, it doesn't allow to upload video from customer's client side, e.g. web page. It might encounter CORS problem.
Create a video ingestion
Call API to create a video ingestion
, you have to specify content_type
for your file to upload. We currently support video/mp4(.mp4), video/avi(.avi) and video/quicktime(.mov).
Don't forget your specified content_type
and the return video_id
& upload_url
, they will be used later.
After creation, you could retrieve the info of video ingestion any time with video_id
by getting a video ingestion.
Please note that one video ingestion is only for one video file to upload.
Upload the video
Then you can upload your video before the time of expired_at
which is one day from creation time.
Use any HTTP client to PUT your file directly into the upload_url
, along with your specified content type header. Below is a curl example:
curl -X PUT -H 'Content-Type: video/mp4' --data-binary @"/tmp/video.mp4" 'UPLOAD_URL_HERE'
If you succeed, you would receive HTTP 200 response with exact bytes of file size in the x-goog-stored-content-length header.
What if you encounter a problem during the upload? Don't worry, you could just start over this upload process again and again before you go to the next step.
Transcode the video
After you finished file upload, update the video ingestion to notify our system to start transcoding.
Once the status
of video ingestion is turned into transcoding, you should never touch the upload_url
again, and wait till it completed.
Check if the video is ready
Since the transcoding time for each video is different, you have to check the status
and progress_percent
by
getting a video ingestion. And the time needed approximately equals to your video length.
When the status
of video ingestion becomes completed, you just finished the whole upload process.
You could then get video details, update video details and publish your video.