This series is written by a representative of the latter group, which is comprised mostly of what might be called "productivity users" (perhaps "tinkerly productivity users?"). Though my lack of training precludes me from writing code or improving anyone else's, I can, nonetheless, try and figure out creative ways of utilizing open source programs. And again, because of my lack of expertise, though I may be capable of deploying open source programs in creative ways, my modest technical acumen hinders me from utilizing those programs in what may be the most optimal ways. The open-source character, then, of this series, consists in my presentation to the community of open source users and programmers of my own crude and halting attempts at accomplishing computing tasks, in the hope that those who are more knowledgeable than me can offer advice, alternatives, and corrections. The desired end result is the discovery, through a communal process, of optimal and/or alternate ways of accomplishing the sorts of tasks that I and other open source productivity users need to perform.
Showing posts with label video.lecture. Show all posts
Showing posts with label video.lecture. Show all posts

Monday, April 9, 2012

Addendum to the first installment: alternate screencast applications

As you may recall, in the inaugural entry for this blog I described a crude mock-up I'd cobbled together, using Linux utilities, for producing screencast video lectures along the lines of those found on the khanacademy web site. I recently had occasion to explore some alternate screencast applications, since ogv files ceased playing back sanely on one of my systems. That issue was ultimately addressed by "upgrading" the video card in my aging Pentium 4 computer (with an old 128 MB nvidia card I got for $15). But not before I investigated some alternatives to recordmydesktop.

Of course there are various options for screencasting in Linux: I've read about Istanbul, Byzanz, vnc2flv, and some others, for example. I've so far gravitated toward recordmydesktop because it "just worked" and because it can be used from the command-line. But because of the video card issue mentioned above, I did recently decide to explore a couple of other alternatives which I'll write about in this entry, namely xvidcap and ffmpeg.

I should mention at the outset that, as those who read the first installment of this blog will be aware, I need something that not only records a video of a part of the desktop (actually, a particular application window in my case), but that allows for sound recording as well: after all, these are lecture videos I'm producing. So any screencast application that does not have built-in sound recording isn't going to work for my purposes.

Screencasting with ffmpeg

