Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vincent Wehrwein
website
Commits
343b8b96
Commit
343b8b96
authored
5 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Continued auto-intro integration (untested)
parent
53ee1c77
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
encoding.py
+36
-12
36 additions, 12 deletions
encoding.py
with
36 additions
and
12 deletions
encoding.py
+
36
−
12
View file @
343b8b96
...
@@ -12,13 +12,6 @@ def set_metadata(dest, course, lecture):
...
@@ -12,13 +12,6 @@ def set_metadata(dest, course, lecture):
dest
[
'
metadata
'
]
=
metadata
dest
[
'
metadata
'
]
=
metadata
dest
[
'
chapters
'
]
=
chapters
dest
[
'
chapters
'
]
=
chapters
def
schedule_intro
(
lectureid
):
lecture
=
query
(
'
SELECT * FROM lectures where id = ?
'
,
lectureid
)
course
=
query
(
'
SELECT * FROM course where id = ?
'
,
lecture
[
'
course_id
'
])
data
=
{
'
path
'
:
path
,
'
lecture_id
'
:
lectureid
}
set_metadata
(
data
,
course
,
lecture
)
schedule_job
(
'
intro
'
,
data
)
def
schedule_remux
(
lectureid
,
videoid
=
None
):
def
schedule_remux
(
lectureid
,
videoid
=
None
):
lecture
=
query
(
'
SELECT * FROM lectures WHERE id = ?
'
,
lectureid
)[
0
]
lecture
=
query
(
'
SELECT * FROM lectures WHERE id = ?
'
,
lectureid
)[
0
]
course
=
query
(
'
SELECT * FROM courses WHERE id = ?
'
,
lecture
[
'
course_id
'
])[
0
]
course
=
query
(
'
SELECT * FROM courses WHERE id = ?
'
,
lecture
[
'
course_id
'
])[
0
]
...
@@ -52,7 +45,7 @@ def add_remux_job():
...
@@ -52,7 +45,7 @@ def add_remux_job():
schedule_remux
(
lectureid
,
videoid
)
schedule_remux
(
lectureid
,
videoid
)
return
redirect
(
request
.
values
.
get
(
'
ref
'
,
url_for
(
'
jobs_overview
'
)))
return
redirect
(
request
.
values
.
get
(
'
ref
'
,
url_for
(
'
jobs_overview
'
)))
def
schedule_transcode
(
source
,
fmt_id
=
None
,
video
=
None
):
def
schedule_transcode
(
source
,
fmt_id
=
None
,
video
=
None
,
intro_path
=
None
):
if
video
:
if
video
:
fmt_id
=
video
[
'
video_format
'
]
fmt_id
=
video
[
'
video_format
'
]
assert
(
video
[
'
lecture_id
'
]
==
source
[
'
lecture_id
'
])
assert
(
video
[
'
lecture_id
'
]
==
source
[
'
lecture_id
'
])
...
@@ -62,10 +55,23 @@ def schedule_transcode(source, fmt_id=None, video=None):
...
@@ -62,10 +55,23 @@ def schedule_transcode(source, fmt_id=None, video=None):
course
=
query
(
'
SELECT * FROM courses WHERE id = ?
'
,
lecture
[
'
course_id
'
])[
0
]
course
=
query
(
'
SELECT * FROM courses WHERE id = ?
'
,
lecture
[
'
course_id
'
])[
0
]
data
=
{
'
input
'
:
{
'
path
'
:
source
[
'
path
'
],
'
streams
'
:
[]},
'
output
'
:
json
.
loads
(
fmt
[
'
options
'
]),
'
filters
'
:
[]}
data
=
{
'
input
'
:
{
'
path
'
:
source
[
'
path
'
],
'
streams
'
:
[]},
'
output
'
:
json
.
loads
(
fmt
[
'
options
'
]),
'
filters
'
:
[]}
if
source
[
'
type
'
]
==
'
plain
'
:
if
source
[
'
type
'
]
==
'
plain
'
:
stream
=
{
'
name
'
:
'
video
'
,
'
type
'
:
'
video
'
}
data
[
'
input
'
][
'
streams
'
].
append
({
'
name
'
:
'
video
'
,
'
type
'
:
'
video
'
})
data
[
'
input
'
][
'
streams
'
].
append
(
stream
)
data
[
'
input
'
][
'
streams
'
].
append
({
'
name
'
:
'
audio
'
,
'
type
'
:
'
audio
'
})
stream
=
{
'
name
'
:
'
audio
'
,
'
type
'
:
'
audio
'
}
elif
source
[
'
type
'
]
==
'
autointro
'
:
data
[
'
input
'
][
'
streams
'
].
append
(
stream
)
if
not
intro_path
:
ctx
=
{
'
source_id
'
:
source
[
'
id
'
],
'
fmt_id
'
:
fmt
[
'
id
'
]}
if
video
:
ctx
[
'
video_id
'
]
=
video
[
'
id
'
]
schedule_intro
(
lecture
[
'
lecture_id
'
],
transcode_ctx
=
ctx
)
return
data
[
'
input
'
][
'
streams
'
].
append
({
'
name
'
:
'
src_video
'
,
'
type
'
:
'
video
'
})
data
[
'
input
'
][
'
streams
'
].
append
({
'
name
'
:
'
src_audio
'
,
'
type
'
:
'
audio
'
})
data
[
'
filters
'
].
append
(
'
movie=$WORKER_RAW/%s, loop=loop=-1:size=1:start=0, fade=out:st=7:d=1, trim=duration=8[intro_video]
'
%
intro_path
)
data
[
'
filters
'
].
append
(
'
anullsrc,atrim=duration=8[intro_audio]
'
)
data
[
'
filters
'
].
append
(
'
movie=$WORKER_RAW/outro_slide.png, loop=loop=-1:size=1:start=0, fade=in:st=0:d=1, trim=duration=5[outro_video]
'
)
data
[
'
filters
'
].
append
(
'
anullsrc,atrim=duration=5[outro_audio]
'
)
data
[
'
filters
'
].
append
(
'
[src_video]fade=in:st=0:d=1[tmp_video]
'
)
data
[
'
filters
'
].
append
(
'
[intro_video] [intro_audio] [tmp_video] [src_audio] [outro_video] [outro_audio] concat=n=3:a=1 [video] [audio]
'
)
else
:
else
:
assert
(
False
)
assert
(
False
)
set_metadata
(
data
[
'
output
'
],
course
,
lecture
)
set_metadata
(
data
[
'
output
'
],
course
,
lecture
)
...
@@ -92,6 +98,24 @@ def insert_transcoded_video(jobid, jobtype, data, state, status):
...
@@ -92,6 +98,24 @@ def insert_transcoded_video(jobid, jobtype, data, state, status):
video_id
=
insert_video
(
data
[
'
lecture_id
'
],
data
[
'
output
'
][
'
path
'
],
data
[
'
format_id
'
],
status
[
'
hash
'
],
status
[
'
filesize
'
],
status
[
'
duration
'
],
data
[
'
source_id
'
])
video_id
=
insert_video
(
data
[
'
lecture_id
'
],
data
[
'
output
'
][
'
path
'
],
data
[
'
format_id
'
],
status
[
'
hash
'
],
status
[
'
filesize
'
],
status
[
'
duration
'
],
data
[
'
source_id
'
])
schedule_remux
(
data
[
'
lecture_id
'
],
video_id
)
schedule_remux
(
data
[
'
lecture_id
'
],
video_id
)
def
schedule_intro
(
lecture_id
,
**
data
):
lecture
=
query
(
'
SELECT * FROM lectures where id = ?
'
,
lecture_id
)
course
=
query
(
'
SELECT * FROM course where id = ?
'
,
lecture
[
'
course_id
'
])
data
[
'
path
'
]
=
'
intros/l_%i.png
'
%
lecture
[
'
id
'
]
data
[
'
lecture_id
'
]
=
lecture_id
set_metadata
(
data
,
course
,
lecture
)
schedule_job
(
'
intro
'
,
data
)
@job_handler
(
'
intro
'
)
def
transcode_after_intro
(
jobid
,
jobtype
,
data
,
state
,
status
):
if
'
transcode_ctx
'
not
in
data
:
return
source
=
query
(
'
SELECT * FROM sources WHERE id = ?
'
,
data
[
'
transcode_ctx
'
][
'
source_id
'
])[
0
]
video
=
None
if
data
[
'
transcode_ctx
'
].
get
(
'
video_id
'
):
video
=
query
(
'
SELECT * FROM videos WHERE id = ?
'
,
data
[
'
transcode_ctx
'
][
'
video_id
'
])
schedule_transcode
(
source
,
data
[
'
transcode_ctx
'
][
'
fmt_id
'
],
video
=
video
,
intro_path
=
data
[
'
path
'
])
@app.route
(
'
/internal/jobs/add/reencode
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@app.route
(
'
/internal/jobs/add/reencode
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@mod_required
@mod_required
@csrf_protect
@csrf_protect
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment