-
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
[feature request] Define functions for making mpv play the curent subtitle audio at point 25%, 50% and 75% of the audio #69
Comments
I have written these functions to accomplish the behavior I described:
I mapped those functions to these keys:
I release the code included in this comment under Creative Commons Zero License |
I just found out that
Lines 326 to 332 in 07567d5
Lines 334 to 341 in 07567d5
Both functions are mapped by default. Lines 73 to 74 in 07567d5
I think these already defined functions cover most use cases. In order to cover more use cases, we could provide a macro that helps users define functions, which would be similar to the functions I defined in #69 (comment), for jumping to specific parts (25%, 30%, 50%, 75%). |
I had another idea that has to do with jumping to specific parts in mpv: We could define functions for seeking backward or seeking forward (5s, 10s) from the current playback position. My use case: I sometimes use programs for automatically generating subtitles for audio files, those subtitles contain some errors, so I need to manually fix them (e.g. split long subtitles, correct time span). While I'm splitting subtitles, I need to listen the part that comes after the point and then go back to the point I was in to make sure that I'm splitting a subtitle in the right position, in this case I wish I could seek backward. |
That could be fun. =) I think I've mostly been using middle-click in subed-waveform to sample sound without affecting the playback position, but something that's more keyboard-focused might work for your workflow. Have you figured out keyboard shortcuts and functions that make sense to you? (No rush, just curious!) |
Or maybe if there was the idea of some kind of register, like the way you can save Emacs positions to a register and then jump back to them... |
@sachac In GNU Emacs 29.4, In the video below, I show how seeking helps me listen specific parts of a subtitle. Note that the benefit of seeking is that I don't have to listen the entire subtitle again in order to listen a specific part. The following list explains what happens in the video:
output.webmI used the command in the first code block below to download the sample video and the sample subtitle file shown in the video. I created the file rm -rf /tmp/subtitles \
&& mkdir /tmp/subtitles \
&& curl \
--output /tmp/subtitles/video.ogv \
'https://upload.wikimedia.org/wikipedia/commons/4/41/Creative_Commons_and_Commerce.ogv' \
&& curl \
--data-urlencode 'format=json' \
--data-urlencode 'action=query' \
--data-urlencode 'prop=revisions' \
--data-urlencode 'rvprop=content' \
--data-urlencode 'rvslots=*' \
--data-urlencode 'formatversion=2' \
--data-urlencode 'titles=TimedText:Creative_Commons_and_Commerce.ogv.en.srt' \
'https://commons.wikimedia.org/w/api.php' | jq --raw-output '.query.pages.[].revisions.[].slots.main.content' > /tmp/subtitles/video.en.srt (add-to-list 'load-path "/tmp/subed/subed")
(require 'subed-srt)
(require 'subed-waveform)
(add-hook 'subed-mode-hook 'subed-enable-sync-player-to-point)
(add-hook 'subed-mode-hook 'subed-enable-loop-over-current-subtitle)
(add-hook 'subed-mode-hook 'subed-enable-replay-adjusted-subtitle)
(add-hook 'subed-mode-hook 'subed-waveform-minor-mode)
(add-hook 'subed-mode-hook 'my-subed-custom-keys-minor-mode)
(defun my-subed-mpv-seek-backward ()
(interactive)
(subed-mpv-seek -100))
(defun my-subed-mpv-seek-forward ()
(interactive)
(subed-mpv-seek 100))
(define-minor-mode
my-subed-custom-keys-minor-mode
"Custom keys for `subed-mode'."
:keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "M-;") 'my-subed-mpv-seek-backward)
(define-key map (kbd "M-'") 'my-subed-mpv-seek-forward)
map)) emacs \
--quick \
--load /tmp/subtitles/init.el \
/tmp/subtitles/video.en.srt Sidenote: I initially created the issue for functions that would allow to jump to the 25%, 50% and 75% of the audio, but now I believe that seeking is more needed, so we should focus our attention on seeking and then we can focus on those functions for jumping to 25%, 50% and 75%. |
Let me explain my use case: When I am editing a subtitle in a *.srt file, I sometimes want to check if the audio for that segment is consistent with the subtitle, to check this I am willing to listen to the entire audio for that subtitle. When editing the end time of a subtitle, I frequently want to check if the last part of the audio is consistent with the subtitle. Currently, when the end time of a subtitle changes, the audio is played from the start time, so I unwillingly need to listen to the audio starting from the beginning. I believe it would be more convenient for some users (such as me) if there were a function that would allow the user to play the audio starting at position 75%, so that the user don't need to listen to the 0%-75% segment, which the user might not be interested in listening.
In my use case, there are some subtitles which are 15 seconds long. Sometimes when I change the end time, I want to listen the last part of the audio (i.e. the segment 75%-100% in the current subtitle audio). Having to listen to a 15 seconds audio even though I'm interested in the last part is bothersome. I wish there were a function that I could map to a key to a function that makes mpv play the current subtitle audio starting at 75%.
I believe having functions that play the current subtitle audio at positions 25%, 50% and 75% would make
subed
more convenient to other users, because users can map those keys to a key and instruct mpv to play starting at a point that is closer to the part they are interested in listening.The text was updated successfully, but these errors were encountered: