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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
videoag
dominic_render_video
Commits
1dfe8355
Verified
Commit
1dfe8355
authored
May 26, 2024
by
Dominic Meiser
Browse files
Options
Downloads
Patches
Plain Diff
move project structs into their own mod
parent
b6bd1be1
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.rs
+5
-162
5 additions, 162 deletions
src/main.rs
src/render/mod.rs
+2
-2
2 additions, 2 deletions
src/render/mod.rs
with
7 additions
and
164 deletions
src/main.rs
+
5
−
162
View file @
1dfe8355
...
@@ -3,30 +3,26 @@
...
@@ -3,30 +3,26 @@
#![forbid(elided_lifetimes_in_paths,
unsafe_code)]
#![forbid(elided_lifetimes_in_paths,
unsafe_code)]
mod
iotro
;
mod
iotro
;
mod
project
;
mod
question
;
mod
question
;
mod
render
;
mod
render
;
mod
time
;
mod
time
;
use
self
::{
use
self
::{
iotro
::
Language
,
iotro
::
Language
,
question
::
Ques
tion
,
project
::{
Project
,
ProjectLecture
,
ProjectSource
,
Resolu
tion
}
,
render
::
{
ffmpeg
::
FfmpegOutputFormat
,
Renderer
}
,
render
::
Renderer
,
time
::{
parse_date
,
parse_time
,
Date
,
Time
}
time
::{
parse_date
,
parse_time
,
Time
}
};
};
use
camino
::
Utf8PathBuf
as
PathBuf
;
use
camino
::
Utf8PathBuf
as
PathBuf
;
use
clap
::
Parser
;
use
clap
::
Parser
;
use
console
::
style
;
use
console
::
style
;
use
rational
::
Rational
;
use
serde
::{
Deserialize
,
Serialize
};
use
serde_with
::{
serde_as
,
DisplayFromStr
};
#[cfg(feature
=
"mem_limit"
)]
#[cfg(feature
=
"mem_limit"
)]
use
std
::
sync
::
RwLock
;
use
std
::
sync
::
RwLock
;
use
std
::{
use
std
::{
collections
::
BTreeSet
,
fmt
::
Display
,
fmt
::
Display
,
fs
,
fs
,
io
::{
self
,
BufRead
as
_
,
Write
},
io
::{
self
,
BufRead
as
_
,
Write
}
str
::
FromStr
};
};
#[cfg(feature
=
"mem_limit"
)]
#[cfg(feature
=
"mem_limit"
)]
...
@@ -73,159 +69,6 @@ struct Args {
...
@@ -73,159 +69,6 @@ struct Args {
stereo
:
bool
stereo
:
bool
}
}
macro_rules!
resolutions
{
(
$
(
$res:ident
:
$width:literal
x
$height:literal
at
$bitrate:literal
in
$format:ident
),
+
)
=>
{
#[allow(non_camel_case_types,
clippy::upper_case_acronyms)]
#[derive(Clone,
Copy,
Debug,
Deserialize,
Eq,
Ord,
PartialEq,
PartialOrd,
Serialize)]
enum
Resolution
{
$
(
#[doc
=
concat
!
(stringify
!
(
$
width),
"x"
,
stringify
!
(
$
height))]
$res
),
+
}
const
NUM_RESOLUTIONS
:
usize
=
{
let
mut
num
=
0
;
$
(
num
+=
1
;
stringify!
(
$res
);)
+
num
};
impl
Resolution
{
fn
values
()
->
[
Self
;
NUM_RESOLUTIONS
]
{
[
$
(
Self
::
$res
),
+
]
}
fn
width
(
self
)
->
usize
{
match
self
{
$
(
Self
::
$res
=>
$width
),
+
}
}
fn
height
(
self
)
->
usize
{
match
self
{
$
(
Self
::
$res
=>
$height
),
+
}
}
fn
bitrate
(
self
)
->
u64
{
match
self
{
$
(
Self
::
$res
=>
$bitrate
),
+
}
}
fn
format
(
self
)
->
FfmpegOutputFormat
{
match
self
{
$
(
Self
::
$res
=>
FfmpegOutputFormat
::
$format
),
+
}
}
}
impl
FromStr
for
Resolution
{
type
Err
=
anyhow
::
Error
;
fn
from_str
(
s
:
&
str
)
->
anyhow
::
Result
<
Self
>
{
Ok
(
match
s
{
$
(
concat!
(
stringify!
(
$height
),
"p"
)
=>
Self
::
$res
,)
+
_
=>
anyhow
::
bail!
(
"Unknown Resolution: {s:?}"
)
})
}
}
}
}
resolutions!
{
nHD
:
640
x
360
at
500_000
in
AvcAac
,
HD
:
1280
x
720
at
1_000_000
in
AvcAac
,
FullHD
:
1920
x
1080
at
750_000
in
Av1Opus
,
WQHD
:
2560
x
1440
at
1_000_000
in
Av1Opus
,
// TODO qsx muss mal sagen wieviel bitrate für 4k
UHD
:
3840
x
2160
at
2_000_000
in
Av1Opus
}
#[derive(Deserialize,
Serialize)]
struct
Project
{
lecture
:
ProjectLecture
,
source
:
ProjectSource
,
progress
:
ProjectProgress
}
#[serde_as]
#[derive(Deserialize,
Serialize)]
struct
ProjectLecture
{
course
:
String
,
label
:
String
,
docent
:
String
,
#[serde_as(as
=
"DisplayFromStr"
)]
date
:
Date
,
#[serde(default
=
"Default::default"
)]
#[serde_as(as
=
"DisplayFromStr"
)]
lang
:
Language
<
'static
>
}
#[serde_as]
#[derive(Deserialize,
Serialize)]
struct
ProjectSource
{
files
:
Vec
<
String
>
,
stereo
:
bool
,
#[serde_as(as
=
"Option<DisplayFromStr>"
)]
start
:
Option
<
Time
>
,
#[serde_as(as
=
"Option<DisplayFromStr>"
)]
end
:
Option
<
Time
>
,
#[serde(default)]
#[serde_as(as
=
"Vec<(DisplayFromStr, DisplayFromStr)>"
)]
fast
:
Vec
<
(
Time
,
Time
)
>
,
#[serde(default)]
#[serde_as(as
=
"Vec<(DisplayFromStr, DisplayFromStr, _)>"
)]
questions
:
Vec
<
(
Time
,
Time
,
String
)
>
,
metadata
:
Option
<
ProjectSourceMetadata
>
}
#[serde_as]
#[derive(Deserialize,
Serialize)]
struct
ProjectSourceMetadata
{
/// The duration of the source video.
#[serde_as(as
=
"DisplayFromStr"
)]
source_duration
:
Time
,
/// The FPS of the source video.
#[serde_as(as
=
"DisplayFromStr"
)]
source_fps
:
Rational
,
/// The time base of the source video.
#[serde_as(as
=
"DisplayFromStr"
)]
source_tbn
:
Rational
,
/// The resolution of the source video.
source_res
:
Resolution
,
/// The sample rate of the source audio.
source_sample_rate
:
u32
}
#[derive(Default,
Deserialize,
Serialize)]
struct
ProjectProgress
{
#[serde(default)]
preprocessed
:
bool
,
#[serde(default)]
asked_start_end
:
bool
,
#[serde(default)]
asked_fast
:
bool
,
#[serde(default)]
asked_questions
:
bool
,
#[serde(default)]
rendered_assets
:
bool
,
#[serde(default)]
rendered
:
bool
,
#[serde(default)]
transcoded
:
BTreeSet
<
Resolution
>
}
fn
ask
(
question
:
impl
Display
)
->
String
{
fn
ask
(
question
:
impl
Display
)
->
String
{
let
mut
stdout
=
io
::
stdout
()
.lock
();
let
mut
stdout
=
io
::
stdout
()
.lock
();
let
mut
stdin
=
io
::
stdin
()
.lock
();
let
mut
stdin
=
io
::
stdin
()
.lock
();
...
...
This diff is collapsed.
Click to expand it.
src/render/mod.rs
+
2
−
2
View file @
1dfe8355
...
@@ -7,10 +7,10 @@ use self::{
...
@@ -7,10 +7,10 @@ use self::{
};
};
use
crate
::{
use
crate
::{
iotro
::{
intro
,
outro
},
iotro
::{
intro
,
outro
},
project
::{
Project
,
ProjectLecture
,
ProjectSourceMetadata
,
Resolution
},
question
::
Question
,
question
::
Question
,
render
::
ffmpeg
::{
Ffmpeg
,
FfmpegInput
},
render
::
ffmpeg
::{
Ffmpeg
,
FfmpegInput
},
time
::{
format_date
,
format_time
,
Time
},
time
::{
format_date
,
format_time
,
Time
}
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
};
...
...
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