Friday, August 24, 2012

Batch Encoding H.264 Video with HandBrake

Batch Encoding H.264 Video with HandBrake

(Just as in the previous section, in this section I’m going to use “H.264 video” as a shorthand for “H.264 baseline profile video and AAC low-complexity profile audio in an MPEG-4 container.” This is the combination of codecs+container that works natively in Safari, in Adobe Flash, on the iPhone, and on Google Android devices.)
HandBrake also comes in a command-line edition. As with ffmpeg2theora, the command-line edition of HandBrake offers a dizzying array of options. (Type HandBrakeCLI --help to read about them.) I’ll focus on just a few:
  • --preset "X", where “X” is the name of a HandBrake preset. The preset you want for H.264 web video is called “iPhone & iPod Touch”, and it’s important to put the entire name in quotes.
  • --width W, where “W” is the width of your encoded video. HandBrake will automatically adjust the height to maintain the original video’s proportions.
  • --vb Q, where “Q” is the average bitrate (measured in kilobits per second).
  • --two-pass, which enables 2-pass encoding.
  • --turbo, which enables turbo first pass during 2-pass encoding.
  • --input F, where “F” is the filename of your source video.
  • --output E, where “E” is the destination filename for your encoded video.
Here is an example of calling HandBrake on the command line, with command line flags that match the settings we chose with the graphical version of HandBrake.
you@localhost$ HandBrakeCLI --preset "iPhone & iPod Touch"
                            --width 320
                            --vb 600
                            --two-pass
                            --turbo
                            --input pr6.dv
                            --output pr6.mp4
From top to bottom, this command runs HandBrake with the “iPhone & iPod Touch” preset, resizes the video to 320×240, sets the average bitrate to 600 kbps, enables two-pass encoding with a turbo first pass, reads the file pr6.dv, and encodes it as pr6.mp4. Whew!

Tuesday, August 14, 2012

How to I change my Keyboard Layout on Openbox?

From a terminal run the following command:

sudo dpkg-reconfigure console-setup
 
This will step through various configuration options for your console, along with Keyboard Layout.

For temporarily switching between keyboard layouts

Especially if you don't have too many keybindings 
So I needed to have both the regular US keyboard as well as the US International keyboard so that I could type in Thai keyboard.
Here are the steps I took:
1) Determine which keyboard layouts you want to switch between. Determine if you want 2, 3, or more. This tutorial will work with as many as you need, but this is the first step 
2) Open up a text editor and open the file ~/.config/openbox/rc.xml
3) Scroll down to the keybindings section - you should see stuff like <keybinding key="“blah-blah”"></keybinding>
4) Find any line which says </keybinding>
5) Go to the end of that line and hit Enter
6) Copy and paste the following text:

    <keybind key="C-F11">
    <action name="Execute">
    <startupnotify>
    <enabled>true</enabled>
    <name>English keyboard</name>
    </startupnotify>
    <command>setxkbmap us</command>
    </action>
    </keybind>

    <keybind key="C-F12">
    <action name="Execute">
    <startupnotify>
    <enabled>true</enabled>
    <name>Thai keyboard</name>
    </startupnotify>
    <command>setxkbmap th</command>
    </action>
    </keybind>

7) Edit the <key=“C-F12”> and the <command>setxkbmap th</command> to fit your desires (C is Ctrl key, A is Alt key, S is Shift key, and change it if you want :-D)
8) Rinse, Lather, and Repeat for all of your other desired keymaps.
9) Restart Openbox or reboot computer.
That's it!

Sunday, July 22, 2012

How-to: Mount a Network drive in Ubuntu

Recently, one of my roommates bought an external network drive, so everyone in the house can upload their music and movies. It’s hooked right into the network through the router so it’s easy for anyone to access– pretty cool stuff. It was pretty simple to setup in Windows, but it took a little bit of research for Ubuntu. Specifically, we have Maxtor “Shared Storage II” hard-drive, and I wanted it to auto-mount each time I reboot my computer. I figured it out using the tutorial here, but the basics are below.
  1. First you will need to install the “smbfs” package. This is what we will use to mount the drive.
    sudo aptitude install smbfs
  2. We will also need a folder to mount the drive in. I used /media/public.
    sudo mkdir /media/public
  3. Then, we need to edit /etc/fstab. This is where we add all the information needed to find and mount the drive. Open /etc/fstab using the command:
    gksudo gedit /etc/fstab
    At the end of the file add the following lines:
    # Mount our network drive
    //SERVER/SHARE /MOUNT-POINT smbfs guest 0 0
    Where “SERVER” is the name of your drive on the network. This can be either a name or IP address. For example, mine was “MAXTOR”. Replace “SHARE” with the folder in the drive you’d like to mount– mine was “Public”. “MOUNT-POINT” is the directory we created earlier, such as “/media/public”. The rest of the parameters have to do with permissions, and also where you can add advanced options. For more information on the advanced preferences, see
    man mount.smbfs
  4. The final step is to tell the system to reload /etc/fstab and mount our drive. Do this with the command:
    sudo mount -a
    Then, you’re done! At this point you should be able to see the files in your drive with the command
    ls /MOUNT-POINT

Thursday, June 14, 2012

How to join or merge multiple .avi or .mpg files

I have recently started watching the fab serialized movie Bloodspell, which is created entirely in Neverwinter Nights.
Bloodspell is released in a series of 6-7 MB files. So far they’re up to part 7. This certainly makes it easier to download on to my laptop and enjoy 10 minutes of Bloodspell at a time. However, I want to burn this to a DVD and watch all seven at once on my home DVD player. Before I did this I just wanted to string together the 7 .avi files into one larger file. (I can’t stand a mess!) Sounds like a simple request? Guess what, in my distro, Ubuntu, it is!

This will most likely work on just about any linux distro that includes the ability to install mplayer/mencoder.
First, let’s get the right programs.
sudo apt-get install mencoder mplayer
Now that the hard part is out of the way, we’re going to make use of the wonderful cat command. I’d renamed each Bloodspell video as b1.avi – b7.avi. Now to string them all end to end.
cat b1.avi b2.avi b3.avi b4.avi b5.avi b6.avi b7.avi > bloodspell.avi
Now we’re 2/3 of the way there! Stringing together .avi files can cause a breakdown in the sync between video and sound. So, we’ll use mencoder to sort things out.
mencoder -forceidx -oac copy -ovc copy bloodspell.avi.avi -o bloodspell_final.avi
That’s it! You’ve got one contiguous .avi file now containing all seven bloodspell releases to date. This will of course work with other .avi files. It will also work with .mpg or .mpeg files as well.
Later we’ll discuss getting this .avi file on to a DVD so you can watch it anywhere.
geek out.

Wednesday, May 9, 2012

Convert a video to black and white on Ubuntu

Convert a video to black and white on Ubuntu 


First: Install MPlayer 
sudo apt-get install mplayer libxine-extracodecs

If you can not install libxine-extracodecs, skip it. 

Then: Convert your video 
mencoder color-video.avi -o black-white-video.avi -vf hue=0:0 -oac copy -ovc lavc
or 
mencoder color-video.avi -o black-white-video.avi -vf hue=0:0 -oac pcm -ovc lavc

Good luck:)