Saturday, May 28, 2011

Tangent: Handbrake, PlayStation 3 and 5.1 Surround Sound

I'm currently in the process of building a media center at home so I can just use my PlayStation 3 to navigate and play all the movies I own. I'm using Handbrake to convert my videos and I was using the PS3 Media Server (PMS) to stream videos to my PlayStation. After completing converting around thirty (30) movies so far I hit a bump. While testing some videos, I realized that my audio receive said I was only using 2CH audio (apposed to 5.1 surround sound; which I knew was available for this movie). I struggled at first thinking that I didn't convert it right, but when checking the movie properties it clearly stated I had a 2CH audio stream and a 5.1CH audio stream. Then I was thinking it was PMS, but I had 5.1 audio channel output enabled. It couldn't have been my PS3... could it? While streaming the video, I attempted at switching the audio stream manually and poof, it worked! Happy for a second, then wondering why doesn't the audio automatically choose the 5.1 stream?

After reading around, it appeared to be different per device/application. Now I'm not a guru on the specifics of codecs but from playing with tools in the past and with new ones to examine this recent incident, there were some key points to note (oh, I didn't mention it yet but I'm using MPEG-4):

There can exist multiple audio tracks for a single file.

Each track has an identifier (number) assigned to it.

An audio track can have (don't know if it's 'required') a language value assigned it.

There is a flag (or something) which classifies the track as enabled or disabled.

I have read that Apple TV would automatically choose the 'best' audio track (whether it was disabled or not) so media files with 2CH and 5.1CH would choose 5.1CH if you had the system hooked up to a 5.1 system. I was then playing with VLC and noticed that it acts in its own way as well. I was curious to know, how does the PlayStation 3 pick the audio channel? Hoping their was an option in the settings, the only one I could find was setting the preferred language for an audio track on a Blu-ray/DVD. Could it be that when encoding the video files I did so incorrectly and the PS3 was doing what it was told or was it that the PS3 didn't have the ability to know what is best?

The Test Plan

I prepared a total of eight (8) video files; four (4) files had 2CH track at a lower identifier than the 5.1CH track, the other vice versa. The groups of four (4) files had all cases of setting the 2CH track and 5.1CH track enabled and/or disabled. Now to see how the PlayStation reacts! I browsed the media on the PS3 and when opened, looked at the status bar to see what audio channel the system had chosen. The results are here:

Test File

First Audio Track

2 Channel Audio Disabled

5.1 Channel Audio Disabled

PS3 Selection

1

2CH

No

No

2Ch

2

2CH

No

Yes

2Ch

3

2CH

Yes

No

5.1CH

4

2CH

Yes

Yes

2Ch

5

5.1CH

No

No

5.1CH

6

5.1CH

No

Yes

2Ch

7

5.1CH

Yes

No

5.1CH

8

5.1CH

Yes

Yes

5.1CH

After looking at these results, this is the process I believe the PS3 will do:

Use the first available audio track which matches the preferred language (a PS3 setting) that is enabled.

If no track is found, use the first available audio track which matches the preferred language.

If no track is found, use whatever I can get my hands on!

I could do even more testing to find out the exact argument... but I really don't want to commit even more time to this issue. Since I knew how the PS3 would react, I now know what I have to do to get my PS3 to use the 5.1CH over the 2CH automatically for my current and future movies. What I have to do now:

For all future encodings, give a higher priority to the 5.1CH audio track.

For all current encodings, disable the 2CH audio track and enable the 5.1CH audio track.

Note: Yes, I could just remove the 2CH audio track, however, I didn't want to rule out the option to go to 2CH if I ever needed it in the future.

Now I no longer have to be bothered in checking if the video I am watching has 5.1 surround sound when I wish to play it.

Final Note

Other who stumble onto this same problem might be curious to know how to enable/disable the audio tracks in an MPEG-4 file. I was using MP4Box to modify my already transcoded movie files. From my Handbrake preset, track two (2) was my 2CH audio track and track three (3) was my 5.1CH audio track (for movies that had 5.1 surround sound). I used the following command to disable track two (2) and enable track three (3):