Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
#######
#
# E-scripts on processing and editing subtitles.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
#   (find-eev-quick-intro)
#   http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/subtitles.e>
#           or at <http://angg.twu.net/e/subtitles.e.html>.
#        See also <http://angg.twu.net/emacs.html>,
#                 <http://angg.twu.net/.emacs[.html]>,
#                 <http://angg.twu.net/.zshrc[.html]>,
#                 <http://angg.twu.net/escripts.html>,
#             and <http://angg.twu.net/>.
#
#######




# «.subed»			(to "subed")
# «.subed-mpv-low-level»	(to "subed-mpv-low-level")
# «.subed-keys»			(to "subed-keys")
# «.mpv-geometry»		(to "mpv-geometry")
# «.pysubs2»			(to "pysubs2")
# «.gryms-code»			(to "gryms-code")
# «.Subtitles.lua»		(to "Subtitles.lua")
# «.aeneas»			(to "aeneas")



<edrx> sachac: I used this to download the automatic subtitles of
       the video that I have just recorded -
       https://0x0.st/oTrh.txt - but the .vtt file looks like this:
       https://0x0.st/oTrC.txt
<edrx> sachac: this is tricky to edit because of the timestamps on
       words - like <00:00:04.400><c> and</c><00:00:04.880><c>
       this</c><00:00:05.120>...
<edrx> sachac: do you have tricks to convert that to another
       format? I tried pysubs2 - more precisely: pip3 install
       pysubs2; pysubs2 --help; pysubs2 --to srt *.vtt




#####
#
# subed
# 2022apr19
#
#####

# «subed»  (to ".subed")
# (find-es "emacs" "subed")
# (find-epackage-links 'subed "subed" t)
# (find-epackage       'subed)
# (code-c-d "subed" "~/.emacs.d/elpa/subed-1.0.10/")
# (find-subedfile "")
# (find-subedfile "subed-mpv.el")

# (find-subedgrep "grep --color=auto -niH --null -e cps *")
# (find-es "mplayer" "geometry")

-geometry 400x300+520+100

# (find-efunctiondescr 'customize-apropos)
# (find-efunction      'customize-apropos)
# (find-efunction      'customize-apropos "apropos-read-pattern")
# (customize-apropos "")
# (customize-apropos "subed")
# (find-customizegroup 'subed)
# (customize-group     'subed)
# (find-efunction 'find-customizegroup)

# (customize-variable 'subed-default-subtitle-length)
# (customize-option 'subed-default-subtitle-length)



#####
#
# Low-level tests for subed-mpv.el
# 2022oct09
#
#####

# «subed-mpv-low-level»  (to ".subed-mpv-low-level")
# (find-fline "~/LOGS/2022oct09.emacs" "<quiliro> edrx: subed-mpv is not found")
# (to "subed")
# (require 'subed-mpv)
# (find-eapropos "subed-mpv")
# (find-efunction 'subed-mpv--play)
# (find-efunction 'subed-mpv-jump)
# (find-efunction 'subed-mpv-pause)
# (find-efunction 'subed-mpv-unpause)

;; Check that you have the video:
(find-1stclassvideo-links "2022pict2elua")
(find-2022pict2eluavideo "0:00")

;; Copy it and its subtitles to /tmp/:
(find-eevvideossh0 "cp -v 2022-pict2e-lua.{mp4,vtt} /tmp/")
(setq my-video "/tmp/2022-pict2e-lua.mp4")

;; Then...
(require 'subed-mpv)
(subed-mpv--play my-video)
(subed-mpv-jump 20000)
(subed-mpv-jump 200000)
(subed-mpv-pause)
(subed-mpv-unpause)





#####
#
# subed-keys
# 2022jul15
#
#####

# «subed-keys»  (to ".subed-keys")
# (find-eevvideosfile "2022jul10-apresentacao-C2.vtt")
# (find-es "emacs" "transparence-in-keymaps")
# (find-subedfile "subed.el" "(defconst subed-mode-map")
# (require 'subed)
# (find-ekeymapdescr subed-mode-map)

;; M-j          subed-mpv-jump-to-current-subtitle
;; M-k          subed-kill-subtitle

(define-key subed-mode-map (kbd "M-j") nil)
(define-key subed-mode-map (kbd "M-k") nil)
(define-key subed-mode-map (kbd "M-p") nil)

(defun j () (interactive) (subed-mpv-jump-to-current-subtitle))
(defun k () (interactive) (subed-kill-subtitle))
(defun sk () (interactive) (find-es "subtitles" "subed-keys"))
(defun sk () (interactive) (find-2b '(find-es "subtitles" "subed-keys")))
(defun sk () (interactive) (find-2a '(find-subedfile "subed.el" "(defconst subed-mode-map")))





#####
#
# mpv-geometry
# 2022may02
#
#####

# «mpv-geometry»  (to ".mpv-geometry")
# (find-fline "/sda5/videos/" "A_Tour_of_the_Acme_Editor-dP1xVpMPn8M.webm")

* (eepitch-shell)
* (eepitch-kill)
* (eepitch-shell)
mpv  -geometry 400x300+520+100 /sda5/videos/A_Tour_of_the_Acme_Editor-dP1xVpMPn8M.webm
mpv --geometry=400x300+520+100 /sda5/videos/A_Tour_of_the_Acme_Editor-dP1xVpMPn8M.webm

# (find-customizevariable 'subed-mpv-arguments)
# (find-evariable-links   'subed-mpv-arguments)
# (find-fline "~/.emacs.custom" "subed-mpv-arguments")








#####
#
# pysubs2
# 2022apr19
#
#####

# «pysubs2»  (to ".pysubs2")

rm -Rv /tmp/edrx-pict2e/
mkdir  /tmp/edrx-pict2e/
cd     /tmp/edrx-pict2e/

yt-dlp --write-sub --write-auto-sub \
  --skip-download -o 2022-pict2e-lua \
  "http://www.youtube.com/watch?v=hiHsUhGVLGM"

wget http://angg.twu.net/eev-videos/2022-pict2e-lua.mp4

ls -lAF
mpv /tmp/edrx-pict2e/2022-pict2e-lua.mp4






#####
#
# gryms-code
# 2022apr19
#
#####

# «gryms-code»  (to ".gryms-code")
# (find-yttranscript-links "2022pict2elua" "hiHsUhGVLGM")
# (find-efunction 'find-yttranscript-links)
# (find-fline "~/LOGS/2022apr19.emacs")
# https://bpa.st/OKIQ

* (python-mode)
* (eepitch-python)
* (eepitch-kill)
* (eepitch-python)
import youtube_transcript_downloader
url    = "http://www.youtube.com/watch?v=hiHsUhGVLGM"
f      = "find-2022pict2eluavideo"
tr     = youtube_transcript_downloader.get_transcript(url)
trits0 = tr.items()
trits1 = '\n'.join(('% (' + f + ' "' + key + '" "' + text + '")' for key, text in trits0))
print(trits1)

trits2 = tuple(trits0)
trits3 = zip(trits2, trits2[1:])
vtts   = []
for (start,thistext),(stop,nexttext) in trits3:
    vtts.append(f"{start} --> {stop}\n{thistext}\n")

header = "WEBVTT\nKind: captions:\nLanguage: en-GB\n"
body   = "\n".join((header, *vtts))
print(body)



#####
#
# Subtitles.lua
# 2022apr20
#
#####

# «Subtitles.lua»  (to ".Subtitles.lua")
# (find-anggfile "LUA/Subtitles.lua")




#####
#
# aeneas
# 2022nov11
#
#####

# «aeneas»  (to ".aeneas")
# (find-fline "~/LOGS/2022nov11.emacs" "<sachac> edrx: oh, you can use aeneas")
# https://www.readbeyond.it/aeneas/
# https://github.com/readbeyond/aeneas
# https://pypi.org/project/aeneas/1.4.0.0/
# https://www.youtube.com/watch?v=xP870sdyCXE
# https://media.emacsconf.org/2022/backstage/editing-captions.html





https://sachachua.com/blog/2022/10/subed-el-word-level-timing-improvements/
https://sachachua.com/dotemacs/index.html

(defun my-caption-download-srv2 (id)
  (interactive "MID: ")
  (require 'subed-word-data)
  (when (string-match "v=\\([^&]+\\)" id) (setq id (match-string 1 id)))
  (let ((default-directory "/tmp"))
    (call-process "yt-dlp" nil nil nil "--write-auto-sub" "--write-sub" "--no-warnings" "--sub-lang" "en" "--skip-download" "--sub-format" "srv2"
                  (concat "https://youtu.be/" id))
    (subed-word-data-load-from-file (my-latest-file "/tmp" "\\.srv2\\'"))))

(defun my-caption-fix-common-errors (data)
  (mapc (lambda (o)
          (mapc (lambda (e)
                  (when (string-match (concat "\\<" (regexp-opt (if (listp e) (seq-remove (lambda (s) (string= "" s)) e)
                                                                  (list e)))
                                              "\\>")
                                      (alist-get 'text o))
                    (map-put! o 'text (replace-match (car (if (listp e) e (list e))) t t (alist-get 'text o)))))
                my-subed-common-edits))
        data))



https://news.ycombinator.com/item?id=34105063 BBC Subtitle Guidelines (bbc.co.uk)




https://sachachua.com/dotemacs/
https://sachachua.com/dotemacs/#subed


# (find-eevvideosfile "2022jul10-apresentacao-C2.vtt")

http://mbork.pl/2022-09-05_Comments_in_srt_files

<sachac> edrx: set subed-auto-find-video to nil

# (find-fline "~/LOGS/2023jan03.emacs" "emacsconf-subed")





#  Local Variables:
#  coding:               utf-8-unix
#  End: