Raspberry Pi 2 
Monday, March 2, 2015, 09:44 PM
Long time no blogging.

I picked up a Raspberry Pi 2 from Adafruit and started in messing around with it tonight.

Here's what I've done so far - I grabbed the latest IMG of Raspbian and installed it to an SD Card using ApplePi Baker.

Now, the first thing you have to do when booting the Pi from an image like that is to expand the file system. If all goes well, the thing should auto-book into a primitive looking text interface called 'raspi-config', and the first menu item is 'Expand Filesystem'. Select that, and confirm that you want to do this, and to reboot the Pi. If for some reason the Pi bails out of this process (as mine did) simply type:
sudo raspi-config
and try it again. Second time is the charm.

The next thing you should do is to go into the Internationalization options, and get your Pi set up for your locale - I chose En-CA-UTF8 (english, canada, utf-8 charset) instead of the default EN-UK-UTF8) and I chose the EN USA layout for my keyboard. With all of that sorted out I went down to 'Overclock' and set it to the Raspberry Pi 2 default of 1000Mhz. Also be sure to dip into the 'Advanced' section and enable SSH. A reboot later, and I was good to go.

Now you'll want to get your Raspberry Pi 2 on the network. At the command prompt, enter:
This will fire up the Linux desktop, which isn't a lot to talk about. What you're looking for here is the WiFI setup GUI - which will make getting your RPi2 onto the network a breeze, provided you sprung for the $13 WiFi dongle like I did. Wires are for squares!

You can 'shutdown' the Desktop and return to the command line. If you type:
at the command line, you can find out what your Raspberry Pi's IP address is.

Back on my Mac,I fired up the Terminal and typed in:
ssh pi@
(that's the IP address of my Pi - yours is likely different). It'll ask you if you are sure you want to connect (yes) and then ask you for a password. The default is 'raspberry'.

Then I headed over here and started following the tutorial. So far, I'm on the second step - the 'upgrade' - it's taking a very long time, but that's to be expected. Pretty sure that just getting Raspbian installed and up to date is going to be the extent of evening #1. More later.
add comment   |  permalink   |   ( 2.9 / 10 )

"New" server 
Thursday, June 24, 2010, 10:35 PM
I've swapped out my fire-breathing linux server for a server built on an old G4 Mac Mini I had kicking around. The difference in the noise level here is amazing - the mini is practically silent. Had very little trouble getting everything moved over and setup here (there's more than one domain being served off this machine).

In the days ahead I'll be expanding this post to document how to secure MAMP for use as a real production server. There is information out there, but it's all in bits and pieces and some of it isn't all that current. I'll do my best to write up a clear and concise guide.

add comment   |  permalink   |   ( 3 / 3281 )

Encoding for the PS3 
Monday, February 15, 2010, 09:58 AM
The Sony PS3 is a little picky about what kinds of video files it will play. In the case of .MP4 files, the format is difficult to get exactly right. I'm sure that if you've tried before, you will have gotten the dreaded "Corrupt Data" message from the PS3.

The correct method is similar to the posts below about encoding from bluray format in that you need to process the audio and video separately, and then mux the results back together into the final .mp4 file. Here is the recipe:

Step 1: Separate the Audio
Separate the audio from your source into a separate .wav file. See below for how to do this for a bluray source. If your source is almost anything else, the following will do it for you:

mplayer -quiet %source% -ao pcm:fast:file=audiodump.wav -vc dummy -vo null -channels 2

Step 2: Encode the audio

neroaacenc -lc -br 128000 -if audiodump.wav -of temp_audio.m4a

Step 3: Encode the video
Note that there will be some small but significant changes to the usual video encoding command line here. These will ensure a file that plays back on the PS3 beautifully. Note that I have omitted the usual crop, scale, and dsize commands from the -vf section, as these will vary greatly from file to file. Look at the bluray entries below for more information on these command line parameters. Just be sure to put the "format=i420" as the last filter in the chain.

mencoder %source% -o temp_video.h264 -of rawvideo -nosound -mc 0
-ovc x264 -x264encopts qp=20:bframes=3:partitions=p8x8,b8x8,i4x4,p4x4:
level_idc=4:threads=auto -vf format=i420

Step 4: Mux the result

MP4Box -add temp_video.h264 -add temp_audio.m4a -fps 23.976 %filename.mp4%

