Skip to content

Commit

Permalink
Merge branch 'main' into snyk-upgrade-99ee1bdf317deb804248d6d7ad2640a9
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperSuperDev authored Jan 21, 2022
2 parents b189c5b + aed3a94 commit fc1daa3
Show file tree
Hide file tree
Showing 82 changed files with 1,463 additions and 1,368 deletions.
16 changes: 16 additions & 0 deletions .envs/.local/hmac.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import hmac
from hashlib import sha1
from time import time


def hmac_sha1(key, msg):
return hmac.new(key, msg, sha1).hexdigest()


method = "GET"
duration_in_seconds = 60 * 60 * 24
expires = int(time() + duration_in_seconds)
path = "/v1/my_account/container/object"
key = "MYKEY"
hmac_body = "%s\n%s\n%s" % (method, expires, path)
signature = hmac.new(key, hmac_body, sha1).hexdigest()
1,333 changes: 776 additions & 557 deletions client_nextjs/package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions client_nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
},
"dependencies": {
"@chakra-ui/icons": "^1.1.2",
"@chakra-ui/react": "^1.7.2",
"@chakra-ui/react": "^1.7.3",
"@choc-ui/logo": "^1.0.0",
"@emotion/react": "^11.7.0",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"axios": "^0.24.0",
"framer-motion": "^4.1.17",
"head": "^1.0.0",
"next": "12.0.4",
"next": "12.0.7",
"plyr-react": "^3.2.1",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
# Your stuff: custom apps go here
"nonovium_video_backend.video_encoder.apps.VideoEncoderConfig",
"nonovium_video_backend.videos.apps.VideosConfig",
"nonovium_video_backend.gears.apps.GearsConfig",
"nonovium_video_backend.pipelines.apps.PipelinesConfig",
]
# https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps
INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
Expand Down
26 changes: 23 additions & 3 deletions ffmpegDocker
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg:3.4-scratch \

# Use ZeroMQ to toggle filter value on-fly

# Let's start some process continuously writing some radio music, and listen it:
# Let's start some process continuously writing some radio music and listen it:

docker run --rm -d -v $(pwd):$(pwd) -w $(pwd) -p 11235:11235 \
--name radio-writer jrottenberg/ffmpeg \
-i http://radio.casse-tete.solutions/salut-radio-64.mp3 \
-filter_complex '[0:a]volume@vol=1,azmq=bind_address=tcp\\\://0.0.0.0\\\:11235[out]' \
-filter_complex '[0:a]volume@vol=1azmq=bind_address=tcp\\\://0.0.0.0\\\:11235[out]' \
-map '[out]' ./salut-radio.mp3

ffplay ./salut-radio.mp3
Expand All @@ -30,4 +30,24 @@ docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg:3.4-scratch \
docker run -v $(pwd):$(pwd) -w $(pwd) \
jrottenberg/ffmpeg:3.4-scratch -stats \
-i https://env-0561487.jcloud-ver-jpe.ik-server.com/wp-content/uploads/sites/5/2020/07/High_Tech_Logo_2.mp4 \
-r 1 -f image2 ./tmp/image%03d.jpg
-r 1 -f image2 ./tmp/image%03d.gif

docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg \
-stats \
-i ./test/CF-Downloaded_test_default.mp4 \
-vf scale=-2:1080 -movflags +faststart \
-crf 17 -vcodec h264 -acodec aac -strict \
-2 -max_muxing_queue_size 512 -f mp4 ./test/test_WASM_CF-Downloaded.mp4


docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg \
-stats \
'-i', 'tears_of_steel_1080p.mp4', '-vf', 'scale=-2:1080', '-movflags',
'+faststart', '-crf', '17', '-vcodec', 'h264', '-acodec', 'aac', '-strict',
'-2', '-max_muxing_queue_size', '1024', '-f', 'mp4', 'tears_test.mp4'


docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg \
-stats \
-i ./test/CF-Downloaded_test_default.mp4 \
-vframes 1 -ss 0.5 -y ./test/CF-Thumbnail.jpeg
Empty file.
11 changes: 11 additions & 0 deletions nonovium_video_backend/gears/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin

from .models import GearFile

# Register your models here.


@admin.register(GearFile)
class GearFileAdmin(admin.ModelAdmin):
list_display = ("gear_id", "user", "file")
fields = ("user", "file")
6 changes: 6 additions & 0 deletions nonovium_video_backend/gears/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GearsConfig(AppConfig):
name = "nonovium_video_backend.gears"
verbose_name = "Gears"
27 changes: 27 additions & 0 deletions nonovium_video_backend/gears/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.1.13 on 2022-01-04 13:08

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import nonovium_video_backend.gears.models
import uuid


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='GearFile',
fields=[
('file', models.FileField(upload_to=nonovium_video_backend.gears.models.user_directory_path)),
('gear_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='gear_files', to=settings.AUTH_USER_MODEL)),
],
),
]
Empty file.
24 changes: 24 additions & 0 deletions nonovium_video_backend/gears/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import uuid

from django.db import models

# Create your models here.


def user_directory_path(instance, filename):
return "user_{0}/{1}".format(instance.user.id, filename)


class GearFile(models.Model):
file = models.FileField(upload_to=user_directory_path)
gear_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
user = models.ForeignKey(
"users.User",
on_delete=models.CASCADE,
related_name="gear_files",
null=True,
blank=True,
)

def __str__(self):
return str(self.gear_id)
3 changes: 3 additions & 0 deletions nonovium_video_backend/gears/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions nonovium_video_backend/gears/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.shortcuts import render

# Create your views here.
Empty file.
21 changes: 21 additions & 0 deletions nonovium_video_backend/pipelines/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from django.contrib import admin

from .models import VideoFile

# Register your models here.


@admin.register(VideoFile)
class VideoFileAdmin(admin.ModelAdmin):
list_display = ("user", "file")
fields = (
"user",
"file",
"title",
"width",
"height",
"size",
"duration",
"thumbnail",
)
readonly_fields = ("width", "height", "size", "duration")
6 changes: 6 additions & 0 deletions nonovium_video_backend/pipelines/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class PipelinesConfig(AppConfig):
name = "nonovium_video_backend.pipelines"
verbose_name = "Pipelines"
26 changes: 26 additions & 0 deletions nonovium_video_backend/pipelines/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.1.13 on 2022-01-04 11:12

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import nonovium_video_backend.pipelines.models


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='VideoFile',
fields=[
('file', models.FileField(upload_to=nonovium_video_backend.pipelines.models.user_directory_path)),
('video_id', models.UUIDField(default='$7b2a4f90-47be-411a-b5c7-b8c395efdc2f', primary_key=True, serialize=False)),
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='video_files', to=settings.AUTH_USER_MODEL)),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2022-01-04 11:12

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('pipelines', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='videofile',
name='video_id',
field=models.UUIDField(default='$fdc6d087-7243-4107-be33-ec1e3454805a', primary_key=True, serialize=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.1.13 on 2022-01-04 11:24

from django.db import migrations, models
import uuid


class Migration(migrations.Migration):

dependencies = [
('pipelines', '0002_auto_20220104_1112'),
]

operations = [
migrations.AlterField(
model_name='videofile',
name='video_id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Generated by Django 3.1.13 on 2022-01-04 13:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('pipelines', '0003_auto_20220104_1124'),
]

operations = [
migrations.AddField(
model_name='videofile',
name='duration',
field=models.FloatField(editable=False, null=True),
),
migrations.AddField(
model_name='videofile',
name='height',
field=models.PositiveIntegerField(editable=False, null=True),
),
migrations.AddField(
model_name='videofile',
name='size',
field=models.PositiveIntegerField(editable=False, null=True),
),
migrations.AddField(
model_name='videofile',
name='thumbnail',
field=models.ImageField(blank=True, null=True, upload_to=''),
),
migrations.AddField(
model_name='videofile',
name='title',
field=models.CharField(blank=True, max_length=255, null=True),
),
migrations.AddField(
model_name='videofile',
name='width',
field=models.PositiveIntegerField(editable=False, null=True),
),
]
Empty file.
33 changes: 33 additions & 0 deletions nonovium_video_backend/pipelines/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# from os.path import splitext
import uuid

from django.db import models

# Create your models here.


def user_directory_path(instance, filename):
return "user_{0}/{1}/{2}".format(instance.user.id, instance.video_id, filename)


class VideoFile(models.Model):
file = models.FileField(upload_to=user_directory_path)
video_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
title = models.CharField(max_length=255, null=True, blank=True)
width = models.PositiveIntegerField(editable=False, null=True)
height = models.PositiveIntegerField(editable=False, null=True)
size = models.PositiveIntegerField(editable=False, null=True)
duration = models.FloatField(editable=False, null=True)
thumbnail = models.ImageField(null=True, blank=True)
user = models.ForeignKey(
"users.User",
on_delete=models.CASCADE,
related_name="video_files",
null=True,
blank=True,
)

def __str__(self):
return str(self.video_id)

print(user_directory_path)
3 changes: 3 additions & 0 deletions nonovium_video_backend/pipelines/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.test import TestCase

# Create your tests here.
33 changes: 33 additions & 0 deletions nonovium_video_backend/pipelines/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import contextlib
import os
import tempfile
from typing import Generator

from django.core.files import File


@contextlib.contextmanager
def get_local_path(fieldfile: File) -> Generator[str, None, None]:
"""
Get a local file to work with from a file retrieved from a FileField.
"""
if not hasattr(fieldfile, "storage"):
# Its a local file with no storage abstraction
try:
yield os.path.abspath(fieldfile.path)
except AttributeError:
yield os.path.abspath(fieldfile.name)
else:
storage = fieldfile.storage
try:
# Try to access with path
yield storage.path(fieldfile.path)
except (NotImplementedError, AttributeError):
# Storage doesnt support absolute paths,
# download file to a temp local dir
with tempfile.NamedTemporaryFile(mode="wb", delete=False) as temp_file:
storage_file = storage.open(fieldfile.name, "rb")

temp_file.write(storage_file.read())
temp_file.flush()
yield temp_file.name
3 changes: 3 additions & 0 deletions nonovium_video_backend/pipelines/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# from django.shortcuts import render

# Create your views here.
18 changes: 18 additions & 0 deletions nonovium_video_backend/users/migrations/0032_auto_20220104_0124.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.1.13 on 2022-01-04 01:24

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('users', '0031_auto_20211028_1645'),
]

operations = [
migrations.AlterField(
model_name='user',
name='user_image',
field=models.CharField(default='https://avatars.dicebear.com/api/avataaars/34436.svg?size=150', max_length=250, verbose_name='Profile Image URL'),
),
]
Loading

0 comments on commit fc1daa3

Please sign in to comment.