For her Master's research,
wormwood_pearl has to analyse some video. Not that much video, in the scheme of things - a couple of hours in total - but she has to decide and note down what's happening in every one-second chunk of said video.
Ladies and gentlemen, I give you the non-stop, fast-moving, white-heat world of SCIENCE!
[The lab has licenses for some expensive-looking software that's meant to do this automagically and without human intervention, but needless to say it doesn't actually work.¹]
So she asked me if it was possible to script VLC to play a video for a second, then pause for a couple of seconds (so she could update her spreadsheet), play for another second, and so on until the video finished. That way she'd (a) get accurate seconds, and (b) save lots of time that would have been spent clicking back and forth. I said "Er, yeah, probably".
It turns out that recent versions of VLC do, in fact, have a nice-looking scripting infrastructure based on Lua, but I don't have, and can't install, VLC on my work machine. So (at
addict_yin's suggestion) I tried it with mplayer instead, and after a bit of fiddling got it to work. The program's very simple, but it's possible that someone else has this need, so I thought I'd make it public.
If you too need to play a video in pause-interspersed chunks (of any length you like!), you can
download Sleepy here. Installation and use is very simple, and described (at least for *nix systems - let me know if you want to use it on Windows) in the README. It requires
perl and
mplayer, both of which are free and run on damn near anything. If you think you can improve it, please fork the
GitHub repository (because all the cool kids are using GitHub these days, right?), and then send me a pull request. All comments and criticisms are welcome.
Yes, this is all massive overkill for what's actually a very simple script :-)
¹ It could be worse. Apparently an important early experiment on foam formation required a grad student to make up a soap foam between two glass plates, put the assemblage on a photocopier, and then press "Copy" every few seconds for up to ten hours straight. As my friend Micah put it when telling this story, if a
nodding bird could do your research better than you could, you've probably taken a wrong turn somewhere.