This enhances Emacs by integrating the powerful mpv media player with EMMS and Org mode. This allows for a seamless experience of watching videos, taking timestamp notes, and control mpv directly within Emacs.
A key feature is adding full Windows support to EMMS via a PowerShell bridge, a feature not available by default.
- Play local files and remote URLs with mpv player, control from Emacs without switching window
- Process videos interactively in Emacs, such as Download/Clip/Convert/Screenshot/OCR and so on
- Integrate with Org Mode deeply, making take interactive video notes easily
- Add full support for EMMS on Windows, which makes this can work on all platforms
Except the required mpv and EMMS, there are some optional dependencies (for enhanced features):
- yt-dlp: For playing/downloading online videos
- ffmpeg: For clipping and converting media
- tesseract: For OCR on screenshots
- biliass: danmaku file converter, used for some video sites like bilibili.com
Ensure mpv and any desired optional tools (yt-dlp, ffmpeg, etc.) are installed and available in your system's PATH:
# For Arch Linux User
yay -S mpv ffmpeg yt-dlp tesseract xclip
# yay -S biliass-git
# For macOS User
brew install mpv ffmpeg yt-dlp tesseract tesseract-lang
# pipx install biliass
# For Windows User
winget install mpv ffmpeg yt-dlp Tesseract-OCR
# pip install biliass
Then install this package from MELPA and start to use:
(use-package mpvi :ensure t)
(use-package mpvi
:ensure t
:config
;; M-x customize-group mpvi
(setq mpvi-mpv-ontop-p t)
(setq mpvi-mpv-border-p t)
(setq mpvi-cmds-on-init
'(((set_property autofit "40%x85%"))
((set_property geometry "-3%+8%")))))
You'd better config yt-dlp
before use, e.g., edit ~/.config/yt-dlp/config
:
--cookies-from-browser edge
--format "bestvideo+bestaudio/best"
Also, you can config mpv
globally by editing ~/.config/mpv/mpv.conf
, e.g.:
autofit=40%x85%
geometry=50%:50%
Play a video with command mpvi-open
or through emms
:
mpvi-open
open a local video file or a remote video url. Prefer the file or url under cursor.mpvi-emms-add
add a file or url to the playlist of EMMS, that is, make it to be played later.
Then the playing video can be controled with commands below:
mpvi-speed / mpvi-position / mpvi-volume
tunempvi-toggle-fullscreen|ontop|mute|video|border|title-bar
togglempvi-toggle|load|dalay|capture-subtitle
subtitlempvi-switch-playlist
playlistmpvi-screenshot / mpvi-capture-ocr
screenshot/ocrmpvi-browse
Handoff playing to system program such as browser
Use mpvi-export
to export a video, that is:
- Download a remote video to local disk (through
yt-dlp
) - Clip or transcode a local video (through
ffmpeg
) - All functions are integrated into this single command, making it very flexible and convenient
Insert a timestamp link to org buffer with command mpvi-insert
:
- The format of link is
[[mpv:PATH#TIME][TIME]]
or[[mpv:PATH#START-END][START -> END]]
- Put cursor on the link, and invoke
mpvi-insert
again to update it (withC-u
prefix, update the END) - The timestamp link can be edited directly, like a normal link
- Click the timestamp link to play back the video. If end time exists, it will play as A-B loop
When cursor is on the link, keys like ,h
, ,a
, ,b
, ,v
,e
can be used. See mpvi-org-link-map
for details.
Another command mpvi-insert-screenshot
is used to insert a screenshot as attachment to the org buffer.
Command mpvi-control
can popup a dedicated buffer as a control panel.
Except showing playing state, various keybinds can be used in the control panel:
Space
toggle pausem
muteM
videoT
ontopf
fullscreenL
A-B Loopn p N P M-n M-p < > ← →
change positionC-l
revert positionj k [ ] { }
change speedl Backspace
revert speed0 9 ↑ ↓
change volumes C-s
screenshotv z t C-t
subtitler
ocre
exportc
playlisto
browsei
insert/update video linkI
update end timeC-i
insert screenshot/ g
prompt for seekq C-q C-g
quit
Another interactive control command is mpvi-seek
:
- It is similar with
mpvi-control
and almost share the same keybinds, - but it uses a minibuffer to facilitate input and adjust playback progress.
- It is more suitable for situations that require instant action.
See mpvi-control-map
and mpvi-seek-map
for more keybind details.
Related packages:
- https://github.com/lorniu/bilibili.el, watching Bilibili in Emacs
Issues and PRs are welcome.
Have a nice day.