Turn your class audio and PDF into YouTube videos using Free Software Tools

Fri, 20 Nov 2015 08:31:15 -0500

Tags: PDF, MEncoder, YouTube


Last year I taught a graduate level, semester length class in Machine Learning over Large Datasets at Facultad de Matématica, Astronomía y Física de la Universidad Nacional de Córdoba, in Argentina.

I have made the slides and audio recordings of the classes available on-line at the class' site (in Spanish, sorry) under a CC-BY-SA license. I have recently dovetailing the audio and PDF into videos which I'm uploading to a playlist in YouTube. In this blog post I want to describe the tools I used to record and create the final videos.

Before the class

Get a head mounted microphone and install Mp3 Voice Recorder from F-Droid to record the class. The program is a native build of the LAME MP3 Encoder, it uses very little battery and runs well recording for a couple of hours. However, that program is very primitive and produces a single file name for the MP3 (mezzo.mp3). You need to rename right away or it will be overwritten.

Have your slides in PDF with embedded fonts. From a regular PDF, I use Ghostscript:

 gs -sDEVICE=pswrite -sOutputFile=- -q -dNOPAUSE -dNOCACHE class.pdf -c quit | ps2pdf - > class-no-fonts.pdf

At the class

To show the slides I use a script by Marcelo Fidel Fernandez which I modified to record the time each slide starts:

DISPLAY=:1 python pdf_viewer.py class-fonts.pdf  > timings.txt

But the MP3 and the slides need to be fine tuned by hand.

I also recorded a backup stream at the laptop using ALSA record:

arecord -f cd /path/to/class.wav

This was handy in one occasion when I lost the phone recording.

To have a last backup of the timings, I projected the class into a VNC session and recorded it, too:

vnc4server -geometry 1024x768
vncviewer :1 -PasswordFile ~/.vnc/passwd
vnc2swf -o /path/to/class.vnc -t vnc -P ~/.vnc/passwd :1 

I never used those files, though. Note: the other formats supported by vnc2swf can't cope with the length of a full class.

After the class

Extract the slides as PNG files using ImageMagick:

convert class.pdf -geometry 200\%x200\% class.png

Listen to the audio and determine the beginning of the 2nd slide and the total audio length in seconds (MPlayer is handy here).

Use the perl script to patch the timings file into a encoding plan:

timings_to_avi.pl timings.txt 25 2 clase3 2743.0 > slides.txt

Then create a temporary AVI file with the images using MEncoder:

mencoder mf://@slides.txt -mf w=726:h=544:fps=2:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

And add the audio:

mencoder -ovc copy -audiofile class.mp3 -oac copy output.avi -o class.avi

Finally, upload it to YouTube or host it yourself with an html5 video tag.


Your name:

URL (optional):

Your e-mail (optional, won't be displayed):

Something funny using the word 'elephant' (spam filter):

Your comment: