Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix chapter title with chapter index #4

Open
alainpannetier opened this issue Jul 31, 2021 · 2 comments
Open

Prefix chapter title with chapter index #4

alainpannetier opened this issue Jul 31, 2021 · 2 comments

Comments

@alainpannetier
Copy link

I also tweecked a 'quick & dirty' numbering mod.

    def create_chapter(self, chapter, i) -> bool:
        start = chapter["start_time"]
        end = chapter["end_time"]
        diff = end - start
        args =  [
            "ffmpeg",
            "-i", self.file.media_filepath,
            "-ss", str(start),
            "-t", str(diff),
            "-acodec", "copy",
            "-vcodec", "copy",
            self.file.output_chapter_file(str(i) + "-" + chapter["title"])
            ]
        ret = subprocess.run(args)
        return ret.returncode == 0

Called as follows. A bit ugly.

    def split_into_chapters(self):
        if not self.file.chapters:
            self.log("No chapters available.")
            return False

        if not self.file.create_output_folder():
            self.log("Failed to create output folder.")
            return False

        for i, chapter in enumerate(self.file.chapters):
            if not self.create_chapter(chapter, i):
                self.log("Failed to create chapter " + i + " file: " + chapter["title"])
        return True
@bjsi
Copy link
Owner

bjsi commented Aug 30, 2021

I agree this would be a very useful feature. I will look into adding a command line option to do this.

@derritter88
Copy link

Would be cool to have such a feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants