Tuesday, November 28, 2006

Creating and posting videos with xvidcap in Ubuntu

One of the reasons I'm excited about teaching online is that there are so many tools I can use to help me share information with students. Animations, videos, audio recordings (e.g., podcasts), blogs, discussion boards, PDFs of readings, textbooks, and plain ol' HTML pages can all be combined to make a course that is (hopefully) more interesting and accessible than just a textbook and HTML pages. So, in the coming months I'm going to be trying out various programs to see which ones I can use while creating content.

For the past few weeks I've been exploring different methods of creating videos. There are two specific things I want to do with videos in my course:
  • Create videos of tasks being performed on the desktop (screencap videos), primarily to create tutorials to help students use Excel, browse my course website, and other such things.
  • Create animated mini-lectures on key topics, probably based on PowerPoint (or OpenOffice Impress) slides. These will ideally be less than 5 minutes each and contain a combination of text, images, and animations.
There are many non-free, non-open-source products available to help with this, such as Camtasia and Articulate Presenter. While I'm sure they're good programs (they are widely used), they're hideously expensive: Camtasia Studio runs around $300 and Articulate Presenter costs at least $500. I've seen some Articulate Presenter videos - they've got an excellent navigation system built it, and are seamlessly cross-platform, but before I go spending $500 on a glorified screencapture program I want to explore the free solutions first.

Xvidcap

The predominant free open source video capture solution for Linux seems to be xvidcap. The program is completely free; it can be downloaded from xvidcap's Sourceforge page. They even have a .deb file that installs in seconds on Ubuntu; to install it all you have to do is download the .deb file and then double-click on it in the file browser (Nautilus), which will bring up a dialog that installs the program.

Using xvidcap is fairly straightforward; it has a small control panel and a little red box. Once you hit record on the control panel, xvidcap records everything that occurs in that little red box. The box can be resized to fit whatever you want to record using the eyedropper tool, which allows you to either click and drag to move the box or click into a program window to have the box sized to fit that program's window. The box is attached to the bottom of the control panel by default, but can be undocked from the control panel by hitting the lock button.

xvidcap screen shot
Screenshot of xvidcap; the program records everything that occurs in the red box.

The preferences are accessed by right-clicking on the filename (to bring up the main menu) and then clicking "preferences." Xvidcap can either save a series of screencaps to a directory (what xvidcap calls single-frame recording, which lacks audio) or can record a full-motion video with audio (multi-frame recording). The preferences window allows you to set all sorts of preferences - you can choose your output file format, video and audio codecs, video and audio quality, and frame-rate. Choosing wisely here is key, as too high a quality or framerate will result in videos with skipped frames (which will look and sound bad) or files that are unplayable on most computers (e.g., Microsoft Windows doesn't have DIVX codecs installed by default). As a minor note, some codec and framerate combinations are not possible, which unfortunately is often reported to you solely in the form of a program crash (but it's easy to reopen).

xvidcap preferences screen shot
Screenshot of xvidcap's multi-frame capture preferences.

My computer is old enough that I needed to lower the video quality and reduce the framerate as low as possible (7.5fps for the Microsoft DIVX 2 or MPEG DIVX codecs) to enable 700x700 video recordings without frame skippage. Reducing the size of the recording window does enable me to make higher-quality recordings, but there's only so small you can resize something before you lose important details.

Once you've got the options set, recording a video is about as easy as hitting the record button. When you're done recording, xvidcap will pop up a little screen summarizing the video that you just captured; pay attention to the framerate - if it's significantly lower than what you were hoping for, you will probably have to re-record the video (lowering the quality or recording area size). Practice recording with various settings to see what works best on your machine.

As a final note, if you're recording directly to flash video you may want to make note of the movie dimensions, as you may need that information to properly embed the video in a webpage.

Microphones and audio

Xvidcap will record audio along with your video; all you need is a working microphone and xvidcap takes care of the rest. This allows for easy narration of videos, something I plan to do regularly.

I'm using a Sennheiser PC 150 stereo headset with noise canceling microphone; it's probably not the best microphone out there, but it seems to work well. Setting up the microphone in Ubuntu was easy, if non-intuitive. I had to open the volume control (by right-clicking on the speaker in the task bar), go to the preferences in that control (edit/preferences), put a checkmark by all the microphone options ("microphone", "Mic boost", and "mic select"), unmute the microphone on the capture tab, and then turn on the "Mic boost +20db" option in the switches tab. As I said: easy, but not intuitive.

Choosing video codecs and creating Flash video files

Xvidcap has a number of codec options, and I'm still trying to figure out which codecs work best; here's what I've found so far (with very limited testing only only a couple of computers):
  • The MPEG 4 DIVX and general AVI file (DIVX, mpeg) work well for me on Linux, but don't seem to play well on Windows or Mac computers by default (they need DIVX codecs)
  • The Microsoft DIVX 2 and Microsfot avi file format seems to works well on Linux, Windows, and Macs.
  • The mp2 audio codec seems to work well on Linux and Windows, but not Mac. Unfortunately, I can't seem to get the mp3 codec to work with the Microsoft DIVX 2 codec.
  • Flash videos (.flv, what YouTube uses) work very well cross platform, but require a flash player to play.
