From 6565b9156ad8585e3172ce12bcf1f6d4ff50f86b Mon Sep 17 00:00:00 2001 From: admonisher-of-thieves <198962141+admonisher-of-thieves@users.noreply.github.com> Date: Wed, 12 Feb 2025 13:47:35 -0600 Subject: [PATCH] keep the chapters of the input video --- src/parser.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/parser.rs b/src/parser.rs index 22ae48d..78b2ef6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -145,6 +145,7 @@ impl BitstreamParser { Ok(&self.grain_headers) } + #[allow(clippy::too_many_lines)] pub fn modify_grain_headers(&mut self) -> Result<()> { assert!( WRITE, @@ -193,6 +194,19 @@ impl BitstreamParser { .as_mut() .unwrap() .set_metadata(ictx.metadata().to_owned()); + + for chapter in ictx.chapters() { + let Ok(_) = self.writer.as_mut().unwrap().add_chapter( + chapter.id(), + chapter.time_base(), + chapter.start(), + chapter.end(), + chapter.metadata().get("title").unwrap_or(""), + ) else { + continue; + }; + } + self.writer.as_mut().unwrap().write_header()?; for (stream, mut packet) in ictx.packets().filter_map(Result::ok) {