View Full Version : NicAudio 2.0.6 in CodePlex project


tebasuna51
15th March 2008, 02:45
IMPORTANT EDIT
At this moment (2016) I recommend use LWLibavAudioSource like AviSynth audio decoder instead NicAudio (or BassAudio).
Then I never will make new versions of NicAudio.
---------------------------------------------------------------------------------------------------- EDIT END
Like was announced in this thread (http://forum.doom9.org/showthread.php?p=1106929#post1106929), I open a new project in CodePlex to unify the NicAudio sources and continue the development (if any).

In last years there are mod's from Dimzon, Nic (of course), IanB and now for me. All of them, and also the BeHappy people, are invited to the NicAudio developer team.

In http://www.codeplex.com/NicAudio there are now the source code and a first release (2.0 to begin a new age).

Any comment are welcome.

EDIT: Actual version 2.0.6 (2012-08-27)
CHANGE LOG
------
27/08/2012 Tebasuna 2.0.6
ac3,dts Solved some initialization issues with no-linear decode.
http://forum.doom9.org/showthread.php?p=1587337
lpcm,raw Some minor improvements.

25/10/2011 Tebasuna 2.0.5
dts Accepted special stereo dts modes Lt+Rt, A+B (dual mono)...

12/08/2009 Tebasuna 2.0.4
lpcm Solved bug writing last block in some cases

25/06/2009 Tebasuna 2.0.3
mpa Skip ID3v2,3,4 initial tag to avoid false sync frames.

buzzqw
15th March 2008, 09:14
thanks for your effort tebasuna51!

what's about adding support for flac, multichannel pcm (as in bluray dvd), AC3+, DTSHD... ?

yea, know.. tha latter are a little bit difficult... but

BHH

tebasuna51
15th March 2008, 11:52
what's about adding support for flac,
BassAudio can decode flac.

multichannel pcm (as in bluray dvd),
Done, LPCM in BluRay mode, with something like:
NicLPCMSource("FileName.pcm", 96000, -24, 8)

AC3+, DTSHD... ?
See the TODO list in the readme.txt

DTSHD, I don't know a free decoder, actually we can use DelayCut to extract the core dts.

AC3+, is still in beta stage in ffmpeg project.

MLP/ThrueHD, the ffmpeg decoder seems correct, we need a volunteer to include this decoder. Anyone?

buzzqw
15th March 2008, 13:22
NicLPCMSource("FileName.pcm", 96000, -24, 8)

nice, but a "automatic" recognition of file will be even better.. like NicLPCMSource("FileName.pcm") .. if possible

i know bassaudio (and thanks again btw).. but having a single dll for most common audio formats will be easier

BHH

tebasuna51
15th March 2008, 21:06
nice, but a "automatic" recognition of file will be even better.. like NicLPCMSource("FileName.pcm") .. if possible

Maybe you can persuade Madshi to work in the NicAudio developer team. :)

Atak_Snajpera
7th April 2008, 18:56
Mp2 and Mp3 decoding is not perfect :)
Source (mp2) and transcoded files (AC3 AAC OGG) using BePipe
http://www.sendspace.com/file/nizv9b

tebasuna51
8th April 2008, 00:07
Mp2 and Mp3 decoding is not perfect :)
Source (mp2) and transcoded files (AC3 AAC OGG) using BePipe
http://www.sendspace.com/file/nizv9b

Thanks for the sample.

Of course your output files are corrupted but I can't reproduce these results. Using your source.mp2 and decoding with NicMPG123Source() function I obtain perfect outputs ac3, aac and ogg.

With your source.mp2 I obtain bitidentical wav files using old or new NicAudio, old or new MPASource (WarpEnterprises). The differences with Bass decoder are less than -135 dB (32 bits float), and the differences with Lame 3.97 are less than -96 dB (16 bit int).

In your Command_Line_Example.cmd (simplified):

bepipe --script "import(^job1.avs^)" | ...

In job1.avs there are more AviSynth functions or only the NicMPG123Source()?

Any user can reproduce the corrupted outputs?

Atak_Snajpera
8th April 2008, 17:27
#VideoSource
LoadPlugin("C:\Users\Dawidos\Documents\Delphi_Projects\RipBot264\Tools\dgindex\DGDecode.dll")
video=MPEG2Source("C:\Temp\RipBot264temp\job1\job1.d2v")

#AudioSource
LoadPlugin("C:\Users\Dawidos\Documents\Delphi_Projects\RipBot264\tools\AviSynth plugins\NicAudio\NicAudio.dll")
audio=NicMPG123Source("C:\Temp\RipBot264temp\job1\job1 L2 2ch 48 384 DELAY -221ms.mp2")
audio=ResampleAudio(audio,48000)

#Delay
audio=DelayAudio(audio,-0.221)

#Normalize
audio=Normalize(audio,1)

