Log in

View Full Version : NicAUDIO bug report: 6Channel Ac3->MP4 under MEGUI


sjchmura
20th August 2006, 15:48
I was asked to post some samples from teh MEGUI forums.

Here is a small ac3 clip that failes. This clip has no errors in ac3filter(well, I cut it out so I hope it does not now) but it encodes FINE in BeSweet/BeHappy/NeroReCode.


http://rapidshare.de/files/30053014/...ELAY-760ms.ac3

So this is the error. Encodes fine in nero or besweet.

Channels=6, BitsPerSample=16, SampleRate=48000Hz
C:\Program Files\Multimedia\Encoding\megui\tools\neroaacenc\neroAacEnc_SSE2.exe -ignorelength -q 0.5 -if - -of "F:\Star.Wars.ep3.DELAY-760ms.mp4"Error:
MeGUI.AviSynthException: m2AudioAC3Source: error in file "F:\Star.Wars.ep3.DELAY-760ms.ac3"
at MeGUI.AviSynthAudioEncoder.encode()

shon3i
20th August 2006, 15:54
http://rapidshare.de/files/30053014/...ELAY-760ms.ac3link is broken

aslo BeHappy use same engine like MeGUI, so BeHappy use same version of NicAudio and simmilar settings. what you settings use in MeGUI

Dark Eiri
20th August 2006, 18:22
I got the exact same error. Help please ._.

squid_80
20th August 2006, 19:52
The link has been posted wrong. Corrected: http://rapidshare.de/files/30053014/Star.Wars.ep3.DELAY-760ms.ac3

tebasuna51
20th August 2006, 19:54
The correct link is:

http://rapidshare.de/files/30053014/Star.Wars.ep3.DELAY-760ms.ac3

This file start like 5.1 but have a fragment (8 frames) of 2.0. See DelayCut log:
====== PROCESSING LOG ======================
Time 00:00:04.768; Frame#= 150. Some basic parameters changed between Frame #1 and this frame
Time 00:00:04.992; Frame#= 157. Some basic parameters changed between Frame #150 and this frame
NicAudio crash at this point (also with BeHappy).

Other decoder/player produce an audible cut but continue.
You can use DirectShowSource with MEGUI/BeHappy.

Edit: NicAudio also crash with ac3 44.1 KHz and give the same error message. See a possible solution in this post (http://forum.doom9.org/showthread.php?p=859928#post859928)

squid_80
20th August 2006, 20:55
It's also possible to run the stream through projectx with the "replace all non-3/2 ac3 by 3/2lfe silence" option turned on, if you have suitable silent replacement frames in ac3.bin.

sjchmura
22nd August 2006, 05:52
BeSweet encodes it fine. So how did you find the errors? AC3Fix - on the whole file - shows zero errors. COuld I have induced these errors in the cutting to make it small. I can post the whole clip if you would like.

THe problem wtih directshow is the following - getting it to work right. Nero7 decoder does not work and ac3filter also fails - you just get 2 channel even if set to "AS IS". If you "Force 3/2" you still get 2 channel. RIght now I have ac3filter encoding every NON ac3 file to ac3 so I only need 1 digital audio connection.

When I return to chicago I will try the projectx solution.

squid_80
22nd August 2006, 08:57
This sort of thing normally happens with DVB broadcasts, the program has 6 channel sound but the advertisements only have stereo. So unless you cut in exactly the right spot when removing ads, you end up with a few frames of stereo audio which isn't exactly wrong but can confuse some programs.
AC3Filter should be able to handle it, I don't know why it's not working for you.

tebasuna51
22nd August 2006, 10:39
BeSweet encodes it fine. So how did you find the errors? AC3Fix - on the whole file - shows zero errors. COuld I have induced these errors in the cutting to make it small. I can post the whole clip if you would like.
I agree with squid_80 about how this frames are there, and, because are correct frames, AC3Fix don't say nothing.
DelayCut show a 5.1 stream and, trying to fix, show a problem between frame 150 and 157.
If you cut a fragment between 4800 ms (32 ms/frame) and 5000 ms and open after in DelayCut show a 2.0 ac3 stream.

A hard way to find the errors is analyze the frame headers with WinHex after 4.6 sec. (crash point of NicAudio).
THe problem wtih directshow is the following - getting it to work right. Nero7 decoder does not work and ac3filter also fails - you just get 2 channel even if set to "AS IS". If you "Force 3/2" you still get 2 channel. RIght now I have ac3filter encoding every NON ac3 file to ac3 so I only need 1 digital audio connection.
Yes, DirectShow is problematic because each user have a different configuration. With ffdshow properly configured work fine for me.

Nic
23rd August 2006, 18:08
I'm looking into the issue. On that clip NicAudio.dll is throwing an exception to AviSynth to tell it that there was a problem reading a frame. This causes the crash strangely.
The main problem is there is an issue with that AC3 file. How I mask that is another question.

I'll keep working on it.

-Nic

ps
The exception is thrown because the "Flags" from the frame differ to what they should be.

pps
Does anyone have a small nice 44100khz AC3 file that breaks NicAudio too? That would help with my testing greatly.
(I tried making a 44.1khz file in ffmpeg but that doesn't seem to have the alternating ac3 frame size, at least not on my test, so I do need an example file)

ppps
So I/you can find it easily, the thread where tebasuna51 talks of the 44.1 issue is here http://forum.doom9.org/showthread.php?p=860537#post860537

Nic
23rd August 2006, 21:28
Try this: http://nic.dnsalias.com/NicAudio_alpha.zip
Might be worse, could be better. Don't have enough bad AC3/44.1k files to test on. I'm away tomorrow till Monday so thought I may as well post this, so I've got feedback on my return.

-Nic

sjchmura
24th August 2006, 17:23
I will be back from San Fran to home Friday and will test it nic. I about 50% of what I captured (through 1394) from NCB-Unviersal HD have these issues. I will also try the projectX fix.

So is nero and besweet just "reading past" the errors???

Thanks for looking into this. When this is fixed I will post it in the MEGUI thread about this issue.

Best

Steve
:D

Nic
24th August 2006, 18:29
Yup, as is azid. It's definitely an error and all decoders I had glitched on it slightly.

With the original NicAudio, any problems would cause it to throw an exception back to AviSynth. This new version should handle it better, but I need more test streams to make it bulletproof.

-Nic

sjchmura
25th August 2006, 01:03
Sure - let me cut come after I get home. How long do you need them? Do you want the entire length or should I make it as small as possible (and still get the error)??

Thanks

STeve

Dark Eiri
25th August 2006, 03:04
Thanks Nic! This alpha solved the problem! You're awesome!

Sharktooth
25th August 2006, 03:45
Is this alpha stable enough to put it in the megui autoupdate server or should i wait for a beta or maybe a stable version?

dimzon
25th August 2006, 08:40
Try this: http://nic.dnsalias.com/NicAudio_alpha.zip
Might be worse, could be better. Don't have enough bad AC3/44.1k files to test on. I'm away tomorrow till Monday so thought I may as well post this, so I've got feedback on my return.

-Nic
Does this alpha based on my last sources (incl DRC control and 5-channel bugfix). If not please provide Your source.

tebasuna51
25th August 2006, 10:55
Does this alpha based on my last sources (incl DRC control and 5-channel bugfix). If not please provide Your source.
This alpha works fine replacing with silence wrong frames (like Azid). I think is better this solution than stop decoding.
Include DRC control and 5-channel bugfix, but don't support NicMPG123Source then is based in sources previous to 1.5 NicAudio_25_dll_20060314.

Based in last sources I know (20060314), I make a new m2audio_ac3.cpp modified (http://www.mytempdir.com/885614). I think solve this thread bug and the 44.1 KHz bug.

There are still a problem related with this Nic's comment:
"The length of the stream is calculated by the filesize/framelength, if the framelength can be variable this can't work."
In fact I make a mod with:
FrameCount = int((StreamLength - StreamOffset) / FrameLength);

If (Samplerate == 44100)
FrameCount = int(0.5 + 147 * (StreamLength - StreamOffset) / (640 * Bitrate)));
But this work only with ac3 Aften generated. Let me explain this a little bit more:

I detect the 44.1 KHz bug testing Aften with the wav sample (http://www.xiph.org/vorbis/listen/41_30sec.wav) provided by jruggle.
I encoded the sample with Aften and also with SoftEncode at 192 Kb/s. NicAudio crash with Aften encoded just at the begining (frame 4) but with SoftEncoded crash at frame 118.
Here is the ac3 samples (http://www.mytempdir.com/885681).

To maintain 192 Kb/s we need Framesize = 192 * 640 / 147 = 835,918... bytes, then we need a 4% of frames with 834 bytes and a 96% of frames with 836 bytes.
The encoder must maintain the proportion between short and long frames in order to preview the FrameCount with the StreamLength in:
FrameCount = (147 * StreamLength) / (640 * Bitrate)

I make some 44.1 KHz test with this results:

Nominal Theoretic Real Real Calculated
ac3 Bitrate FrameSize FileLength Bitrate FrameCount FrameCount Error
----------- -------- --------- ---------- --------- ---------- ---------- -----
0030_aften 192 kbps 835.918 720560 191.999 862 861.998 0
0030_aften 224 kbps 975.238 840654 223.999 862 861.998 0
0030_aften 448 kbps 1950.476 1681310 447.999 862 861.999 0
0242_aften 224 kbps 975.238 6776930 224.000 6949 6949.000 0
4409_aften 192 kbps 835.918 105933426 191.999 126727 126726.998 0

0030_soften 192 kbps 835.918 719696 191.769 862 860.964 1
0030_soften 224 kbps 975.238 840388 223.928 862 861.725 0
0030_soften 448 kbps 1950.476 1681726 448.110 862 862.213 0
0242_soften 224 kbps 975.238 6775224 223.943 6949 6947.251 2
4409_soften 192 kbps 835.918 105816846 191.788 126727 126587.535 139
Seems the samples encoded with aften maintain the % between FrameSizes to reach the bitrate, but SoftEncode make 50% short/long Frames and need other method to calculate FrameCount.

For SoftEncode the average FrameSize is = 1 + 2 * int(Bitrate * 320 / 147), 835 bytes for 192 Kb/s, and now:
FrameCount = StreamLength / (1 + 2 * int(Bitrate * 320 / 147))

What is the correct method? I don't find anything in specs.

What do others encoders? Please provide ac3 44.1 KHz samples with others encoders than SoftEncode, Aften or free encoders.

tebasuna51
31st August 2006, 17:11
At Swedish Radio (http://www.sr.se/cgi-bin/mall/artikel.asp?ProgramID=2446&Artikel=740607) there are some free samples ddwav 44.1 KHz 5.1 640 Kb/s.
I don't know the encoder but must be a commercial one because DRC is present.

The test:
Nominal Real Real Calculated
ac3 Bitrate FileLength Bitrate FrameCount FrameCount Error
----------- -------- ---------- ------- ---------- ---------- -----
SURROUNDTEST 640 Kb/s 10128544 639,999 3635 3634,999 0
BILJAKTEN_LOW 640 Kb/s 11719576 640,000 4206 4206,000 0
FIREBIRD 1 640 Kb/s 23815314 639,999 8547 8546,999 0
DEMO2_DD 640 Kb/s 26052790 640,000 9350 9350,000 0
Work like Aften, preserving the bitrate and we can apply:
FrameCount = int(0.5 + (147 * StreamLength) / (640 * Bitrate))

Any new version to test (Nic/Dimzon)?

Nic
31st August 2006, 17:52
@tebasuna51: Thanks for finding samples. Have a cold at present, so can't get the motivation to look into them. But that should change this weekend.

Nic
1st September 2006, 10:45
Ok,

http://nic.dnsalias.com/NicAudio_alpha2.zip

This should work better on 44.1khz files, I modified my code slightly (I was being too harsh on checking for valid AC3 files).

Also, I was using NicAudio_25_dll_20060314 as my base, but I was using the VC6 project files which didn't include mpg123. I've changed that now (still using VC6 project files, i prefer VC6 for small things, better compatibility).

Anyway let me know how this build works, couldn't have done it without tebsuna51's sample files. So lots of thanks to him.

-Nic

ps
If this seems ok, i'll do a proper release of course.

dimzon
1st September 2006, 13:52
still using VC6 project files, i prefer VC6 for small things, better compatibility
<offtop>
Actually it's wrong bcz VC6 is not C++ standart compliant! So it is'nt even true C++...
</offtop>

Nic
1st September 2006, 14:40
@dimzon: :D Depends on what you mean by compatibility. Your right of course, but I meant for others to use the source (i.e. any version of VC from 6 upwards can load the project files) and also the VC6 runtime DLLs are more ubiquitous.

Of course I could say to you; the abbreviation is "isn't" not "is'nt", the word is "standard" not "standart", etc. But I don't feel the need to correct people over minor points... ;)

-Nic

dimzon
1st September 2006, 15:08
i.e. any version of VC from 6 upwards can load the project files)
Actualy I have found some problems (http://forum.doom9.org/showthread.php?t=108083) compiling original mpasource(written in VC6).

Nic
1st September 2006, 15:19
That's a separate issue, normally it's not too hard to port from VC6 to other versions. Apart from certain STL issues...

All seems to be well though in NicAudio. Just need some people to test :)
-Nic

tebasuna51
1st September 2006, 15:59
First test:
- Ok with bug thread (Star War 5.1 with 2.0 fragment)
- Ok with NicMPG123Source
- 44.1 KHz Aften and Swedish Radio samples:
Seems we need round
FrameCount = int(0.5 + (147 * StreamLength) / (640 * Bitrate))
because:
Real Calculated
ac3 FileLength FrameCount FrameCount Error
----------- ---------- ---------- ---------- -----
BILJAKTEN_LOW 11719576 4206 4206.000 0
FIREBIRD 1 23815314 8547 8546.999 -1
All my samples with Calculated Framencount x.999 have the last frame cut.

- 44.1 KHz SoftEncode have last frames cut:
Real Calculated
ac3 FileLength FrameCount FrameCount Error
----------- ---------- ---------- ---------- -----
4409_soften 105816846 126727 126587.535 140
4,876 sec lost in 4413,892 sec.

Nic
1st September 2006, 18:49
@tebasuna51: Thanks :) Please try http://nic.dnsalias.com/NicAudio_alpha3.zip

That should have the rounding fixed.

-Nic

tebasuna51
1st September 2006, 21:46
@Nic: Thanks, for me NicAudio_alpha3 is OK now