Skip to content

lorniu/mpvi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT MELPA

Watch video and take interactive video notes in Emacs

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.

Features

  • 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

Installation

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%

Usage

Commands to open and operate the video

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 tune
  • mpvi-toggle-fullscreen|ontop|mute|video|border|title-bar toggle
  • mpvi-toggle|load|dalay|capture-subtitle subtitle
  • mpvi-switch-playlist playlist
  • mpvi-screenshot / mpvi-capture-ocr screenshot/ocr
  • mpvi-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

Take video notes in Org Mode with mpvi-insert

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 (with C-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.

Interactively control playing with mpvi-control or mpvi-seek

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 pause m mute M video T ontop f fullscreen L A-B Loop
  • n p N P M-n M-p < > ← → change position C-l revert position
  • j k [ ] { } change speed l Backspace revert speed
  • 0 9 ↑ ↓ change volume
  • s C-s screenshot v z t C-t subtitle
  • r ocr e export c playlist o browse
  • i insert/update video link I update end time C-i insert screenshot
  • / g prompt for seek
  • q 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.

Miscellaneous

Related packages:

Issues and PRs are welcome.

Have a nice day.

About

Watch video and take interactive video notes in Emacs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •