الاثنين، 25 أغسطس 2008

How to Enable Surround Sound in Ubuntu Linux

Update (04/21/10): The information in this original post is no longer applicable since Ubuntu switched to the PulseAudio sound infrastructure. I'm leaving it all here for reference, but here's how to do it now:

Step 1: open up a terminal (Applications > Accessories > Terminal or Alt+F2 and type 'gnome-terminal' into the command applet)

Step 2: at the command prompt, type alsamixer

Your prompt should change to something like this:

Step 3: Scroll all the way to the right (using the arrow keys) until you reach a section labeled "Channel." It will most likely say "2ch" over it. Press the 'up' arrow key until it says 6ch (for 5.1 surround) or 8ch (for 7.1 surround).

Exit the alsamixer program by pressing ctrl+C. You should be all set. You may have to go into your Sound Preferences and change either the 'Profile' setting on the 'Hardware' tab or fiddle with the devices in the 'Output' tab. I didn't have to do this, but you might.

If you have any problems, leave me a note in the comments and I'll try to help.

Update (10/08/08): I was using Gutsy when I wrote this post, but I have since upgraded to Intrepid Ibex (8.10) and it still works for me. YMMV

I've been hard at work lately trying to get my motherboard's (an Asus M2V-MX SE socket AM2) 6-channel surround sound working with Linux and it's been a surprisingly stubborn pain in my ass. However, I finally succeeded this past weekend and decided to document my process here for others to hopefully benefit from.

The first complication I ran into when trying to get surround sound working is that my mobo does not have the normal multichannel output jacks. That is, instead of having the blue, orange, and black plugs that are in most multichannel setups, it instead just has what appears to be standard blue, pink, and green jacks that are usually used for stereo output, mic-input, and line-in, respectively.

What is poorly documented, though, is that the pink and green jacks can double as the orange and black plugs when enabled by software. It's a stupid way of doing things, IMHO, but low-end mobo manufacturers apparently do it to save costs.

Anyway, in Windows, enabling this hidden functionality was accomplished using the Realtek Sound Manager program that was installed with my sound driver. However, as with damn-near all driver utilities, it does not have a Linux equivalent.

Instead, open the Alsa-mixer GUI by double-clicking on the speaker icon in the upper-right of the screen (a.k.a., the Volume Control applet):

Then select 'Preferences' from the 'Edit' pull-down menu:

From here, you'll want to scroll down a bit and check the 'Channel Mode' box, and you'll probably want to check the 'Surround,' 'Front,' 'LFE,' and 'Center' boxes as well:

When you go back to the main applet, click on the 'Options' tab, which should now have an option to choose the number of channels:

Select '6ch' for a 5.1 setup or '8ch' in a 7.1 setup. This should unlock the hidden functionality of those pink and green jacks. On my system, the pink jack converts to the orange function and the green converts to the black function, but YMMV.

You could stop here, but I suggest doing one more step to make sure everything is configured properly. Open up a terminal and type:
speaker-test -Dplug:surround51 -c6 -twav
This will make a creepy disembodied voice play through each channel in succession so you can be sure your speakers are plugged into the right jacks.

Btw, this command is for a 5.1 / 6-channel surround card. A 7.1 system will use this command instead:
speaker-test -Dplug:surround71 -c8 -twav
For some people (like me), the system automatically duplicates the front channels' sound to the back channels for listening to stereo sources, such as mp3s, normal non-DVD video files, etc. Other people, however, will need to do a bit more to make this happen. If you're one of these people, open up a terminal and type:
gedit ~/.asoundrc
Whether this file is blank or already has some stuff in it, just skip down to the bottom and copypasta this in (courtesy of the Gentoo wiki):
pcm.!dmix {
type dmix
ipc_key 1024
slave {
pcm "hw:0,0"
channels 6
period_size 512
buffer_size 1024
}
}
pcm.!default {
type plug
slave.pcm "dmix"
slave.channels 6
route_policy duplicate
}
You may have to change "hw:0,0" to something else, depending on your sound card's location. When you restart, surround signals will still work like before, but stereo signals should be duplicated. If, on the other hand, you have no sound or your sound is weird, just reopen the ~/.asoundrc file and delete the part you added (or try one of the other configurations from the aforementioned Gentoo wiki). No big deal.

Let me know in the comments if this works for you or not or if you have any questions.

الاثنين، 11 أغسطس 2008

How to Compile QT4 GUI For HandBrake

This is a guide for compiling the QT4 GUI for HandBrake that was updated by gonza from the HandBrake forums. I posted this guide on the Ubuntu forums, but I wanted to post it here as well so it could be updated as needed.

Update (5/15/09): I have working binaries of the latest code available in my PPA repository. Directions for adding it to your package manager are available here.

install git if you don't already have it (sudo aptitude install git-core), along with the dependencies for HandBrakeCLI, then type
git clone git://repo.or.cz/HandBrake.git
navigate to the newly created HandBrake directory:
cd HandBrake
and add the bonne/qhandbrake branch (all on one line):
git checkout --track -b bonne/qhandbrake origin/bonne/qhandbrake
You might need to type git pull just to make sure you're up to date. Then, compile HandBrakeCLI as normal:
make
navigate to the qt4 directory:
cd qt4
and then compile the GUI (dependencies include qt4-core and qt4-dev-tools, I think):
qmake && make
You should be left with a binary named qtHB. This GUI is feature-complete (as far as I can tell), including video previews, a working queue, advanced x264 options, presets, and so on. You can run it by typing ./qtHB into a terminal, or you can copy it into your /usr/bin directory like any other program.

Unfortunately, qtHB *refuses* to bundle into a proper deb binary, but I believe you can download and run my precompiled binaries as long as you have the proper qt4 dependencies installed.
Download 64-bit qtHB
Download 32-bit qtHB

HandBrake GUI Roundup

I previously posted all of this information in a thread at the Ubuntu forums, but I wanted to post it here, too, so I could update it as new versions/information arise. This is a list of all of the GUIs/frontends (that I know of) for HandBrake, along with information regarding features/limitations and development progress for each.

1. GHB is the official GTK GUI that is included with the HandBrake source code (currently just available in the SVN repository). It was written by a swell guy known as JohnAStebbins from the HandBrake forums and it's nearly on par with the OS X GUI in features. However, some people have trouble getting it to compile. On Ubuntu, it requires at least Hardy. (you can download 32-bit and 64-bit deb binaries from here or you can compile from source using HandBrake's official SVN repository [directions here]).

2. qtHB (aka qHandBrake) is an early, yet promising GUI based on the official QT4 HandBrake code that languished in SVN until a HandBrake forums user known as gonza updated it recently. It is still in early development and not yet included in the official SVN code, but it is nearly as complete as GHB and significantly easier to compile (fewer dependencies). (You can read about it here or download and compile it using my instructions here).

3. HandBrakeGTK (aka RippedWire) is a port of a Windows CLI wrapper that requires mono-devel to run. It has a bug that causes it to not pass advanced x264 options to the CLI, which is a total deal-breaker for me. However, its queue feature works well, so it can be useful for batch rips if you don't mind using baseline AVC. It also works well with other codecs, such as xvid, that don't suffer from the adv. x264 opts bug. Another advantage is that you can easily update the HandBrakeCLI backend without affecting the graphical frontend. RippedWire does not appear to be in active development. (read about its history here or download it here. 64-bit users can try this one, which I built from the author's mono project files on my 64-bit system [just install mono-devel, move the executable into the same directory as your HandBrakeCLI binary and type mono HandBrakeGTK.exe]).

4. gHandBrake is a GTK CLI wrapper written from scratch by a guy that goes by Derrik81787. I later added x264 options to it, but I'm a terrible programmer and it ended up really unstable. Derrik seems to have dropped the project because his site for it is gone (Update: he's too busy with classes to work on it now but plans to revisit development in the future), but I would love to see someone tweak the code for better stability (the big issue appears to be with malloc, which I know nothing about; leave a comment if you'd like to pitch in). The major advantage to this frontend is that it is really easy to compile and it has very simple dependencies, unlike the official GTK GUI. (read about it here or download it here).

If you have anything to add, or if you have any corrections, please leave me a comment.