There you have it. Copy the result to your PS3 via an SD Card or USB Stick, and it will play back perfectly on the PS3.
1 comment ( 36 views )   |  permalink   |   ( 3 / 6152 )

BluRay to .mp4 Part 3 
Wednesday, February 4, 2009, 06:48 AM
Well, it has been an interesting week of tinkering around, trying to find the best way to do this process of turning a bluray title into an .mp4 file. The software line-up has been reduced considerably.

Of course you need AnyDVD HD. And you'll need to follow the instructions in Part 1 of these instructions on obtaining and installing a UDF File System. And you'll need the neroaacencoder - follow the instructions in Part 1 for that.

You need the newest version of eac3to. There have been a lot of improvements to this tool that makes the process fairly painless.

Ok, let's start. Put your bluray disc (I'm still using Wall-E as my example) into your bluray drive, and open up a Command Prompt window. With the latest eac3to in your path, cd to a place on your computer where you want to store the 20Gb intermediate files that you are going to be ripping from the bluray disc. Then enter the following command:

eac3to j:

J: is the drive letter of my bluray drive - substitute the letter for your own drive here.

eac3to will chew on the disc a bit, and then spit out a listing of all the playlists. Now in the case of Wall-E there are 7 different playlists - the main movie in 3 different languages, plus the "geek squad" version of the movie in 3 different languages, etc. etc. With some experimentation on my part, I found that the playlist I wanted was #6. Remember - the longest playlist is not necessarily the movie. On Wall-E the longest playlist is the geek squad version. Not what you want. Now, enter this command to list the streams for playlist 6:

eac3to j: 6)

This will take some time--about 5-6 minutes--but be patient, eventually eac3to will list the video, audio, and subtitle streams contained in playlist 6. What we want is video stream 2, and audio stream 5. The command syntax for eac3to is really simple - you list the stream, and then say what you want done with it. Enter the following command line:

eac3to j: 6) 2: video.* 5: audiodump.wav -down2 -down16

I'll break this down a bit:

2: video.*
This tells eac3to that we want to save track 2 as a file called "video". The "*" tells it to give the file an extension according to the format of the stream. In Wall-E's case, the video is encoded with h264, so the resulting file will be "video.h264". Easy.

5: audiodump.wav -down2 -down16
This tells eac3to that we want audio track 5 saved to a .wav file, down-mixed to stereo, and down-converted to 16 bit audio.

eac3to will set about doing these tasks, and will take some time to do it - up to 4 hours or so depending on the speed of your system. If you have the drive space to do so, ripping the entire disc to your harddrive first will speed up the process considerably. For example, if you had ripped Wall-E to the harddrive first, you'd use the following syntax:

eac3to e:\quack_d1_can, substituting your own drive letter and the name of your particular folder.

eac3to will do the processing in 2 passes. Because the movie Wall-E is chopped up into several files (46 pieces in all) there are tiny gaps in the audio track. eac3to will recognize this, and create a gap log file as it does the first pass. It will then go back and do a second pass on the audio, using the log file created in the first pass to eliminate the gaps. The reason the movie is chopped up into so many pieces is actually a testament to Pixar's obsessive tendencies - they not only translate the audio for the movie into different languages, but they also translate most of the visual signage seen in the movie - each little piece is a version of a scene where there is a sign or other visual material that has printed English in it. Other playlists use other pieces, with all those visual bits translated into either french, or spanish. Pretty cool.

In the end, you'll have a video stream "video.h264" and an audio file "audiodump.wav". Follow the rest of the steps from Part 2 to encode the audio and video, and mux them into an .mp4 file.
add comment   |  permalink   |   ( 3 / 5771 )

Blu-Ray to .mp4 Part 2 
Sunday, January 11, 2009, 10:14 AM
After writing this, I discovered that I was doing a step wrong. There is an additional tool you will need called BDInfo that will parse the playlists on the blu-ray disc, and help you discover the correct playlist for your movie. You can then load the playlist in TSMuxer instead of the process I described below, and have a much easier (and correct) time of putting the movie back together. I heartily recommend this tutorial and in fact I've been having a lot of fun with the MediaCoder program described in that tutorial. Pretty nice GUI for beginners, and has access to the advanced encoder options for fussy people like me.

At this point you've downloaded all the software I mentioned in Part 1. You'll need to put all this software on your computer somewhere in your PATH. Follow the instructions here. You've got the UDF driver installed according to the instructions in Part 1. You've got your blu-ray drive hooked up, and you are ready to go.

Step 1: Extract the movie.
Put your blu-ray disc in your blu-ray drive. For the sake of this tutorial, I'm going to be using Wall-E from Disney, since it has the most obnoxious file arrangement I've seen on a blu-ray disc (so far). If you can rip this one, you can rip anything.

Start up tsMuxeR GUI. Click the "add" button, and navigate to your blu-ray disc. You'll see a few folders. Enter the one called "BDMV". You'll see a few more folders. Enter the one called "STREAM". Here you'll see a large number of ".m2ts" files. If this were a normal blu-ray disc, you could simply select the largest file and that would be the main movie. On this particular disk the movie is scattered across 23 different files. By a process involving playing each file with mplayer, I determined that the movie was in files 00000.m2ts through 00022.m2ts. Select the 00000.m2ts file to begin. tsMuxeR will chew on the file a bit, then add it to the input files box.

A number of tracks appear in the Tracks box. Ignore these for now - we have to add the other 22 pieces of the movie to the input box. Click the "append" button, and select the "00001.m2ts" file. You'll see that it is appended to the input files list. Repeat this step for each of the remaining 21 files. When you are done, scroll through the input files list to make sure you got all the files, in the right order, with no repeats.

Now we'll have to delete tracks we don't want to demux. Select the first track in the list, and note that the track info (you might have to widen the tsMuxeR interface to see it completely) lists this as a lower resolution track. Click the "remove" button to delete the track. Repeat this for the second track as well. We want to keep the 1920 x 1080 track. We also want to keep the DTS audio track, so skip down to the AC3 track following that, and keep hitting the "remove" button until only two tracks remain in the list.

Under the Output section, select the "Demux" radio button, and then click "Browse" to select a spot on your hard drive with a LOT of room - about 20 Gb free. Then click the Start Demuxing button, and then go find something interesting to do. On my machine, with this movie, the process too about an hour.

When you are done you'll have two large files saved on your hard drive with long file names. Rename them to something sensible, such as "video.264" and "audio.dts".

Step 2: Encode the audio
Relative to the other steps, this one is fairly quick, so we'll do it first. Open a command prompt, and navigate to the folder you demuxed the files to. Enter this command:

eac3to audio.dts audiodump.wav -down2 -down16

This will convert the DTS file into a stereo .wav file. Once this is done, you can delete the audio.dts file.

Now enter this command:

neroaacenc -lc -br 128000 -if audiodump.wav -of temp_audio.m4a

This will convert the .wav file into a standard .m4a AAC file. Once this is done you can delete the audiodump.wav file.

Step 3: Encode the video
First we need to determine the cropping and scaling. Mplayer will help us out here. Enter this command:

mplayer video.264 -vf cropdetect

Let it run a little while, then ESC out of the video playback. The correct cropping will be reported on the command line. For Wall-E, the cropping was -vf crop=1904:800:8:140. Now, with that information in hand, enter this command:

mplayer video.264 -vf crop=1904:800:8:140,scale=1280:-10 -frames 10

mplayer will report the correct scaling needed for this movie. In this case, it is 1280x544. You can substitute any other mod16 number for 1280, depending on what size you want to encode the file movie at, and mplayer will give you the correct height.

With these two pieces of information at hand, we are ready to encode the video:

mencoder video.264 -fps 24000/1001 -o temp_video.h264
/-of rawvideo -sws 9
/-vf crop=1904:800:8:140,scale=1280:544,dsize=1280:544
/-nosound -mc 0 -ovc x264
/-x264encopts qp=18:bframes=3:partitions=all:me=umh:nocabac

This will take a very long time - on my system it took about 8 hours to churn through the movie. When this is done you can delete the video.264 file.

Step 4: Muxing
The final step is to remux the video and audio streams into an .mp4 file container:

mp4box -add temp_video.h264 -add temp_audio.m4a -fps 23.976 -tmp c:\temp Wall-E.mp4

Once this is done, you can delete the temp_video.h264 and temp_audio.m4a files. Congratulations - you're done! The resulting .mp4 file should be playable on an AppleTV, XBox360 or Sony PS3.

If you want to retain the .DTS soundtrack, you can skip the audio re-encoding section, and mux everything into an .mkv file, but that's something I don't have a lot of experience with, so I'll leave that an exercise for the reader.
1 comment ( 23 views )   |  permalink   |   ( 3 / 5788 )