Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th December 2007, 04:35   #1  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
Possible bug in soundout()?

I think I've encountered what I consider a bug in soundout(), that causes a race condition in AutoMKV on my quad core box.

Namely, soundout() doesn't close stdout to a "cmd" output type until it actually closes (i.e. if one has a std 5sec timeout, it doesn't close it until the timeout expires or one hits "close").

Now, virtualdub exits right away, but the cmd process doesn't seem to have to exit right away. In AutoMKV, it sees that the virtualdub it spawned is closed and then looks at the file size to see if encoded correctly (has to be over a minimum size).

Now, if the output program is NeroAAC, it seems to do a lot of housekeeping on the output file when it reaches the end of the input (i.e. its stdin reaches end of file due to soundout() closing stdout). Part of this housekeeping seems to be rewriting the file from scratch (or at least refreshing file size quickly shows the file size drop to 0 and then be recreated).

On a quadcore box, automkv is able to get the size of the file when its 0.

From my perspective, either soundout() should close stdout earlier, or more correctly, avisynth/virtualdub shouldn't exit until the programs they executed (in this case neroaac) exit.
spotter is offline   Reply With Quote
Old 20th December 2007, 08:46   #2  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
@spotter: Thanks, I'll investigate. I'm currently experimenting with various additions/rewrites, so I hope you have a little patience. Hopefully in the beginning of the new year.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 20th December 2007, 15:44   #3  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
does my analysis make sense to you?
spotter is offline   Reply With Quote
Old 6th January 2008, 13:47   #4  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
The output pipe is closed immediately after the last samples have been delivered.

The process is however forcefully terminated, when the windows is closed. Nero might not be finished updating the file when it is terminated.

Is the output correct, if you do not use autoclose or close the window early?
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 6th January 2008, 15:19   #5  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Please try: http://klauspost.googlepages.com/SoundOut-test.zip

I have added a process exit check. It will wait 5 seconds. If more than 5 seconds elapses it will ask if you forcefully wants to terminate the thread.
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 6th January 2008 at 15:22.
sh0dan is offline   Reply With Quote
Old 6th January 2008, 16:12   #6  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
ok, have a friend's wedding today and a research paper due tomorrow, so it might be a couple of days.

thanks.
spotter is offline   Reply With Quote
Old 8th January 2008, 18:19   #7  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
it took longer than 5s to exit, but it did exit before I said ok to killing it. Any chance soundout can just wait till it exits by default, ala in unix

if (pid = fork()) {
wait(pid);
} else {
exec();
}

not a win32 programmer (even after spending a summer at microsoft), so unsure about the semantics for windows.

Last edited by spotter; 8th January 2008 at 18:22.
spotter is offline   Reply With Quote
Old 8th January 2008, 19:50   #8  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Basicly I deliver all the audio samples, close the pipes and wait for the process to exit by itself.

Could you provide some additional info so I can reproduce the bug, since NeroAAC works fine here.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 8th January 2008, 20:10   #9  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
this is the script automkv creates

Quote:
LoadPlugin("D:\Copy of AutoMKV\exe\filter\NicAudio.dll")
LoadPlugin("D:\Copy of AutoMKV\exe\filter\SoundOut.dll")
LoadPlugin("D:\Copy of AutoMKV\exe\filter\FFmpegSource.dll")
NicAC3Source("D:\Movie\temp\movie t80 3_2ch 448kbps delay 0ms.ac3")
DelayAudio(0.0000)
#Applying STEREO downmixing routines
function stereo(clip a)
{
flr = GetChannel(a, 1, 2)
fcc = GetChannel(a, 3)
lfe = GetChannel(a, 4)
lfc = MixAudio(fcc, lfe, 0.2071, 0.2071)
mix = MergeChannels(lfc, lfc)
lrc = MixAudio(flr, mix, 0.2929, 1.0)
blr = GetChannel(a, 5, 6)
Return MixAudio(lrc, blr, 1.0, 0.2929)
}
#
6==Audiochannels() ? stereo() : last
function addvideo(clip c) {
blankclip(length = Int(100 * AudioLengthF(c) / float(audiorate(c))), fps=100)
Return audiodub(last,c)
}
Normalize()

Soundout(output="cmd",type=1,format=3,autoclose=true,executable="D:\Copy of AutoMKV\exe\besweet\neroaacenc.exe",prefilename=" -ignorelength -q 0.35 -if - -of audio.mp4",postfilename="",nofilename=true,showoutput=false)
basically what I observe is that when neroaac does a lot of work after the the pipe closes. If the disk is slow on IO (for instance because a lot of other IO is going on). It can take a while to complete. soundout() closes b4 that happens. For instance, with the modified version you posted, it asks to kill the process, but as I only see it 20-30s after it pops up, the neroaac process already quit (checking task manager) so killing it does nothing. (hence I'm not sure what you mean by waiting for process to exit, as there would be nothing to forceably kill if you did that).

What I'm asking, instead of the modified version that asks to forcably kill the child process, you just wait on that process to exit.
spotter is offline   Reply With Quote
Old 11th January 2008, 04:19   #10  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
wondering if you need any more info from me?
spotter is offline   Reply With Quote
Old 11th January 2008, 10:22   #11  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
@spotter: No - actually the prompt just proves that the fix is working. I've increased the timeout, and added a parameter to control it. I've tested with a 2 hour stream, and it works nicely.

The prompt must come up, if the app doesn't terminate by itself, otherwise users can be stuck there.

The prompt actually does the opposite of what it's advertising.
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 11th January 2008 at 10:25.
sh0dan is offline   Reply With Quote
Old 16th January 2008, 18:40   #12  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
@sh0dan: do you have the a copy that I can use?
spotter is offline   Reply With Quote
Old 16th January 2008, 19:26   #13  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
another thing to think about, is it possible to have the even when the "terminate" window is up, to continue checking to see if the process quit by itself, and if it did, close the window automatically and continue?
spotter is offline   Reply With Quote
Old 16th January 2008, 21:10   #14  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
http://klauspost.googlepages.com/SoundOut-test2.zip

Rather untested though. Exit timeout is 60 seconds - if you don't want the box, increase "exittimeout" parameter until it doesn't appear - parameter is in seconds.
__________________
Regards, sh0dan // VoxPod

Last edited by sh0dan; 16th January 2008 at 21:13.
sh0dan is offline   Reply With Quote
Old 17th January 2008, 23:51   #15  |  Link
spotter
Registered User
 
Join Date: Jan 2002
Posts: 251
btw, done a bunch of encodes w/ the new one, seems to work great for me.
spotter is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:45.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.