Repository navigation
Add save-chapters command for FFmetadata chapter export (#323) - #599
Open
Davidvisualstudio007 wants to merge 4 commits into
Open
Davidvisualstudio007 wants to merge 4 commits into
Davidvisualstudio007 wants to merge 4 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #323
This adds a
save-chapterscommand that saves the detected scenes as chapters in FFmetadata format. You can then add them to a video with ffmpeg without re-encoding:What I changed:
write_scene_list_ffmetadata()toscenedetect.output. I based it on the EDL writer, so it works with a file path or an open filesave-chapterscommand with-f,-tand-ooptions, and a[save-chapters]section in the config.-tlets you change chapter names using$SCENE_NUMBERFor the timing I used
_frame_timecode_seconds(), so it stays accurate at 23.976 and 29.97 and doesn't drift like the EDL issue in #593.I added 22 tests in
test_output.pyand 2 intest_cli.py, including one that actually runs ffmpeg to add the chapters to a video and checks they're there. Ruff passes and the output and CLI tests all pass on the latest main. I also tried it on goldeneye.mp4 and the chapters showed up in VLC.I left YouTube style chapters out for now. YouTube needs the first chapter at 00:00, at least 3 chapters, and each one at least 10 seconds long, so I wasn't sure how you'd want short scenes handled.