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. |
![]() |
#1 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
TWriteAVI - Write AVI/WAV files in Avisynth
Edit: 3rd Oct 2022.
Quote:
TWriteAVI by Tritical, Squid_80 and Mikeytown2, v2.0 update StainlessS. Moved here from MPEG 2 Encoding forum. http://forum.doom9.org/showthread.ph...71#post1745671 Code:
TWriteAVI v2.05 TWriteAVI v2.0, write to lossless file whatever can be played, to AVI (or WAV), and using the ForceProcessAVI/WAV functions, can write the files without playing them (and faster than eg VDub Video Analysis Pass [about 70% of VDub time]). DO NOT USE with MT, is already multi-threaded and will crash/mess up AVI or WAV file format. Function TWriteAvi(clip c,String filename,bool "overwrite"=false,bool "showall"=false,string "fourcc"="",int "dwChannelMask"=-1) c, Video clip with optional audio. ALL valid colorspaces with exception of YV411. Filename: NOT optional. Output filename. Overwrite: Fails on existing unless overwrite==True. Showall: Default false. Shows all codecs, not just ones supporting your clip colorspace. Fourcc: Default "". Characters UPPER case (usually) fourCC code for codec, eg "ULY0" for YV12 UT_Video rec601. dwChannelMask: Default -1. -1 = No Override, Use standard mapping as for v2.6 OPT_dwChannelMask. 0 = Non Located ie multiple MONAURAL channels. Otherwise, need 1 bit set for each valid channel, see dwChannelMask flags at below link. https://msdn.microsoft.com/en-us/library/windows/desktop/dd390971%28v=vs.85%29.aspx Or in brief defaults here on Wiki:- http://avisynth.nl/index.php/Internal_functions#OPT_dwChannelMask Or in full, https://msdn.microsoft.com/en-us/library/windows/hardware/dn653308%28v=vs.85%29.aspx Removed old Idxname arg (was not much use). Writes clip to filename returning original clip (after equivalent of Trim(0,0), audio trim/pad to same len as video). Audio 8, 16, 24 and 32 bit, also Float. Up to 8 channels (7.1), written as uncompressed PCM or IEEE 32 bit Float format. Will auto close output FILE on last frame. NOTE, for clips where audio is longer/shorter than video, TWriteAVI will do equivalent to Trim(0,0) to trim/pad audio to same length as video (no effect if no audio). v2.03, Modified behaviour a little. Now if frames not requested in strictly sequential order, will write all intervening frames between last written frame and requested frame, if requested frame already written then requested frame will not be written a second time. ####### ForceProcessAVI(clip c,bool "Debug"=True) Force Process clip c, ie read from first to last frame, for TWriteAVI writes the AVI file (Video + Audio) without having to play clip. Debug, default True, sends some progress info to DebugView (google). ############## Function TWriteWAV(clip c,String filename,bool "overwrite"=false,int "dwChannelMask"=-1) c, clip with audio. Filename: NOT optional. Output filename. Overwrite: Fails on existing unless overwrite==True. dwChannelMask: Default -1. -1 = No Override, Use standard mapping as for v2.6 OPT_dwChannelMask. 0 = Non Located ie multiple MONAURAL channels. Otherwise, need 1 bit set for each valid channel. Writes audio from clip to filename returning original clip (return audio is NOT trimmed to same length as video). Audio 8, 16, 24 and 32 bit, also Float. Up to 8 channels (7.1), written as uncompressed PCM or IEEE 32 bit Float format. Will auto close on last sample. NOTE, entire audio is written to WAV, not just the length of video clip, [maybe use Trim(0,0) beforehand to trim/pad]. ####### ForceProcessWAV(clip c) Force Process clip c audio only, ie read from first to last audio sample, for TWriteWAV writes the WAV file (Audio) without having to play clip. ####### Default channel Mappings when dwChannelMask = Default -1: 0x00004, // 1 -- -- Cf 0x00003, // 2 Lf Rf 0x00007, // 3 Lf Rf Cf 0x00033, // 4 Lf Rf -- -- Lr Rr 0x00037, // 5 Lf Rf Cf -- Lr Rr 0x0003F, // 5.1 Lf Rf Cf Sw Lr Rr 0x0013F, // 6.1 Lf Rf Cf Sw Lr Rr -- -- Cr 0x0063F, // 7.1 Lf Rf Cf Sw Lr Rr -- -- -- Ls Rs Speaker_Location:- SPEAKER_FRONT_LEFT 0x1 SPEAKER_FRONT_RIGHT 0x2 SPEAKER_FRONT_CENTER 0x4 SPEAKER_LOW_FREQUENCY 0x8 # Shown above as Sw (Sub Woofer) SPEAKER_BACK_LEFT 0x10 SPEAKER_BACK_RIGHT 0x20 SPEAKER_FRONT_LEFT_OF_CENTER 0x40 SPEAKER_FRONT_RIGHT_OF_CENTER 0x80 SPEAKER_BACK_CENTER 0x100 SPEAKER_SIDE_LEFT 0x200 SPEAKER_SIDE_RIGHT 0x400 Not used by Default Mappings: SPEAKER_TOP_CENTER 0x800 SPEAKER_TOP_FRONT_LEFT 0x1000 SPEAKER_TOP_FRONT_CENTER 0x2000 SPEAKER_TOP_FRONT_RIGHT 0x4000 SPEAKER_TOP_BACK_LEFT 0x8000 SPEAKER_TOP_BACK_CENTER 0x10000 SPEAKER_TOP_BACK_RIGHT 0x20000 Code:
From Doom9 Forum thread:- http://forum.doom9.org/showthread.php?t=172837 The original TWriteAVI was intended to produce lossless intermediate file for HC-Enc, as HC-Enc later did this itself, there was no longer any call for TWriteAVI. [EDIT: From two posts below, seems it may have been initially written for use with VDub] TWriteAVI v2.0, can write lossless whatever can be played to AVI (or WAV), and using the ForceProcessAVI/WAV functions, can write the files without playing them (and faster than eg VDub Video Analysis Pass [EDIT: about 70% of VDub time]). Two Pass: WhateverSource(...) A_Two_Pass_Function(Pass=1) # Create some kind of deshaker log or whatever. ForceProcessAVI() # Force Pass 1, creating log (A function From TWriteAVI plug) A_Two_Pass_Function(Pass=2) # Use created log return Last The ForceProcessAVI function forcibly processes both video and audio streams (ie reads each frame/sample in sequence), so that any eg log files produced by either video and/or audio processing filter will be forcibly written to disk. ForceProcessAVI/WAV are runtime functions not filters and so only return on completion. Simultaneous play and save AVI WhateverSource(...) FN="Output.AVI" FOURCC="ULY0" # Ut_Video TWriteAVI(FN,Overwrite=true,fourcc=FOURCC). return Last Do some kind of processing and save AVI, Then play Lossless file. WhateverSource(...) FN="Output.AVI" FOURCC="ULY0" # Ut_Video Sharpen(0.3) # Whatever TWriteAVI(FN,Overwrite=true,fourcc=FOURCC). # Write Sharp AVI whilst clip is played ForceProcessAVI() # Force Write above TWriteAVI file without playing clip. AVISource(FN) # Load Saved AVI return Last # Play Sharpened AVI lossless clip TWriteWAV/ForceProcessWAV, work in similar way to the AVI writing functions. See also Avisynth settings for WaveExtensible and Float output for compatible players (otherwise audio may be converted to 16bit on output from avisynth to a player). # For Float/WaveExtensible player eg MPC-HC (Else comment out below if Player not capable) Global OPT_UseWaveExtensible = (AudioChannels>2||AudioBits>16) # If more than 2 channels or > 16 bit, set true (Also Float, ie > 16 bits). Global OPT_AllowFloatAudio = (IsAudioFloat) # Must be set true to play in eg Media Player Classic - Home Cinema A demo included with TWriteAVI v2.0, splices 1000 clips together using temporary lossless intermediate files, this necessary due to some kind of system resources limitiation using Avisynth (limited to opening about 28 video files at one time). Q. What is TWriteAVI for ? A. Writes lossless AVI/WAV where required, specifically why you may want to do this is your problem, TWriteAVI is just the solution. Soundout plugin, allows for writing WAV files, BUT, returns immediately and so WAV will not be available for use until some time later, TWriteWAV together with ForceProcessWAV ensures WAV file is available on disk on return from ForceProcessWAV. ssS Avs v2.58 dll, and Avs/+ v2.60 dll, + source + VS2008 Project Files + AVS Script Demo Files. (~345KB) EDIT: Process two instances of a two pass filter Code:
WhateverSource(...) Clip1 = Trim(0,-2000) # 2000 frames File1="D:\File1.txt" Clip2 = Trim(2000,0) # remainder File2="D:\File2.txt" Clip1.A_Two_Pass_Function(Pass=1,LogFile=File1) ForceProcessAVI() # Clip1, Force Pass 1 Clip2.A_Two_Pass_Function(Pass=1,LogFile=File2) ForceProcessAVI() # Clip2, Force Pass 1 Result1 = Clip1.A_Two_Pass_Function(Pass=2,LogFile=File1) # Clip 1 Pass 2 Result2 = Clip2.A_Two_Pass_Function(Pass=2,LogFile=File2) # Clip 2 Pass 2 return Result1++Result2
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 3rd October 2022 at 22:28. Reason: Update |
|
![]() |
![]() |
![]() |
#3 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
Glad you like V.
Also note, can use eg Code:
KillAudio(Last).ForceProcessAVI() KillAudio just so it dont bother scanning all audio too, should be a bit faster than VDub analysis, and can also do whole (EDIT:two pass) thing in single script. (I did something like that yesterday, seemed quite a bit faster but I did not time it). EDIT: Timed above twice each (both same each time), VDub analysis 47 secs, ForceProcessAVI 33 secs, so is somewhat faster (~70% of VD time). EDITED:
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 9th November 2015 at 18:12. Reason: faux pas |
![]() |
![]() |
![]() |
#4 | Link |
User of free A/V tools
Join Date: Jul 2006
Location: SK
Posts: 826
|
Problems with filename?
Hi Stainless,
your plugin was very useful to me but suddenly I'm facing a problem which I can't seem to resolve. Please have a look at my script Code:
source = GetSourceFilename("mkv") FFVideoSource(source) Crop(12, 2, -4, -2) KNLMeansCL(d=1, a=2, s=4, h=5.0, device_type="GPU") AddBorders(0, 0, 0, 4) output = "processed-" + GetSourceFilename("avi") TWriteAvi(output, overwrite=true, fourcc="MAGY") Code:
# Replaces the script filename (ending with ".avs") with the same filename but supplied extension (ends with ".extension") function GetSourceFilename(string extension) { position = FindStr(ScriptName(), ".avs") return LeftStr(ScriptName(), position-1) + "." + extension } Code:
output = GetSourceFilename("avi") |
![]() |
![]() |
![]() |
#5 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
Code:
Avisource("K.avi") output = "D:\KAYPEC\Z.AVI" # FAIL #output = "Z.AVI" # OK #output = "OUT\Z.AVI" # OK TWriteAvi(output, overwrite=true, fourcc="ULY0") return last Trying to find the problem.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#6 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
What a silly Billy I am
![]() Change your 'ScriptName' to 'ScriptFile' (both of them), and it should work OK. You were creating filename something like:- "D:\KYPEC\processed-D:\KYPEC\K.avi" EDIT: You created eg "processed-D:\KYPEC\K.avi" which when turned into full path became "D:\KYPEC\processed-D:\KYPEC\K.avi"
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 18th December 2015 at 21:16. |
![]() |
![]() |
![]() |
#8 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
Kypec, just a tip, you can use RT_Debug or eg RT_DebugF("%s",StringVar,name="KYPEC: ") to output any suspect
variables to DebugView, in your above case it would output something like "KYPEC: processed-D:\KYPEC\K.avi" for the erroneous path string. EDIT: From RT_Stats plugin.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 20th December 2015 at 09:06. |
![]() |
![]() |
![]() |
#9 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
TwriteAVI, v2.01, Update, see 1st post.
Minor mod only, Show Error massage with Filename on Open Error.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#10 | Link | |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
I read the whole thread and part of the linked one and I still don't know what TWriteAVI is or what it does.
Never mind, Reel.Deal has summed it up nicely: Quote:
How would it be used in a 2-pass scenario? How would it be used to create a lossless copy? |
|
![]() |
![]() |
![]() |
#11 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
The original TWriteAVI was intended to produce lossless intermediate file for HC-Enc, as HC-Enc later did this itself, there was no
longer any call for TWriteAVI. [EDIT: From two posts below, seems it may have been initially written for use with VDub] TWriteAVI v2.0, can write lossless whatever can be played to AVI (or WAV), and using the ForceProcessAVI/WAV functions, can write the files without playing them (and faster than eg VDub Video Analysis Pass [EDIT: about 70% of VDub time]). Two Pass Code:
WhateverSource(...) A_Two_Pass_Function(Pass=1) # Create some kind of deshaker log or whatever. ForceProcessAVI() # Force Pass 1, creating log (A function From TWriteAVI plug) A_Two_Pass_Function(Pass=2) # Use created log return Last so that any eg log files produced by either video and/or audio processing filter will be forcibly written to disk. ForceProcessAVI/WAV are runtime functions not filters and so only return on completion. Simultaneous play and save AVI Code:
WhateverSource(...) FN="Output.AVI" FOURCC="ULY0" # Ut_Video TWriteAVI(FN,Overwrite=true,fourcc=FOURCC). return Last Do some kind of processing and save AVI, Then play Lossless file. Code:
WhateverSource(...) FN="Output.AVI" FOURCC="ULY0" # Ut_Video Sharpen(0.3) # Whatever TWriteAVI(FN,Overwrite=true,fourcc=FOURCC). # Write Sharp AVI whilst clip is played ForceProcessAVI() # Force Write above TWriteAVI file without playing clip. AVISource(FN) # Load Saved AVI return Last # Play Sharpened AVI lossless clip this necessary due to some kind of system resources limitiation using Avisynth (limited to opening about 28 video files at one time). Q. What is TWriteAVI for ? A. Writes lossless AVI/WAV where required, specifically why you may want to do this is your problem, TWriteAVI is just the solution. EDIT: Perhaps Kypec and Vampiredom would like to comment on their usage. EDIT: Soundout, allows for writing WAV files, BUT, returns immediately and so WAV will not be available for use until some time later, TWriteWAV together with ForceProcessWAV ensures WAV file is available on disk on return from ForceProcessWAV. EDIT: Also note, if required, could use eg CallCmd() or RT_Call() to call some kind of processor/encoder on output AVI/WAV, perhaps also auto creating simple AVS file if necessary for the encoder input.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 20th December 2015 at 17:23. |
![]() |
![]() |
![]() |
#13 | Link | ||
Registered User
Join Date: Mar 2012
Location: Texas
Posts: 1,646
|
That description's been there before I started to work on the wiki, Mikeytown2 was active around the time it was added so maybe he's the one that summed it up nicely
![]() Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#14 | Link |
User of free A/V tools
Join Date: Jul 2006
Location: SK
Posts: 826
|
I used the plugin in my workflow like this - first, the intermediate AVI file is created by running the following script through AVSMeter:
Code:
source = GetSourceFilename("mkv") FFVideoSource(source) Crop(12, 2, -4, -2) KNLMeansCL(d=1, a=2, s=4, h=5.0, device_type="GPU") AddBorders(0, 0, 0, 4) output = "processed-" + GetSourceFilename("avi") TWriteAvi(output, overwrite=true, fourcc="MAGY") Code:
source = GetSourceFilename("avi") AviSource(source) ![]() |
![]() |
![]() |
![]() |
#15 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
Kypec,
In your first script, could add to end Code:
ForceProcessAVI() # Forcibly write AVI Return MessageClip("DONE") ForceProcessAVI should be about same speed as AVSMeter, maybe a bit faster (a very tiny bit not really worth mentioning). Before the above return MessageClip("DONE"), Could insert code to create AVS and BAT files, avs to use avisynth to open the lossless file, and batch file that hands the avs as argument to Simple x264 launcher. Demo of creating any kind of script/bat file here:- http://forum.doom9.org/showthread.ph...52#post1749752 Some functions that may assist in your task Code:
RT_FilenameSplit(string filename,int "get"=15) Splits the un-named filename string into component parts selected by 'get' bit flags arg and returns the parts joined together. 'Get' (default 15, 1 -> 15), If set, Bit 0=DRIVE, 1=Dir, 2=Name, 4=Extension. Add 1 for Drive (bit 0), add 2 for Dir (bit 1), add 4 for Name (bit 2), add 8 for Extension (bit 3). Some combinations do not make sense, eg Drive + Extension (1+8=9). Below sensible options. 1 = Drive (includes trailing ':') 2 = Dir (includes trailing '\') 3 = Drive + Dir 4 = Name 6 = Dir + Name 7 = Drive + Dir + Name 8 = Extension (includes leading '.') 12 = Name + Extension 14 = Dir + Name + Extension 15 = Drive + Dir + Name + Extension Assuming a current working directory of eg "D:\avs\avi\", 'filename'="test.avi" and 'get'=15, returns "D:\avs\avi\test.avi", so given a relative filename and default 'get'=15, is equivalent to RT_GetFullPathName(filename). *** *** *** RT_GetFullPathName(string "name") Creates an absolute or full path name for the specified relative path 'name'. eg 'RT_GetFullPathName("test.avs")' might return "D:\avs\test.avs". Throws and error if cannot return path. *** *** *** RT_GetFileExtension(string s) Returns filename extension from the supplied filename, including '.' prefix. RT_StrReplace(string source,string find,string replace,bool "sig"=True) # Based on Algorithm by Vampiredom, Gavino & IanB. String args 'source', 'find' and 'replace' unnamed and compulsory. Takes a source string, searches for all occurences of find string and replaces the found strings with the replace string. Can use "" in replace string (only in replace) to delete the found substrings from the source string. Newlines are treated no differently to other characters, and could be replaced/deleted. v1.14, added 'sig' arg,default true is Case Significant (as previous version). Set false for case insignificant find string. RT_StrReplaceMulti(string source,string find,string replace,bool "sig"=True) String args 'source', 'find' and 'replace' unnamed and compulsory. Takes a source string, searches for all occurences of find substrings and replaces the found substrings with the replace substrings. Find string and Replace string are both multiline [Chr(10) separated] strings, both of n lines where find[i] and replace[i] are matched pairs, ie the first line of a multiline find is replaced by the first line of a multiline replace, etc. Can use "" in replace string (only in replace) to delete the found substrings from the source string. Differs from RT_StrReplace, in that both find and replace strings are multiline strings and MUST match in number of lines. Cannot use either carriage return [Chr(13)] or newline [Chr(10)] in find or replace as these are interpreted as end of current line, you would need to use RT_StrReplace() instead. eg S=RT_StrReplaceMulti("THE cat SAT.","SAT"+Chr(10)+"THE","sat"+Chr(10)+"The") produces "The cat sat.". v1.14, added 'sig' arg,default true is Case Significant (as previous version). Set false for case insignificant find string. *** *** *** RT_QuoteStr(string) Non-clip function. Encloses supplied string arg in double quotes, Use on filenames containing spaces. Do NOT use with eg RT_FileDelete, only on filenames sent to a DOS command. RT_WriteFile(String FileName, string format,dat1,...,datn,bool "Append"=False) Writes a formatted string to FileName file. The unnamed 'format' string and optional unnamed 'dat' args are used to construct the text string that is written, uses C/CPP printf() style formatting. Format: compulsory string controlling format and describing the datn type args that are expected. datn: Variable number of data args of any type (excluding clip). Append, Default False, optional and MUST be supplied with name (eg Append=True) as we do not know where optional data args end, Appends to file if already exists, else opens new FileName. OMITTED A lot more RT_WriteFile stuff. Quote:
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 21st December 2015 at 17:27. |
|
![]() |
![]() |
![]() |
#16 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
Here an Avisynthesizer_MOD BATCH script template (Avisynthesizer_MOD here: http://forum.doom9.org/showthread.ph...ynthesizer_MOD)
EDIT: See post #25 for later version of script:- http://forum.doom9.org/showthread.ph...34#post1750834 BATCH-KYPEC-AviSource.avst Code:
#ASYNTHER BATCH-KYPEC-AviSource # Avisynthesizer_Mod TEMPLATE FILE, Above is shown in Avisynthesizer_Mod as "BATCH-KYPEC-AviSource" # Below not enclosed in square brackets, so is Non-Repeating ie Batch Mode, multiple AVS files generated. SourceFilename = "___FILE___" # Source Filename inserted here by Avisynthesizer_Mod ################################### # FULL PATH Directories, DONT End In BACKSLASH/SLASH LOSSLESS_DIR = "D:\KYPEC\LOSSLESS" AVSOUTPUT_DIR = "D:\KYPEC\AVSOUTPUT" BATOUTPUT_DIR = "D:\KYPEC\BATOUTPUT" OUTPUT_DIR = "D:\KYPEC\OUTPUT" ### FOURCC = "ULY0" # UT_Video YV12 rec601 Lossless codec ################################### ################################### ################################### AVISource(SourceFilename) # Mod for your source filter, FFMpegSource or whatever (amend Avisynthesizer_Mod description to suit) Trim(0,0) # Trim/Pad audio to length ### Insert whatever you want, Trim, Crop, etc # ... Return Last # COMMENT OUT, when happy with Trim/Crop etc. ################################### ################################### ################################### # AVS Template to Load Lossless AVI file AVS_TMPT=(""" Return AVISource("___AVI__") """) ### # BAT Template to encode Lossless AVI file to output, Can use either "___AVS___" or "___AVI___" in BAT file. BAT_TMPT=(""" "C:\BIN\ffmpeg.exe" -i "___AVS___" "___OUT_FILE___.MP4" Pause REM Wait user press key : Comment out if required (Precede Pause with 'REM ', or delete this line) """) ################################### Node = RT_FilenameSplit(SourceFilename,get=4) # Filename Node only, no path nor extension Avi=RT_String("%s\\%s.AVI",LOSSLESS_DIR,Node) Avs=RT_String("%s\\%s.AVS",AVSOUTPUT_DIR,Node) Bat=RT_String("%s\\%s.BAT",BATOUTPUT_DIR,Node) Out=RT_String("%s\\%s",OUTPUT_DIR,Node) # Excluding file Extension, (You may want '.MKV' or '.MP4' or whatever, append in batch template) # AVS_TMPT = RT_StrReplace(AVS_TMPT,"___AVI__",AVI) # FndS = RT_String("___AVI___\n___AVS___\n___OUT_FILE___\n") RepS = RT_String("%s\n%s\n%s\n",AVI,AVS,OUT) BAT_TMPT = RT_StrReplaceMulti(BAT_TMPT,FndS,RepS) # RT_DebugF("Writing AVS '%s'",AVS,name="KYPEC: ") RT_WriteFile(Avs,"%s",Avs_TMPT) # Write AVS file RT_DebugF("Writing BAT '%s'",Bat,name="KYPEC: ") RT_WriteFile(Bat,"%s",Bat_TMPT) # Write BAT file ################################### RT_DebugF("Calling TWriteAVI '%s'",AVI,name="KYPEC: ") TWriteAVI(AVI,Overwrite=true,Fourcc=FOURCC) # Write and play processed clip ### RT_DebugF("Calling ForceProcessAVI",name="KYPEC: ") ForceProcessAVI # Immediate write without play, comment out to return Processed clip simultaneously writing. #RT_DebugF("Loading Lossless",name="KYPEC: ") #AviSource(AVI) # Return Lossless, ONLY if used above ForceProcessAVI RT_DebugF("Calling Encode BAT '%s'",BAT,name="KYPEC: ") Assert(RT_Call(BAT,Hide=False,Debug=True)==0,RT_String("RT_Call: Call Failed on\n%s",BAT)) # Call Encoder, Only if ForceProcessAVI used. RT_DebugF("ALL DONE",name="KYPEC: ") #Return Last Return MessageClip("Done") Requires RT_Stats, TWriteAVI v2.0, ffmpeg.exe, UT_Video codec, Avisynthesizer_Mod. EDIT: Changed to Hide=False in RT_Call command (Show ffmpeg window, allow ffmpeg ask 'Overwrite ?' and user press key after encode).
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 6th January 2016 at 13:17. Reason: Update |
![]() |
![]() |
![]() |
#17 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
DOS GURU assistance needed for above script, [EDIT: Oops CLI GURU, if Groucho2004 is watching {I dont wanna be bitch slapped again}
![]() this BAT batch template, need to detect and return ERRORLEVEL from ffmpeg call Code:
BAT_TMPT=(""" "C:\BIN\ffmpeg.exe" -i "___AVS___" "___OUT_FILE___.MP4" Pause REM Comment out if required (Precede Pause with REM) """) Could synthesize error by using either RT_FileDelete(AVI) or RT_FileDelete(AVS) immediately before RT_Call line. EDIT: Above not so much necessary as I forgot that RT_Call can only return SUCCESS status whether process started, and not any return value from that process (we can only return a single item to avisynth, not 2 or more). I shall try to find a way to access returned value, and try to complete RT_Stats mods and publish v2.0 RT_Stats soon. Would still be helpful though if someone can post above ERRORLEVEL solution.
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 23rd December 2015 at 16:30. |
![]() |
![]() |
![]() |
#18 | Link | |
Registered User
Join Date: Feb 2002
Location: California
Posts: 2,641
|
Quote:
Code:
<snip> tasklist /FO CSV /NH >>PMH_Log_Files\tasklist.txt FOR /F "tokens=1* delims=,? " %%a in (PMH_Log_Files\tasklist.txt) do ( if not %%a=="PMBVolumeWatcher.exe" (if /i not %%a=="PMBDeviceInfoProvider.exe" (if /i not %%a=="PMBContentAnalyzer.exe" ( echo %%a | findstr "PMB" if not ERRORLEVEL 1 ( IF EXIST PMH_Log_Files\tasklist.txt (DEL /S /Q PMH_Log_Files\tasklist.txt echo PlayMemories Home or Action Cam Movie Creator is running. echo Quit PlayMemories Home or Action Cam Movie Creator before starting the program. pause exit )))))) IF EXIST PMH_Log_Files\tasklist.txt (DEL /S /Q PMH_Log_Files\tasklist.txt) <snip> |
|
![]() |
![]() |
![]() |
#19 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,812
|
Thank you John,
I think I may add some kind of optional START_SUCCESS, SUCCESS, FAIL args(used for default return codes), (not really quite sure how yet), and if ALL given then try to return some kind of start/good/bad answer (otherwise just return started as 0 for OK, as currently implemented). (Programs can return their own error code, there is no STANDARD code so basically any return is possible from an executable). I'll come back and look at what you've supplied above when I've figured out what I'm gonna do. Again thanx. ![]()
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? |
![]() |
![]() |
![]() |
#20 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
1. Detecting an error level: it's easiest if you only care if %errorlevel% is zero (success) or nonzero (failure)
Code:
[try something...] if errorlevel 1 goto failed [do stuff] goto :EOF :failed @echo failed! try again! pause goto :EOF If you want the exact error level, it's harder. See this (robvanderwoude.com) 2. Returning an error level from a batch file: Code:
exit /b 42 Code:
echo %errorlevel% EDIT sorry, it's "if errorlevel 1" not "if %errorlevel% 1" Last edited by raffriff42; 24th December 2015 at 02:31. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|