Sean’s Obsessions

Sean Walberg’s blog

DivX -> VCD Conversion

For a while now I’ve been wondering how to convert an .AVI file into a VCD, having tried once or twice but ending up stuck. Recently, a friend sent me a show he taped from TV, which prompted me to try again. I succeeded, and here’s how I did it. The basic steps in converting any digital movie into a VCD seem to be the following:

  • Transcode the file into an MPEG II audio and MPEG I video stream
  • Recombine the audio and video streams into one file
  • Create a VCD image out of the resulting file
  • Burn the image to CD

Note that there are lots of other things that can be done, such as titles, effects, multiple movies, etc, but this is the simplest case. The first step is what caused me the most grief, since the file I had wasn’t in a format that transcode knew about

1
2
3
4
5
6
7
8
9
10
11
# tcprobe -i RevolutionOS.avi
[tcprobe] RIFF data, AVI video
[avilib] V: 29.970 fps, codec=DX50, frames=3595, width=720, height=480
[avilib] A: 44100 Hz, format=0x11, bits=4, channels=2, bitrate=355 kbps,
[avilib]    3595 chunks, 3681280 bytes, CBR
[tcprobe] summary for RevolutionOS.avi, (*) = not default, 0 = not detected
import frame size: -g 720x480 [720x576] (*)
       frame rate: -f 29.970 [25.000] frc=4 (*)
      audio track: -a 0 [0] -e 44100,4,2 [48000,16,2] -n 0x11 [0x2000] (*)
                   bitrate=355 kbps
           length: 3595 frames, frame_time=33 msec, duration=0:01:59.953

Note the third line of the output, “format=0x11”, meaning that the software couldn’t figure out what the codec was. I ended up converting it to PCM with

1
mencoder RevolutionOS.avi  -o RevolutionOS_pcm.avi -noskip -ovc copy  -oac pcm

Then, I could transcode and create the vcd with this script (note that this site offers an easier version that uses mplayer for everything… wish I knew about that!)

Basically, this script tries to calculate all the clipping needed to scale your video into the size needed for VCDs. It also figures out how many CDs you need. The basic transcoding goes like this:

1
transcode -i FILE -x VIDEOCODEC,AUDIOCODEC -y mpeg2enc,mp2enc -o BASENAME

The input A/V codecs can be autodetected. After the transcode step, you’ll have two files, BASENAME.{m1v,mpa} containing the video and audio streams respectively. Note, to extract the audio to an mp3, you can do something like

1
transcode -i FILE -x NULL -y null,lame -o foo

which will generate foo.mpg. You can use -E and -b to specify the sampling frequency and bitrate respectively. After you have the video and audio streams, you put them back together:

1
2
tcmplex -i BASENAME.m1v -p BASENAME.mpa -o BASENAME.mpg \
  -m 1 -F template

where there is a file called “template” containing the words

1
maxFileSize = 795

for an 80 min CD, or 735 for a 74 min CD. This multiplexes the streams as a VCD into BASENAME-nn.mpg Then, convert each .mpg to a VCD:

1
vcdimager -t vcd2 -c BASENAME-nn.cue -b BASENAME-nn.bin BASENAME-nn.mpg

The VCDs can then be burned with:

1
cdrdao write --device 1,0,0 --speed 8 BASENAME-nn.cue

1,0,0 is the SCSI ID of your burner, you can get it by running “cdrecord –scanbus”.

Again, most of this is automated through divx2vcd… However if you run into problems like I did, you may have to do it the long way.

All the software such as transcode was obtained from Freshrpms.net.

Sean

Better RSS Tool

One of the comments to an older article pointed out Feed On Feeds as a good RSS aggregator, and I finally got around to trying it.

I have to admit, it’s pretty much exactly what I was looking for. The main screen lists all your feeds, with a count of how many new articles were posted. You can then mark items read, either per item, per feed, or everything. It’s really very handy. Screenshots in the extended entry.

Main screen. Note that one blog has a new item:

You can click on the “1 new” or on the number of items, and it will take you to either only the new items, or everything. Here, I clicked to see what’s new at Geek Blog

My biggest beef with the software is that it isn’t templated, so if I want to change the HTML I’m changing the author’s source. If I ever get time, maybe that’s a contribution I can make to his project. It also uses the Magpie RSS parser, which is just as anal as XML::RSS which I was using in my own project, so I’m no further ahead there.

