Monday, January 12, 2009

Org-Mode and VLC

Vlc is a wonderful media player. For movies, it automatically integrates a subtitle file if one is available by the same base name as the movie file.

Org-Mode is a wonderful outlining, notetaking, organizing utility for Emacs, the editor I use to do almost everything involving text of any nature.

Carsten Dominic has written a Relative Timer feature into Org-Mode. I use audio-visual materials quite alot in teaching, and I have often taken notes of videos or movies, to facilitate development of a lesson or a worksheet. The Org-Mode relative timer is a fantastic help, and Carsten has now made it better, integrating a facility to pause the timer.

I discovered an emacs lisp routine "dired-mplayer" at , and adapted it very crudely to start up vlc from emacs dired. It now starts vlc asynchronously, so emacs doesn't freeze up waiting for the video to finish, which leaves me free to take notes using Org-Mode and the Relative Timer feature. But pausing is what I needed, and Carsten's new feature makes that work.

I have incorporated a facility in dired-vlc that will simultaneously open a note buffer in org-mode in Emacs, and start the timer.

At this point, I use an org-remember template to open a buffer in a file of video notes. Then, insert a time stamp at t=0, and proceed.

I assigned the command to pause and restart to F11, so I can pretty easily pause the video and immediately afterwards pause the org-mode timer. Same for restart.

To make this more useful, I hope to incorporate code to pause the video and the timer simultaneously, wait for a note, and then restart both on command.

Here's the code for dired-vlc. It's more than just rough, but it works.

;;--------------------------------------------------begin dired-vlc.el---------------------
;; -*- mode: elisp -*-
;; Time-stamp: <2009-01-13>
;; AED 05 January 2009

(require 'org)

(defvar dired-vlc-program "/usr/bin/vlc")

(defun dired-vlc (&optional timer)
"Asynchronously start vlc on file through dired. If an optional
argument is given (C-u), the org relative timer is started. This
function purports to start vlc in rc mode, to leave open the
possibility of remote control."
(interactive "P")
(let ((file (expand-file-name (dired-get-filename)))
ext files basename dir curr-file ;idx-file sub-file srt-file
command options)
(setq basename (file-name-nondirectory
(file-name-sans-extension file)))
(setq dir (file-name-directory file))
(setq files (directory-files dir t basename))
(delete file files)
(setq command (format "\"%s\" \"%s" dired-vlc-program "--intf rc"))
; file))
(if (y-or-n-p (format "Run command %s?" command))
; (shell-command command))))
(start-process "junk" nil dired-vlc-program file)))
(if (equal timer '(4)) (org-timer-start))

;; end dired-vlc.el

No comments: