-
Notifications
You must be signed in to change notification settings - Fork 16
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
Trim overlaps #50
Trim overlaps #50
Conversation
- option to check and ask to trim on load - option to always trim on save - trim end of current or start of next subtitle - custom or prefix args to trim by: - any number of milliseconds - the value of subed-subtitle-spacing, or - 1 millisecond
whitespace
That's a neat idea! Any chance you can write tests for it? You can look in
the tests subdirectory to see some examples, and type "make test" in the
main directory to run the tests. Let me know if you get stuck or need help
figuring things out! :)
Sacha
…On Tue., Dec. 21, 2021, 13:05 mooseyboots, ***@***.***> wrote:
i had a crack at implementing trimming overlapping subtitles and thought i
would share what i came up with.
as per rndusr's recommendations, it includes
- customize option to ask to trim on load
- customize option to always trim on save
- custom options and prefix args to trim by:
- any number of milliseconds
- the value of subed-subtitle-spacing, or
- 1 millisecond
- customize option to either trim end of current or start of next sub.
personally i only have experience with .srt subtitle files, so that is all
i have used this with. i also don't know the codebase super well. but
thought i would share my efforts nonetheless.
------------------------------
You can view, comment on, or merge this pull request online at:
#50
Commit Summary
- a3fff1d
<a3fff1d>
handle trimming of subtitles that overlap
- 6d72ef7
<6d72ef7>
add fully configurable trimming of subtitle overlaps:
- 0a1c54f
<0a1c54f>
docstrings
File Changes
(3 files <https://github.com/sachac/subed/pull/50/files>)
- *M* subed/subed-common.el
<https://github.com/sachac/subed/pull/50/files#diff-b0b0c4192d685448c971c553c4d3fffdb359d0d96053584b65b4e2751ab905a2>
(138)
- *M* subed/subed-config.el
<https://github.com/sachac/subed/pull/50/files#diff-e090d5c5faf1f4ff62e7b280467676c0df2d1673e19c65e68cee6d316c85928d>
(32)
- *M* subed/subed.el
<https://github.com/sachac/subed/pull/50/files#diff-0b220c0531feadb3db8e19a88eb3882b80f98422d0e91e139912ab3205284a68>
(2)
Patch Links:
- https://github.com/sachac/subed/pull/50.patch
- https://github.com/sachac/subed/pull/50.diff
—
Reply to this email directly, view it on GitHub
<#50>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACD7ES7FGL4YEB4OJ5TV23USC6XPANCNFSM5KQYJ2RQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
hey s, sure that's a good idea. i'm a silly noob with testing but am slowly getting the hang of it on another project. i'll just take a while to nut it out. reference: #6 |
Sure! I'll add it to my todo list too in case I get to it first. It's a
good learning opportunity. :) Thanks again for sharing this!
…On Sat., Dec. 25, 2021, 06:52 mooseyboots, ***@***.***> wrote:
hey s, sure that's a good idea. i'm a silly noob with testing but am
slowly getting the hang of it on another project. i'll just take a while to
nut it out.
—
Reply to this email directly, view it on GitHub
<#50 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACD7ETUWRTL7YDKOERNTVTUSWWA7ANCNFSM5KQYJ2RQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you commented.Message ID:
***@***.***>
|
Worked on some tests tonight and rewrote it to use the functions for adjusting time stop/start. Haven't pushed my changes yet, as I want to take another look when I'm less sleepy. :) I'm a little unsure about having all the options for controlling it. Are you okay if I simplify it to just use either msecs as a numeric argument or subed-subtitle-spacing, instead of having another way to control whether subed-subtitle-spacing is used? People can set subed-subtitle-spacing to 1 if they want stop times and start times to be at least 1 msec apart, or have a function that calls it with an arg. (I'll probably change my config to that, actually.) Would that still work for your use case? |
hey, that's great to hear! it would have taken me days and days of work. i'm also happy if you modify what i proposed, i'm sure you'll improve it. in my use case, i just tend to use 1ms. i really just need to blast away all overlaps before i start editing, so the gap isn't that crucial for me. i kind of wrote what i wanted but then expanded it to fit rndusr's suggestions. it was also a way for me to start learning what |
You can now trim subtitle overlaps with ~M-x subed-trim-overlaps~. By default, this adjusts the stop time of overlapping subtitles to ~subed-subtitle-spacing~ milliseconds before the next subtitle starts. Use ~M-x customize-group~ ~subed~ to configure trimming to happen automatically when buffers are loaded or saved, which time is adjusted, and how much time to leave between subtitles. * README.org (Features): Document M-x subed-trim-overlaps. * subed/subed-common.el: (subed-trim-overlaps): New command that trims overlapping subtitles in the current buffer. (subed-trim-overlap-stop): New command that adjusts the stop time of the current subtitle so that it stops before the next subtitle starts. (subed-trim-overlap-next-start): New command that adjusts the start time of the next subtitle so that it starts after the current subtitle stops. (subed-trim-overlap-check, subed-trim-overlap-maybe-sanitize, subed-trim-overlap-maybe-check, subed-trim-overlap-stop, subed--identify-overlaps): New function. * subed/subed-common.el (subed-sanitize-functions): Add subed-trim-overlap-maybe-sanitize. (subed-validate-functions): Add subed-trim-overlap-maybe-check. * subed/subed-config.el (subed-trim-overlap-on-save, subed-trim-overlap-check-on-save, subed-trim-overlap-check-on-load, subed-trim-overlap-use-start): New user options. Co-authored-by: mooseyboots / mousebot <mousebot@riseup.net> Based on #50 with some simplification and reuse.
Okay, I think I've mostly gotten things sorted out with tests and stuff at a97a9e5 . I promise I didn't rename and fiddle with things just to be ornery. =) I wanted functions to be mostly discoverable with M-x, so I gave them (mostly) the subed-trim-overlap prefix. Customization options tend to be grouped alphabetically too, so I renamed them to be close together. I wanted to reuse the subed-adjust-subtitle-time-stop and -start functions because they seemed to have a fair bit of thought put into the logic. And then I ended up also tweaking how the sanitizing and validation functions were called so that we could have generic validation functions without having to add them to each of the specific validation functions... Would you consider trying out this version and seeing if it works for you? It seems to pass the tests and it works interactively for me. (Sorry for the somewhat heavy touch editing the code; I'm learning my way around maintaining subed too!) |
hey, s, no probs, happy to defer to your hands. |
i had a crack at implementing trimming overlapping subtitles and thought i would share what i came up with.
as per rndusr's recommendations, it includes
personally i only have experience with .srt subtitle files, so that is all i have used this with. i also don't know the codebase super well. but thought i would share my efforts nonetheless.