diff --git a/src/render/ffmpeg.rs b/src/render/ffmpeg.rs index 05dbf4b..9e3c476 100644 --- a/src/render/ffmpeg.rs +++ b/src/render/ffmpeg.rs @@ -40,6 +40,7 @@ impl FfmpegInput { cmd.arg("-r").arg(fps.to_string()); } if let Some(start) = self.start { + cmd.arg("-seek_streams_individually").arg("false"); cmd.arg("-ss").arg(format_time(start)); } if let Some(duration) = self.duration { diff --git a/src/render/mod.rs b/src/render/mod.rs index b5ea7e4..46e0c5b 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -279,7 +279,7 @@ impl<'a> Renderer<'a> { // add all of our inputs 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 logo = ffmpeg.add_input(FfmpegInput::new(self.target.join("logo.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(); for (i, (ff_st, ff_end)) in project.source.fast.iter().rev().enumerate() { if let Some(prev_end) = part2_end_of_the_start { - let recffbetween = format!("recff{i}between"); - ffmpeg.add_filter(Filter::Trim { - input: rec.clone().into(), + let recffbetween = ffmpeg.add_input(FfmpegInput { start: Some(*ff_end), - duration: Some(prev_end), - output: recffbetween.clone().into() + duration: Some(prev_end - *ff_end), + ..FfmpegInput::new(rec_file.clone()) }); part2.push_front(recffbetween.into()); } else { @@ -310,12 +308,10 @@ impl<'a> Renderer<'a> { } part2_end_of_the_start = Some(*ff_st); - let recffpart = format!("recff{i}part"); - ffmpeg.add_filter(Filter::Trim { - input: rec.clone().into(), + let recffpart = ffmpeg.add_input(FfmpegInput { start: Some(*ff_st), duration: Some(*ff_end - *ff_st), - output: recffpart.clone().into() + ..FfmpegInput::new(rec_file.clone()) }); let recff = format!("recff{i}"); @@ -333,34 +329,28 @@ impl<'a> Renderer<'a> { let end = project.source.end.unwrap(); let part2_last_part_duration; if part2.is_empty() { - let rectrim = "rectrim"; part2_last_part_duration = end - start; - ffmpeg.add_filter(Filter::Trim { - input: rec.into(), + let rectrim = ffmpeg.add_input(FfmpegInput { start: Some(start), duration: Some(part2_last_part_duration), - output: rectrim.into() + ..FfmpegInput::new(rec_file.clone()) }); part2.push_back(rectrim.into()); } // otherwise add the first and last parts separately else { - let rectrimst = "rectrimst"; - ffmpeg.add_filter(Filter::Trim { - input: rec.clone().into(), + let rectrimst = ffmpeg.add_input(FfmpegInput { start: Some(start), duration: Some(part2_end_of_the_start.unwrap() - start), - output: rectrimst.into() + ..FfmpegInput::new(rec_file.clone()) }); part2.push_front(rectrimst.into()); - let rectrimend = "rectrimend"; part2_last_part_duration = end - part2_start_of_the_end.unwrap(); - ffmpeg.add_filter(Filter::Trim { - input: rec.into(), + let rectrimend = ffmpeg.add_input(FfmpegInput { start: Some(part2_start_of_the_end.unwrap()), duration: Some(part2_last_part_duration), - output: rectrimend.into() + ..FfmpegInput::new(rec_file.clone()) }); part2.push_back(rectrimend.into()); }