I connect my PC to my home theater via SPDIF, so when watching video files that uses AAC 5.1 channels, it is downmixed to stereo and the surround channels are lost.
I would like to be able to convert all 5.1 AAC output to 5.1 AC3, so my HT properly plays 6 discrete chanels.
My current approach is to use avconv
to convert my files's audio streams like this:
avconv -i <inputfile> -codec copy -codec:a ac3_fixed -b:a 448k <outputfile>
It works, but it has a few drawbacks:
All audio streams are converted to AC3, even the ones I don't need or want to, like stereo, DTS or AC3. I would like to convert only the AAC 5.1 ones. Command should be generic enough so I don't have to inspect the file or pick streams manually.
While conversion works fine, there are a few issues: volume is huge, loud as I've never seen before, and I fear some metadata is lost on conversion.
I must run this for every video I want to watch. It takes time and waste a lot of HDD space.
So, is there a solution that fixes at least one of these drawbacks?
Possible approaches:
Set OS (pulse audio?) to encode multichannel PCM to AC3 on-the-fly? (that would be amazing, since it would not only with videos but also for games.
Fix my command line with some smart parameters
Thanks!
You can set codecs for individual streams in avconv with -c:n - where n is the number of the stream. Let's say that your AAC stream is stream 2 (so, the third stream in the container):
Here's a quick & dirty script to find the stream number of an AAC stream, and feed that into avconv:
This will not work if you have more than one 5.1 AAC stream, and it will only work with file names that have spaces if you quote them. To use it, paste that code scrap into gedit & save it as 'aac-only-to-ac3', somewhere in your $PATH (like ~/bin). Make sure you make it executable.
Then, to use the script,
and to do every MKV in a directory