Flash video seems like it's probably the most cross-platform and browser-independent format currently, so that's what I'm looking at using for now. There are two choices for making flash movie files in xvidcap:
  1. Create the flash files directly from xvidcap
  2. Create the movies using another codec and then convert them to flash files
The first option is probably the easiest, but since I might also want to distribute the videos in a number of other formats (and don't know how lossy the flv codecs are), I wanted to at least explore how to convert other formats to flash videos (.flv files).

Converting from the DIVX MPEG4 codec to flash files was relatively easy using mencoder (a component of mplayer). The command line to convert the files I eventually settled on (thanks to the mplayer manual) was:
mencoder inputfile.mpeg -o outputfile.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050 -lavfopts i_certify_that_my_video_stream_does_not_use_b_frames
This conversion step also allows you to scale the size of the video to whatever you want; simply add the flag -vf scale=YYY:-2 to the command line and the movie will be scaled to YYY pixels wide (proportionally scaling the vertical dimension).

Flash movie files have timing information in them that helps flash players play them; mencoder apparently does not include this information. However, the program flvtool2 can add this information (I found this thanks to DRM's excellent post). There is no flvtool2 package for Ubuntu, but downloading and installing it was relatively easy1. Once you've got flvtool2 installed, all you need to do to add the timing information is:
flvtool2 -U inputfile.flv
Flvtool2 can also be used to do a number of other things, including adding timestamps to the video for thumbnails (so users can skip through the video to specific timepoints).

Putting a flash video on the web

To actually play a flv file in a webpage you need a flash file on the webpage that will play the movie. While Adobe Flash can create these for you (for the low low price of $699 for Flash Pro 8), the entire point of this exercise has been to create videos using free open source tools. That's where FlowPlayer comes in.

FlowPlayer is a free open-source flash video player that can be easily added to a website; all you have to do is upload a few files to the server (as a user; no need to be root or actually install anything), insert FlowPlayer's quickstart HTML code into the HTML page of your choice, and you've got flash videos embedded into your webpage.

Samples

For a sample of how this looks, I've created three short videos and posted them here. Sorry, but you won't be hearing my voice in any of those videos, you'll just hear some music recorded by putting my microphone in front of a speaker (translation: badly recorded music)2.

And, here's an example of one of those sample videos embedded into this page:

Adblock









Exciting, isn't it?

Conclusion

It seems like xvidcap will be able to produce satisfactory video tutorials that focus on how to use programs and websites, and the videos produced will be easy to distribute in a variety of formats, including flash videos on the web. However, I have no idea if xvidcap will be able to easily create videos of slide-based presentations (using OpenOffice Impress); figuring out how to create videos of slide-based content will have to be the subject of another post.

1: To install flvtool2 just unzip into a directory and follow the instructions in the readme.txt (which basically say to run "ruby setup.rb config", "ruby setup.rb setup", and "sudo ruby setup.rb install"). You may have to install ruby first; Ruby can be installed via Ubuntu's standard interface.

2: I can't very well be a pseudonymous blogger and have my voice plastered all over the internets, now can I?

1 comment:

Radagast said...

Importing comments:

nlink
I think this artcile is great, there is another software I have been using for a long time and that has also been good to deliver me some really good videos. I had been able to create videos for my clients that can give them a demo on how to use my softwares or programs and that reduced the customer complaints by around 70%. You can test this Easy Software to Create Videos.
April 28, 2007, 2:48:14 AM PDT – Like – Reply

Radagast
Sadly my computer seems old enough (or I haven't figured out which XVidCap flags to use) that I can't record fullscreen right now (or, rather, I can, but I get tons of dropped frames). I need to figure out how to do that ...
January 28, 2007, 8:06:42 PM PST – Like – Reply

umar
Very interesting. I'm waiting for next tutorial with fullscreen mode.
January 27, 2007, 7:28:58 AM PST – Like – Reply

Radagast
I agree - it was frustrating to end up with Flash as the distribution method, as I know first hand how much trouble it can cause on Linux. Heck, I have FlashBlock installed on every computer I use.

I'll have to look into the Democracy player; that's a great idea. I was hoping to not force students to install a new piece of software just to take my class, but that might be worth it. Maybe I could distribute videos as both flash and a more open codec; it's easy enough to create Flash video from other codecs. Hm!
November 29, 2006, 8:28:37 AM PST – Like – Reply

lambic
It's a shame, after finding open source options for everything else, you were forced down the route of using Flash as your video format, a proprietary and less than perfect format. It doesn't always play well with Linux, although I hear the latest version is a significant improvement.

You may be interested in Democracy , an open source media player which works on Windows, Mac and Linux and plays just about every video codec out there.
November 29, 2006, 5:58:30 AM PST