Make XBMC prefer AAC track over AC3?
#1
Hello,

Is there a way to tell XBMC to use AAC (Audio Track 1) by default, instead of AC3 (Audio Track 2) for an mp4?

I've batch encoded all my files using Handbrake's AppleTV 2 preset. For 95% of the media files, this works fine. However, there are some that no matter what I do, the AC3 file has occasional audio glitches in it. Switching to the AAC file works. I play files to a 2.1 soundbar that only receives PCM, doesn't decode AC3.

MediaInfo of a problematic file:
Code:
Audio #1
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 20mn 25s
Bit rate mode                            : Variable
Bit rate                                 : 160 Kbps
Maximum bit rate                         : 273 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Delay relative to video                  : 80ms
Stream size                              : 23.4 MiB (15%)
Encoded date                             : UTC 2012-06-29 03:36:32
Tagged date                              : UTC 2012-06-29 03:39:14

Audio #2
ID                                       : 3
Format                                   : AC-3
Format/Info                              : Audio Coding 3
Mode extension                           : CM (complete main)
Format settings, Endianness              : Big
Codec ID                                 : ac-3
Duration                                 : 20mn 25s
Bit rate mode                            : Constant
Bit rate                                 : 224 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Bit depth                                : 16 bits
Compression mode                         : Lossy
Delay relative to video                  : 80ms
Stream size                              : 32.7 MiB (21%)
Encoded date                             : UTC 2012-06-29 03:36:32
Tagged date                              : UTC 2012-06-29 03:39:14


Thank you!
Reply
#2
Good question. I have a ton of rips with the same setting, and an ATV2. If I find anything out about an easy way to get XBMC to prefer AAC then I'll try to remember to bump this thread. Unless someone else knows of a way?
Reply
#3
That would be a good feature.

Prefer 2.0 AAC if sound settings are analog 2.0 (ie HDMI direct to TV)

Prefer 5.1 AC3 if sound settings are passthrough (ie HDMI direct to amp)
Reply
#4
There was a similar post about setting audio track 2

It would apply because its asking how to prefer stream#2 to be default and a explanation of how the OSD settings prefers this is also contained.

http://forum.xbmc.org/showthread.php?tid=146792

You guys that have interest in this should read expand on that.

uNi
Reply
#5
Ah, good, I was looking for FernetMenta's post on that. I'll have to ask to be sure, but it sounds like it's possible to set a "flag" on the existing files that will give preference.
Reply
#6
I've been down the flag route before and set everything to AudioStream 0 in MySQL settings table. I didn't realize the "Set as default for all movies" erased all previous settings. No wonder my movies keep reverting and subtitles keep turning off Smile (See this thead for info on that.)

I was hoping for information on how to call g_settings.m_defaultVideoSettings.m_AudioStream, or what that does. I checked SQL & config files, didn't notice where the g_settings are stored. Oh well. If anyone has that info, I'd appreciate it.

Anyway, so I wrote a PHP page to flag all new files to use AAC (AudioStream 0) instead of the default XBMC behavior. Warning! I am not a PHP programmer or MySQL programmer! If bad code makes you lose faith in humanity, please skip this section.

The page checks for all files that don't have previous settings set, then inserts MY default settings into the settings table. If you set a file to use subtitles or DTS or something else, it'll skip that file. Limits to 10 files to let you check the script.

PHP Code:
<?php

$dsn 
'mysql:dbname=xbmc_video75;host=mysqlserver';
$user 'xbmcuser';
$password 'xbmcpassword';
try {
    
$dbh = new PDO($dsn$user$password);
     
        
$unsetfilesquery "select files.idFile
from files left join settings
on files.idFile=settings.idFile
where settings.idFile is null
limit 10"
;
        
        
$tosetfiles = array();
        foreach (
$dbh->query($unsetfilesquery) as $unsetfile)
        {
            
$tosetfiles[] = array(
                
'idFile' => $unsetfile['idFile']
            );
        }

        
         foreach(
$tosetfiles as $tosetfile) {

                echo 
$tosetfile['idFile'];
                
        
$query "INSERT INTO  settings ( `idFile` ,`Deinterlace` ,`ViewMode` ,`ZoomAmount` ,`PixelRatio` ,
`VerticalShift` ,`AudioStream` ,`SubtitleStream` ,`SubtitleDelay` ,`SubtitlesOn` ,`Brightness` ,`Contrast` ,
`Gamma` ,`VolumeAmplification` ,`AudioDelay` ,`OutputToAllSpeakers` ,`ResumeTime` ,`Crop` ,`CropLeft` ,
`CropRight` ,`CropTop` ,`CropBottom` ,`Sharpness` ,`NoiseReduction` ,`NonLinStretch` ,`PostProcess` ,
`ScalingMethod` ,`DeinterlaceMode`)
VALUES (:idFile,  '1',  '0',  '1',  '1',  '0',  '0',  '-1',  '0',  '0',  '50',  '50',  '20',  '0',  '0', 
 '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '0',  '1',  '0');"
;
        
$preparesql $dbh->prepare($query);
        
$preparesql->execute(array(':idFile'=>$tosetfile['idFile']
        ));

     }

} catch (
PDOException $e) {
    echo 
'Connection failed: ' $e->getMessage();
}
?>
Reply

Logout Mark Read Team Forum Stats Members Help
Make XBMC prefer AAC track over AC3?0