Track: Video

Inspiration

I discovered from the documentation the steps to put a single video on the Theta Network using the Theta Video API. I had to make between four to ten API calls.

  1. Create a pre-signed URL to Upload a Video API.
  2. Upload a Video using the pre-signed URL API.
  3. Transcode a Video using an Upload API.
  4. GET your Video to check its progress API.
  5. You have to continue to call the fourth API at intervals until the video transcoding is completed.

    Also, I discovered there is no Theta Video API for bulk uploading of videos.
    if I had 100 videos I wanted to place on the theta network, I will have to carry out the steps above 100 times. This will be about 400 to 1000 API calls.

So, I was inspired to create a Theta Bulk Video Upload Service that solves these problems.

What it does

  1. Our application gives developers a fantastic user experience for both single upload and bulk upload.
  2. You can perform a single API call to our service to upload multiple videos at once.
  3. Our application carries out all the necessary steps optimally using our multithreaded approach to better handle multiple videos.
  4. We give the developer the final transcoded videos combined responses in one response.
  5. We support synchronous and asynchronous processing of bulk upload.
  6. You can choose the synchronous flow which will keep the HTTP request running until the processing is done.
  7. You can choose the asynchronous flow, you set your webhook as part of the request to us, And you will get the final processing response on your webhook when it is done.

How we built it

We built our bulk service by creating an effective bulk service implementation that integrates with the Theta Video APIs.

  1. We used Java because Java allowed us to implement a multithreaded approach to solving this problem.
  2. When our application receives the HTTP request with the videos for bulk upload. We spin up a thread pool of three threads to handle the request because of Theta Video API transcoding limit per API Credentials is three videos at a time.
  3. Each thread picks from the lists of videos to be uploaded and carries out the four steps to upload and transcode a video on Theta video API.
  4. They work asynchronously to complete the process and combine the responses from the final step of the transcoding of the videos.
  5. The final combined response is sent back to the developer on the HTTP response or webhook depending on the option selected when our service is called.
  6. I sent a single request to our service to upload 3 videos at once, See the response below.
    {"status":"success","message":"Operation Successful","data":[{"id":"video_50ptz6q5cvmc2bu9egmerymxyf","duration":"12960","state":"success","progress":100,"error":null,"resolution":null,"metadata":{},"playback_uri":"https://media.thetavideoapi.com/video_50ptz6q5cvmc2bu9egmerymxyf/master.m3u8","player_uri":"https://player.thetavideoapi.com/video/video_50ptz6q5cvmc2bu9egmerymxyf","use_drm":null,"create_time":"2023-05-31T16:04:23.374Z","update_time":"2023-05-31T16:05:06.457Z","service_account_id":"srvacc_cc55yrv86dh8x5n2wygu4ipm1","file_name":null,"sub_state":"none","source_upload_id":"upload_tq40miatiu6ekuver6yu94wnh","source_uri":null,"playback_policy":"public","start_time_override":null},{"id":"video_9p7nsyyxfwnxtccdd0twh28rj5","duration":"7616","state":"success","progress":100,"error":null,"resolution":null,"metadata":{},"playback_uri":"https://media.thetavideoapi.com/video_9p7nsyyxfwnxtccdd0twh28rj5/master.m3u8","player_uri":"https://player.thetavideoapi.com/video/video_9p7nsyyxfwnxtccdd0twh28rj5","use_drm":null,"create_time":"2023-05-31T16:04:23.394Z","update_time":"2023-05-31T16:04:55.237Z","service_account_id":"srvacc_cc55yrv86dh8x5n2wygu4ipm1","file_name":null,"sub_state":"none","source_upload_id":"upload_kky3yhzmgx8pk217wadv80amq","source_uri":null,"playback_policy":"public","start_time_override":null},{"id":"video_nse7x24x1dv602bfjfjkiwwmx0","duration":"12087","state":"success","progress":100,"error":null,"resolution":null,"metadata":{},"playback_uri":"https://media.thetavideoapi.com/video_nse7x24x1dv602bfjfjkiwwmx0/master.m3u8","player_uri":"https://player.thetavideoapi.com/video/video_nse7x24x1dv602bfjfjkiwwmx0","use_drm":null,"create_time":"2023-05-31T16:04:23.499Z","update_time":"2023-05-31T16:05:06.865Z","service_account_id":"srvacc_cc55yrv86dh8x5n2wygu4ipm1","file_name":null,"sub_state":"none","source_upload_id":"upload_1hug9q1j0zhdx9zc2cteamf8p","source_uri":null,"playback_policy":"public","start_time_override":null}]}

Steps to Test Our Application

  1. Our Application is a backend service hosted on AWS, to test it you need Postman
  2. You can download Postman from https://www.postman.com/downloads
  3. Import our postman collection which contains our server URL and form-data request fields
  4. Open Postman, Towards the top left you will see import, put the collection URL below in the input field.
  5. https://api.postman.com/collections/2921007-ccb7a915-7647-4bd6-a0b0-aad4e82f50d7?access_key=PMAT-01H1Y6PFXMKHDET95ZKCF76GYR
  6. After successfully importing the collection, you can click the imported collection at left "Theta Video Bulk Upload Service" folder and click the "Bulk Video Upload API" request
  7. Under the HTTP URL field you will see different mini tabs like Params, Authorization, body e.t.c
  8. Select "body", you will see the 'files' field click "Select files" to select videos to upload.
  9. For testing, you can download small-size videos from this google drive folder (URL below)
  10. https://drive.google.com/drive/folders/1t1iPzanAVcZ5m1qkyrgLUShE09em9Vc1?usp=share_link
  11. To process synchronously and wait for the final response set the "async-flow" field to false
  12. To process Asynchronously and get the final response on your webhook set the "async-flow" field to true and set the webhook field to your webhook URL.
  13. You can generate a webhook URL and monitor incoming webhooks at https://webhook.site/ it is free and easy to use.
  14. The API key and API secret fields contain our details, you can use that for testing.
  15. Click "Send" towards the top right to send the request.
  16. For the asynchronous flow you will get the final response on your webhook.

Impact

Surprisingly, we are already making an impact in the Theta community even though the hackathon is not over yet.
A friend of mine is competing in his own team, building his own product for the hackathon.
He decided to integrate into our Theta Bulk Video Upload Service due to the user experience and ease of integration it provides for uploading videos to the Theta Video Service, compared to the normal flow where he would have to call multiple APIs to create a pre-signed URL, upload to the pre-signed URL, transcode the video, and check the transcoding progress.

He was excited to use our service because we handle everything for him in one request.

Challenges we ran into

We didn't face many challenges as the Theta Video API is well documented so we knew what exactly to do to get the job done.

Accomplishments that we're proud of

We are proud of the fact that we were able to build something innovative. We are sure it will improve the user experience of the developers integrating into the Theta Video API product.

What we learned

We learned how to create a decentralized bulk upload service that rides on Theta Video API. It was fantastic and interesting to build it.

What's next for Theta Video Bulk Upload Service

  1. We look forward to winning the hackathon.
  2. We look forward to deploying our Theta Bulk Upload Service as part of Theta Products.
  3. We look forward to a partnership with Theta Network.

Built With

  • http
  • java
  • springboot
  • thetavideoapi
  • webhook
Share this project:

Updates

Submission history