tubesync icon indicating copy to clipboard operation
tubesync copied to clipboard

Split by chapters

Open azukaar opened this issue 3 years ago • 11 comments

Enable the --split-chapter options to split the videos into multiple videos

azukaar avatar Feb 02 '22 19:02 azukaar

I don't believe --split-chapter is available over the embedded yt-dlp API at the moment so this suggestion may be difficult to evaluate.

meeb avatar Feb 03 '22 04:02 meeb

Ah which package are you using? Because it is available in the official yt-dlp binary

azukaar avatar Feb 03 '22 13:02 azukaar

The general yt-dlp package, but using the embedded API not CLI flags. I can't see any available options for chapter splitting here: https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L191

meeb avatar Feb 03 '22 13:02 meeb

The general yt-dlp package, but using the embedded API not CLI flags. I can't see any available options for chapter splitting here: https://github.com/yt-dlp/yt-dlp/blob/master/yt_dlp/YoutubeDL.py#L191

Any updates on this? I see there is a new major version of yt-dlp out https://pypi.org/project/yt-dlp/ Does the api have support for chapters with this and if not could tubesync be changed to use the cli version instead if that is what is getting updated/supported more regularly?

bawitdaba avatar Aug 15 '22 01:08 bawitdaba

Last I looked into this it might be possible with some filters and not via the direct API args. It's still not in the main API in the latest yt-dlp releases. I've been spending my time on some other issues. I'll get around to this eventually, but it might be a while. I'm happy to accept PRs for features if it's a feature you want to have sooner though.

meeb avatar Aug 15 '22 01:08 meeb

Last I looked into this it might be possible with some filters and not via the direct API args. It's still not in the main API in the latest yt-dlp releases. I've been spending my time on some other issues. I'll get around to this eventually, but it might be a while. I'm happy to accept PRs for features if it's a feature you want to have sooner though.

Not sure what the OP was trying to do, but I really wanted support for chapters within the final mkv file. I did some experimenting and was able to modify sync\youtube.py with the following to enable chapters I tested this and it works. I am trying to also add sponsorblock, but haven't verified if that's working yet.

sync\youtube.py changes at line 94

    opts = get_yt_opts()
    opts.update({
        'format': media_format,
        'merge_output_format': extension,
        'outtmpl': output_file,
        'quiet': True,
        'progress_hooks': [hook],
        'writeinfojson': info_json,
        'sponsorblock_remove': True,
        'postprocessors': [{
                # Embed metadata in video using ffmpeg.
                'key': 'FFmpegMetadata',
                'add_chapters': True,
                'add_metadata': True
            }, {
                # --sponsorblock-remove all
                'key': 'SponsorBlock',
                'categories': 'all',
                'api': 'https://sponsor.ajay.app',
                'when': 'after_filter'
            }, {
                'key': 'FFmpegSubtitlesConvertor',
                'format': 'srt'
            }, {
                'key': 'FFmpegThumbnailsConvertor',
                'format': 'jpg',
                # Run this before the actual video download
                'when': 'before_dl'
            }, {
                'key': 'EmbedThumbnail',
                'already_have_thumbnail': True
            }, {
                'key': 'FFmpegEmbedSubtitle'
            }

            ]
    })

bawitdaba avatar Oct 11 '22 05:10 bawitdaba

Awesome, thanks! I've not tested this since my original comment but if this works for you now I'm very happy to merge these changes in. If you can confirm sponsorblock works or not as well feel free to submit a PR, or if you prefer I can just make the changes manually. Thanks for the contribution.

meeb avatar Oct 11 '22 05:10 meeb

Awesome, thanks! I've not tested this since my original comment but if this works for you now I'm very happy to merge these changes in. If you can confirm sponsorblock works or not as well feel free to submit a PR, or if you prefer I can just make the changes manually. Thanks for the contribution.

I haven't gotten the sponsorblock to work, but here is the original code where i got chapters working without sponsorblock this should be good to commit.

    opts = get_yt_opts()
    opts.update({
        'format': media_format,
        'merge_output_format': extension,
        'outtmpl': output_file,
        'quiet': True,
        'progress_hooks': [hook],
        'writeinfojson': info_json,
        'postprocessors': [{
                # Embed metadata in video using ffmpeg.
                'key': 'FFmpegMetadata',
                'add_chapters': True,
                'add_metadata': True,
            }, {
                'key': 'FFmpegSubtitlesConvertor',
                'format': 'srt'
            }, {
                'key': 'FFmpegThumbnailsConvertor',
                'format': 'jpg',
                # Run this before the actual video download
                'when': 'before_dl'
            }, {
                'key': 'EmbedThumbnail',
                'already_have_thumbnail': True
            }, {
                'key': 'FFmpegEmbedSubtitle'
            }

            ]
    })

bawitdaba avatar Oct 12 '22 22:10 bawitdaba

Nice, thanks. I'll pop this into the next release after some testing. Thanks for the contribution.

meeb avatar Oct 14 '22 10:10 meeb

I think I managed to get YoutubeDL.py to do splitting chapters. I asked a question in MeTube Github and got some help.

Using this made it work {"postprocessors": [{"key": "FFmpegSplitChapters"}]}

BenJamesAndo avatar Apr 05 '23 11:04 BenJamesAndo

Thanks! That's a useful filter to know about. This would still require quite some effort as I'd need to track all the downloaded files rather than one file per media item, but I'll certainly look into it as a feature if I get time.

meeb avatar Apr 05 '23 12:04 meeb