Let’s say you have a middling to lousy Internet connection, but you still want to take advantage of an online video language course. What’s the solution? Download the videos, obviously; my processor is much faster than streaming them over my middling to lousy connection.
The videos, however, are streamed under the “mms” protocol. This doesn’t mean that they can’t be downloaded (they are free to view, by the way); it just means that you can’t download them directly, you have to stream them and save them as they’re streamed. (Essentially, this is downloading them in real time; so saving the thirty-two minute video takes thirty-two minutes.) While I’m at it, I want to convert them from the execrable Windows Media format they’re provided in to a different, free, and good format; namely, Ogg Theora. What to do?
Well, Video LAN Client, or VLC, provides the answer. This cross-platform media player can handle playlists and deals with just about every media format known to man. ffmpeg, on the other hand, will be used for converting the video to Ogg Theora. There are plenty of tutorials online explaining how to use VLC to save a streaming mms video to disk, and plenty explaining how to use ffmpeg to convert a video to Theora. (I’ll show you all in a minute, only I’ll do it in a better way.) It involves navigating lots of menus; it takes several seconds per video, which is fine when you’re only doing a video or two.
Thing is, this is a multi-part language course. With fifty-two parts. Downloading them all individually, one by one, when it takes half an hour to do each, and then converting them all manually with ffmpeg, would be a hideous nightmare. However, VLC is a Unix application by birth and by choice, and consequently it has a fully developed command-line interface. This means that it can be scripted. Which means that I can get all this done without a fuss or a bother; in the time it takes to download one video manually, or even less, I can write a script which will handle each and every one for me, and convert them all to Theora while it’s at it. But how, you ask?
RTFM! I went into the documentation and learned how to tell VLC to save a streaming video while it streams when invoking it on the command line, and how to tell vlc to exit when it’s done. (Check the script below!) This took about ten minutes. I then hammered out the script; I had to look up the syntax for while loops in a bash script, which took another ten minutes or so. I then ran it, corrected a couple of errors, and ran it again. About a half hour of work, and I was able to download and convert all fifty-two videos without a lick of trouble, while not even looking at the computer the entire time unless I wanted to. Without the scriptability of the command line, I would have had to nurse the whole process for well over twenty-four hours to get it done.
Yes, the command line is superior, if you read the documentation and take a few minutes to do it right instead of doing it easy. That’s the way with all fields; why should computers be any different? An automatic transmission is easy as pie; but a standard gets better gas mileage and provides better control.
It’s the same way with computers. A graphical interface is shiny and lets you pointy-clicky and probably after a few minutes accidentally stumble on whatever you need to do, then immediately forget how you did it until you pointy-clicky your way back to it again the next time. But the command line gets you more control, more facility, once you’ve learned how to use it. Learning how to use it requires work; there’s no two ways about it. But that work will pay off once you do it.
So here’s the script. Enjoy it in all its ugly wonder.
#!/bin/bash
# +AMDG
i="0"
while [ $i -lt 53 ]
do
i=$[$i+1];
if [ $i -lt 10 ]; then
vlc --sout videos_{$i}of52.wmv mms://video_path_0$i.wmv vlc://quit;
ffmpeg -i videos_{$i}of52.wmv -sameq -acodec libvorbis videos_{$i}of52.ogg;
fi
if [ $i -ge 10 ]; then
vlc --sout videos_{$i}of52.wmv mms://video_path_$i.wmv vlc://quit;
ffmpeg -i videos_{$i}of52.wmv -sameq -acodec libvorbis videos_{$i}of52.ogg;
fi
done
exit;
Of course, this puts actual curly braces in the final file name, something I didn’t intend. But a quick line of bash, using the rename Perl script (standard on every Linux distribution I’ve used), took care of all that; another half-minute. Big whoop.
The condition is necessary because the videos are named in the form “video_$number.wmv”, where $number is always two-digit, even when it’s less than ten. They do this simply by adding a leading zero (as in “03″). That makes it show up in numerical order in file listings (instead of that annoying “video29, video3, video 30″ listing you’d get otherwise), but it did necessitate two different statements, one if there was a leading zero and one if not. I could have made this just one, but it was more work than it was worth, as this worked splendidly.
Learn the command line! It’s better!
Praise be to Christ the King!

Cool. What language are you studying?
+AMDG
I’m trying to become vaguely competent in Spanish again, mostly as a career move. As it is, I can only understand Spanish spoken in a horrendous American accent, and I have trouble with it even then.
Praise be to Christ the King!
I am a perfect dunce when it comes to foreign languages. I did two years of Spanish in high school and a year of Spanish in college, but I nearly failed every year. It was good for me, though. At the time I believed that I could excel at anything if I worked hard enough. Ah well, I was fortunate that God showed me that my confidence was actually pride–and eventually, foolishness.
I’ve heard good things about Coffee Break Spanish. Best of luck.
P.S. In my field, the career-building language is Mandarin. I’ll pass!
+AMDG
Wait ten years; it won’t be Mandarin anymore. Remember in the early 1990s, when the Japanese were taking over the world?
Language learning is *hard*. Really, really hard. There’s just no way around that; it’s hard for everybody, it’s just that some people enjoy it more than others. It’s even hard for children, despite the popular myth that children learn languages easily; it just looks like it’s easy because they’re doing it all day, rather than a half an hour a few times a week.
Anybody *can* learn a foreign language, given sufficient motivation. But the necessary motivation is often quite high. I’ve had insufficient motivation all my life; I’ve been learning Spanish and French for ten years, and still can’t speak either. Eventually, I’ll do it. God help me.
Praise be to Christ the King!
That is very true for programmers. But common folk can’t take the trouble to learn the scripting language just to download videos. And consider that for every task you want, you learn a new scripting language. Too much work for common people. It’s easier for them to pay someone and get a windows software made for this purpose.
+AMDG
“It’s easier for them to pay someone and get a windows software made for this purpose.”
Really? What “windows software” answers this particular problem?
“And consider that for every task you want, you learn a new scripting language.”
It’s hard to answer this any less concisely than “uh-uh.” I know Perl, can stammer in shell, and am learning C. I never write utility scripts in anything other than shell. Nor, of course, do I ever need to. What makes you think that every different task requires a different scripting language?
“Too much work for common people.”
Really? Because without doing this, they just don’t have the videos, period. They have to watch them over their unreliable net connection, stop-action and all; can’t buffer enough to get a smooth viewing experience; and can’t watch at all if they’re not connected to the Internet. So it’s either “half an hour looking up shell syntax”, “spend twenty-seven hours doing it manually via GUI menus”, or “do without”.
Also, I am not a programmer.
Praise be to Christ the King!