#AudioDub
audio=ConvertAudioTo16bit(audio)
AudioDub(video,audio)

tebasuna51
9th April 2008, 03:07
Mp2 and Mp3 decoding is not perfect :)

Bug detected and fixed. Thanks for your help.

The problem was a continuous message:

MPEG 1.0 layer II, 384 kbit/s, 48000 Hz stereo

mixed with the audio data only with Bepipe, works fine with BeHappy. A file (common.c in mpg123-lib) send the message to stdout instead stderr.

Please use the new NicAudio.dll v2.0.1 (http://www.codeplex.com/NicAudio)

dimzon
9th April 2008, 11:39
The problem was a continuous message:

MPEG 1.0 layer II, 384 kbit/s, 48000 Hz stereo

mixed with the audio data only with Bepipe, works fine with BeHappy. A file (common.c in mpg123-lib) send the message to stdout instead stderr.


OMG! Very funny side-effect ;)

Fizick
13th April 2008, 20:01
tebasuna51,
Seems, you rename NicMpaSource to NicMPG123Source?
Please add some note to documentation.

tebasuna51
13th April 2008, 20:31
tebasuna51,
Seems, you rename NicMpaSource to NicMPG123Source?
Please add some note to documentation.

Nope, the original NicMpaSource was based in libmad libraries without support for mp3, only mp1/2.

Dimzon add NicMPG123Source (2006-03-06) using the MPASource from WarpEnterprises and mpg123-lib, with support for mp3 and VBR.

Like NicMPG123Source make the same than NicMpaSource + mp3 + VBR, I supress NicMpaSource.

There are only a reference in the changelog:
"libmad deprecated"
maybe I need explain this better.

Susana
24th April 2008, 20:12
Thank you very much for continuing this proyect tebasuna51. I had an ac3 3/0.1 and with nicaudio 1.x couldn't use avisynth; now it works fine with v2.x. Using avisynth scripts speeds up sincronization tasks :)

Atak_Snajpera
3rd May 2008, 21:03
NicAudio can not decode this AC3
http://www.mediafire.com/?tz0blxwtp9e

Decoding via DirectShowSource (FFDshow Audio) and BassAudio work.

tebasuna51
4th May 2008, 01:24
NicAudio can not decode this AC3
http://www.mediafire.com/?tz0blxwtp9e

Yep, NicAudio decode this ac3 and output 10:54 of 5.1 ... silence :rolleyes:

The problem is first frame (5.1), all parameters are taken from first frame and when second frame arrive is a 2.0 then is filled with silence and so on.

This mix of 5.1 frames and 2.0 are common in TV captures (movie-commercials) and fill with silence this frames is a good idea to maintain the sync but the first frame must be the appropriate.

DelayCut is necesary to examine and repair, see the log:
[Input info]
Bitrate=384
Actual rate=384.000000
Sampling Frec=48000
TotalFrames=20446
Bytesperframe=1536.0000
Filesize=31405056
FrameDuration= 32.0000
Framespersecond= 31.2500
Duration=00:10:54.272
Channels mode=3/2: L+C+R+SL+SR
LFE=LFE: Present
[Target info]
StartFrame=0
EndFrame=20445
NotFixedDelay= 0.0000
Duration=00:10:54.272
====== PROCESSING LOG ======================
Time 00:00:00.000; Frame#= 1. Crc1 error SILENCED: read = 53A4; calculated=DBA7
Time 00:00:00.032; Frame#= 2. Some basic parameters changed between Frame #1 and this frame
Time 00:04:24.192; Frame#= 8257. Some basic parameters changed between Frame #2 and this frame
Time 00:04:24.192; Frame#= 8257. Crc1 error SILENCED: read = A88B; calculated=2088
Time 00:04:24.224; Frame#= 8258. Some basic parameters changed between Frame #8257 and this frame
Number of written frames = 20446
Number of Errors= 5

Like you can see the first frame is 5.1. The message:
"Frame#= 2. Some basic parameters changed"
is a big warning, you need use Delay Start -32 ms to delete the first frame and the fixed ac3 is decoded fine by NicAudio.

There are also another 5.1 frame (8257) but now isn't a problem, is filled with silence.

Underground78
6th June 2008, 18:48
Bug detected and fixed. Thanks for your help.

The problem was a continuous message:

MPEG 1.0 layer II, 384 kbit/s, 48000 Hz stereo

mixed with the audio data only with Bepipe, works fine with BeHappy. A file (common.c in mpg123-lib) send the message to stdout instead stderr.

