Glenn's Junk Chest

An assortment of Glenn's writings, photography, gaming resources, flash movies, and other creative output.


Tuesday, February 21, 2006

Politics: Welcome to China

If you're in the United States, visiting this video at Google's video service currently presents you with this stark message:

This video is not playable in your country.

No reason is given. No avenue of appeal is suggested. It's not clear whether this is due to government action, google's own self-censorship, or some obscure feature of the political landscape. Go ahead, visit the realms where someone else decides what's suitable for you to see or hear. It's not a good feeling.

Now, the fact of the matter is that this sounds like it may be an option available when a video is uploaded. Some yahoo checked the option for "Don't show this video to visitors from the US". They probably did it to make a point, and as far as I'm concerned, the point is successfully made.

Governments and organizations need to stop trying to filter content from other countries at the border. I don't care if it's comic books being shipped to Canada, offensive cartoons published in Europe, yahoo auctions of world war II nazi memorabilia, or opinion articles about taiwanese independence. If free expression is a fundamental human right (which I certainly believe it is) then placing restrictions on who can access other's expression is just as much a violation of that right as stopping the expression itself.


Tuesday, February 07, 2006

Video: DVD video onto a PSP using a Mac

Well, I've been looking into this a lot lately.

An MPEG4 file that is playable by the PSP has the following characteristics:
1) It is 320x240, 368x208 or 400x192
2) It has a framerate of 29.97 or 14.985 fps.
3) It has stereo AAC audio at 24000 hz.
4) Its total bitrate is no greater than 768 kbit/sec.
5) It is named in the format "M4V#####.MP4", where ##### are numerical digits, and placed on the PSP's memory stick in "/MP_ROOT/100MNV01/"
6) It has properly formed PSP-friendly headers.

Optionally, there can be a second "thumbnail" file accompanying the MP4, which is a 160x120 jpeg image named "M4V#####.THM", where the ##### are the same numbers as used for the video file. This file is entirely optional and has no other features.

If any of the above 6 things are not true, it won't play. If you're on a Macintosh, and you have arbitrary source material that Quicktime can read, I recommend using the altShiiva application. (google translated version). Since it reads files using Quicktime, it's very input friendly, and, once you figure out its quirks, quite dependable. If you produce output that is 368x208 or 400x192 you'll need to run it through a command line utility called PSPREZ before it will work, since files at those resolutions require deliberately malformed headers in order to work. (no kidding.)

I, of course, totally hate it. The documentation is in Japanese, it doesn't appear to be frequently updated, and there's no provision for saving your settings, so you have to make sure you get them right every time you launch the app. Many people prefer to use ffmpegX on the mac, but I find it buggy and the UI confusing, and some of what it's doing under the hood really perplexes me. What I really want to do is use ffmpeg from the command line, because that way I can simply record the command line I used and reuse it, modified as needed.

Here's what I currently do when I want to go from a DVD to PSP on my Mac. I capture the video using Handbrake, to a reasonably high quality MPEG4/MP3 AVI, typically at 480x272 resolution. I do this because I figure if I keep this file, it's a useful resolution for playback on my TV or Mac, and if I gain the ability to compress a better PSP version in the future it's already at the PSP's native resolution. (I also like this format because it will play on my PS2 over the net using the media player software from gameshark. In general, I find it a good format for legacy devices.)

Then I use the ffmpeg command line that's built in to the PSPWare application. ffmpeg can be compiled in a bunch of different ways, with a bunch of different options, but the one in PSPWare is already compiled with the necessary libraries and extensions to do proper PSP output, and is capable of reading the AVI I just created without modification.

I then issue a command like this:

./PSPWare.app/Contents/Resources/PSPWareHelper.app/Contents/Resources/ffmpeg -y -i /Vid_Movies/SteamBoy480.avi -title "SteamBoy" -s 368x208 -r 29.97 -b 450 -acodec aac -ac 2 -ar 24000 -ab 32 -f psp /Vid_Movies/M4V10102.MP4

The "-i /Vid_Movies/SteamBoy480.avi" is the source
The "-title "SteamBoy"" is the name that will appear in PSP menus
The "-s 368x208" specifies the video size.
The "-b" is the bitrate for the video
The "-ab" is the bitrate for the audio
The "-f psp" switch tells ffmpeg to do proper PSP output, and it does proper headers so there is no need for PSPREZ.
The "/Vid_Movies/M4V10102.MP4" is the output file name, already in a PSP-acceptable format.

ffmpeg has a lot more options, but I find that this is a pretty good starting place. I rarely use the others except sometimes for cropping or padding video.

As a bonus, the ouput of this command will work on a video iPod without further modification, though you'll probably want to change the filename to something less crufty.

If you're interested in compiling your own ffmpeg that will do this, I suggest you look at the one in PSPWare. It displays the following information when it is run:

ffmpeg version 0.4.9-pre1-based-MobileHackerz030, build 4743, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --enable-faac --enable-a52 --enable-gpl --disable-ffserver --disable-ffplay --enable-memalign-hack --disable-vhook --extra-cflags=-mtune=970 --enable-pthreads --enable-faac --disable-mmx --disable-audio-oss --disable-audio-beos --disable-v4l --disable-debug --disable-pp --enable-g726 --disable-network --disable-gprof --extra-cflags=-force_cpusubtype_ALL --disable-strip --disable-shared
built on May 22 2005 23:36:15, gcc: 4.0.0 20041026 (Apple Computer, Inc. build 4061)


Sometimes, I want to do a compression from DVD to PSP overnight, without being on hand to initiate the second step of the two-step process. When that's the case, I often do something like this on the command line:

sleep 13800 ; ./ffmpeg -y -i /Vid_Movies/SteamBoy480.avi -title "SteamBoy" -s 368x208 -r 29.97 -b 450 -acodec aac -ac 2 -ar 24000 -ab 32 -f psp /Vid_Movies/M4V10102.MP4

This tells the shell to do nothing for 4 hours, then run the command that comes after the ;. Since I can count on handbrake being done by then, this allows me to have it happen without intervention. If I'm ripping multiple things from a DVD, I can even queue them up with multiple commands, separated by semicolons.

Update: My company, Clotho Advanced Media, Inc., has now written a command-line utility for OS X that allows for Quicktime conversions on the command line. Using it, I can now convert from a much wider variety of sources into PSP (and thus iPod) playable formats. In order to do this, I first convert it using our tool into an intermediary format that ffmpeg can process, and then use ffmpeg to convert it into PSP format. This is proving pretty succesful for us, and we're likely to put it together into a commercial offering at some point in the near future.