Laurent’s Blog

Wednesday, 12 November, 2008

Converting WMA 5.1 to AC3 – Part 2

Filed under: Audio Encoding — Tags: , , , , , , , , — hemie143 @ 21:12

In part 1, I wanted to convert the audio stream of a WMV file into an AC3 file. That should not be a problem, unless the audio stream has a strange sampling frequency and you want to keep the 5.1 channels. The solution is to use Aften for encoding and bepipe.exe to stream the audio into Aften.

What’s BePipe ? This is a tool that found its roots in avs2wav and it allows you to pipe an audio stream from any audio/video file, if that file can be read by AviSynth.

In order to work with smaller files, a good option is to demux the audio stream from the movie. This can easily be done with the help of the Windows Media Stream Editor, a tool from the Windows Media Encore 9 Series. So, instead of working with a 8Gb WMV movie file, we can now work with a WMA audio file of about 300-400 Kb. Let’s call this file “soundtrack.wma”.

First, we should ensure that AviSynth is able to read the file. First install AviSynth, but that should already be done, if you are using MeGUI. Next, download the BassAudio plugin for AviSynth. You should be able to find it from the Doom9’s forums, from RapidShare or from aviSynth.org.  The file should be BassAudio23.7z. Decompress it and copy the DLLs from the BassAudio23/Release folder to the plugins folder of AviSynth, wherever you have installed it.

Secondly, copy the BePipe.exe from the same BassAudio23.7z to the folder where soundtrack is located.

Create an AVI script “wma2ac3.avs” containing the following :

BassAudioSource("soundtrack.wma")
ConvertAudiotoFloat()
SSRC(48000)

The first line will make sure that the BassAudio libraries are used to decode the audio, instead of the default DirectShow decoder. The second line will force to use a float resolution in order to use any resolution that is used (from 8 to 24 bit). The third line will force a resampling frequency of 48 KHz.

You may test the process with the following command at the prompt :

BePipe.exe --script "import(^wma2ac3.avs^)" -

There are two arguments. The first argument (–script) allows you to define an AviSynth script. In this case, this is simply a script importing the previously created AviSynth script. The caret characters are there to replace the double quotes. The second argument (-, a single hyphen) instructs bepipe to redirect the output to stdout (standard output, or on screen).

If all is working well, you should see some garbage scrolling in your DOS box. What remains now is to encode this stuff into an AC3 stream. But that will be for next time.

1 Comment »

  1. The complete command line can be:
    BePipe.exe –script “BassAudioSource(^soundtrack.wma^).SSRC(48000)” – | Aften – soundtrack.ac3

    -ConvertAudiotoFloat() not needed
    -Warning with BassAudio23.7z use only v2.4
    -Read this:
    http://forum.doom9.org/showthread.php?p=1219593#post1219593

    Comment by Tebasuna51 — Tuesday, 2 December, 2008 @ 21:34


RSS feed for comments on this post. TrackBack URI

Leave a comment

Create a free website or blog at WordPress.com.