RETURN TO VARUNRAMESH.NET

A Script for Resumable Lecture Videos

Saturday, May 21st 2016


During Autumn quarter this year, all of my class lectures were recorded and available online. I initially tried to attend every lecture, but the ability to skip class and watch it later was too tempting. I soon found myself waking up at 2PM everyday and watching all my lectures through the SCPD video system.

This lifestyle presented couple of problems. First, the SCPD player was annoying to use since bad internet connections would force me to reload and lose my place in the video. Second, I found myself rebooting frequently to switch operating systems – this would also cause me to lose my place. I could use the download feature on the SCPD site to solve the first problem, but the second still remained.

Instead of fixing my life, I decided to fix my technology. What I really needed was a video player that could remember where I left off. This would also allow me to split my lectures into parts and rotate between them (I found that this prevents me from getting bored while watching 2-hr lectures). I looked at a wide variety of video players, but I didn’t find any ideal solutions. Most players don’t remember positions, and those that do typically only remember positions on the last video viewed. Furthermore, I often switch OS’s (primarily OSX and Linux), and I want my timecodes to work on both (and ideally be synchronized). Given these constraints, I figured the only solution was to make my own tool.

I obviously didn’t create a video player from scratch – instead I used MPlayer, a GUI-less video player that is launched from the command-line. What makes MPlayer awesome is that it outputs video progress to stdout as the video plays. Using this feature, I was able to write a simple wrapper script to launch MPlayer and read/store the timecodes.

MPlayer is interesting since, as the video progresses, the application actually erases the previous line in order to write the new timecode. It does so using “\r” (carriage return) to return to the beginning of the line and rewrite the previous data. From there, it was as simple as splitting the stdout stream on that code and extracting the video position with a regex. The timecode is saved every five seconds. When the same video is opened again, the wrapper script uses the “-ss” flag to pass in the saved timecode.

In order to share timecodes between machines, the timecodes are stored in a folder in my home directory, indexed by the SHA-1 hash of the video file’s contents. I then set up that folder to be a symlink into my Dropbox and voila! Cross-platform synchronized video resuming in less than 100 lines of code, which you can download and use here.

This simple project shows how existing tools can be recombined to solve a daily problem and boost productivity. I’ve encountered tons of these little hacks (every engineer has a couple!) and I’m always blown away by the cool ideas that people think up. Leave a comment if you have any similar projects you’d like to share!

View Comments

Blue Screen - Ludum Dare 30 Entry

Friday, August 29th 2014


Last weekend, I participated in Ludum Dare, a game jam where you make a game from scratch in under 48 hours. The theme this time was “Connected Worlds.”

The game I developed is titled Blue Screen, where you travel between the real world and cyber space. Blue screens serve as the boundary between these worlds. I might have bitten off more than I could chew for this one, so it’s pretty short, but I hope that the central conceit works. All art, code, music, and sound was created within the duration of the competition. You can play the game on itch.io.

If you can’t run the game, then you can check out a video of a full playthrough below.

View Comments

ASCII Bell Character

Sunday, August 17th 2014


The other day, I accidentally printed a ton of binary data to my terminal. Upon doing so, my computer started to beep incessantly - which startled me a bit. I looked through the list of processes, closing all the terminals, but the beeps persisted.

Turns out this is a feature, and not me going insane. The ASCII value 7 is the Bell character, one of several control codes or non-printed characters in ASCII. Apparently this dates back to the days of teletypewriters, where it was used to ring a physical bell (as opposed to just a digital sound).

This article points out that it can even happen in the case of the Unicode bullet.

It just so happened that my data was full of 0x07, and all the beeps queued up, running the entire time as I searched Google and Wikipedia for solutions. The answer in my this case was to use the command net stop beep, found on this Stack Overflow post.

View Comments

Simple Reloading Server in Bash

Tuesday, August 5th 2014


It’s often extremely useful to have a server that automatically reloads when any of the source files change. Grunt is commonly used for this, but in some cases that is overkill - a simple bash script will suffice. The script below uses Python 2 to start the server and inotify-utils to wait on changes in a directory.

#!/bin/sh
set -e

# Create site dir if it does not exist
mkdir -p site

# Python server
cd site
python -m SimpleHTTPServer &
cd ..

# Kill python server on exit
trap "exit" INT TERM
trap "kill 0" EXIT

while true; do
  echo "Building site..."
  sass theme/styles.scss:theme/styles.css
  python2 buildsite.py

  echo "Waiting for changes..."
  inotifywait -e modify -r .
done
View Comments

The Damned

Sunday, July 20th 2014


A couple weeks ago, I took part in a game jam on itch.io called the AGDG Microgame Jam. The premise behind the jam was to create a WarioWare style game that takes place on a single screen. I chose to try a local multiplayer game, in the vein of the frantic, competitive multiplayer from the GameCube adaption of WarioWare.

Unfortunately, since it was mostly made during a single weekend, I didn’t get a chance to play-test at all, and for a multiplayer game that’s a death knell. If I get the chance to actually test it out, I might go back and tweak the mechanics.

Possible Concerns:

  1. It’s too easy to survive, especially after a certain amount of blocks have dropped from the arena.
  2. More obstacles should be implemented that actually bring out the chain mechanic.
  3. Chain physics is still wonky.
  4. Players may be so unwilling to cooperate, that any movement at all is impossible
View Comments