Skip to content

Commit 98b323a

Browse files
Merge pull request #42 from Web-Multi-Media/Sync_subtitle
Improve subtitles handling
2 parents 1501b30 + 5feb860 commit 98b323a

41 files changed

Lines changed: 1373 additions & 279 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This project is a video presentation server based on Django Rest Framework and R
88

99

1010
Support is currently limited to H264 encoded content.
11-
Subtitles are added automatically if an adequate match is found (after a conversion from .srt to webvtt).
11+
Subtitles are added automatically if an adequate match is found. You can also upload you own subtitle or resync existing ones.
1212

1313

1414
How to use
@@ -30,7 +30,7 @@ Migrate the database:
3030

3131
Populate the database:
3232

33-
docker-compose -f docker-compose-prod.yml run --rm web python3 manage.py populatedb
33+
docker-compose -f docker-compose-prod.yml run --rm web ./wait-for-it.sh db:5432 -- python3 manage.py populatedb
3434

3535
Run the server:
3636

@@ -41,17 +41,17 @@ Now the application should be accessible from your browser at `http://localhost:
4141

4242
#### CONFIGURATION
4343

44-
The videos contained in the Videos/ folder are updated everytime the app is launched.
44+
The videos contained in the Videos/ folder are indexed everytime the populatedb command is launched.
4545

46-
If you want to manually triggers an update, use the following command
46+
If you want to trigger an update, use the following command
4747

48-
docker-compose -f docker-compose-prod.yml run --rm web python3 manage.py populatedb
48+
docker-compose -f docker-compose-prod.yml run --rm web python3 manage.py updatedb
4949

50-
If you want to reload videos while the app is running, you need to have a superuser created.
50+
If you want to manually modify the data, you can access the admin page with a superuser account. For that, create one with the following command.
5151

5252
docker-compose -f docker-compose-prod.yml run --rm web python3 manage.py createsuperuser
5353

54-
then go to `http://localhost:1337/admin/`, select all Videos and check 'reload Videos' actions.
54+
then go to `http://localhost:1337/admin/`.
5555

5656
The following variables can be configured in .env file:
5757

Videos/folder2/spongebob2.mp4

194 KB
Binary file not shown.

Videos/subtitles/spongebob.srt

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
1
2+
00:00:00,918 --> 00:00:02,294
3+
[alarm clock sounding]
4+
5+
2
6+
00:00:02,377 --> 00:00:03,754
7+
Time for boating school.
8+
9+
3
10+
00:00:04,046 --> 00:00:05,214
11+
Let her rip, Gary.
12+
13+
4
14+
00:00:12,054 --> 00:00:13,138
15+
Ah.
16+
17+
5
18+
00:00:19,019 --> 00:00:20,354
19+
Ta-da!
20+
21+
6
22+
00:00:20,437 --> 00:00:22,523
23+
Not bad, partner in crime.
24+
25+
7
26+
00:00:22,773 --> 00:00:24,983
27+
The toast could have been
28+
a little darker though.
29+
30+
8
31+
00:00:25,108 --> 00:00:26,109
32+
See you later.
33+
34+
9
35+
00:00:26,193 --> 00:00:27,277
36+
Hey SpongeBob.
37+
38+
10
39+
00:00:27,361 --> 00:00:28,820
40+
Wanna go jellyfishing?
41+
42+
11
43+
00:00:28,946 --> 00:00:31,240
44+
Sorry Patrick, I can't.
45+
I have school today.
46+
47+
12
48+
00:00:31,365 --> 00:00:34,451
49+
What am I supposed to do all
50+
day while you're at school?
51+
52+
13
53+
00:00:34,576 --> 00:00:36,995
54+
I don't know.
55+
What do you normally do when I'm gone?
56+
57+
14
58+
00:00:37,120 --> 00:00:39,373
59+
Wait for you to get back.
60+
61+
15
62+
00:00:39,957 --> 00:00:43,794
63+
Wait a second, Patrick.
64+
Why don't you come to school with me?
65+
66+
16
67+
00:00:43,919 --> 00:00:45,838
68+
Hey, that's a great idea.
69+
70+
17
71+
00:00:45,963 --> 00:00:49,633
72+
You and me in school together
73+
as classmates. Think about it!
74+
75+
18
76+
00:00:53,262 --> 00:00:54,304
77+
Wow.
78+
79+
19
80+
00:00:54,888 --> 00:00:58,976
81+
♪ Road, road, road, road ♪
82+
83+
20
84+
00:00:59,101 --> 00:01:00,435
85+
♪ Road, road ♪
86+
87+
21
88+
00:01:00,561 --> 00:01:03,355
89+
♪ When I'm on the road ♪
90+