Another Reason VI Rocks

I’ve recently started playing with PIC microcontrollers at home, and have found some more of vi’s features saving me time. I can’t believe I haven’t used this before, the ability to run makefiles from within an editor session, and have vi interpret the output. Like programming in C, Makefiles can be used to automate the building of a project. An .asm file is written by the programmer, which is compiled by an assembler into a .hex file. The .hex file contains the opcodes and memory locations to be burned to the PIC by the programmer. So, the makefile I wrote is

1
2
3
4
5
6
rs232.hex:      rs232.asm
    gpasm -a inhx8m rs232.asm
burn:
    picprog --pic-serial-port=/dev/ttyS1 --burn  -i rs232.hex
clean:
    rm *.hex *.lst *.hx? *.cod

The first line says that the .hex file depends on the .asm file, so that if the latter is newer, use gpasm to build the .hex. The burn target doesn’t depend on anything, so it has to be called manually to use picprog to copy the .hex file to the pic. Finally, I have a clean target the gets rid of some of the temporary files.

The process then, to get my code to the PIC is:

1
2
make
make burn

On to the vi part… vi has a build in command to execute a Makefile in the current directory. Surprisingly enough, type :make and it will be build. Similarily, :make burn can be used to burn the PIC without leaving your vi window. The real value comes in when you get vi to interpret the output. If there is an error in my code, gpasm says something like:

1
2
3
gpasm -a inhx8m rs232.asm
rs232.asm:114:Error [157] Unknown opcode "abcf"
make: *** [rs232.hex] Error 1

The 114 is the line number the problem is on. Wouldn’t it be nice if vi would keep track of the errors, and jump to the appropriate line number? Quickfix to the rescue. By default, vi is set up to understand gcc’s output, which is different from gpasm’s. gpasm can be understood with:

1
setlocal errorformat=%f:%l:Error\ %m,%f:%l:Message\ %m

You can put that in your .vimrc or create a compiler file, mine is /usr/share/vim/vim61/compiler/gpasm.vim. Then, :compiler gpasm causes it to be loaded. When you run a :make from within vi, it learns the line numbers that have errors or warnings. Lots of commands are available, read the Quickfix docs for the complete list, but the common ones are: :cn - go to the next error :cp - go to the previous error :cc N - go to error # N :clist - show all the errors So, with the gpasm.vim file in place, I put the following in ~/.vimrc

1
2
:set autowrite
:compiler gpasm

The autowrite command forces a save whenever I do a :make, ensuring that I’m compiling what was on my screen.

Starting Out With CVS

As often as I use CVS, I can never remember how to start a new project from an existing code base. Invariably, I look in the man pages and on the web, and read through several pages to get what I want. Here is the way to do it.

The goal here is to take some existing code, put it under source control, and then set it up so you can begin checking it back in. We import, delete, then check out to do this:

The example uses a project called “rs232”

Make sure $CVSROOT is set:

1
2
$ echo $CVSROOT
/export/home/CVS

(if not, set it, then “cvs init”)

Get into the directory with the code:

1
2
3
4
$ pwd
/export/home/sean/rs232
$ ls
Makefile  rs232.asm  rs232-poll.asm

Import the code into CVS:

1
$ cvs import rs232 VENDOR HEAD

You’ll be prompted to make a comment, I usually use “Initial import” You’ll then see the files being created (the ‘N’ at the left column)

1
2
3
4
5
"/tmp/cvsY0a2zz" 5L, 244C written
N rs232/Makefile
N rs232/rs232-poll.asm
N rs232/rs232.asm
No conflicts created by this import

So, now the CVS repository is created:

1
2
3
4
5
$ ls -l $CVSROOT/rs232
total 16
-r--r--r--    1 sean     users         530 Nov  3 08:27 Makefile,v
-r--r--r--    1 sean     users        6347 Nov  3 08:27 rs232.asm,v
-r--r--r--    1 sean     users        3799 Nov  3 08:27 rs232-poll.asm,v

Since I’d like to continue editing the code where it is, delete the working directory and check it out (or, we could have moved the original files to a tempdir)

