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
A better SponsorBlock #360
Conversation
I was also planning to rewrite the sponskrub integration. However, my plan was quite different from your implementation. Here is what I was thinking:
Doing it this way would provide us with a lot more flexibility imo. Let me know what you think of this appoach |
Looking at your code in more detail, using your method of |
|
Yes, leave sponskrub as-is for now. We'll worry about how to document it once this new implementation is complete
In that case, we should split the PP into
I am not familiar enough with ffmpeg to comment on this. I'll trust your judgement on this for now. If need be, we can generalize it later
Yes, please do so if possible
It is though. Take this example: the video has chapters
I don't understand. Nothing needs to change in the chapter merger. It is simply that when we cut sections out, we cut off only the chapters matching the regex given by user.
If needed, we could seperate the chapter code into its own function. However, this is not necessary for this PR. Once we put the modified chapter data in the infodict using |
Ok, I'll bring it back, and move to Deprecated Options.
Ok, I'll do.
SponSkrub does in fact implement the cut the way you just described, but the current implementation is different. SponSkrub implementation is easier from the developer perspective, but it is not necessarily better from the user perspective. Please take a look at I would rather want to have that feature present, I don't like to see chapters split for no reason. Please tell me if you dislike that particular feature of cut.
Please take a look at
However, it is not the reason why I suggested to extract
Let's look at ways to combine these pieces together.
This design tries to separate concerns. The separation of concern comes at the cost of having to modify chapters twice, and having to cut the video twice. At first, that double cut seems avoidable by having Alternative design is to have It is still possible to retain chapter writing in All future chapter handling code would have a natural post-processor to tag along to. What do you think about creating |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, just a few things that might be worth thinking about
@pukkandan, looks like
On the other hand, are you OK with having |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Small changes:
Big change: implementing Please review.
COLUMNS=80 $(PYTHON) yt_dlp/__main__.py --help | $(PYTHON) devscripts/make_readme.py generate an enormous diff. Is that line correct? |
huh, I thought I had already replied to your earlier comment. I must have typed it up and then forgot to submit 😢 Give me some time to collect my thought again on the various points. Then I will review
Yes. The big diff is caused due to the new option names being too long. Anyway, you should revert that and only create the corresponding options for now. We can |
Reverted changes in README + some small fixes. Workflow checks failed due to
I've added |
Yes it has no use, I just forgot to disable that test |
Fixed lint error. Python 3.4 on Windows fails with |
You can ignore the 3.4 test. By the time this code is merged, it will be removed |
@nihil-admirari hey there, not sure if im jumping the gun on giving this a test, but when i try When i didnt cut i had this warning thrown also on my quick usage i wonder if another flag of say |
I shortened command line options: dropped
Please always provide WEBM format
It looks like a rather popular problem. https://ipcamtalk.com/threads/fix-non-monotonous-dts-errors-in-ffmpeg.30465/#post-286226 suggested to add
Tested with the latest FFmpeg Unless someone knows a magic workaround, nothing can be done about it. You can try to open an issue in FFmpeg bug tracker, but it looks like there is a plenty of such bug reports already. I can only suggest you to switch to MP4, for which cutting does work. |
@nihil-admirari thanks for the additions Sorry! i didnt even realize there was a -v i should have looked harder, will in the future 👍 . sorry, ive jsut come from the base yt-dl and my format settings were not working with yt-dlp, so i was just using whatever the default detected was. i can confirm it removes the sponsor as expected with the format you suggested now and with almost no overhead to the processing 😄 good job! an amazing speed improvement on the original sponskrub implementation! once the all category issue is resolved i will give it a test with subtitles also. Though it should be noted that others may run into similar issues as i did, maybe a note in the readme for sponsor block should be added warning about format issues once that is done? though like you've found it looks more like an ffmpeg issue than an issue with your post processor |
This issue does not exist in ffmpeg versions <= |
Have you pulled the latest changes from this branch? Caveat: because of force push (rebase on
Actually, it was supposed to warn even when doing a cut. Fixed.
Added a warning. I tried various FFmpeg options that were mentioned as workarounds in various places.
|
@nihil-admirari not sure what happened as i had the new flags, in any case |
Indeed, cutting was disabled by default to match SponSkrub behaviour. It made sense for SponSkrub, which implements cut by re-encoding. In this implementation cutting is fast, and, I presume, the majority of people who use SponsorBlock would like to cut rather than contemplate the chapters. Changed to cut by default. |
@phyzical, if you still feel like testing, you can find patched FFmpeg here: https://github.com/nihil-admirari/FFmpeg-With-VP9-Timestamp-Fix/releases. It should handle VP9 videos with corrupted timestamps. |
@nihil-admirari no worries ill give it a crack later today after work 👍 |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Signed-off-by: nihil-admirari <50202386+nihil-admirari@users.noreply.github.com>
And merge adjacent chapters based on title, not categories
This was the perfect idea. I have modified it to use output template instead. Then, added code to merge adjacent chapters based on title rather than category. This now satisfies both our uses. By default, no data is lost in the chapter names, but by using I've also made a few small changes. Have a look at the commit messages If you are satisfied with how it is now, I believe this can be merged |
'sponsor': 'Sponsor', | ||
'intro': 'Intermission/Intro Animation', | ||
'outro': 'Endcards/Credits', | ||
'selfpromo': 'Unpaid/Self Promotion', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, old names were better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't care either way, but these are the actual names as documented here: https://wiki.sponsor.ajay.app/index.php/Segment_Categories
I made some minor fixes. I'm OK with merging this, though I don't quite understand why the smallest sponsor contributing to overlap is the most representative of the overlap itself. |
@nihil-admirari Thanks for sticking with me till the end of the PR even though it took some large delays and quite a few detours to get this done 😄 |
SponsorBlock options: * The fetched sponsor sections are written to infojson * `--sponsorblock-remove` removes specified chapters from file * `--sponsorblock-mark` marks the specified sponsor sections as chapters * `--sponsorblock-chapter-title` to specify sponsor chapter template * `--sponsorblock-api` to use a different API Related improvements: * Split `--embed-chapters` from `--embed-metadata` * Add `--remove-chapters` to remove arbitrary chapters * Add `--force-keyframes-at-cuts` for more accurate cuts when removing and splitting chapters Deprecates all `--sponskrub` options Authored by: nihil-admirari, pukkandan
Please follow the guide below
x
into all the boxes [ ] relevant to your pull request (like that [x])Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
Changes are similar in purpose to SponSkrub, but the implementation is completely different.
What is the purpose of your pull request?
Description of your pull request and other information
This is a complete replacement of SponSkrub. New features:
concat
FFmpeg demuxer, mentioned in Trim video without re-encoding faissaloo/SponSkrub#32. According to https://sattlers.org/2019/09/30/ffmpeg-split-and-cut-video-segments/, small stutter/frame skipping mentioned in the issue can be fixed by forcing key frames, an option for which is also provided.videoDuration
from SponsorBlock responses into account.--skip-chapters
.