Log in

View Full Version : BeHappy - AviSynth based audio transcoding tool (UPD 19-07-2006)


Pages : [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27

dimzon
27th December 2005, 13:45
http://img464.imageshack.us/img464/2619/bh720je.png

Use-Case
BeHappy is designed mostly for movie audiotrack transcoding. It's powerfull BeLight/BeSweet replacement. So do not ask me about:

Batch trancoding support
Tags support

If You need to transcode multiple files at "one click" and/or tagging support - use foobar2000 (http://foobar2000.org/) converter

Screenshots
http://img107.imageshack.us/img107/8316/untitled6ta.png

http://img167.imageshack.us/img167/7659/untitled5vg.png

http://img288.imageshack.us/img288/9819/untitled8kq.png http://img259.imageshack.us/img259/7243/untitled2xe.png

http://img101.imageshack.us/img101/9778/untitled4ey.png http://img127.imageshack.us/img127/2340/111111111111118dm.png http://img99.imageshack.us/img99/4794/untitled2uy1.png

http://img62.imageshack.us/img62/6428/c19lr.png

http://img232.imageshack.us/img232/274/aftenam4.png

http://img88.imageshack.us/img88/5688/untitled5ez1.png

http://img142.imageshack.us/img142/6162/untitled0lk2.png

http://img139.imageshack.us/img139/3029/untitled8rr.png

http://img114.imageshack.us/img114/2207/untitled7bq.png

http://img105.imageshack.us/img105/6730/untitled7ir.png

System requirements

Supported operating systems: Windows 2000, Windows XP, Windows XP 64-bit edition, Windows Vista
RAM: 128MB
Display: 800x600 resolution
Microsoft .NET Framework Version 2.0 (http://www.microsoft.com/downloads/details.aspx?familyid=0856eacb-4362-4b0d-8edd-aab15c5e04f5&displaylang=en)
Avisynth v2.56 (http://sourceforge.net/project/showfiles.php?group_id=57023)


Installation

Download and extract latest BeHappy from BeHappy Workspace (http://workspaces.gotdotnet.com/behappy)
Download and extract latest NicAudio.dll from BeHappy Workspace (http://workspaces.gotdotnet.com/behappy), place NicAudio.dll to AviSynth plugins folder
If You plan to use Stereo To 5.1 UpMix functionality download and extract latest SoxFilter from here, place it to AviSynth plugins folder
If You plan to use AudX MP3 5.1 surround encoding download and extract latest enc_AudX_CLI from BeHappy Workspace (http://workspaces.gotdotnet.com/behappy), place enc_AudX_CLI.exe and audxlib.dll to BeHappy folder
If You plan to encode to MP3 download and extract Lame encoder from rarewares (http://rarewares.org/mp3.html) (recomended version is 3.97b2). Place lame.exe into BeHappy folder
If You plan to encode to OggVorbis download and extract fresh OggEnc2 from rarewares (http://rarewares.org/ogg.html), place oggenc2.exe to BeHappy folder
If You plan to encode to FLAC download and extract fresh FLAC (http://flac.sourceforge.net/) coder, place flac.exe into BeHappy folder
If You plan to encode to WavPack download and extract fresh WavPack encoder (http://www.wavpack.com/), place wavpack.exe into BeHappy folder
If You plan to use Coding Technologies AAC encoder (http://codingtechnologies.com/products/aacPlus.htm)

Download and extract latest enc_aacPlus from BeHappy Workspace (http://workspaces.gotdotnet.com/behappy), place enc_aacPlus.exe to BeHappy folder
Download and extract latest GPAC's MP4Box, place mp4box.exe to BeHappy folder
Download and install fresh WinAmp player (http://winamp.com/player/free.php) (Full version is enought)
Copy enc_aacplus.dll and nscrt.dll from Winamp\Plugins to BeHappy folder
If You doesn't want to use WinAmp You can uninstall it now ;)

If You plan to encode to Nero AAC download and extract fresh FREE NeroDigital AAC (http://www.nero.com/nerodigital/eng/Nero_Digital_Audio.html), place neroAacEnc.exe and neroAacEnc_SSE2.exe into BeHappy folder




Original idea


Workspace (http://workspaces.gotdotnet.com/behappy) is hosted @ http://www.gotdotnet.com/workspaces/ui/resources/gdn/images/logo.jpg (http://workspaces.gotdotnet.com/behappy)

Note
MeGUI since v 0.2.3.2038 23 Jan 2006 share same code with BeHappy. So you can use MeGUI for audio encoding via AviSynth too. MeGUI audio part has less functionality/flexibility but is more stable

Mini FAQ:
TODO

tebasuna51
27th December 2005, 20:48
*** READ THIS: actualized 2025-02-24 ***

- BeHappy Workspace link don't work because GotDotNet Workspaces have been phased out.

- New BeHappy home: CodePlex BeHappy project (http://www.codeplex.com/BeHappy) with last mod's included.
- And now https://github.com/jones1913/BeHappy
- And a upgrade here (https://forum.doom9.org/showthread.php?p=2015201#post2015201) (without sources)

------------------------------------------
*** Now the original post ***
------------------------------------------

Good job, Dimzon!

For me work the 'Delay', 'Split', 'Downmix', ...

Only with the 'Upmix' I get always:
Error: Can't find audio stream!

Please be patient with me, because I have a lot of comments:

Questions
In Avisynth internal plugin info say SuperEq(string filename), then wait for a parameter like this:
SuperEq("C:\Equalizer Presets\Loudness.feq")
Can work SuperEq(clip, values="0 0...96...0")?

In Upmix using Reverberation you put the plugin reverb(). Is a external plugin and need be downloaded?

EnsureVBRMP3Sync(). We can work with mp3 audio?. Is not necessary a decoder first to work with uncompressed audio?

If is possible, EnsureVBRMP3Sync() must be before AudioDubEx(BlankClip(...)) or after?

Petitions
With buttons 'New' and 'Edit' in Source, DSP and Destination we can test others decoders, DSP functios and encoders.

Please include the Downmix - DPL I, like DPL II but:
ssr = MixAudio(sl, sr, 0.2222, 0.2222)
ssl = Amplify(ssr, -1.0)


Bugs
The last buffer send to the encoder can be incomplete but is send complete, then there are extrabytes at end.
The RiffChunkSize in wav header is incorrect.

A example (without DSP), the same Input.wav and three outputs:
Input.wav (with correct classical wav header)
--------------
FileLength ..: 1920044 bytes
RiffChunkSize: 1920036 Ok = FileLength - 8 = DataLength + 36
DataLength ..: 1920000
Duration ...: 10.000000 sec.

Output.wav (RiffChunkSize error, Extrabytes at end of file)
--------------
FileLength ..: 1933356 bytes
RiffChunkSize: 1920450 Error: Must be FileLength - 8 = 1933348
DataLength ..: 1920000 Warning: ExtraBytes at end of file, bytes = 13312
Duration ...: 10.000000 sec. (with DataLength Ok, extrabytes are ignored)

Output.dat (Raw PCM, without header)
--------------
FileLength ..: 1933312 bytes
Duration ...: 10.069333 sec. Error: Extrabytes interpreted as data

Output.ogg
--------------
Duration ...: 10.069333 sec. Error: Extrabytes interpreted as data
Another warning: with source 5.1, 48 KHz (ac3, aac, dts, ...) greater than 124 min. 16.54 sec
m_nSizeInBytes = m_nSampleCount * nBlockAlign is > 2^32, then we need a int64 variable in source code.

chros
28th December 2005, 11:04
Isn't there mp3 output yet ?

dimzon
28th December 2005, 12:34
@tebasuna51
Upmix is not forking yet, this is just algorytm, not working script yet!

EnsureVBRMP3Sync - I think it must be right after decoder. I believe this is just buffering to avoid desync and it can be used with any source type (maybe i'm wrong?)

Petitions
Please include the Downmix - DPL I, like DPL II but:
ssr = MixAudio(sl, sr, 0.2222, 0.2222)
ssl = Amplify(ssr, -1.0)

I beleive you can do it yourself - just edit downmix.extension via notepad - I believe you are able to do it. And don't forget to share modified file with me :D

With buttons 'New' and 'Edit' in Source, DSP and Destination we can test others decoders, DSP functios and encoders.
there are some troubles implementing this functionality... But you can add new Source, DSP and Destination manualy:
Creating new Source
Use nicaudio.extension as starting point for new source. Copy it to yorsource.extension and open via notepad. Don't forget to generate new UUID(GUID) for UniqueID attribute
Edit Name attribute and
Edit <Script> element
{0} means input file name
{1} means output file name
{2} means unique string (to use as part of identifier)
{3} means '{' character (to allow '{' to be used)
{4} means '}' character (to allow '}' to be used)
Add/Delete/Edit <SupportedFileExtension> element

Sample:
<?xml version="1.0"?>
<BeHappy.Extension
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://workspaces.gotdotnet.com/behappy">
<AudioSource Name="MySourceName" UniqueID="5D209A6D-E6EA-4640-AF60-BAE14A529792">
<Script>SomeSource("{0}")</Script>
<SupportedFileExtension>ext1</SupportedFileExtension>
<SupportedFileExtension>ext2</SupportedFileExtension>
<SupportedFileExtension>ext3</SupportedFileExtension>
</AudioSource>
</BeHappy.Extension>

Creating new DSP
There are 2 ways to create simple DSP:
Creating very simple DSP
Example:

<BeHappy.Extension
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://workspaces.gotdotnet.com/behappy">
<AudioDSP Name="Normalize to 100%" UniqueID="6158f79f-d8a0-4021-89ae-b77b37c04c55">
<Script>
# Some script:
Normalize()
</Script>
</AudioDSP>
</BeHappy.Extension>
Creating multioption DSP
Take look @ DownMix.extension and UpMix.extension - good examples of multioption DSP
<?xml version="1.0"?>
<BeHappy.Extension
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://workspaces.gotdotnet.com/behappy">
<AudioDSP UniqueID="9579E57B-2D27-4583-99A4-921718E25B41">
<Plugin>
<MultiOptionDSP Type="BeHappy.Extensions.MultiOptionDSP, BeHappy">
<TitleFormatString>DSP Name, Selected Option = {0}</TitleFormatString>
<ScriptPrologue>
# ScriptPrologue
# this part of script will be included in resulting script without any conditions
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</ScriptPrologue>
<Option>
<Name>Option Name 1</Name>
<Value>
# this part of script will be included in resulting script only if this option is selected
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</Value>
</Option>
<Option>
<Name>Option Name 2</Name>
<Value>
# this part of script will be included in resulting script only if this option is selected
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</Value>
</Option>
<Option>
<Name>Option Name 3</Name>
<Value>
# this part of script will be included in resulting script only if this option is selected
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</Value>
</Option>
<Option>
<Name>Option Name 4</Name>
<Value>
# this part of script will be included in resulting script only if this option is selected
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</Value>
</Option>
<Option>
<Name>Option Name 5</Name>
<Value>
# this part of script will be included in resulting script only if this option is selected
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</Value>
</Option>
<Option>
<Name>Option Name 6</Name>
<Value>
# this part of script will be included in resulting script only if this option is selected
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</Value>
</Option>
<Option>
<Name>Option Name 7</Name>
<Value>
# this part of script will be included in resulting script only if this option is selected
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</Value>
</Option>
<ScriptEpilogue>
# ScriptEpilogue
# this part of script will be included in resulting script without any conditions
# {0} means input file name
# {1} means output file name
# {2} means unique string (to use as part of identifier)
# {3} means '{' character (to allow '{' to be used)
# {4} means '}' character (to allow '}' to be used)
</ScriptEpilogue>
</MultiOptionDSP>
</Plugin>
</AudioDSP>
</BeHappy.Extension>

Creating new Destination
Creating new Destination is very close to new Source. Take look @ ffmpeg-ac3.extension, enc_aacPlus.extension, wavpack.extension, flac.extension
<ExecutableArguments>
{0} means output file name
{1} means samplerate in Hz
{2} means bits per sample
{3} means channel count
{4} means samplecount
{5} means size in bytes

Example:
<?xml version="1.0"?>
<BeHappy.Extension
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://workspaces.gotdotnet.com/behappy">
<AudioEncoder Name="EncoderName" UniqueID="83517DA6-B34F-45ee-B48C-5D9370CC6032">
<Script>#Some script to be used for this encoder</Script>
<ExecutableFileName>encoder.exe</ExecutableFileName>
<ExecutableArguments>- "{0}" --cbr 32000</ExecutableArguments>
<SupportedFileExtension>ext1</SupportedFileExtension>
<SupportedFileExtension>ext2</SupportedFileExtension>
<SupportedFileExtension>ext3</SupportedFileExtension>
</AudioEncoder>
</BeHappy.Extension>

Creating a really complex Source/DSP/Encoder with it's own GUI
If you are familiar with .NET you can create really fine and complex extension. Take look @ BeHappy.OggVorbis.Encoder.Extension project.
You must:

Create Class Library
Add reference to BeHappy.Extensibility.dll
Impelent IDigitalSignalProcessor or IAudioSource or IAudioEncoder interface
Optionally implement ISupportConfiguration interface
Create .extension file (refer to BeHappy.OggVorbis.Encoder.extension for example)


PS. One *.extension can contain any amount of DSP Source and Encoder at same time

dimzon
28th December 2005, 14:11
fresh beta out

dimzon
28th December 2005, 15:12
Bugs
The last buffer send to the encoder can be incomplete but is send complete, then there are extrabytes at end.
Finally I found a bug in Microsoft VfW AVIStreamRead function - it still "read" data even if EOF is alredy occured....

Now I'm using such workaround:

int nHowMany = Math.Min((int) (m_aviStreamInfo.dwLength-frameSample), MAX_SAMPLES_PER_ONCE) ;
AVIStreamRead(m_aviStream, frameSample, nHowMany, h.AddrOfPinnedObject(), frameBufferTotalSize, out bytesRead, out samplesRead);

dimzon
28th December 2005, 19:42
http://img309.imageshack.us/img309/1055/untitled2222bw.jpg

download it @ workspace @ gotdotnet.com

tebasuna51
29th December 2005, 02:22
Thanks for your rapid and large answer. I have a lot of work to do.
First I want answer your questions.
EnsureVBRMP3Sync - I think it must be right after decoder. I believe this is just buffering to avoid desync and it can be used with any source type (maybe i'm wrong?)
I think is not necessary for uncompressed audio, but I'm not sure.
Which software did You use for such diagnostic?
I make a little utility to read wav header. But with a hex editor (I use WinHex) you can see the header (only 44 bytes). Here is a graphical description of wav header:
http://ccrma.stanford.edu/courses/422/projects/WaveFormat/
I can use int64 in source BUT there are only 4 bytes in WAV HEADER - how I must write this to WAV?
This is the problem for the wav limit 4 GB. And 2 GB limit is for soft using 'signed long int' for these fields.
The faad decoder (aac) can generate 'invalid' wav's > 4 GB, and fill these fields (RiffLength and DataLength) with 0xFFFFFF00.
Foobar also make 'invalid' wav's > 4 GB, and fill these fields with the 4 low order bytes.
Really the only way, afaik, to use a wav > 4 GB is split it in mono wav's. Then Tranzcode, WaveWizard and BeSplit can generate valid (not for BeSplit because a bug in BlockAlign field) mono wav's with the original length. The method is ignore these fields and continue working until end of file.
I prefer the faad method (0xFFFFFF00) because Foobar method can be confused with valid fields.
Can you fix my source?
I send you a PM (2005-12-19) about this. In your previous BeHappy version you use for DataLength:
Int64 nByteSize = streamSampleLength * m_WavHeader.nBlockAlign;
target.Write(BitConverter.GetBytes((uint)Math.Min(nByteSize,uint.MaxValue)),0,4);
And I suggest you use the same method for RiffLength. In actual version the int64 is missing and you use for DataLength the method from RiffLength (?).

In the actual version, the variable with possible overflow is used also in:
private uint m_nSizeInBytes;
...
m_nSizeInBytes = m_nSampleCount*m_wavHeader.nBlockAlign; // may be > 2^32
...
private void createEncoderProcess()
...
info.Arguments = string.Format(m_commandLine, m_output,
m_wavHeader.nSamplesPerSec, m_wavHeader.wBitsPerSample,
m_wavHeader.nChannels,m_nSampleCount,m_nSizeInBytes);

dimzon
29th December 2005, 10:56
I prefer the faad method (0xFFFFFF00) because Foobar method can be confused with valid fields.

pleaese check this code:


private long m_nSizeInBytes;
...
private void writeHeader(Stream target )
{
const uint FAAD_MAGIC_VALUE = 0xFFFFFF00;
const uint WAV_HEADER_SIZE = 36;
bool useFaadTrick = m_nSizeInBytes>=(uint.MaxValue-WAV_HEADER_SIZE);
target.Write(System.Text.Encoding.ASCII.GetBytes("RIFF"),0,4);
target.Write(BitConverter.GetBytes(useFaadTrick?FAAD_MAGIC_VALUE:(uint)(m_nSizeInBytes + WAV_HEADER_SIZE)),0,4);
target.Write(System.Text.Encoding.ASCII.GetBytes("WAVEfmt "),0,8);
target.Write(BitConverter.GetBytes((uint)0x10),0,4);
target.Write(BitConverter.GetBytes(m_wavHeader.wFormatTag),0,2);
target.Write(BitConverter.GetBytes(m_wavHeader.nChannels),0,2);
target.Write(BitConverter.GetBytes(m_wavHeader.nSamplesPerSec),0,4);
target.Write(BitConverter.GetBytes(m_wavHeader.nAvgBytesPerSec),0,4);
target.Write(BitConverter.GetBytes(m_wavHeader.nBlockAlign),0,2);
target.Write(BitConverter.GetBytes(m_wavHeader.wBitsPerSample),0,2);
target.Write(System.Text.Encoding.ASCII.GetBytes("data"),0,4);
target.Write(BitConverter.GetBytes(useFaadTrick?FAAD_MAGIC_VALUE:(uint)m_nSizeInBytes),0,4);
}

tebasuna51
29th December 2005, 12:26
@Dimzon
Yes, I think can work OK.
Thanks.

dimzon
29th December 2005, 13:45
introducing new feature - Multioption encoder (wait for fresh beta)
http://img521.imageshack.us/img521/5043/cool3oj.png

scharfis_brain
29th December 2005, 14:54
I don't know whether you are already doing this:

any_audiosurce()
ConvertAudioTo24bit() #or better float or 32bit
downmix() / upmix() / normalize()
ConvertAudioTo16bit()

this should effectively reduce rounding errors.

dimzon
29th December 2005, 15:07
I don't know whether you are already doing this:

any_audiosurce()
ConvertAudioTo24bit() #or better float or 32bit
downmix() / upmix() / normalize()
ConvertAudioTo16bit()

this should effectively reduce rounding errors.
thanx, i will implement it nex year!

dimzon
29th December 2005, 15:27
New beta is out!
Get it @ workspace @ gotdotnet.com

Prodater64
29th December 2005, 15:32
Usually, ac3 to ac3 encodings with besweet (and also with ffmpeg as i heard) has a problem, that resulting ac3 has low volume.
Has BeHappy same problem or does it manage this issue well?

dimzon
29th December 2005, 15:43
Usually, ac3 to ac3 encodings with besweet (and also with ffmpeg as i heard) has a problem, that resulting ac3 has low volume.
Has BeHappy same problem or does it manage this issue well?
BeHappy use ffmpeg for AC3 encoding bcz there are not any another free avaluable AC3 encoder :(

dimzon
29th December 2005, 16:51
Hey! Now we can create more advanced DSP using Sox Audio Effect Filter !

dimzon
29th December 2005, 17:43
2 All
Hi! You can help BeHappy project!
I need:
New DSP scripts - Dinamyc Range Compression e.t.c
BeHappy logo & icons

tebasuna51
30th December 2005, 17:24
Now BeHappy works Ok with wav header and without extrabytes at end.

I make a test with a source 5.1, 48 KHz (ac3) > 132 min. and BeHappy works Ok for wav > 4 GB and for a transcode to aac.

Relevant info of input.ac3
SampleRate 0 : 48000 KHz.
BitRate 15 : 448 Kb/s.
Audio coding mode (acmod) 7 : 3/2 - L, C, R, SL, SR
Low Frequency Effects channel 1 : Present
FileSize : 444358656 bytes.
Frames : 247968
Duration : 7934.976 seconds ( 2 h. 12 m. 14.976 s.)

Relevant info of output.wav
FileSize ....: 4570546220
RiffLength...: 4294967040 (= 0xFFFFFF00) Error: ... (always with > 4GB)
NumChannels .: 6
SampleRate ..: 48000
OffsetData ..: 44
DataLength ..: 4294967040 (= 0xFFFFFF00) Warning: assumed Datalength = 4570546176 (FileSize - 44)
Duration ...: 7934.976 sec., (2h. 12m. 14.976 s.)
For aac transcode I use:
behappy.extension.encoder.nero7aac.exe -o "D:\...\132.mp4"
-rr 48000 -rb 16 -rc 6 -vbr_streaming
-aacprofile_he -codecquality_high

Relevant info of output.mp4 (from Foobar2000 v0.8.3)
bitrate = 191
samplerate = 48000
channels = 6
aac_profile = HE AAC
codec = AAC
tool = Nero AAC Codec 4.2.1.0
samples = 380878848
FileSize = 189,944,318 Bytes (181.15 MB)
Length = 2:12:14.976

As you can see the duration is preserved exactly. Congratulations Dimzon.

FredThompson
31st December 2005, 04:40
What ideas do you have for the logo? (colors, style, some logos you like, etc.)

To buttress the Hun's suggestion: http://www.digitalprosound.com/Htm/SoapBox/soap2_Apogee.htm

It deals with sample rate, not resolution but the concept still applies, expand to at 2x, preferably 4x, do the modifications, downsample.

tebasuna51
31st December 2005, 12:02
I don't know whether you are already doing this:

any_audiosurce()
ConvertAudioTo24bit() #or better float or 32bit
downmix() / upmix() / normalize()
ConvertAudioTo16bit()

this should effectively reduce rounding errors.
From AviSynth doc:

Starting from AviSynth v2.5. If some filters doesn't support a specific sample type, they are converted to the format preserving most quality (most often floats). Float samples are also automatically converted back to 16bit before delivering them as output.
SoxFilter converts audio to 32 bit integers.
Amplify: 8bit and 24bit Audio samples are converted to float in the process, the other audio formats are kept.
Normalize: The audio sample type is converted to float or is left untouched if it is 16 bits.
SSRC Shibata Sample Rate Converter is a resampler. Audio is always converted to float.
...

Then a first conversion to a specific format don't guarantee maintain this format along a DSP function.
We can analyze each DSP to search the optimum format.

scharfis_brain
31st December 2005, 12:31
since we are using several chained instances of mixaudio, we need to process in a higher bit depth than 16 bit.

Prodater64
2nd January 2006, 04:53
I don't understand how does it work.
I want to know how to do any format to ac3 output.
Could it be reached from command line?
Is ac3 output configurable (channels, hz, kbps, etc.)
Once the script is created, with which app i will obtain the final ac3 audio file?
TIA.

tebasuna51
2nd January 2006, 11:58
since we are using several chained instances of mixaudio, we need to process in a higher bit depth than 16 bit.
The Downmix DSP function's can be improved replacing the line 9 from file DownMix.extension:

c{2}=last

with:

c{2}=ConvertAudioToFloat(last)

All internal plugins used (GetChannel, MixAudio, Amplify and MergeChannels) support float format (also Normalize if you want use this DSP after the Downmix).

In a simple test the differences between the int16 and float methods are below 0.0001 (-80.76 dB)

Mr_Odwin
3rd January 2006, 15:22
ConvertAudioTo24bit() #or better float or 32bit
ConvertAudioTo16bit()

this should effectively reduce rounding errors.

A bit off topic I know, but what do those functions do? What is the difference between 16 bit, 24 bit, 32 bit and float? Is one 'more accurate' but more cpu-intensive? Google wouldn't tell me. :(

tebasuna51
8th January 2006, 14:30
BeHappy New Year!

I make some mod's to BeHappy and I have also a petition, all included in:
http://personal.telefonica.terra.es/web/burgosrosa/behappym.zip
Here is a brief description:

1) I don't know how generate UniqueID, then for new extension I copy the Downmix UniqueID and I make a little change. Works for me.

2) Downmix: Mod <AudioDSP> Append DPL I option and c{2}=ConvertAudioToFloat(last) in <ScriptPrologue>

3) SSRC: New <AudioDSP> multioption. The samplerate conversion utility.

4) Mono -> Stereo: New <AudioDSP> without comment.

5) TimeStretch: New <AudioDSP> Only to check this function with 'tempo' parameter and two common presets. Maybe we need a complex emergent window to select between the three parameters 'tempo', 'pitch' and 'rate' and their associate values (like Belight 'SoundTouch').
At last the most used 'tempo' need a capture box to put manualy exact values (a slider don't work). Maybe at 'Tweak' section?.

6) MPASource: New <AudioSource>: Tested this decoder plugin (avisynth.org) and work ok for mp3 and mp2 inputs.

7) ffmpeg MP2: New <AudioEncoder>: Tested ffmpeg like mp2 encoder.

8) TODO:
We can use avs input to emulate the BeSweet input .mux (6 mono wav like input), with this merge.avs:

m1 = WAVSource("D:\Test\Mono_FL.wav")
m2 = WAVSource("D:\Test\Mono_FR.wav")
m3 = WAVSource("D:\Test\Mono_C.wav")
m4 = WAVSource("D:\Test\Mono_LFE.wav")
m5 = WAVSource("D:\Test\Mono_SL.wav")
m6 = WAVSource("D:\Test\Mono_SR.wav")
MergeChannels(m1, m2, m3, m4, m5, m6)

But I don't know how split a multichannel wav in mono wavs with BeHappy.
Maybe Dimzon can include a new 'Destination' item 'Mono wavs Writer' inside BeHappy code, or anybody can make a 'decoder' with standar input support.
I think is easy to do, but out of my knowledge. I only can can write a simple standalone app to do this job with a multichannel wav file input, included (Wav2mono.zip) in behappym.zip.

I appreciate test and comment.

dimzon
10th January 2006, 11:35
BeHappy New Year!
I make some mod's to BeHappy and I have also a petition, all included in:
http://personal.telefonica.terra.es/web/burgosrosa/behappym.zip
Here is a brief description:

WOW, Thanx a lot!
Unfortunally I can't download it now :(


1) I don't know how generate UniqueID, then for new extension I copy the Downmix UniqueID and I make a little change. Works for me.

http://kruithof.xs4all.nl/uuid/uuidgen


7) ffmpeg MP2: New <AudioEncoder>: Tested ffmpeg like mp2 encoder.

Why ffmpeg and not tooLame? Does ffmpeg produce better quality?


or anybody can make a 'decoder' with standar input support.
I will write it a little later :)

tebasuna51
10th January 2006, 14:12
Thanks for the reply.
Why ffmpeg and not tooLame? Does ffmpeg produce better quality?
I don't know if there are quality differences, but TooLame don't work for me.
I tried TooLame v0.2k and v0.2l.

The unique partial success I get is with TooLame v0.2l and this parameters:
<ExecutableArguments>- "{0}"</ExecutableArguments>

Partial because:
- TooLame don't read the header and is treated as raw PCM, then there are a initial click and the data is treated as 44100 (default for TooLame)

- Insert a:
<UseRawPCM>true</UseRawPCM>
seems don't work for this kind of extension.

- Insert a parameter to override the default 44100 like:
<ExecutableArguments>-s 48000 - "{0}"</ExecutableArguments> or
<ExecutableArguments>- -s 48000 "{0}"</ExecutableArguments>
Produce a:
Error: Can't start encoder: Cannot process request because the process (1644) has exited.

- With TooLame v0.2k the parameters:
<ExecutableArguments>- "{0}"</ExecutableArguments>
work without errors but the encoded file is incorrect (a click and a short silence).

- Any other combination of parameters produce errors like:
Error: Abnormal encoder termination 1 OR
Error: Can't start encoder: Cannot process request because the process (596) has exited.

Maybe I don't found the correct method.

Prodater64
14th January 2006, 10:26
I asked a question on jan/2 http://forum.doom9.org/showthread.php?p=760695#post760695

Could somebody answer me, please.


I don't understand how does it work.
I want to know how to do any format to ac3 output.
Could it be reached from command line?
Is ac3 output configurable (channels, hz, kbps, etc.)
Once the script is created, with which app i will obtain the final ac3 audio file?
TIA.

tebasuna51
14th January 2006, 13:11
I don't understand how does it work.
Refer to original idea for a complete discussion:
http://forum.doom9.org/showthread.php?t=103069

Basically:
1) Open/Decode any audio source to obtain a uncompressed audio.
You can use a specific audio decoder plugin (NicAudio for dts/ac3, MpaSource for mp2/mp3) or the generic DirectShowSource then the adequate installed filter is used. If you have ffdshow installed you can use Audio decoder configuration facility.

2) Use any DSP or Tweak option to modify the uncompressed audio. Then you can: Delay, Split, Downmix, Resample (SSRC), Stretch, Amplify, Normalize, ...(the Upmix option don't work now).

3) Recompress the audio (or save as wav) with any of the tested encoders.

I want to know how to do any format to ac3 output.
1) Select the source and the appropriate decoder (or DirectShowSource).
2) Apply the desired DSP and/or Tweak options. (maybe nothing)
3) Select the output filename and ffmpeg ac3 encoder
4) Add to Job Control and run the job (in Job Control window)

Could it be reached from command line?
Then you need write the avs script (or use Export Avisynt Script from BeHappy), and use BePipe (see the related thread 'original idea')

Is ac3 output configurable (channels, hz, kbps, etc.)
The free encoder ffmpeg only accept, afaik, the bitrate parameter (like ac3enc with BeSweet). The channels and Hz are taken from the source (DownMix or Resample can modify this).

Once the script is created, with which app i will obtain the final ac3 audio file?
Add to Job Control and run the job (in Job Control window) and the ac3 is obtained.

tebasuna51
16th January 2006, 18:42
Tested TwoLAME 0.3.3 Release 2005-06-09, (The fork of the tooLAME project. ICL4.5), from http://www.rarewares.org/mp3.html

It work fine with BeHappy and is based in TooLAME 0.2mbeta, then can be used instead ffmpeg for mp2 encoder.

There are new version 0.3.4 and 0.3.5 (Last updated 29-Nov-2005) in http://www.twolame.org/ , but I don't found any Windows compiled exe.

Included in http://personal.telefonica.terra.es/web/burgosrosa/behappym.zip with other minor changes (interested see the readme inside the zip).

dimzon
16th January 2006, 18:47
Tested TwoLAME 0.3.3 Release 2005-06-09, (The fork of the tooLAME project. ICL4.5), from http://www.rarewares.org/mp3.html

It work fine with BeHappy and is based in TooLAME 0.2mbeta, then can be used instead ffmpeg for mp2 encoder.

There are new version 0.3.4 and 0.3.5 (Last updated 29-Nov-2005) in http://www.twolame.org/ , but I don't found any Windows compiled exe.

Included in http://personal.telefonica.terra.es/web/burgosrosa/behappym.zip with other minor changes (interested see the readme inside the zip).

can you reupload it to http://www.mytempdir.com

tebasuna51
16th January 2006, 18:55
@Dimzon
Upload bhappym.zip: http://www.mytempdir.com/388248

dimzon
16th January 2006, 19:05
@Dimzon
Upload bhappym.zip: http://www.mytempdir.com/388248

Ok, Thanx!
according documentation SSRC can't convert any samplerate to any another.
http://www.avisynth.org/SSRC

but You can use ResampleAudio http://www.avisynth.org/ResampleAudio

So I think better solution will be to write more intellectual function. It must check: does SSRC applicable to this samplerates and use ResampleAudio if not

tebasuna51
16th January 2006, 19:12
Also TimeStretch can do the job:
"Adjusting "Rate" is equivalent to using AssumeSampleRate and ResampleAudio, but at very high quality."

buttfacepoop
23rd January 2006, 07:16
great work dimzon. i switched over to behappy from besweet as encoding with nero 7's aac was becoming too difficult with besweet.

just one question - is it not possible to do 2-pass encoding with your tool because of the stdin input?

dimzon
23rd January 2006, 09:21
great work dimzon. i switched over to behappy from besweet as encoding with nero 7's aac was becoming too difficult with besweet.

just one question - is it not possible to do 2-pass encoding with your tool because of the stdin input?
Does you really need it? Can you post me link @ 2-pass audio encoder?

buttfacepoop
24th January 2006, 00:51
Does you really need it? Can you post me link @ 2-pass audio encoder?

sorry i mean normalizing.

dimzon
24th January 2006, 11:42
sorry i mean normalizing.
normalizing are possiible via AviSynth ( Normalize() )

NorthPole
29th January 2006, 01:02
Really liked the idea behind behappy and looking forward to the upmix option (if it is possible).

I had a question about the bepipe command line utility. Currently I am upmixing audio for recorded TV. I have been using fbr2k with a dsp plugin to convert and write the 6 channel wave. Then I was pluggin the wave into behappy to get the correct ac3 file. I tried to go directly from the mp2 to the ac3 in fb2k but can't because of the ac3 channel mapping problem. I had the idea of calling bepipe from fb2k to remap (i think its just frameserving) the audio and encode with ffmpeg.
To see if it could worked I tried to get bepipe working from the command prompt with the following command line:

BePipe.exe --script "WavSource(^incorrect.wav^) AudioDubEx(BlankClip(length=Int(1000*AudioLengthF(last)/Audiorate(last)),width=32,height=32,pixel_type=^RGB24^,fps=1000),last) 6==Audiochannels(last)?GetChannel(last,1,3,2,5,6,4):last AudioDubEx(Tone(),last)" | ffmpeg.exe -i - -y -acodec ac3 -ab 448 "correct.ac3" <incorrect.wav

No luck. runs fine but doesn't remap the channels. Any suggestions?

tebasuna51
29th January 2006, 03:28
I think Bepipe can't work from fb2k because you need the physical file "incorrect.wav" and can't be supplied by "< incorrect.wav".

Work ok with:
BePipe.exe --script "WavSource(^incorrect.wav^).GetChannel(1,3,2,5,6,4)" | ffmpeg.exe -i - -y -acodec ac3 -ab 448 "correct.ac3"

With your command line ffmpeg encode directly "incorrect.wav".

NorthPole
29th January 2006, 13:45
@tebasuna51

thanks for the reply.

I get a pipe error why I try your command line?

C:\Temp>BePipe.exe --script "WavSource(^incorrect.wav^).GetChannel(1,3,2,5,6,4)" | ffmpeg.exe -i - -y -acodec
ac3 -ab 448 "correct.ac3"
***************************************
BePipe by dimzon
***************************************
Script used:
# BEGIN
WavSource("incorrect.wav").GetChannel(1,3,2,5,6,4)
# END


ffmpeg version CVS, build 3277056, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --enable-a52 --enable-gpl --enable-memalign-hack
built on Dec 8 2005 10:06:35, gcc: 3.4.2 (mingw-special)
Scanning for Audio Stream...
Found Audio Stream
Channels=6, BitsPerSample=16, SampleRate=48000Hz
Writing Header...
Writing Data...
0% pipe:: Error while opening file
Done!

Any ideas?
Tried 2 different builds of ffmpeg. The one above and the one from the ffmpeggui setup.

NorthPole
29th January 2006, 14:15
@tebasuna51

Runs ok when I use this command line but doesn't remap channels

C:\Temp>BePipe.exe --script "WavSource(^incorrect.wav^).GetChannel(1,3,2,5,6,4)" | ffmpeg.exe -i - -y -acodec
ac3 -ab 448 "correct.ac3" <incorrect.wav
ffmpeg version CVS, build 3277056, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --enable-a52 --enable-gpl --enable-memalign-hack
built on Dec 8 2005 10:06:35, gcc: 3.4.2 (mingw-special)
Input #0, wav, from 'pipe:':
Duration: N/A, bitrate: 4608 kb/s
Stream #0.0: Audio: pcm_s16le, 48000 Hz, 5:1, 4608 kb/s
Output #0, ac3, to 'correct.ac3':
Stream #0.0: Audio: ac3, 48000 Hz, 5:1, 448 kb/s
Stream mapping:
Stream #0.0 -> #0.0
***************************************
BePipe by dimzon
***************************************
Script used:
# BEGIN
WavSource("incorrect.wav").GetChannel(1,3,2,5,6,4)
# END


Scanning for Audio Stream...
Found Audio Stream
Channels=6, BitsPerSample=16, SampleRate=48000Hz
Writing Header...
Writing Data...
size= 957kB time=17.5 bitrate= 448.0kbits/s s/s
video:0kB audio:957kB global headers:0kB muxing overhead 0.000000%
Done!

Note: input says it is coming from pipe?
Running winxp operating system.

NorthPole
29th January 2006, 14:24
Final Note:

The version of bepipe that I am using was download from the link on the first post. Datestamp on the file is 11/25/05 even though the date on the website says 12/09/05. File version 1.0.2155.27457.

I believe I have the latest and perhap the only released version of bepipe.

tebasuna51
30th January 2006, 04:08
I have same versions:
fmpeg version CVS, build 3277056
Last Bepipe version 1.0.2155.27457

Yesterday work ok, and now I get the same error:
0% pipe:: Error while opening file

I test:
BePipe.exe --script "WavSource(^incorrect.wav^).GetChannel(1,3,2,5,6,4)" > correct.wav

and work. Maybe is a sync issue betwen bepipe and ffmpeg.
Sorry, I can't help you, maybe Dimzon ...

About:
"Note: input says it is coming from pipe?"

The chars "< | >" are called 'pipe' commands, the input file for ffmpeg is taken from "< incorrect.wav" and not from bepipe output, then the channels aren't remapped.

damrod
30th January 2006, 11:56
nice tool !

i will give it a try...

btw with nero aac can you make abr encoding?? if you specify bitrate it's cbr and vbr is not abr... i want to make true abr@64 for exemple...can find the parameters in cmdline for aacenc32.exe (i use it to attack nero7 dlls)

is nero aac he-aac v2 or v1...the v2 is aac+ with SP i think (same quality @44 than he-aac@64..if i remember right)

NorthPole
30th January 2006, 14:43
@tebasuna51
BePipe.exe --script "WavSource(^incorrect.wav^).GetChannel(1,3,2,5,6,4)" > correct.wav

works ok for me too.

Thanks for your efforts. Maybe I'll give the upmix option a shot.

NorthPole
31st January 2006, 04:08
Ok, I modified the upmix extension with the following and got some 6 channel upmixes.

<?xml version="1.0"?>
<BeHappy.Extension xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://workspaces.gotdotnet.com/behappy">
<AudioDSP UniqueID="9579E57B-2D27-4583-99A4-921718E25B41">
<Plugin>
<MultiOptionDSP Type="BeHappy.Extensions.MultiOptionDSP, BeHappy">
<TitleFormatString>{0}</TitleFormatString>
<ScriptPrologue>
# Store clip in variable
Stereo_{2} = convertaudiotofloat(last)
</ScriptPrologue>
<Option>
<Name>Upmix Using SuperEQ Files</Name>
<Value>
# SuperEq files with 20ms delay
fl_{2} = SuperEQ(Stereo_{2}.getleftchannel,"c:\program files\behappy\front.feq")
fr_{2} = SuperEQ(Stereo_{2}.getrightchannel,"c:\program files\behappy\front.feq")
cc_{2} = SuperEQ(Stereo_{2}.ConvertToMono,"c:\program files\behappy\center.feq")
lfe_{2} = SuperEQ(Stereo_{2}.ConvertToMono,"c:\program files\behappy\lfe.feq")
sl_{2} = SuperEQ(Stereo_{2}.getleftchannel,"c:\program files\behappy\back.feq")
sr_{2} = SuperEQ(Stereo_{2}.getrightchannel,"c:\program files\behappy\back.feq")
sl_{2} = DelayAudio(sl_{2},0.02)
sr_{2} = DelayAudio(sr_{2},0.02)
</Value>
</Option>
<Option>
<Name>Upmix using Sox Filter</Name>
<Value>
# Sox filter with 20ms delay
Front_{2} = mixaudio(Stereo_{2}.soxfilter("filter 0-600"),mixaudio(Stereo_{2}.soxfilter("filter 600-1200"),Stereo_{2}.soxfilter("filter 1200-7000"),0.45,0.25),0.50,1)
Back_{2} = mixaudio(Stereo_{2}.soxfilter("filter 0-600"),mixaudio(Stereo_{2}.soxfilter("filter 600-1200"),Stereo_{2}.soxfilter("filter 1200-7000"),0.35,0.15),0.40,1)
fl_{2} = GetLeftChannel(Front_{2})
fr_{2} = GetRightChannel(Front_{2})
cc_{2} = ConvertToMono(stereo_{2}).SoxFilter("filter 625-24000")
lfe_{2} = ConvertToMono(stereo_{2}).SoxFilter("lowpass 65")
sl_{2} = GetLeftChannel(Back_{2})
sr_{2} = GetRightChannel(Back_{2})
sl_{2} = DelayAudio(sl_{2},0.02)
sr_{2} = DelayAudio(sr_{2},0.02)
</Value>
</Option>
<ScriptEpilogue>
# Return result
MergeChannels( fl_{2}, fr_{2}, cc_{2}, lfe_{2}, sl_{2}, sr_{2})
ConvertAudioTo16Bit()
</ScriptEpilogue>
</MultiOptionDSP>
</Plugin>
</AudioDSP>
</BeHappy.Extension>

This is a pretty basic approach.

If you want to use the supereq option (built into avisynth) you need to run fb2k and save a equalizer frequency file from the dsp manager, equalizer tab. I saved one for the front, center, lfe and back. I would upload them but I don't know how or where to do that. (This is similar to kpexs' upmix program method). Note that you need to change the reference in the above code to point to your appropiate .feq files.

If you use the sox filter mentioned earlier in this thread (I think its page 1, near the bottom) you can find a link to the sox avisynth beta plugin. You have to copy that to your avisynth plugin subdirectory. That it.

If anybody has better ideas for the sox settings, let me know. Thanks.

@tebasuna51,
A while back you asked about the reverb function/program/option. It is a soxs' filter option that you can access with the sox plugin.

dimzon
31st January 2006, 11:23
@NorthPole
Nice. Can you post your EQ-files too?

tebasuna51
31st January 2006, 13:56
I would upload them but I don't know how or where to do that.
The .feq files are plain text and very short. You can use Notepad to Copy and Paste in the post directly.
@tebasuna51,
A while back you asked about the reverb function/program/option. It is a soxs' filter option that you can access with the sox plugin.
Thanks, but I think is Dimzon who ask about reverb.

I don't know very much about upmix procedures. Maybe if ursamtl read this post can help with their expert opinion about upmix.

Now I'm working with compand function from Sox, trying to do a Dynamic Range Compression DSP function for BeHappy. If anybody work about this, let me know.