1
2
3
4
5
6
7
8
9
10
$ cd ..
$ rm -rf rs232/
$ cvs co rs232
cvs checkout: Updating rs232
U rs232/Makefile
U rs232/rs232-poll.asm
U rs232/rs232.asm
$ cd rs232
$ ls
CVS  Makefile  rs232.asm  rs232-poll.asm

Make your changes, then use cvs ci to check in.

Oh, Yea

I completely forgot to post an update about the baby! He’s two weeks old now, and doing very well! I’ve had 2 weeks off of work, and will be going back to work on Monday.

Name: Isaac Christian Jensen Walberg
Birthweight: 10lbs, 8oz
Birthdate: October 17th, 3am CST

Some pics here

I have some more pics to scan in, I’m beginning to think it would be easier to get a digital camera :|

It’s a Boy!!!

3:01 am, healthy baby boy! More details to come, I’ll make calls tomorrow.

Open Relays Aren’t the Only Problem

While looking through The Lost Olive, I found this paper dealing with someone who found himself relaying spam through a web exploit. In a nutshell, someone didn’t read up on CGI Security in a photo web log, and a user found that people were exploiting the hole to send out spam emails.

First of all, the paper details some excellent troubleshooting, starting off with “something seems odd”, and getting down to sniffing networks and looking at processes. If nothing else, the paper is worth reading for that reason.

More importantly, it shows that spammers are using more complicated vectors than the traditional open relays, and that blacklists aren’t going to help. (It also shows that if you’re going to run any sort of server on the Internet, even for fun, take responsibility for it!)

I’ve read potential solutions, from a sender-pays strategy, to an all-out whitelist. I still believe that anything that limits the open nature of the Internet isn’t good.

I’m trying to think of a system based on trust, such as PGP’s Web of Trust. Most of the email that you get is from someone you know, or at least within a couple of degrees of freedom, right? I’m also thinking that for scaling purposes, and technological reasons, it should be done on the MTA level rather than the user level.

That’s about it for now. An email just arrived, someone named “NICOLA.BARIBEAU” apparently had a great time this weekend, I’d better give it my full attention.

Increase Your DI;C;K SIZE.

The only solution to Penis Enlargement
hukneapdarlt qplenqcynqi
ONLY THIS WEEK: Add at least 3 INCHES or get your money back!
sipfrdddkwmyr pjjhogdhncrzd

No, I haven’t gone crazy. Read this to see what I’m up to.

We are so sure our product works we are willing to prove it by offering
a free trial bottle + a 100% money back guarantee upon purchase if you
are not satisfied with the results.

—> Click Here To Learn More
Also check out our *brand new* product: Penis Enlargement Patches
Comes with the 100% money back warranty as well!
ewikyubgtussrc okncjwpfpqpt

Perl Links

I usually try to provide some original thoughts here, but I’ve run across several perl links that are worth passing along:

1 - Advanced usage of CPAN, including determining dependencies, updating all the modules on the system, and a simpler way to replicate modules across systems

2 - Excerpts from the new Perl Cookbook, which talks about DBD::SQLite, a DBD module that lets you do SQL databases without a SQL server (sort of an embedded SQL database)

3 - More from the new Perl cookbook, interesting things on “pretending a string is a file”, and regex shortcuts for balanced operators (ie {}, [], (), etc)

4 5 6 - Three articles on design patterns in Perl, sort of a warm up to the author’s upcoming book.

More RSS

Still on the quest to simplify my life with RSS feeds, I gave AmphetaDesk a try. It was a simple install, not to mention a nice interface. However, it’s way too glitzy for my needs – it took several screens to fit in what my own concoction fits in a little over one.

Furthermore, I have to run it on my desktop and proxy in the request, since my simply K6/233 doesn’t need the strain.

So, I’m pretty much resolved to continuing to build my own. It’s really simple, a CGI that calls a TT2 template. The template spits out two columns of RSS feeds, to which I can customize on a per feed basis. Right now, all the hooks are in to do things like change refresh times (since the rss feeds are cached), or display comments. It’s just a matter of writing some admin screens to automate it, otherwise I end up hardcoding the options in the script.

Here’s a screenshot:

Through this blogging thing I’ve also got around to figuring out CSS, which made the layout easier.

Those looking to learn Perl and web development, this is an excellent project (I suppose almost any language will do). There are several patterns in use, such as Caching and Templating, not to mention XML parsing and the opportunity to build some elegant data structures.

Sean