Please use the new NicAudio.dll v2.0.1 (http://www.codeplex.com/NicAudio)

Hello,

I have a similar problem when I encode using x264 cli an avs script with NicMPG123Source and SoundOut, I have this kind of output :

http://img182.imageshack.us/img182/3425/bugjs7.gif (http://imageshack.us)

I use the last version of NicAudio and SoundOut. If I remove SoundOut the problem disappeares so I don't really know if NicAudio is really guilty ...

Thanks in advance,

Underground78

tebasuna51
6th June 2008, 20:36
Yes, but now the message is in stderr and don't corrupt the audio.
The audio output is ok, you can minimize the window.
In next version I delete the annoying message.

Underground78
6th June 2008, 20:47
Yes, but now the message is in stderr and don't corrupt the audio.
The audio output is ok, you can minimize the window.
In next version I delete the annoying message.

Yes, I know it's not really a big problem except for reading the progress of the encoding so thank you ! :)

Atak_Snajpera
6th June 2008, 23:30
Will we see eac3 support in near future. FFmpeg should have it by now.

tebasuna51
7th June 2008, 01:58
Will we see eac3 support in near future. FFmpeg should have it by now.

We need developers to do the job.

Kurtnoise
24th June 2008, 07:00
seems that the last version has some trouble with wav sources extracted from VirtualDubMod...easy to reproduce : take an AVI file with mp3 as audio track -> extract the audio stream to wav with the tool and then try to transcode it. An error raises unfortunately with the RawWavSource(...). Works fine with WavSource(...) though.

Could you look at this please ?

tebasuna51
24th June 2008, 08:13
seems that the last version has some trouble with wav sources extracted from VirtualDubMod...easy to reproduce : take an AVI file with mp3 as audio track -> extract the audio stream to wav with the tool and then try to transcode it. An error raises unfortunately with the RawWavSource(...). Works fine with WavSource(...) though.

Could you look at this please ?

RawavSource can open uncompressed audio formats and work with wav files extracted with VirtualDub/Mod if the audio is in 'Full Processing Mode' <No compression (PCM)>

When wav files are extracted in 'Direct Stream Output' mode are only wav headers and the compressed stream. Then RawavSource send the message:
unsupported Audio Format

These streams, in wav container, can be open with NicMPG123Source, if mp3, or NicAc3Source if ac3.

EDIT: If these streams are opened with WavSource the default internal decoder is applied, maybe for mp3 can be accepted, but if is ac3 the DRC is applied losing quality.

Kurtnoise
24th June 2008, 12:47
thanks for the confirmation...

tebasuna51
25th September 2008, 11:36
New release NicAudio v2.0.2 (http://www.codeplex.com/NicAudio)

CHANGE LOG
----------
24/09/2008 Tebasuna 2.0.2
- mp3: Anoying message supress.
- ac3: 1MB (at least 13 sec) initial garbage assumed like delay instead reject the file.
Now ac3 delayed with VirtualDub style are delayed acordly (same behaviour than standard players).
- dts: Correct decode more amod+lfeon options instead automatic downmix. Support for padded dts.
Core extraction in DTS HD. Seems work fine with DTS High Res. (CBR),
still in beta stage with DTS Master Audio (VBR) please report any problem.
- rawav: Not needed first parameter, by default assumed ignorelength if > 2GB
Improved w64 support.

Note:
The DTS MA support can be slow:
- At the begining we need scan all the file to know the FrameCount (basic to be managed by AviSynth) because the extra HD frames have variable length.
- When do rewind/forward the method used to locate the exact frames need explore the file from the begining to search the correct position.
- To extract the core from a DTS MA I always recommend use DelayCut before.

stax76
25th September 2008, 11:55
Thanks for the new release, it's very useful for MPEG4 GUIs. Request: something like NicAutoSource accepting all supported source formats and a parameter and function to downmix ac3/dts to stereo would be very useful.

Edit: seems downmix is already supported.

Wilbert
25th September 2008, 20:51
@tebasuna51,

A user doesn't need to agree to the GPL in order to be able to download and use a plugin which is GPLed. I hope you can remove that ...

IanB
26th September 2008, 00:42
Good work :D

But loose the smart arse javavirused download links, i.e. javascript:__doPostBack('ctl00$ctl00$Content$TabContentPanel$Content$ReleasePanelOrderingContainer$ReleaseFilesCtrl$FileList$ctl00$FileNameLink','').

Please provide links that you can Right Click/Save As or wget [paste] with.

Leak
26th September 2008, 09:26
But loose the smart arse javavirused download links
I doubt that's in his control - Codeplex is a site like SourceForge (though it's probably biased towards Windows and .Net) so he has to use what everyone there uses...

Blame ASP.Net for those links - but even then whoever wrote the code for those download pages would have to be out of his mind to have it produce such links...

tebasuna51
26th September 2008, 11:11
I don't understand (and don't want understand) about licenses and don't have a fix space to host.
I used Codeplex because Dimzon use it for BeHappy, but no problem to host NicAudio in Doom or warpenterprises.
Here is the last release and sources (http://www.sendspace.com/file/lrxb8x).

yonta
26th September 2008, 12:18
Thanks for the update!

I tested the new version and here's what I found.

NicMPG123Source("test.mpa", Normalize=1)
NicMPG123Source("test.mpa", Normalize=0)
NicMPG123Source("test.mpa", 1)
NicMPG123Source("test.mpa", 0)

All of the above scripts fail with an error saying "invalid argument to NicMPG123Source".

NicMPG123Source("test.mpa")
This one works.

All ac3/dts/dts-hd/LPCM samples I have seem to work just fine.

Gavino
26th September 2008, 13:05
Normalize is a bool, so you need to say, for example

NicMPG123Source("test.mpa", Normalize=true)

yonta
26th September 2008, 13:38
Normalize is a bool, so you need to say, for example

NicMPG123Source("test.mpa", Normalize=true)

Aah, stupid me!
Thanks for the tip.

Fizick
26th September 2008, 15:20
It is not violation of GPL

tin3tin
24th October 2008, 14:32
Is there a way to force it to read paths with '-' letters?

I'm getting an acces violation error on paths like:
"C:\pa -th\audio.mp3"

tebasuna51
24th October 2008, 17:01
Is there a way to force it to read paths with '-' letters?

I'm getting an acces violation error on paths like:
"C:\pa -th\audio.mp3"

Tested without problem this .avs:
NicMPG123Source("D:\pa -th\audio.mp3")
SoundOut()

Maybe the problem is out of NicAudio.

tin3tin
24th October 2008, 23:19
Well, here NicMPG123Source and mpasource will not load an audiofile with '-' in the path. If I take it out it works.

DirectShowSource works with the '-' in the path.

Could it be ffdshow related(I got that installed).

tebasuna51
25th October 2008, 03:39
Well, here NicMPG123Source and mpasource will not load an audiofile with '-' in the path. If I take it out it works.

DirectShowSource works with the '-' in the path.

Could it be ffdshow related(I got that installed).

Where don't load?

Please put your OS, avs file and app to open the avs file.

ffdshow isn't related.

tin3tin
26th October 2008, 08:32
Strange, now I can't reproduce it(on this computer. I'm using XP sp3 on both my computers, using NicMPG123Source in MPC).

