File Transcoding

File transcoding allows you to upload video files to the VideoCoin Network and transcode it to different formats.

VideoCoin Network presetly supports H264 Inputs and HLS outputs for files

List available streaming profiles

Below is the endpoint to retrieve all existing output profiles. Determine which profile will best suit your desired output stream and note the id property:

$ curl -X GET https://console.videocoin.network/api/v1/profiles
{
"items": [
{
"id": "190b9d72-208d-4fa2-90b7-5b203c0025d2",
"name": "SD",
"description": "SD",
"is_enabled": true
},
{
"id": "45d5ef05-efef-4606-6fa3-48f42d3f0b96",
"name": "FullHD",
"description": "FullHD",
"is_enabled": true
},
{
"id": "e53e377f-2621-4ef1-8004-7d782e9608eb",
"name": "HD",
"description": "HD",
"is_enabled": true
}
]
}

Create the stream object

Create the stream and include the required name, input_type, output_type and profile_id values. profile_id is the value of the desired profile in the previous step. Note that this request requires authorization in the form of a Bearer token. See "API Authorization" for more:

$ curl -X POST -H 'Authorization: Bearer <TOKEN>' -H 'Content-Type: application/json' -d '{"name": "file", "input_type": "INPUT_TYPE_FILE", "output_type": "OUTPUT_TYPE_HLS", "profile_id": "190b9d72-208d-4fa2-90b7-5b203c0025d2"}' https://console.videocoin.network/api/v1/streams
{
"id": "3f18785d-b757-4f18-77e2-36680043fff1",
"name": "file",
"output_url": "https://streams.videocoin.network/3f18785d-b757-4f18-77e2-36680043fff1/index.m3u8",
"stream_contract_id": "1959998627787229139",
"stream_contract_address": "",
"status": "STREAM_STATUS_NEW",
"input_status": "INPUT_STATUS_NONE",
"created_at": "2019-11-06T22:54:06.866402573Z",
"updated_at": "2019-11-06T22:54:06.866452401Z",
"ready_at": null,
"completed_at": null,
"rtmp_url": "",
"input_type": "INPUT_TYPE_FILE",
"output_type": "OUTPUT_TYPE_HLS"
}

Start preparation of the stream

Using the id value of the previous operation, begin running the stream to prepare its input and output destinations:

$ curl -X POST -H 'Authorization: Bearer <TOKEN>' https://console.videocoin.network/api/v1/streams/3f18785d-b757-4f18-77e2-36680043fff1/run

Uploading file to the stream's ingest

The stream is not yet ready to receive video until its status property is equal to STREAM_STATUS_PREPARED. For more about the various values of a stream's status property, see the "List of stream statuses (status)" section in the "Streams" page:

$ curl -X GET -H 'Authorization: Bearer <TOKEN>' https://console.videocoin.network/api/v1/streams/3f18785d-b757-4f18-77e2-36680043fff1
{
"id": "3f18785d-b757-4f18-77e2-36680043fff1",
"name": "live",
"output_url": "https://streams.videocoin.network/3f18785d-b757-4f18-77e2-36680043fff1/index.m3u8",
"stream_contract_id": "1959998627787229139",
"stream_contract_address": "0x548CEb2CD19Df313e2aA65c9301CBb9d264dBB8F",
"status": "STREAM_STATUS_PREPARED",
"input_status": "INPUT_STATUS_NONE",
"created_at": "2019-11-06T22:54:07Z",
"updated_at": "2019-11-06T22:54:15Z",
"ready_at": null,
"completed_at": null,
"rtmp_url": "",
"input_type": "INPUT_TYPE_FILE",
"output_type": "OUTPUT_TYPE_HLS"
}

The stream is now ready to receive video over file upload. There are two options to upload file:

Form data

curl -X POST https://videocoin.network/api/v1/upload/local/3f18785d-b757-4f18-77e2-36680043fff1 \
-H 'Authorization: Bearer <TOKEN>' \
-H 'content-type: multipart/form-data' \
-F 'file=@\Users\videocoin\sample.mp4'

or URL:

curl -X POST https://videocoin.network/api/v1/upload/url/3f18785d-b757-4f18-77e2-36680043fff1 \
-H 'Authorization: Bearer <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"url": "http://.../sample.mp4"}'

The HLS output is not ready for use until the stream's status property is equal to STREAM_STATUS_READY:

$ curl -X GET -H 'Authorization: Bearer <TOKEN>' https://console.videocoin.network/api/v1/streams/3f18785d-b757-4f18-77e2-36680043fff1
{
"id": "3f18785d-b757-4f18-77e2-36680043fff1",
"name": "live",
"output_url": "https://streams.videocoin.network/3f18785d-b757-4f18-77e2-36680043fff1/index.m3u8",
"stream_contract_id": "1959998627787229139",
"stream_contract_address": "0x548CEb2CD19Df313e2aA65c9301CBb9d264dBB8F",
"status": "STREAM_STATUS_READY",
"input_status": "INPUT_STATUS_ACTIVE",
"created_at": "2019-11-06T22:54:07Z",
"updated_at": "2019-11-06T22:54:15Z",
"ready_at": "2019-11-06T22:58:15Z",
"completed_at": null,
"rtmp_url": "",
"input_type": "INPUT_TYPE_FILE",
"output_type": "OUTPUT_TYPE_HLS"
}

Once the stream is in STREAM_STATUS_READY state, use the output_url property with any HLS-compatible video player to view your stream's output:

$ ffplay https://streams.videocoin.network/3f18785d-b757-4f18-77e2-36680043fff1/index.m3u8

Ending your stream

The stream will complete automatically as soon as file will be completely transcoded. The stream can also be stopped manually as shown below:

$ curl -X POST -H 'Authorization: Bearer <TOKEN>' \
https://console.videocoin.network/api/v1/streams/3f18785d-b757-4f18-77e2-36680043fff1/stop