Home

2. 📹 Configuring your video source

2.1 Basics

You can upload videos from three primary sources:

  1. Amazon S3
  2. From your local computer (coming soon! ⏭)
  3. From YouTube (coming soon! ⏭)

You can replicate this full document using this video:
📹 https://drive.google.com/file/d/12N426AyXWtaFUUMPyzcttYm4gG_mnLwR/view?usp=sharing

Due to Google Colab's memory constraints to display videos, we'll use this 30-second video for illustration purposes only. We want to show you how the video we will work with looks like:
🎥 https://drive.google.com/file/d/1cMMghe3G6aSu5JFlecxn2W6-nUrlOfCM/view?usp=sharing

Let's use the following code to download the video from the second link. 💻

!pip install gdown -q
import os
import gdown
import zipfile

def download_file_from_drive(file_id, output_path="/content"):
    # Create the output directory if it doesn't exist
    if not os.path.exists(output_path):
        os.makedirs(output_path)

    # Download the file from Google Drive using the file ID
    download_path = os.path.join(output_path, "working_video.mp4")
    gdown.download(f"https://drive.google.com/uc?id={file_id}", download_path, quiet=False)

    print(f"Files extracted to {output_path}")
download_file_from_drive("1cMMghe3G6aSu5JFlecxn2W6-nUrlOfCM", output_path="/content")
from IPython.display import HTML
from base64 import b64encode

# Path to your video file
video_path = "/content/working_video.mp4"

# Read the video file and encode it in base64
with open(video_path, 'rb') as f:
    video = f.read()
video_encoded = b64encode(video).decode('utf-8')

# Create an HTML video tag with the base64 encoded video
video_tag = f"""
<video width="640" height="480" controls>
    <source src="data:video/mp4;base64,{video_encoded}" type="video/mp4">
    Your browser does not support the video tag.
</video>
"""

# Display the video
display(HTML(video_tag))

2.2 Amazon S3

2.2.1 Setting up and configuring your S3 bucket

To connect your data to Tenyks, you'll set up an S3 bucket following this guide. 📁

At a high level, you'll be creating a bucket and a user. 👤

  • The bucket will contain a folder from which Tenyks (utilizing your user) will have access to the video (e.g., s3://mytenyksbucket/video_surveillance/). 🎥
  • The user is expected to have a aws_access_key_id and a aws_secret_access_key, which will be used to retrieve the video.

Important: If you have more than one video, store every single video in a separate folder. ⚠️
For instance:

  • s3://mytenyksbucket/video_1/ 🎞️
  • s3://mytenyksbucket/video_2/ 🎞️
  • ...
  • s3://mytenyksbucket/video_n/ 🎞️