Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dominic_render_video
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
videoag
dominic_render_video
Commits
98f415ad
Verified
Commit
98f415ad
authored
1 year ago
by
Dominic Meiser
Browse files
Options
Downloads
Patches
Plain Diff
add metadata to transcoded videos
parent
9a4b3142
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/iotro.rs
+13
-6
13 additions, 6 deletions
src/iotro.rs
src/main.rs
+1
-1
1 addition, 1 deletion
src/main.rs
src/render/ffmpeg.rs
+28
-0
28 additions, 0 deletions
src/render/ffmpeg.rs
src/render/mod.rs
+19
-2
19 additions, 2 deletions
src/render/mod.rs
with
61 additions
and
9 deletions
src/iotro.rs
+
13
−
6
View file @
98f415ad
...
@@ -13,16 +13,18 @@ use svgwriter::{
...
@@ -13,16 +13,18 @@ use svgwriter::{
#[derive(Clone)]
#[derive(Clone)]
pub
struct
Language
<
'a
>
{
pub
struct
Language
<
'a
>
{
lang
:
&
'a
str
,
pub
(
crate
)
lang
:
&
'a
str
,
format_date_long
:
fn
(
Date
)
->
String
,
pub
(
crate
)
format_date_long
:
fn
(
Date
)
->
String
,
// intro
// intro
lecture_from
:
&
'a
str
,
lecture_from
:
&
'a
str
,
video_created_by_us
:
&
'a
str
,
pub
(
crate
)
video_created_by_us
:
&
'a
str
,
// outro
// outro
video_created_by
:
&
'a
str
,
video_created_by
:
&
'a
str
,
our_website
:
&
'a
str
,
our_website
:
&
'a
str
,
download_videos
:
&
'a
str
,
download_videos
:
&
'a
str
,
questions_feedback
:
&
'a
str
questions_feedback
:
&
'a
str
,
// metadata
pub
(
crate
)
from
:
&
'a
str
}
}
pub
const
GERMAN
:
Language
<
'static
>
=
Language
{
pub
const
GERMAN
:
Language
<
'static
>
=
Language
{
...
@@ -54,7 +56,9 @@ pub const GERMAN: Language<'static> = Language {
...
@@ -54,7 +56,9 @@ pub const GERMAN: Language<'static> = Language {
video_created_by
:
"Video erstellt von der"
,
video_created_by
:
"Video erstellt von der"
,
our_website
:
"Website der Fachschaft"
,
our_website
:
"Website der Fachschaft"
,
download_videos
:
"Videos herunterladen"
,
download_videos
:
"Videos herunterladen"
,
questions_feedback
:
"Fragen, Vorschläge und Feedback"
questions_feedback
:
"Fragen, Vorschläge und Feedback"
,
from
:
"vom"
};
};
pub
const
BRITISH
:
Language
<
'static
>
=
Language
{
pub
const
BRITISH
:
Language
<
'static
>
=
Language
{
...
@@ -88,10 +92,13 @@ pub const BRITISH: Language<'static> = Language {
...
@@ -88,10 +92,13 @@ pub const BRITISH: Language<'static> = Language {
lecture_from
:
"Lecture from"
,
lecture_from
:
"Lecture from"
,
video_created_by_us
:
"Video created by the Video AG, Fachschaft I/1"
,
video_created_by_us
:
"Video created by the Video AG, Fachschaft I/1"
,
video_created_by
:
"Video created by the"
,
video_created_by
:
"Video created by the"
,
our_website
:
"The Fachschaft's website"
,
our_website
:
"The Fachschaft's website"
,
download_videos
:
"Download videos"
,
download_videos
:
"Download videos"
,
questions_feedback
:
"Questions, Suggestions and Feedback"
questions_feedback
:
"Questions, Suggestions and Feedback"
,
from
:
"from"
};
};
impl
Default
for
Language
<
'static
>
{
impl
Default
for
Language
<
'static
>
{
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
1
−
1
View file @
98f415ad
...
@@ -369,7 +369,7 @@ fn main() {
...
@@ -369,7 +369,7 @@ fn main() {
continue
;
continue
;
}
}
if
!
project
.progress.transcoded
.contains
(
&
res
)
{
if
!
project
.progress.transcoded
.contains
(
&
res
)
{
videos
.push
(
renderer
.rescale
(
res
)
.unwrap
());
videos
.push
(
renderer
.rescale
(
&
project
.lecture
,
res
)
.unwrap
());
project
.progress.transcoded
.insert
(
res
);
project
.progress.transcoded
.insert
(
res
);
fs
::
write
(
&
project_path
,
toml
::
to_string
(
&
project
)
.unwrap
()
.as_bytes
())
fs
::
write
(
&
project_path
,
toml
::
to_string
(
&
project
)
.unwrap
()
.as_bytes
())
...
...
This diff is collapsed.
Click to expand it.
src/render/ffmpeg.rs
+
28
−
0
View file @
98f415ad
...
@@ -74,6 +74,14 @@ pub(crate) struct FfmpegOutput {
...
@@ -74,6 +74,14 @@ pub(crate) struct FfmpegOutput {
pub
(
crate
)
fps_mode_vfr
:
bool
,
pub
(
crate
)
fps_mode_vfr
:
bool
,
pub
(
crate
)
faststart
:
bool
,
pub
(
crate
)
faststart
:
bool
,
// video container metadata
pub
(
crate
)
title
:
Option
<
String
>
,
pub
(
crate
)
author
:
Option
<
String
>
,
pub
(
crate
)
album
:
Option
<
String
>
,
pub
(
crate
)
year
:
Option
<
String
>
,
pub
(
crate
)
comment
:
Option
<
String
>
,
pub
(
crate
)
language
:
Option
<
String
>
,
pub
(
crate
)
path
:
PathBuf
pub
(
crate
)
path
:
PathBuf
}
}
...
@@ -83,11 +91,20 @@ impl FfmpegOutput {
...
@@ -83,11 +91,20 @@ impl FfmpegOutput {
format
,
format
,
audio_bitrate
:
None
,
audio_bitrate
:
None
,
video_bitrate
:
None
,
video_bitrate
:
None
,
fps
:
None
,
fps
:
None
,
duration
:
None
,
duration
:
None
,
time_base
:
None
,
time_base
:
None
,
fps_mode_vfr
:
false
,
fps_mode_vfr
:
false
,
faststart
:
false
,
faststart
:
false
,
title
:
None
,
author
:
None
,
album
:
None
,
year
:
None
,
comment
:
None
,
language
:
None
,
path
path
}
}
}
}
...
@@ -161,6 +178,17 @@ impl FfmpegOutput {
...
@@ -161,6 +178,17 @@ impl FfmpegOutput {
if
self
.faststart
{
if
self
.faststart
{
cmd
.arg
(
"-movflags"
)
.arg
(
"+faststart"
);
cmd
.arg
(
"-movflags"
)
.arg
(
"+faststart"
);
}
}
// metadata
macro_rules!
add_meta
{
(
$this:ident
,
$cmd:ident
:
$
(
$meta:ident
),
+
)
=>
{
$
(
if
let
Some
(
value
)
=
$this
.
$meta
.as_deref
()
{
$cmd
.arg
(
"-metadata"
)
.arg
(
format!
(
"{}={}"
,
stringify!
(
$meta
),
value
));
})
+
}
}
add_meta!
(
self
,
cmd
:
title
,
author
,
album
,
year
,
comment
,
language
);
cmd
.arg
(
self
.path
);
cmd
.arg
(
self
.path
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/render/mod.rs
+
19
−
2
View file @
98f415ad
...
@@ -9,7 +9,7 @@ use crate::{
...
@@ -9,7 +9,7 @@ use crate::{
iotro
::{
intro
,
outro
},
iotro
::{
intro
,
outro
},
render
::
ffmpeg
::{
Ffmpeg
,
FfmpegInput
},
render
::
ffmpeg
::{
Ffmpeg
,
FfmpegInput
},
time
::{
format_date
,
Time
},
time
::{
format_date
,
Time
},
Project
,
ProjectSourceMetadata
,
Resolution
Project
,
ProjectLecture
,
ProjectSourceMetadata
,
Resolution
};
};
use
anyhow
::{
bail
,
Context
};
use
anyhow
::{
bail
,
Context
};
use
camino
::{
Utf8Path
as
Path
,
Utf8PathBuf
as
PathBuf
};
use
camino
::{
Utf8Path
as
Path
,
Utf8PathBuf
as
PathBuf
};
...
@@ -501,13 +501,30 @@ impl<'a> Renderer<'a> {
...
@@ -501,13 +501,30 @@ impl<'a> Renderer<'a> {
Ok
(
output
)
Ok
(
output
)
}
}
pub
fn
rescale
(
&
self
,
res
:
Resolution
)
->
anyhow
::
Result
<
PathBuf
>
{
pub
fn
rescale
(
&
self
,
lecture
:
&
ProjectLecture
,
res
:
Resolution
)
->
anyhow
::
Result
<
PathBuf
>
{
let
input
=
self
.video_file_output
();
let
input
=
self
.video_file_output
();
let
output
=
self
.video_file_res
(
res
);
let
output
=
self
.video_file_res
(
res
);
println!
(
"
\x1B
[1m ==> Rescaling to {}p
\x1B
[0m"
,
res
.height
());
println!
(
"
\x1B
[1m ==> Rescaling to {}p
\x1B
[0m"
,
res
.height
());
let
mut
ffmpeg
=
Ffmpeg
::
new
(
FfmpegOutput
{
let
mut
ffmpeg
=
Ffmpeg
::
new
(
FfmpegOutput
{
video_bitrate
:
Some
(
res
.bitrate
()),
video_bitrate
:
Some
(
res
.bitrate
()),
title
:
Some
(
format!
(
"{} {} {}"
,
lecture
.label
,
lecture
.lang.from
,
(
lecture
.lang.format_date_long
)(
lecture
.date
)
)),
author
:
Some
(
lecture
.docent
.clone
()),
album
:
Some
(
lecture
.course
.clone
()),
year
:
Some
(
lecture
.date.year
.to_string
()),
comment
:
Some
(
lecture
.lang.video_created_by_us
.into
()),
language
:
Some
(
lecture
.lang.lang
.into
()),
..
FfmpegOutput
::
new
(
res
.format
(),
output
.clone
())
.enable_faststart
()
..
FfmpegOutput
::
new
(
res
.format
(),
output
.clone
())
.enable_faststart
()
});
});
ffmpeg
.add_input
(
FfmpegInput
::
new
(
input
));
ffmpeg
.add_input
(
FfmpegInput
::
new
(
input
));
...
...
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