Sunday, March 16, 2014

Playing Librarian/Curator Made Easier with Video File Metadata

My video file collection is a mess. There is duplicate content, and files ranging in resolution from 1080p to generic HD to DVD-level and many that are older and even lower than that. Similarly, some have surround sound tracks, and others only have super low-bitrate stereo tracks. I wanted to know what may need to be re-encoded, and to have the ability to sort through the vast volume of data relatively quickly based on various parameters built into the metadata.

This means that I needed to be able to read the metadata, grab some key information from each file, and have the ability to make decisions quickly. For reading the metadata, I chose ffprobe, which is part of the ffmpeg Windows binaries made available from Zeranoe.

Then, I fired up cygwin and used the following bash script to grab the stuff I cared about:

for file in *; 
do ls "$file" >> list.txt;
ffprobe.exe -v quiet -show_streams -show_data -pretty -of json "$file" | egrep codec_name\|width\|height\|bit_rate\|channel_layout\|sample_rate >> list.txt;
The double quotes ward off undesirable behavior when the file names have spaces and other characters that would need to be escaped out in them. The sequence of "OR"ed parameters that egrep is filtering from the output are what allow me to find out what I need to know about both the video and audio parts of each file.

Here's an example of the output for two versions of the same source material that were inadvertently created:

            "codec_name": "h264",
            "width": 704,
            "height": 384,
            "bit_rate": "863.986000 Kbit/s",
            "codec_name": "aac",
            "sample_rate": "48000 KHz",
            "channel_layout": "stereo",
            "bit_rate": "164.469000 Kbit/s",
            "codec_name": "h264",
            "width": 1920,
            "height": 800,
            "bit_rate": "5.983516 Mbit/s",
            "codec_name": "aac",
            "sample_rate": "48000 KHz",
            "channel_layout": "stereo",
            "bit_rate": "198.056000 Kbit/s",
            "codec_name": "ac3",
            "sample_rate": "48000 KHz",
            "channel_layout": "5.1(side)",
            "bit_rate": "640000 Kbit/s",

In this case, there's a clear winner. Version A is "DVD quality" and only contains a stereo soundtrack. Version B is "full HD" and includes not only a slightly higher bit-rate stereo audio track, but also a 5.1 surround audio track. As you can guess, the file sizes are significantly different, so you'd think you can just keep the larger file...  In this case, that would work, but the distinctions are not always so clear, and the data makes the job of curating a bit easier.

With a small amount of work, I should be able to get this output file into a CSV format and then quickly merge, sort, and filter the whole list as a spreadsheet.  

Friday, March 14, 2014

OpenVPN Client on Windows 8.1

After realizing that my L2TP VPN connection wasn't actually working when the PSK was provided, and therefore was not encrypting anything, I decided to implement OpenVPN instead.

I installed the latest OpenVPN x64 Windows client from and quickly discovered -- to my dismay -- that OpenVPN-GUI.exe would not run properly under Windows 8.1.

Mercifully, others had encountered the same problem and documented the basic and simple fact that the CLI application still functions properly, even if the GUI is completely borked in this version of Windows. They were right, and running openvpn.exe from the command line connects like a champ, and works beautifully.

But, this is windows and therefore I reserve the right to be too lazy to type every time I wish to connect.  So, I created a simple two-line batch file, and stuck a shortcut to it on the desktop. Now I just have to run this shortcut as administrator, check the status messages, and minimize the cmd window until I'm ready to disconnect.

The batch file looks a bit like this, but without the obfuscation listed here:
cd c:\users\USERNAME\documents\openvpn\
cmd /K C:\Progra~1\openvpn\bin\openvpn.exe MYVPNPROFILE.ovpn
As you likely guessed, the connection profile file and its corresponding certificate are contained in the C::\users\USERNAME\documents\openvpn\ directory. The "/K" parameter causes the command prompt window to remain open, which is necessary; the same is true of running the batch file as Administrator.  Terminating the window will drop the TAP network connection which is essential for the VPN to function, but it can be safely and easily minimized. If you don't run as admin, there aren't permissions to build the network connection...

Sunday, January 19, 2014

Garage Cabinets, Part Deux

I wanted to get some large items off the floor, so designed another over-sized set of cabinets to fill in some poorly-used space by the water softener.

Step 1: Build a rather large box out of 1/2" plywood. This one is 4' x 29" x 20" (exterior, nominal).

Step 2: Build another (matching) box and install mounting rails in each so the boxes can be attached to wall studs.

Step 3: Install cleats on the wall and provide a temporary support to hold the lower box while it is screwed into the studs.

Step 4: After mounting the box to the studs, frame out the remaining two sides of the base with 2x4. The next picture shows how this will be used to provide "overkill" in terms of load-handling capacity.

Notice how my original cleats are protruding slightly beyond the bounds of the box. This was done intentionally to allow each cleat to be attached to one additional stud.

Step 5: Stack the second box on top of the first, and secure it to the studs.

Step 6: Line up a vertical support that extends to the ceiling. Cut a cross member long enough to attach to two joists, then attach the vertical support to the cross member. Verify that the assembly is level, then attach the vertical support to the base 2x4 frame of the cabinet assembly. Finally, attach the boxes to the vertical support. This support ensures that the cabinets can hold just about anything you could possibly throw at them.

Step 7: Step back and take a breather, everything is in place and leveled off.

Step 8: Try not to worry too much about any minor imperfections; it's more productive to build a face frame and hide them instead. So, that's what we'll do next...

Step 9: Cut and install the face frame. Because of my long cleat on the wall, it was necessary to notch out a piece of the frame on the lower left corner. (Unfortunately, this detail is hidden in the picture below.) Without the end grain of the plywood exposed, the cabinet not only looks better, but is more durable.

Step 10: Load the cabinet with a bunch of junk indispensable items and call it a day.