Videos/subtitles/test.srt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
1
2+
00:00:00,000 --> 00:00:01,500
3+
For www.forom.com
4+
5+
2
6+
00:00:01,500 --> 00:00:02,500
7+
<i>Tonight's the night.</i>
8+
9+
3
10+
00:00:03,000 --> 00:00:15,000
11+
<i>And it's going to happen
12+
again and again --</i>

Videos/subtitles/unicode_fr.srt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
1
2+
00:01:16,924 --> 00:01:19,051
3+
<i>Vous ne passerez pas !</i>
4+
5+
2
6+
00:01:19,176 --> 00:01:20,387
7+
<i>Gandalf !</i>
8+
9+
3
10+
00:01:25,559 --> 00:01:27,769
11+
<i>Je suis un Serviteur de Feu Secret,</i>
12+
13+
4
14+
00:01:27,894 --> 00:01:30,938
15+
<i>D�tenteur de la flamme d'Anor.</i>
16+

backend/.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
frontend/node_modules
2+
node_modules

backend/Dockerfile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11

2-
FROM python:3.6
2+
FROM python:3.8
33

4-
RUN apt-get update -y && apt-get install -y ffmpeg
4+
RUN apt-get update -y && apt-get install -y ffmpeg
5+
6+
COPY ./backend/openssl.cnf /etc/ssl/openssl.cnf
57

68
ENV PYTHONUNBUFFERED 1
7-
COPY . /usr/src/app/
9+
COPY ./backend/ /usr/src/app/
810
WORKDIR /usr/src/app
911

1012
RUN pip3 install -r requirements.txt

backend/Dockerfile.prod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ RUN npm run build
1010

1111
#Build the backend
1212

13-
FROM python:3.6
13+
FROM python:3.8
1414

15-
RUN apt-get update -y && apt-get install -y ffmpeg
15+
RUN apt-get update -y && apt-get install -y ffmpeg
16+
17+
COPY ./backend/openssl.cnf /etc/ssl/openssl.cnf
1618

1719
ENV PYTHONUNBUFFERED 1
1820
COPY --from=0 /usr/src/frontend/build/ /usr/src/frontend/build/

backend/StreamServerApp/admin.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
from django.contrib import admin
2-
from StreamServerApp.models import Video
2+
from StreamServerApp.models import Video, Movie, Series, Subtitle
33
from StreamServerApp.database_utils import delete_DB_Infos, populate_db_from_local_folder, update_db_from_local_folder
44
from django.conf import settings
55

66

7-
def populate_videos(modeladmin, request, queryset):
8-
delete_DB_Infos()
9-
populate_db_from_local_folder(settings.VIDEO_ROOT, settings.VIDEO_URL)
10-
populate_videos.short_description = "Populate videos database"
11-
12-
13-
def update_videos(modeladmin, request, queryset):
14-
update_db_from_local_folder(settings.VIDEO_ROOT, settings.VIDEO_URL)
15-
update_videos.short_description = "Update videos database"
16-
17-
187
class VideoAdmin(admin.ModelAdmin):
19-
actions = []
20-
8+
search_fields = ['name']
219

2210
admin.site.register(Video, VideoAdmin)
23-
admin.site.add_action(populate_videos)
24-
admin.site.add_action(update_videos)
11+
admin.site.register(Movie)
12+
admin.site.register(Series)
13+
admin.site.register(Subtitle)

0 commit comments

Comments
 (0)