Another thing: I don't get any error messages when NicMPG123Source can't load a file with try ... catch(val).
Is it just me or how is this done properly?

tebasuna51
26th October 2008, 11:07
Another thing: I don't get any error messages when NicMPG123Source can't load a file with try ... catch(val).
Is it just me or how is this done properly?

try... catch() ?

Call you NicMPG123Source from a C# source?

NicAudio is writen in C++, you have the sources available, the error messages go by STDERR.

I'm using XP SP3 also.

tin3tin
26th October 2008, 11:42
The file Error.mp3 is a nonsense txt file with the extention changed to mp3.

err_msg=""
try{
loadplugin("NicAudio.dll" )
NicMPG123Source("Error.mp3")
}
Catch(err_msg) {blankclip(length=1,width=720,height=576,fps=25).Subtitle(err_msg)}

This doesn't produce an error message.

[EDIT: On the "-" faults - I think I've found the reason in a changed behaviour in the wxwidgets textctrl.getlabel function which somehow now doesn't deal properly with those strings and getvalue must be used instead. So sorry about that.]

Gavino
26th October 2008, 13:37
try... catch() ?

Call you NicMPG123Source from a C# source?
try ... catch is an Avisynth script language construct (as well as being found in C# or C++).
NicAudio is writen in C++, you have the sources available, the error messages go by STDERR.
In an Avisynth plugin, it's usual to report errors via the ThrowError function provided by the script environment. Looking at the code of the constructor, I can see that NicMPG123Source does this if it cannot open the input file at all, but not if it contains invalid data.

I would regard that as a bug.

tebasuna51
26th October 2008, 18:41
try ... catch is an Avisynth script language construct (as well as being found in C# or C++).
:eek:
Seems I don't know very much about AviSynth.

Gabino, the AviSynth docs spanish translation is pending, maybe you can help the newbies like me with problems with english language.

In an Avisynth plugin, it's usual to report errors via the ThrowError function provided by the script environment. Looking at the code of the constructor, I can see that NicMPG123Source does this if it cannot open the input file at all, but not if it contains invalid data.

I would regard that as a bug.

Yes, is true, then the best way to see if is a valid mp3 is check Audiolength (clip), must be > 0 for a valid mp3 and = 0 when don't exist a valid mp3 frame.

I can add a new ThrowError exit when vi.num_audio_samples==0 in next release.

Thanks.

tebasuna51
28th October 2008, 10:58
In an Avisynth plugin, it's usual to report errors via the ThrowError function provided by the script environment. Looking at the code of the constructor, I can see that NicMPG123Source does this if it cannot open the input file at all, but not if it contains invalid data.

I would regard that as a bug.

Other NicAudio functions (Ac3, dts) also exit without ThrowError when input file is empty:
if (!StreamLength) { // Dummy audio
...
Info.num_audio_samples = 0;
return;
}
Like you see can be detected with Audiolength(), but do you think I must add a ThrowError here instead the normal Return?.

Gavino
28th October 2008, 14:01
Other NicAudio functions (Ac3, dts) also exit without ThrowError when input file is empty: ...
Like you see can be detected with Audiolength(), but do you think I must add a ThrowError here instead the normal Return?.
I would prefer a ThrowError but I suppose you could argue that a clip with AudioLength = 0 is an accurate description of what you have.

Are there any circumstances where you would actually want to regard such a file as valid and not report an error?

tebasuna51
28th October 2008, 15:57
I'm not the author of this soft and I don't know if is necessary or not.

I also prefer a error with a description than need check AudioLength.

If nobody need this 'Dummy audio' I will add a ThrowError in next release.

tebasuna51
28th October 2008, 18:56
Request: something like NicAutoSource accepting all supported source formats...

Here is a beta to test:
uNicAudio203b.7z
(Edit: the actual uNicAudio v2.0.4 is distributed with the standard NicAudio v2.0.4)

Syntax:
UnicAudioSource("FileName.ext", int "Param1", int "Channels", int "SampleBits")

- A unique function call instead 5 different.
- The bool param in NicMPG123Source now is int. The last parameter order in RAW/LPCM was changed.
- Now we can detect mp3, ac3 (VirtualDub) and dts (dtswav) in wav container and use the appropriate decoder.

edit: included the TrowError mentioned in previous post.

IanB
28th October 2008, 23:11
@tebasuna51,

You should not confuse the trivial but valid empty file i.e. "vi.num_audio_samples==0" with any error conditions.

The accepted error path is to throw an Avisynth exception with a useful text message.

I leave it to you as to whether zero length input files are an error or a zero length clip, but please be consistent. Consider the raw mode type of files without any header will validly be zero length for zero samples.

tebasuna51
29th October 2008, 01:40
You should not confuse the trivial but valid empty file i.e. "vi.num_audio_samples==0" with any error conditions.

The accepted error path is to throw an Avisynth exception with a useful text message.

I leave it to you as to whether zero length input files are an error or a zero length clip, but please be consistent. Consider the raw mode type of files without any header will validly be zero length for zero samples.

No problem for me. You are the boss. :rolleyes:

Remember me when I make a request, like the maskchannels audio property, only to be consistent when output WAVE_FORMAT_EXTENSIBLE headers.

Then when the file is empty we put vi.num_audio_samples==0 but without Error.

When a mp2/mp3 don't have valid frames (Samplecount = 0) we send a ThrowError like when don't found ac3 or dts frames.

Midzuki
21st June 2009, 23:25
Just a "bug report" (sort of): NicMPG123Source() returns an Avisynth error message ("access violation" or something) when trying to open tagged MP3s that contain *images* (the well-known "cover arts"). :( OTOH, BassAudio ignores the ID-tags very well. :)

tebasuna51
22nd June 2009, 00:49
Just a "bug report" (sort of): NicMPG123Source() returns an Avisynth error message ("access violation" or something) when trying to open tagged MP3s that contain *images*
Can you upload a sample, please?

Midzuki
22nd June 2009, 02:54
Here it goes:

http://au.geocities.com/rashojin_mizuki/docs/

(filename = "mpthree-issue.zip") <-- no longer available

tebasuna51
22nd June 2009, 11:53
Yep, NicMPG123Source() don't work with this sample.
The workaround is use BassAudioSource (like you say) or delete the ID3v2 Tag with winamp or other before decode.

BTW, NicMPG123Source() work fine with ID3v2 Tag make with winamp, I don't know if this ID3v2 with image is a hack or a official resource, or maybe there are a new mpg123 lib to solve the problem. I will see.

tebasuna51
25th June 2009, 15:47
Was easy to implement, now NicMPG123Source() ignore the initial ID3v2,3,4 tags in the new version NicAudio v2.0.3 (http://nicaudio.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29247#DownloadId=72888)

b66pak
25th June 2009, 16:19
thanks...
_

b66pak
17th July 2009, 18:18
often when i decode 1500kb 5.1 dts tracks to 5.1 wav files with eac3to i get "clipping detected, a 2nd pass will be necessary"...same tracks with nicaudio are decoded in one pass...how is dealing nicaudio with clipping?

also 1500kb 5.1 dts >> 448kb 5.1 ac3 is done in one pass with nicaudio + aften (with BeHappy)...

same thing with eac3to is done in two passes ("clipping detected, a 2nd pass will be necessary")...

witch is the proper way?
_

tebasuna51
21st July 2009, 23:48
When you encode audio data, with lossy formats, the max input value is 1.000, but when you decode these peaks you obtain 0.999 or 1.001 (because is lossy).
If you ignore the clip you have 0.999 and 1.000 values, if you make a second pass with an attenuation, you obtain values between 0.998 and 1.000.

A clip is a encode/decode error, make a second pass don't solve the problem only preserve the error.

NicAudio always ignore decoder clips.
When you only decode with eac3to you can use the -no2ndpass parameter.
If you make downmix use -normalize (2ndpass to maximize the output)

tebasuna51
12th August 2009, 20:36
Solved a bug writing last block with lpcm source.

NicAudio.dll v2.0.4 (http://nicaudio.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=31471#DownloadId=78960)

b66pak
13th August 2009, 19:41
thanks...
_

Underground78
11th November 2009, 20:08
Hello,

Can we hope something like NicEAC3Source() one day ?

tebasuna51
12th November 2009, 00:48
I do't know if the free decoder is finished or not.

After we need a volunteer to translate the decoder to AviSynth plugin (I can help but I'm not a programmer to do all the job).

And, after the BD victory, I don't know if there are sources to decode in eac3.

Underground78
13th November 2009, 22:13
And, after the BD victory, I don't know if there are sources to decode in eac3.

Here in France, EAC3 format is used for the HD channels of the Digital terrestrial television.

tebasuna51
14th November 2009, 02:22
Use Eac3to while wait for the volonteer.

Kurtnoise
14th November 2009, 09:17
Most of the EAC-3 streams from the french HD channels use spectral extension. However EAC3to doesn't support this yet. You need to update FFmpeg libraries from it to support this or use a FFmpeg patched build.

smok3
24th November 2009, 22:06
could we have:
bool 'apply delay based on filename, where filename was generated using 'neurons' demuxer'
switch ? (at least for mp2 files, i'am trying to convert bunch of hdv files, and i'd like really exact sync....

or if there is an alternative solution? (the kind that doesn't make /me write some funny text manipulation scripts)

tebasuna51
25th November 2009, 03:33
The solution is include a Delay() function in the .avs file. NicAudio is only a decoder.

IanB
25th November 2009, 07:24
...
File = "MyProject T01 2_0ch 228Kbps DELAY -248ms.mp2" # Set target filename

R = RevStr(File) # Reverse the string
P = Findstr(R, RevStr(" DELAY ")) # Find right most " DELAY "
Delay = P > 0 ? Value(RevStr(LeftStr(R, P)))/1000.0 : 0.0 # Value as fractional seconds

AudioDub(..., NicMPASource(File).DelayAudio(Delay))
...

or use the DGIndex template generation facility :-...
V=Mpeg2Source("__vid__")
A=NicMPASource("__aud__").DelayAudio(__del__)
AudioDub(V, A)
...This will create a script with the __vid__, __aud__ and the __del__ replaced with the appropriate values for the current project.

And of course DGIndex can be command line driven use the -AT=AVS_Template_File option to enable project script generation.

smok3
25th November 2009, 09:41
A=NicMPASource("__aud__").DelayAudio(__del__)
much appreciated!

(yes, i use templating system and it is cli driven, somehow i missed the __del__ option however...)

tebasuna51
25th November 2009, 13:35
A=NicMPASource("__aud__").DelayAudio(__del__)
...

The NicMPASource method don't exist in NicAudio 2.x versions. Use NicMPG123Source instead.

smok3
25th November 2009, 13:59
i used
NicAudio.dll v1.82 - AviSynth Audio Plugins for MPEG Audio/AC3/DTS/LPCM
patched by dimzon (dimzon541@gmail.com)
(patch for 44.1khz AC3 by tebasuna51 + fixes for corrupt streams)

tebasuna51
25th November 2009, 23:58
No problem for mp2.

henryho_hk
27th November 2009, 11:14
I found cases that, when there is no delay, or when it is a LPCM track, "__del__" is undefined.

IanB
28th November 2009, 22:19
I found cases that, when there is no delay, or when it is a LPCM track, "__del__" is undefined.
You probably should report this as a bug.

But :-...
Delay = "__del__" == "" ? 0.0 : Value("__del__")
...

medp7060
18th December 2009, 06:38
I loaded AC3 audio with NicAC3Source, but VirtualDSub cannot accept it for converting to MP3, is it a way to do that?

tebasuna51
18th December 2009, 12:30
You need downmix the ac3 5.1 (or other multichannel with more than 2 chanels) to stereo.
You can use NicAC3Source("your.ac3", 2) to obtain a dpl downmix, or make the downmix yourself in the .avs.
There are samples in DownMix.extension in BeHappy package.

After the downmix is always recommended a Normalize()

medp7060
19th December 2009, 00:49
Thanks, tebasuna51. Got it.

TDiTP_
3rd January 2011, 03:56
tebasuna51
May be you should use in NicAudio such downmix matrix as in BeHappy?
Now NicAudio's DPLII matrix is as in azid - surround isn't inverted.

tebasuna51
3rd January 2011, 12:45
NicAudio never do DPLII downmix.

The downmix provided for NicAc3Source or NicDtsSource is only the standard Dolby ProLogic (only one surround channel) downmix and was included in liba52/libdts decoders.

I tried don't change at all the original liba52/libdts decoders.
I think the downmix process must be out of the decoders and be generic for all kind of sources, like now we can do with AviSynth script.

Maybe I can include a generic downmix, with all the choices, for my uNicAudio version (http://forum.doom9.org/showthread.php?p=1207564#post1207564) but seems the users aren't interested: 0 answers to my beta test request.

Wilbert
22nd January 2014, 23:24
I was playing with 2.0.6 and suspect there is a bug NicLPCMSource.

I'm working on the documentation again and created a utility (avs2pcm.exe (http://avisynth.nl/index.php/Filter_SDK/avs2pcm)) which can be used to convert avs to pcm using the AviSynth api. Yes it only works for 16 bit and mono so far. Here is what i did:

1) I created the following script:

v = blankclip(24)
a = Tone(length=1, frequency=2, samplerate=48000, channels=1, type="sine", level=1.0).ConvertAudioTo16Bit()
audiodub(v,a)
audiograph(20)

It shows a sine wave. Note it's 48kHz, mono and 16 bit.

2) I opened the script in Virtualdub and encoded it to an uncompressed wav. If i open the wave file in AviSynth i get the sine wave again:

v = blankclip(1000)
a = WavSource("D:\AviSynth\Plugins\avs2pcm\audio_src.wav")
audiodub(v,a)
audiograph(20)

Ok, that's how it supposed to be.

3) I encoded the script in (1) to pcm with avs2pcm.exe. [There is actually no video needed in the script, but that's not relevant here.] With a hex editor i see that the file is exactly the same as the wave file (without the wave header of course). So that means the pcm file is created correctly right?

4) But if i open the wave file in AviSynth i get a garbled sine wave:

v = blankclip(1000)
a = NicLPCMSource("D:\AviSynth\Plugins\avs2pcm\test2.pcm", 48000, 16, 1)
audiodub(v,a)
audiograph(20)


All files can be found here: www.wilbertdijkhof.com/avs2pcm.zip

Two questions. Is there something wrong with NicLPCMSource or am i missing something obvious? If the former, how to fix NicLPCMSource?

tebasuna51
23rd January 2014, 16:52
...
3) I encoded the script in (1) to pcm with avs2pcm.exe. [There is actually no video needed in the script, but that's not relevant here.] With a hex editor i see that the file is exactly the same as the wave file (without the wave header of course). So that means the pcm file is created correctly right?

Nope. You make a .raw (a wav file without header)

A .pcm must have the 16 bit audio data in 2 bytes big endian order, not in little endian order like wav (or .raw).
Also the channel order is different but here there are only 1 channel.

Use
a = RaWavSource("D:\AviSynth\Plugins\avs2pcm\test2.pcm", 48000, 16, 1)
instead
a = NicLPCMSource("D:\AviSynth\Plugins\avs2pcm\test2.pcm", 48000, 16, 1)

StainlessS
23rd January 2014, 18:47
from NicAudio readme

Supported files (all can be > 4GB):
ac3 (TODO: support also eac3 files or Dolby Digital Plus)
dts also dtswav supported
mpa mpeg files: mp1, mp2 and mp3
lpcm from DVD Audio, from BluRay with -SampleBits
raw and uncompressed formats: WAV, WAVE_FORMAT_EXTENSIBLE, W64, BWF, RF64, AU, AIFF and CAF

I guess that it could be better explained in NicAudio readme, exactly what format (subset of DVD Audio) is acceptable.

Perhaps this is the best available definition at present:

A .pcm must have the 16 bit audio data in 2 bytes big endian order, not in little endian order like wav (or .raw).
Also the channel order is different but here there are only 1 channel.

EDIT:
The readme also says this
"SampleBits" Necessary for lpcm and raw files. Valid values 8/16/24/32 (also 33 (32 float) for raw)
(lpcm also accept 20 and -8/-16/-24/-32. Negative values are for BluRay lpcm (big-endian))


Which would seem to indicate that only correct ordering of samples is required as you can set endian-ness as
a function arg via SampleBits (+ve/-ve SampleBits).

Is DVD Audio really little endian, DVD Video-audio is I think big endian ?
(I'm reading previous text as meaning that DVD is little endian, and BluRay lpcm is big endian)


a = NicLPCMSource("test2.pcm", 48000, -16, 1)

produces same sounding noise as without '-' sign

So, does the SampleBits +ve/-ve setting actually work (ordering of samples is irrelevant for mono).

Wilbert
23rd January 2014, 23:08
In addition to the response of StainlessS
A .pcm must have the 16 bit audio data in 2 bytes big endian order, not in little endian order like wav (or .raw).
As i understand it lpcm can be in little or big endian order (see for example here (http://wiki.multimedia.cx/index.php?title=PCM)). I haven't found anything which claims the contrary. This link (https://ccrma.stanford.edu/courses/422/projects/WaveFormat/) says that wav is little endian, so the pcm that i created is little endian too. I guess i need to investigate further ...

tebasuna51
24th January 2014, 14:01
Of course PCM (Pulse Code Modulation) is really generic and there are many options. Without a header we can't know if data is big or little endian, signed, unsigned, int, float, what bitdepth, samplerate, numchannels and order. NicAudio try to open the most standard formats, but can't support all.

You can see m2audio_lpcm.cpp source to know the supported formats.
Revision History:
* Oct 3, 2004: Created by Attila Afra
...
* Aug 21, 2007: Bug fixes, remove restrictions, generalize code. IanB
* Feb 29, 2008: Cancel obsolete code. Support for > 4 GB files. Map channels for new mode IsBluRay. Bugfix for count>Left. Tebasuna

IanB make the actual code for DVD PCM (SampleBits > 0). See the special order for 20/24 bits in your wiki link (http://wiki.multimedia.cx/index.php?title=PCM)

But I see than don't work for .pcm files extracted by eac3to from BluRay's.
Then I make a new mode BluRay with -SampleBits than don't use IanB code to reorder audio data. Is not a simple diference between big and little endian.
The BluRay mode use a more simple way and work with .pcm extracted by eac3to from Bluray, also this channel order and big-endian style is the required by tsMuxeR (with some header added by Pcm2Tsmu.exe)

In m2audio_lpcm.cpp I use a remap matrix:

// Other kind of lpcm with simple big-endian order and channels remapped
if ( SampleBits < 0 ) {
bIsBluRay = true;
SampleBits = 0 - SampleBits; // Valid parameter for BluRay: -16, -24, -32 (?)
Quant = SampleBits / 8; // Quant only auxiliar here to prepare the matrix
// Initializing remap matrix
for (Channels=0; Channels < ChannelCount; Channels++) map[Channels] = (Channels + 1) * Quant;
if (ChannelCount > 5) {
map[ChannelCount - 1] = 4 * Quant; // LFE from last to fourth
map[3] = 5 * Quant; // BL to fifth
map[ChannelCount - 2] = 6 * Quant; // BR from penultimate to sixth
}
if (ChannelCount > 6) map[4] = 7 * Quant; // SL or BC
if (ChannelCount > 7) map[5] = 8 * Quant; // SR
}

And after remap channels, and change big to little endian, Input buffer to Output buffer with:
if ( bIsBluRay ) {
byt = InQuant / 8;
for (i = 0; i < FrameLength; i += InBlock)
for (k = 0; k < ChannelCount; k++)
for (j = 1; j < byt + 1; j++) {
Output[i + map[k] - j] = Input[0];
Input++;
}
}

My question now is for what you need avs2pcm.exe?
What soft need read your .pcm file without headers?

Wilbert
24th January 2014, 23:55
To start with your questions

My question now is for what you need avs2pcm.exe?
What soft need read your .pcm file without headers?
It's just a toy utility that i want to use to explain some things about the avisynth api, and i want to know how to import it in AviSynth.

I did some further digging

RaWavSource("D:\AviSynth\Plugins\avs2pcm\test2.pcm", 48000, 16, 1)

loads it fine since RaWavSource doesn't reorder any bytes and my lcpm was little-endian. (Yes it loads raw files too.)

To my surprise (upon inspection of the code):

NicLPCMSource("D:\AviSynth\Plugins\avs2pcm\test2.pcm", 48000, 16, channels)
NicLPCMSource("D:\AviSynth\Plugins\avs2pcm\test2.pcm", 48000, -16, channels)

results in the same output (number of channels not important). For both the bytes will be swapped, so you can use both if you have a big-endian lpcm file.
I guess for the other samplebits (except 8 bit which is not supported) you will get differences, but i didn't look at that.

So if DVD pcm and BluRay pcm are both big-endian, what is the exact difference between the two?

tebasuna51
25th January 2014, 11:47
The number of channels is important because DVD PCM code don't make channel remap, BluRay code make remap if ChannelCount > 5 (see my first code).

A .pcm 5.1 from BluRay (extracted by eac3to) with 16 like SampleBits finish with a incorrect channel map FL,FR,FC,BL,BR,LFE
With -16 like SampleBits finish with correct FL,FR,FC,LFE,BL,BR. With 6.1 and 7.1 there are diference also.

And the bytes swap for 24 bits is different also:

24 bits BluRay code: B3,B2,B1 -> B1,B2,B3
24 bits DVD code: like wiki link (http://wiki.multimedia.cx/index.php?title=PCM#24-Bit_PCM)

Wilbert
25th January 2014, 23:49
The number of channels is important because DVD PCM code don't make channel remap, BluRay code make remap if ChannelCount > 5 (see my first code).
Ok i see, i missed that at first. Thanks for your explanation.