Video Hosting refers to cloud storage of videos that are ready to be distributed and watched on end devices via the public internet. You can upload original video files in different formats, we process the videos in various ways, and we save the result to our internal storage. As a result, you get videos in HLS/MP4 format with subtitles, timeline previews, and other features available.
You can upload videos to the storage via the Gcore Customer Portal or API. Learn how to add a video via the Gcore Customer Portal.
Upload of videos via API can be done in three ways, which we describe in detail in this article. Quickly navigate to your chosen method here:
When uploading a video to our storage and its processing, the file may have one of the following statuses:
Note: In the status “Viewable,” manifest.m3u8 has already been generated. End users in any player can watch the video, but a limited number of qualities are available. Qualities will be added automatically to manifest.m3u8 as they are ready; you don’t have to do anything. After adding all qualities, the video will be moved to “Ready.”
Example of the response of a video under processing:
{
"id": 2558721,
"name": "Gcore Demo",
"description": "Video copied from an external S3 Storage",
"status": "pending",
"screenshots": [],
"origin_url": "https://s-ed1.cloud.gcore.lu/demo-video/gcore.mp4",
...
"converted_videos": [
{
"name": "vod480n",
"progress": 0,
"status": "processing",
"error": "",
...
},
...
]
}
If the video fails while uploading and checking, it will remain in “empty” status with details in the “error” field. Most commonly, this happens when an end user uploads a non-video file or has a connectivity issue. In that case, re-upload the video from the origin, or delete the entity and create a new one with the correct video file.
Example of the response if an error occurs during video processing:
{
"id": 2558799,
"name": "Gcore Demo",
"description": "Video copied from an external S3 Storage",
"status": "empty",
"error": "File Invalid",
"origin_url": "https://s-ed1.cloud.gcore.lu/demo-video/master.m3u8",
...
"converted_videos": []
}
In the section, we explain how to copy and migrate files from a third-party, external storage to the Gcore Video Streaming. We will explain the process, offer an example API request, then explain how it works.
If your videos are available by public HTTPS URL, this is the best option to copy video files directly from external storage.
Available protocols for migration:
Note: The original file must be in MP4 format or one of the following formats: 3g2, 3gp, asf, avi, dif, dv, flv, f4v, m4v, mov, mp4, mpeg, mpg, mts, m2t, m2ts, qt, wmv, vob, mkv, ogv, webm, vob, ogg, mxf, quicktime, x-ms-wmv, mpeg-tts, vnd.dlna.mpeg-tts.
Streaming formats like HLS (.m3u8/.ts) and DASH (.mpd/.m4v) are intended for the final video distribution to end viewers, so they cannot be used as original file formats.
Examples of good and bad links to video files from external storage:
https://demo-files.gvideo.io/gcore.mp4
(13,8MB from S3 storage)sftp://login:password@domain.com/path/file.mp4
https://demo-files.gvideo.io/hls/master.m3u8
Below, we explain how to get HTTP public access links in some popular external storages.
To copy a video from another server, specify the attribute origin_url
in the POST API request. The original video will be downloaded for Video Hosting on our server side.
Note: You can only upload one video per request.
Here is an example of the API request to set a task for copying a video from external storage:
curl -L 'https://api.gcore.com/streaming/videos/' \
-H 'Content-Type: application/json' \
-H 'Authorization: APIKey 1234$0d16599c' \
-d '{
"video": {
"name": "Gcore Demo",
"description": "Video copied from an external S3 Storage",
"origin_url": "https://s-ed1.cloud.gcore.lu/demo-video/gcore.mp4"
}
}
Example of the response:
{
"id": 2496039,
"name": "Gcore Demo",
"description": "Video copied from an external S3 Storage",
...
}
After setting the task for downloading, it is queued. You can queue an unlimited number of files, and each one will be processed as soon as possible.
Note: Please be aware of RPS limits for using API.
Here’s how it works on our end. We attempt to download a file three times, expecting a 200 OK response to access your provided link. If the download fails, the video entity will stay in the “Empty” status, and details will be added to the field error
. You need to delete the empty video entity and try to create a new one with the correct origin URL.
Once successfully uploaded and processed, the video will be available in the Customer Portal. You can check the status of the video by the GET API request or via webhook notifications.
When you develop your service, a video must be uploaded from the local host (your backend) or by users from a browser or mobile app.
We use the TUS resumable upload protocol for uploading files, which works by cutting the video for upload into small segments and, if an interruption occurs, continuing from the point of interruption.
The uploading process consists of three steps.
Specify the main parameters, and do not use the origin_url
attribute in the POST API request.
Example of the request:
curl -L 'https://api.gcore.com/streaming/videos/' \
-H 'Content-Type: application/json' \
-H 'Authorization: APIKey 1234$0d16599c' \
-d '{
"video": {
"name": "Gcore Demo",
"description": "Uploaded via TUS session"
}
}'
Example of the response:
{
"id": 2501637,
"name": "Gcore Demo",
"description": "Uploaded via TUS session",
"duration": null,
"slug": "70NbFUCZyXU2s3tY",
"status": "empty",
...
}
To upload a file, you must get a TUS server URL and secret token. Specify the “id” parameter from step 1 and get the TUS session parameters.
Example of the request:
curl -L 'https://api.gcore.com/streaming/videos/2501637/upload' \
-H 'Authorization: APIKey 1234$0d16599c'
Example of the response:
{
"servers": [
{
"id": 561,
"role": "upload",
"hostname": "vod-uploader-ed-2.gvideo.co",
"active": true,
"ssl": true
},
...
],
"token": "eyJhbGciOiJIUzI3O6kc3Og...",
"video": {
"id": 2501637,
"name": "Gcore Demo",
"description": "Uploaded via TUS session",
"duration": null,
"slug": "70NbFUCZyXU2s3tY",
"status": "empty",
...
}
}
Where:
servers
: A list of available servers to upload the file; you can use any of them.token
: A secret token for starting the TUS session, valid for 4 hours which is long enough because as soon as the session starts, the token is no longer needed.video
: A copy of the main data pertaining to your video entity.For uploading, use the session parameters taken from the previous step:
endpoint = "https://{hostname}/upload/"
chunksize = 10000000
filename = "{filename}"
filetype = "{file_mime_type}"
token = "{tus_token}"
video_id = {video_id}
client_id = {client_id}
Note: The chunksize
number is given in bytes. Take care to choose the chunk size appropriately:
Transmitted data must comply with the rules for the Upload-Metadata header, including:
Example of bash script:
DEBUG=1 tusc -H "https://vod-uploader-ed-2.gvideo.co" -f "file_to_upload.mp4" -b "/upload/" -- -H "'Upload-Metadata: client_id $(echo <client_id> | base64 -w0),filename $(echo <filename> | base64 -w0),token $(echo <token> | base64 -w0),video_id $(echo <video_id> | base64 -w0)'"
Example of JS code:
Try the CodePen template by copying your token
, video_id
, and client_id
to find out the upload functionality of the TUS protocol:
const options = {
endpoint,
chunkSize,
retryDelays: [0, 1000, 3000],
metadata: {
filename: file.name,
filetype: file.type,
// must provide these 3 fields too
token: token,
video_id: videoid,
client_id: clientid
},
onError(error) {
...
},
onProgress(bytesUploaded, bytesTotal) {
...
},
onShouldRetry: function (err, retryAttempt, options) {
// tus-js-client should retry
return true
},
onSuccess() {
...
}
}
upload = new tus.Upload(file, options)
upload.findPreviousUploads().then((previousUploads) => {
askToResumeUpload(previousUploads, upload)
upload.start()
uploadIsRunning = true
})
Choose your TUS implementation:
Most common TUS errors:
When moving a huge collection of video files, batch upload is the best method. This option will be available soon. Please ask our support team for details.
We can help you to migrate from several storage types. We have compiled a list of storage types with instructions on how to get an HTTP link to access the file:
If your storage type isn’t mentioned in this list, ask our support team and we will be happy to help you with your video migration.
Was this article helpful?
Explore the Streaming Platform by Gcore