Control mpv with emacs and seek to the millisecond in videos with timestamps

Published: 14 February 2022
on channel: NapoleonWils0n
627
15

mpv can be controlled by external programs using the JSON-based IPC protocol

emacs has a package called mpv that allows you to control mpv using emacs and jump to a position in the video when your cursor is on a timestamp in an org document

The main purpose of the mpv.el package is to jump to timestamp in a subtitles file so you can fix any errors in the subtitles

org-timers and the mpv package dont support seeking to the milliseconds
in videos so i have overridden the mpv and org-timers functions to add millisecond support so you can seek more accurately

You can also insert the current playhead position into an org document in with the ffmpeg format for timestamp hh:mm:ss:ms 00:00:00.000,
so you can mark sections of video and use the timestamps with ffmpeg to trim the video into sections

Using the emacs hydra package you can create an mpv mode which sends your keystrokes to mpv over the json interface allowing you to use keys like hjkl to seek back and forth in the video.

You can also insert the playheads current position into the org document with milliseconds and use the timestamp with ffmpeg, pause and quit the video as well

Subtitles notes
vtt subtitle files timestamps will seek to the millisecond because they use a decimal point for milliseconds, but uses a comma and not a decimal point so they only seek to the second

the format in vtt subtitles file includes a decimal point for milliseconds
00:00:05.080

But the srt subtitle format uses a comma and not a decimal point
00:00:05,080

to do:
enable seeking by a single frame backwards and forwards using the comma and period keys, the mpv commands are called frame-back-step and frame-step, which should work with the mpv-run-command from mpv.el

i got it working once then it stopped working not sure why

("," mpv-run-command frame-back-step)
("." mpv-run-command frame-step)

mpv.el set up
https://github.com/NapoleonWils0n/cer...

my emacs config:
https://github.com/NapoleonWils0n/ubu...

mpv.el:
https://github.com/kljohann/mpv.el

mpv.el install:
M-x package-install mpv

emacs hydra
https://github.com/abo-abo/hydra

emacs hydra install
M-x package-install hydra

@SachaChua youtube:
   / sachachua  

SachaChua emacs config:
https://sachachua.com/dotemacs/


Watch video Control mpv with emacs and seek to the millisecond in videos with timestamps online without registration, duration hours minute second in high quality. This video was added by user NapoleonWils0n 14 February 2022, don't forget to share it with your friends and acquaintances, it has been viewed on our site 627 once and liked it 15 people.