use -ss/-t instead of trim
This commit is contained in:
parent
2a8ba70e23
commit
f4fe73bf5f
2 changed files with 13 additions and 22 deletions
|
@ -40,6 +40,7 @@ impl FfmpegInput {
|
||||||
cmd.arg("-r").arg(fps.to_string());
|
cmd.arg("-r").arg(fps.to_string());
|
||||||
}
|
}
|
||||||
if let Some(start) = self.start {
|
if let Some(start) = self.start {
|
||||||
|
cmd.arg("-seek_streams_individually").arg("false");
|
||||||
cmd.arg("-ss").arg(format_time(start));
|
cmd.arg("-ss").arg(format_time(start));
|
||||||
}
|
}
|
||||||
if let Some(duration) = self.duration {
|
if let Some(duration) = self.duration {
|
||||||
|
|
|
@ -279,7 +279,7 @@ impl<'a> Renderer<'a> {
|
||||||
|
|
||||||
// add all of our inputs
|
// add all of our inputs
|
||||||
let intro = ffmpeg.add_input(FfmpegInput::new(self.target.join("intro.mp4")));
|
let intro = ffmpeg.add_input(FfmpegInput::new(self.target.join("intro.mp4")));
|
||||||
let rec = ffmpeg.add_input(FfmpegInput::new(self.target.join("recording.mp4")));
|
let rec_file = self.target.join("recording.mp4");
|
||||||
let outro = ffmpeg.add_input(FfmpegInput::new(self.target.join("outro.mp4")));
|
let outro = ffmpeg.add_input(FfmpegInput::new(self.target.join("outro.mp4")));
|
||||||
let logo = ffmpeg.add_input(FfmpegInput::new(self.target.join("logo.png")));
|
let logo = ffmpeg.add_input(FfmpegInput::new(self.target.join("logo.png")));
|
||||||
let ff = ffmpeg.add_input(FfmpegInput::new(self.target.join("fastforward.png")));
|
let ff = ffmpeg.add_input(FfmpegInput::new(self.target.join("fastforward.png")));
|
||||||
|
@ -297,12 +297,10 @@ impl<'a> Renderer<'a> {
|
||||||
project.source.fast.sort();
|
project.source.fast.sort();
|
||||||
for (i, (ff_st, ff_end)) in project.source.fast.iter().rev().enumerate() {
|
for (i, (ff_st, ff_end)) in project.source.fast.iter().rev().enumerate() {
|
||||||
if let Some(prev_end) = part2_end_of_the_start {
|
if let Some(prev_end) = part2_end_of_the_start {
|
||||||
let recffbetween = format!("recff{i}between");
|
let recffbetween = ffmpeg.add_input(FfmpegInput {
|
||||||
ffmpeg.add_filter(Filter::Trim {
|
|
||||||
input: rec.clone().into(),
|
|
||||||
start: Some(*ff_end),
|
start: Some(*ff_end),
|
||||||
duration: Some(prev_end),
|
duration: Some(prev_end - *ff_end),
|
||||||
output: recffbetween.clone().into()
|
..FfmpegInput::new(rec_file.clone())
|
||||||
});
|
});
|
||||||
part2.push_front(recffbetween.into());
|
part2.push_front(recffbetween.into());
|
||||||
} else {
|
} else {
|
||||||
|
@ -310,12 +308,10 @@ impl<'a> Renderer<'a> {
|
||||||
}
|
}
|
||||||
part2_end_of_the_start = Some(*ff_st);
|
part2_end_of_the_start = Some(*ff_st);
|
||||||
|
|
||||||
let recffpart = format!("recff{i}part");
|
let recffpart = ffmpeg.add_input(FfmpegInput {
|
||||||
ffmpeg.add_filter(Filter::Trim {
|
|
||||||
input: rec.clone().into(),
|
|
||||||
start: Some(*ff_st),
|
start: Some(*ff_st),
|
||||||
duration: Some(*ff_end - *ff_st),
|
duration: Some(*ff_end - *ff_st),
|
||||||
output: recffpart.clone().into()
|
..FfmpegInput::new(rec_file.clone())
|
||||||
});
|
});
|
||||||
|
|
||||||
let recff = format!("recff{i}");
|
let recff = format!("recff{i}");
|
||||||
|
@ -333,34 +329,28 @@ impl<'a> Renderer<'a> {
|
||||||
let end = project.source.end.unwrap();
|
let end = project.source.end.unwrap();
|
||||||
let part2_last_part_duration;
|
let part2_last_part_duration;
|
||||||
if part2.is_empty() {
|
if part2.is_empty() {
|
||||||
let rectrim = "rectrim";
|
|
||||||
part2_last_part_duration = end - start;
|
part2_last_part_duration = end - start;
|
||||||
ffmpeg.add_filter(Filter::Trim {
|
let rectrim = ffmpeg.add_input(FfmpegInput {
|
||||||
input: rec.into(),
|
|
||||||
start: Some(start),
|
start: Some(start),
|
||||||
duration: Some(part2_last_part_duration),
|
duration: Some(part2_last_part_duration),
|
||||||
output: rectrim.into()
|
..FfmpegInput::new(rec_file.clone())
|
||||||
});
|
});
|
||||||
part2.push_back(rectrim.into());
|
part2.push_back(rectrim.into());
|
||||||
}
|
}
|
||||||
// otherwise add the first and last parts separately
|
// otherwise add the first and last parts separately
|
||||||
else {
|
else {
|
||||||
let rectrimst = "rectrimst";
|
let rectrimst = ffmpeg.add_input(FfmpegInput {
|
||||||
ffmpeg.add_filter(Filter::Trim {
|
|
||||||
input: rec.clone().into(),
|
|
||||||
start: Some(start),
|
start: Some(start),
|
||||||
duration: Some(part2_end_of_the_start.unwrap() - start),
|
duration: Some(part2_end_of_the_start.unwrap() - start),
|
||||||
output: rectrimst.into()
|
..FfmpegInput::new(rec_file.clone())
|
||||||
});
|
});
|
||||||
part2.push_front(rectrimst.into());
|
part2.push_front(rectrimst.into());
|
||||||
|
|
||||||
let rectrimend = "rectrimend";
|
|
||||||
part2_last_part_duration = end - part2_start_of_the_end.unwrap();
|
part2_last_part_duration = end - part2_start_of_the_end.unwrap();
|
||||||
ffmpeg.add_filter(Filter::Trim {
|
let rectrimend = ffmpeg.add_input(FfmpegInput {
|
||||||
input: rec.into(),
|
|
||||||
start: Some(part2_start_of_the_end.unwrap()),
|
start: Some(part2_start_of_the_end.unwrap()),
|
||||||
duration: Some(part2_last_part_duration),
|
duration: Some(part2_last_part_duration),
|
||||||
output: rectrimend.into()
|
..FfmpegInput::new(rec_file.clone())
|
||||||
});
|
});
|
||||||
part2.push_back(rectrimend.into());
|
part2.push_back(rectrimend.into());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue