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 19th February 2003, 23:41   #1  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
CALL command

This might be way over the top, but I am wondering if there exists a method or the possibility of implementation of a CALL command (to call an external commandline program) in AviSynth?

The background for the question is this. My wife does some video editing in Movie Maker 2 and then hands it off to me to finish up in Video Vegas. WMM2 creates a Type 1 DV file that nothing seems to like so I have to convert it, or save out the wav and use wavsource or load it in VDub as separate wav audio. If you have 25 files to do this gets to be a real pain, plus I run into many other situations where I wish I could call an external program. Sort of a batch file mentality I guess.

As I was playing around with writing some automatic templates for AVISynthesizer (the real one - the first one), I was struck with how nice it would be to have the ability to call an external program to strip the audio from an AVI as a wav file and then use wavsource. Something like this:

#DV-T1 Template
Call ("avi2wav.exe mytest.avi mytest.wav") #imaginary
V=avisource("mytest.avi")
A=wavsource("mytest.wav")
AudioDub(V,A)

This might also be useful with MPGs and mpasource. I may well be way off target but I sure do wish there was a way to automate this chore from within AviSynth. Am I missing some obvious solution?

Add: Another thing that got me thinking about this was Nic's mpegdecoder and mpasource both do/can call a routine before allowing the script to complete. Nic builds a d2v file if needed and mpasource creates an index. So, it does not seem too big a stretch to think an external executable might be able to run from within Avisynth.
DD

Last edited by DDogg; 20th February 2003 at 02:01.
DDogg is offline   Reply With Quote
Old 20th February 2003, 15:33   #2  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
Well this went over like a lead ballon. So, let me ask a more straight forward question of the coders:

Is it possible to code a plugin/filter with the single purpose of calling and passing params to a external commandline program? If so, would somebody consider doing it?
DDogg is offline   Reply With Quote
Old 20th February 2003, 16:06   #3  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Should be easy enough - you could even make it trigger on a certain frame. If someone could device a plugin, I'd be happy to implement it into the core.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 20th February 2003, 16:38   #4  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
sh0dan, thanks for the lifeline I was starting think this suggestion might be a big hairball. Seriously, IMO, the additional flexibility made possible could be well worth an effort on somebody's part.

Some:
1> One could do both pre-process and post-process operations from within a script.
2> It would open (somewhat) AviSynth to anybody that could write a simple program or even a batchfile to accomplish one-off "individual enthusiasms". If some of those one-offs were of greater interest a more experienced coder could refine them.

Q: Can a plug-in coder send a string to video output? Like "Executing external command, please wait"?

DD

Last edited by DDogg; 20th February 2003 at 16:42.
DDogg is offline   Reply With Quote
Old 20th February 2003, 17:18   #5  |  Link
sh0dan
Retired AviSynth Dev ;)
 
sh0dan's Avatar
 
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
Quote:
Can a plug-in coder send a string to video output? Like "Executing external command, please wait"?
Yes - but unless you open a new window it will be in the final frame of your video.
MPEGSource opens a new window for a progress bar for instance.
__________________
Regards, sh0dan // VoxPod
sh0dan is offline   Reply With Quote
Old 20th February 2003, 18:22   #6  |  Link
Belgabor
VDubMod Devel
 
Belgabor's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 824
@DDogg, you seem to have a small misconception of avisynth scripts or fell into a small trap of thought. The script is not processed once form start to end like e.g. a bash script on linux, there is no temproal one-command-after-the-other, only a stream of frames so to speak which can be accessed randomly.
The result is that a CALL command could only be (someone correct me if I'm wrong)
  • executed on open
  • executed on close
  • executed each time / the first time a specific frame is requested
so, like sh0dan said, reporting of execution status is not possible via video output.

Cheers
Belgabor
__________________
VirtualDubMod [SourceForge : Tracker/DL] (FAQ, Some rules)
Be sure to also download the latest DLL package or get the all inclusive package!
Before you post questions, please read the VirtualDub and/or VirtualDubMod FAQ.
If you have a bug report or feature request for VirtualDubMod, be sure to read the rules first.
We give 100% of your donations to the Open Source community
Belgabor is offline   Reply With Quote
Old 20th February 2003, 19:24   #7  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
Quote:
... or fell into a small trap of thought.
Yep, I am always doing that. A very little knowledge can be dangerous (ME - I cheerfully admit), but, hopefully can occasionally stimulate thought
Quote:
The result is that a CALL command could only be (someone correct me if I'm wrong)

executed on open
executed on close
executed each time / the first time a specific frame is requested

so, like sh0dan said, reporting of execution status is not possible via video output.
Those three options would be more than enough! Status would just have been frosting on the cake. Who am I to quibble? A guy can dream, yes?

Seriously, Belgabor, thanks for helping me understand better and thanks for all the work on VDubMod. So ..., now that I am a toady, would you be interested in writing this plugin?

Last edited by DDogg; 20th February 2003 at 19:27.
DDogg is offline   Reply With Quote
Old 21st February 2003, 10:18   #8  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,285
The chances are, for instance with BeSweet, the "call" command would just be doing a ShellExecute or CreateProcess, so the application will popup and have its own progress showing...It may not be the neatest way, but should be enough

Ill whip it up tonight if I get time, but any of the coders here could code it if any of us have 5mins to spair (which I fear we rarely do )

-Nic
Nic is offline   Reply With Quote
Old 21st February 2003, 11:24   #9  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,285
Actually, here you go :
http://nic.dnsalias.com/Call.zip

Has the source and a Avisynth 2.5 version as well as the normal Call.DLL

I havent really tested it, but someone will be able to fix it if its broken easily. Hopefully the readme.txt will help people use it.

Cheers,
-Nic

ps
Thinking about it you probably need it after some sort of source, so use like:
LoadPlugin("MPEG2Dec.dll")
LoadPlugin("Call.dll")
MPEG2Source("e:\rip\movie.d2v")
Call("d:\besweet", "0,-1")

Call probably has to come after a *Source plugin of some sort
Nic is offline   Reply With Quote
Old 21st February 2003, 20:38   #10  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
Nic, this was really decent of you to take the time to do this. God knows your plate always seems full. I'll give it a few tests and report back. Thanks, very much, again.

DD
DDogg is offline   Reply With Quote
Old 22nd February 2003, 04:21   #11  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
@Nic
The -1 works like a top, but if 0 is used the call command is implemented twice. If 0 is used it activates @ frame 0 and also at the EOF as if it were passed 0,-1 as its args. If you close the player before the end it also activates.

LoadPlugin("call.dll")
LoadPlugin("mpeg2dec.dll")
testcmd="besweet.exe -core( -input matrix.ac3 -output matrix.wav )"
mpeg2source("Matrix.D2V")
Call(testcmd,"-1")

It was great to see one could use a variable as the argument.

I now more fully understand Belgabor's meaning in the post above. I foolishly ( ) thought this might work as if the MP3 could have been produced before the clip:

LoadPlugin("call.dll")
LoadPlugin("mpeg2dec.dll")
LoadPlugin("mpasource.dll")
testcmd="besweet.exe -core( -input matrix.ac3 -output matrix.mp3)"
Call(testcmd,"-1")
V=mpeg2source("Matrix.D2V")
A=mpasource("matrix.mp3")
audiodub(V,A)

I freely and cheerfully admit to a case of ******* . Be that as it may, I still think people may well find some very interesting uses for CALL.

There seems to be a sortof IfThenElse<(kinda) structure that could be used (I think) to change the string of a variable used by CALL? That might open a few more uses.

Q: Anybody know enough about the import command to tell/show me how to read in a file and reset some variables? I think that is possible but the manual is pretty light on the subject.

Last edited by Guest; 22nd February 2003 at 13:09.
DDogg is offline   Reply With Quote
Old 22nd February 2003, 09:41   #12  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,285
Hmmmm. Ill look into that DDogg. Ill make that if your setting it for frame 0 then frame 0 is only called once (I dont believe that its getting called at the end, just that the film is being rewound to the first frame by the encoder)

To make a version of Call that works before encoding begins could be tricky. But then again, If I did everything in the constructor of the filter then that should do it before encoding begins....Hmmmm, ill give it a go later.



-Nic
Nic is offline   Reply With Quote
Old 22nd February 2003, 11:43   #13  |  Link
Nic
Moderator
 
Join Date: Oct 2001
Location: England
Posts: 3,285
Call v1.1

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

This version now lets you do:

LoadPlugin("call.dll")
Call(BlankClip, "lame --decode fatboy.mp3 fatboy.wav", "-2")
WavSource("fatboy.wav")

which creates fatboy.wav just before WavSource trys to load it
Also the "calling frame 0 twice bug" should also be fixed.

Cheers & good luck with it,
-Nic
Nic is offline   Reply With Quote
Old 22nd February 2003, 17:09   #14  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
===> Superman cape to Nic

Wow! This works perfectly:

LoadPlugin("call.dll")
LoadPlugin("mpeg2dec.dll")
LoadPlugin("mpasource.dll")
testcmd="besweet.exe -core( -input matrix.ac3 -output matrix.mp3"
Call(BlankClip, testcmd,"-2")
V=mpeg2source("Matrix.D2V")
A=mpasource("matrix.mp3")
audiodub(V,A)


I had come to think it impossible to do something BEFORE the video event. This adds a new dimension. I'm off to do some expermentation with my head spinning....

Nic, tremendous!

DD

Last edited by DDogg; 22nd February 2003 at 18:00.
DDogg is offline   Reply With Quote
Old 22nd February 2003, 17:16   #15  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Great work, Nic.

I want to commend you also for including the source. This is something we all should do with every binary release.
Guest is offline   Reply With Quote
Old 22nd February 2003, 19:37   #16  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
How would you change this command that uses quotes (from BeSweet GUI) to work with the CALL command? Possible?

"BeSweet.exe" -core( -input "Matrix.ac3" -output "matrix.mp2" ) -azid( -c light -L -3db --maximize ) -2lame( -m d -b 192 -e ) -profile( DSPguru_MP2@192kbps )

The manual says:

"string: surrounded either by "quotation marks" or by ``TeX?-style quotes''. A text string can contain any character except the terminating quotation mark or double-apostrophe. If you need to put a quotation mark inside a string, use the TeX?-style notation. Alternately, you can use Windows extended-ASCII curly-quotes instead of straight quotes to get around this limitation.

I tried replacing the standard double quotes with curly ones “” but that did not work. I don't have a clue what a TeX style quote is.
DDogg is offline   Reply With Quote
Old 22nd February 2003, 19:46   #17  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
Quote:
Originally posted by DDogg
I tried replacing the standard double quotes with curly ones “” but that did not work. I don't have a clue what a TeX style quote is.
Use two single back-quotes to begin a quotation and two single quotes to end it. The usual double quote symbol doesn't produce the correct result.
Guest is offline   Reply With Quote
Old 22nd February 2003, 20:04   #18  |  Link
DDogg
Retired, but still around
 
DDogg's Avatar
 
Join Date: Oct 2001
Location: Lone Star
Posts: 3,058
Quote:
Use two single back-quotes to begin a quotation and two single quotes to end it. The usual double quote symbol doesn't produce the correct result.
I'll go back and try it again. Like this ``stuff''?
Edit: Nope, this no worky for me (just drops through as if it saw a #):
testcmd="``c:\Program Files\DVD2SVCD\BeSweet\BeSweet.exe'' -core( -input ``d:\Matrix\Matrix.ac3'' -output ``d:\Matrix\matrix.mp2'' ) -azid( -c light -L -3db --maximize ) -2lame( -m d -b 192 -e ) -profile( DSPguru_MP2@192kbps )"

Not using the quotes seems to work ok. This works fine.

testcmd="BeSweet.exe -core( -input Matrix.ac3 -output matrix.mp2 ) -azid( -c light -L -3db --maximize ) -2lame( -m d -b 192 -e ) -profile( DSPguru_MP2@192kbps )"

Last edited by DDogg; 22nd February 2003 at 20:20.
DDogg is offline   Reply With Quote
Old 22nd February 2003, 20:33   #19  |  Link
Belgabor
VDubMod Devel
 
Belgabor's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 824
I think I read somewhere that avisynth also accepts TeX stryle quotes, so that my be the reason why it doesnt work. I belive the quotes for besweet are only needed (like with windows commands) if the argument contains white space. I don't know if avisynth allows to escape quotes in strings, otherwise the plugin has to be modified to replace some special character with "
__________________
VirtualDubMod [SourceForge : Tracker/DL] (FAQ, Some rules)
Be sure to also download the latest DLL package or get the all inclusive package!
Before you post questions, please read the VirtualDub and/or VirtualDubMod FAQ.
If you have a bug report or feature request for VirtualDubMod, be sure to read the rules first.
We give 100% of your donations to the Open Source community
Belgabor is offline   Reply With Quote
Old 22nd February 2003, 20:34   #20  |  Link
Guest
Guest
 
Join Date: Jan 2002
Posts: 21,901
I was just answering your question about what TeX-style quotes are. Beyond that...

Glad you have things working, however!
Guest 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 12:45.


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