Most readers of this blog will have heard of the indispensable video-manipulating program ffmpeg. It's possible to do a truly amazing amount of manipulation and creation of videos using that program. And, as it turns out, it's even possible to do screencasting with it (in fact, ffmpeg may actually be used "behind the scenes" by recordmydesktop--though I'm not fully certain about that).

Some recent research on the web resulted for me in some successful experiments in screencasting with ffmpeg. The main ingredient in this screencasting capability is a switch called x11grab. Run from the command line, an ffmpeg screen/sound capture session would be invoked something like this:

ffmpeg -f alsa -ac 2 -ab 48k -i hw:0,0 -f x11grab -r 20 -s 800x600 -i :0.0+227,130 -acodec libmp3lame -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.avi
That command will output an avi file called, appropriately enough, output.avi that is 800x600 resolution and that grabs a portion of the screen that is 227 pixels from the left edge and 130 pixels from the top edge (about where I open the application I wish to record on this machine). The sound portion is transcoded into mp3 by libmp3lame--something I discovered reduces the final size of the file considerably.

I believe ffmpeg can output just about any video format, including ogg theora, as recordmydesktop does. In order for that to be implemented, the -vcodec argument needs to be modified to, in the case of an ogg theora file, to -vcodec libtheora, I believe, while the extension of the output file's name would need, obviously, to be changed to .ogv.

As those who are familiar with ffmpeg will know, I'm barely scratching the surface of the tip of the iceberg here as far as its capabilities go. In fact, ffmpeg's man page has got to be one of the most voluminous and daunting of them, and it's only within the last couple of years that I've begun to be able to make any sense of it. But don't presume that I mined the information above mostly from the man page: rather, I found a working sample command on the web, then went back to the man page to try and better understand how it works and how I might tweak it for my purposes. I'm really still on a very rudimentary level when it comes to understanding and using ffmpeg.

Now, though this ffmpeg solution works quite well, it's turned out to not really be usable for me. This is because, as great as it is, the ffmpeg process cannot be paused while it's running: you either have to stop it and resume anew if you have some reason to pause, or else you'll need to edit the resulting video and cut out  the extraneous portions. In case it's not apparent, it's really useful during a lecture to be able to pause and resume.

So, as well as it worked in my experiments, I decided that, until I can come up with some way to pause the process, then resume, ffmpeg is not going to work for me as well as recordmydesktop does.

Screencasting with xvidcap

Which bring my to the next screencasting application, xvidcap. There's a lot to like about xvidcap. It's a graphical application, but with a very minimal interface--just the type of gui application that appeals to me. It draws a nice, visible perimeter around the area you're recording, and the perimeter can be easily manipulated with the mouse to enclose whatever quadrangular area you'd like. And it does allow for pausing and resuming of the screencast.

A screenshot of xvidcap (running on someone else's machine)
Furthermore, it's able to output a few video formats, among which are mpeg and flv. It looks like a great application and I really wish I could use it. But there's a major problem with sound: you see, xvidcap was developed during an era when oss (Open Sound System) was the standard Linux sound server, but oss is now deprecated in favor of alsa (Advanced Linux Sound Architecture).

In theory, it's possible to emulate oss with alsa. That's what you'll read on the internet, anyway. But the fact of the matter is that, as Linux moves further and further away from the old oss architecture, emulation of it has become harder and harder. I spent quite a few hours trying to implement it on this system, so happy was I with what I'd seen of the video-capturing end of xvidcap. I tried a number of purported solutions I found in my web searches. But none of them enabled me to record sound alongside the video I was capturing with xvidcap. So, I've reluctantly given up on it for now.

Those are the two alternate screencasting programs I've toyed with lately, and with mixed results. Both seem to have their advantages as compared to recordmydesktop, but in the end, it looks as though neither is going to be able to displace it. If you have any sort of pointers for addressing either of the issues I experienced in my attempts to use those applications, I'd be most delighted to hear about them. So please do offer your input.

Segmenting video files

To wrap up this posting, I need first of all to confide that I finally did "upgrade" my old work PC. I replaced the aging Pentium 4 with a not-quite-so elderly dual core machine. So video recording, and especially playback, goes quite a bit more smoothly on this "new" machine.

One odd thing has cropped up regarding video, though. The problem is that, despite the fact that I use the same exact recordmydesktop command to record my screencasts, the resulting files are now almost twice as large as they had been on the old machine: instead of being on the order to 2 megabytes per minute, they're now closer to 4 megabytes per minute.

My suspicion is that the video hardware could be to blame, since I had a pretty old 32 megabyte ATI (PCI) video card in the old machine, while the newer machine has an nVidia 128 megabyte card (PCI-express). I've tried switching video card modules from nv to vesa, but that doesn't seem to affect the resulting video size.

This becomes a problem because I have a file size limit on the site where I must upload my lectures, and they're now routinely going to exceed the size limit. So, until I can figure out how to reduce the video file sizes back closer to what they were, I've had to come up with a work-around--namely to split the video files into parts that, individually, do not exceed the size limit. And for this, ffmpeg once again comes to the rescue.

In order to split my lecture files, I'm using the following command:
 ffmpeg -ss 00:00:00 -i in.ogv -t 00:30:00 -vcodec copy -acodec copy out.ogv
What that does is to start at the beginning of the file (the -ss 00:00:00 part), go 30 minutes into the file, then copy that section to a new file called out.ogv. So, for an hour-long lecture, after having done that to split off the first 30 minutes into a new file, the same command would be run again, except that-ss 00:00:00 would be replaced by-ss 00:30:00. Then, the two parts could be appropriately named (with part1 or part2 in the name, as appropriate) and uploaded.

That's all for this entry. If anyone has tips or recommendations about what's been discussed above or about anything else related to screencasting on Linux, please pipe in.

Afterthought: here's a link that offers some technical details on the sound hardware in my new computer: http://people.atrpms.net/~pcavalcanti/alsa-1.0.15rc2_snd-hda-intel.html#final . I was looking at that as I was trying to work out how I might get xvidcap functioning on this system.

Wednesday, January 11, 2012

First installment: A crude imitation of khanacademy's video lectures using GNU/Linux

The following offers a description--prefaced by a narrative about whence came my inspiration--of a rather kludgy GNU/Linux solution I cobbled together for enhancing my on-line lectures with a video element. I am far from being technically adept as a GNU/Linux user, having only lately in my 11 years of GNU/Linux use become reasonably proficient at administering my own small stock of GNU/Linux machines and my small LAN. Despite a lack of anything that could really pass as expertise in this field, I want to offer this description for two reasons: 1) it may be of help to others who are equally inexpert as I am and who wish to do something like what I've done; and 2) perhaps those who are more technically adept will weigh in and offer corrections, point out alternative applications, make suggestions for improving what I've come up with, or all of the above. It is with these caveats that I offer a description of my humble and rather unsophisticated attempts.

Perhaps you've seen some of the wonderful learning material khanacademy offers? Since I've done a bit of on-line instruction I was eager to see, once I'd heard about the site, what's being done there. I was quite pleased by what I saw and immediately saw in it an answer to a need I've perceived in my own on-line teaching endeavors; namely, how to incorporate into my on-line lectures some sort of video component.

To date, I've simply been recording lectures for my on-line course as audio files and posting the results on my course web site. I found this somewhat dissatisfying, being myself, as are many others, one who learns perhaps best with visual aids. I'd thought about how I might introduce some video element into my lectures but thus far had only considered filming myself looking into a camera and delivering a lecture. Handsome though I am, I could not see how that would result in any very meaningful enhancement to the lecture. The khanacademy method, which involves writing on a sort of virtual blackboard/whiteboard during lecture delivery, on the other hand, seemed to me a very good way of enhancing on-line lectures with video--video content that should surely enhance and augment the lectures.

A presentation program such as Power Point or OpenOffice/LibreOffice's Impress would certainly be an option for incorporating video into on-line lectures, many readers may now be thinking to themselves. That's undoubtedly true and does remain an area for me to explore further.

In terms of presentation programs, I actually have more experience with a more obscure, less polished presentation program called Magicpoint than I do with either of the more popular ones just named. The latest stable release of this program is a few years old, but it does appear the developer continues working on it as he is still, up to Jan. of 2012, releasing snapshots. As I mentioned, I consider myself still very much in the exploratory stage of enhancing my lectures with video so I undoubtedly will explore in the future the use of presentation programs for doing this. But for the moment I am quite enamored of the approach taken in the khanacademy lecture videos: being able to write or print to the screen, in a sort of chalkboard fashion, while delivering an on-line lecture, may offer the possibility of greater spontaneity and thus of more effectively commanding the student's interest during the lecture.

On seeing but a few minutes of the first lecture I accessed at khanacademy, I felt I'd found my answer--incorporating a sort of chalkboard as the video element to accompany the audio. But being a GNU/Linux user on the one hand, and something of a hardware trash-picker on the other, I wasn't sure I could pull this off. I did, as you'll see, come up with a solution that approximates--sufficiently for my current needs, in any case--the video component of the khanacademy lectures.

According to wikipedia, in addition to a screen capture program and a graphics tablet--a hardware item I do not own--khanacademy uses a freeware program called Smoothdraw for making their lecture videos (see http://www.youtube.com/watch?v=QZJAhfaZnUA for a fuller description of how they make their videos). One would assume that likely some video converting software, for conversion to flash, may also be employed by khanacademy. Thus, 4 basic components are required for producing these sorts of video lectures: a graphics tablet, a graphics program, a screen capture program, and possibly a video file conversion program.

In my initial tests to imitate this under GNU/Linux, I decided I would forego the graphics tablet and just use the hardware I already have--a mouse and keyboard. Should I continue to meet with success, I could later acquire a tablet so as to approximate more closely the results produced by the khanacademy. This also saved me some possible hiccups in trying to get the graphics tablet working under GNU/Linux and within the graphics program with which I'd be using it. Having attempted in the past to draw freehand and write using a mouse, I knew this meant I'd be typing to my chalkboard rather than writing by hand. Mouse use would be restricted to adding emphasis, e.g., underlining typed words, perhaps drawing an occassional simple figure like an arrow or "x," and the like.

Though I cut corners, as it were, on the hardware end, I didn't need to cut corners in two other important areas--namely the screen capture program and the video conversion program. recordmydesktop does an excellent job of screen capture, while ffmpeg does the video conversion for me--in this case from the ogg theora output of recordmydesktop to the flash format. The encoding is quite resource-intensive and correspondingly time-consuming--taking over 2 hours to encode a 54-minute lecture on this old P4 2.6 with 1 GB of RAM. But the resulting video came out perfectly fine, despite the wait.

As for the graphics program I decided to start off using tuxpaint--a graphics program for children. It's not nearly as capable as Smoothdraw--for example, it is not possible in tuxpaint to simply scroll away the screen once it's been filled up with writing. But tuxpaint does have an eraser cursor that works to reasonably good effect. It is also a fairly lightweight program, which to me is always desireable, and especially apropos given the older hardware I'm using. There are undoubteldy better choices for graphics programs--programs that would work as well as or better than Smoothdraw for creating the sorts of effects seen in the khanacademy videos. But for an initial foray into this realm tuxpaint has worked well.

As to the particulars of how I am creating my lecture videos using this system, I first start tuxpaint at 1024x768 resolution (my display is set at 1280x1024): tuxpaint --1024x768 --nosound. I then fire up recordmydesktop, as follows: recordmydesktop -x 300 -y 200 --width 800 --height 600 --pause-shortcut Control+p --no-cursor ---v_quality 12 -o recordd-desktp-vid.ogv. After I've moved tuxpaint around on the screen so that just the drawing-board portion of the program is within the frame recordmydesktop creates, I begin recording my lecture, typing in text as needed. Then, as an additional step that may or may not be needed depending on what will be done with the output file, after recordmydesktop has finished encoding the lecture, ffmpeg can be run as follows: ffmpeg -i recordd-file.ogv -s vga convrtd-file.flv.

A few explanations on the switches I use when running these programs. As for tuxpaint, the --nosound option is imperative if you expect to use this program in conjunction with a lecture. The program makes all manner of sounds in regular use--all calculated to delight children, but which would obviously be out of place in a lecture for adults. As to recordmydesktop switches, I find control+p to be a more intuitive pause key sequence than the default (control Mod1 p): this, of course, allows me to pause the video as I deliver my lecture, then to resume it. The --no-cursor switch, as should be evident, causes the cursor to not be recorded in the video. Finally, since I do not need a very high-quality video in the final output, and since I want to decrease the file's size a bit, I use the --v_quality 12 switch (0 being the lowest possible video quality and 63 the highest).

This is a quick and dirty summary of how I've cobbled together, using a set of GNU/Linux utilities, a means of producing lecture videos that mimic crudely the final products seen on khanacademy's web site. As mentioned, I consider this an initial foray into this area. I hope to implement improvements and enhancements and, with feedback from readers who have more experience and/or expertise, to arrive at a much improved means of producing lecture-augmenting videos under GNU/Linux.

Here is a short demo video made using the kludge described above:



If you have pointers for how more effectively to create lecture videos using GNU/Linux, or can suggest improvements on the method I've developed, please offer your input!