Log in

View Full Version : AutoPath Script Head


Emulgator
31st May 2023, 23:35
# $$$$$$$$$$$ Emulgator's Universal AviSynth AutoPath script head 2023-06-01 $$$$$$$$$$$$$$$$$
# A. Saves you from typing long paths.
# B. Simple auto-increment-renaming of script files will bring you time-saving processing of hundreds of camerafiles
# without having to insert these into something like notepad++, and call multi-line replace, and hope...
# C. Public evaluation of such script has become safer, the script contains no filenames anymore.
# D. Moving source files around is a no-brainer now.
# You just move the source script with them and the script will open the files no matter what path they are in.

# Single files with long paths and filenames
# "C:\MyDocuments\NotMyDocuments\Whatwasthatbytheway\2022-000-00#[Still-unknown-to-me-remnants].MTS"
# Copy this script into source file folder, copy source file name including extension, paste onto script file name.
# Now the example file in folder "C:\MyDocuments\NotMyDocuments\Whatwasthatbytheway"
# has got a script sibling named "2022-000-00#[Still-unknown-to-me-remnants].MTS.avs"
# and you don't have to type the path "C:\MyDocuments\NotMyDocuments\Whatwasthatbytheway" anymore at all.

# Even better: Hundreds of camera files to be processed the same way. Rename to 00000.MTS.avs, preview and edit your master script.
# Then once and for all times: In Windows Explorer you generate 256 copies of 00000.MTS.avs by duplicating 8 times: 1-2-4-8-16-32-64-128-256...
# Sequential Auto-rename to 00000.MTS.avs....00255.MTS.avs.
# You may keep these .avs forever, no matter in which camera folder you will drag them: they will be valid as long as their siblings are there;
# so you move orphaned scripts to a parking folder before batch processing.
# And if .m2ts: you know how to rename extensions. Den4b ReNamer or what you prefer.

# On runtime this script will derive file paths and source filter as follows:
# Calls AviSynth internal string functions to get path and script filename, assuming 2 extensions starting with a dot each.
# Derives number of source extension characters (.ts -> 3, .avi -> 4, .mpeg -> 5) by concluding from the position of the second dot
# Applies these derived arguments to appropriate sourcefilters.

# To edit this script in AvsPmod, associate .avs extension with AvsPmod, doubleclick on .avs script, load preview (press F5) and smile ;-)
# Maybe you will have to match some lines to the actual situation
# You are now ready to append your desired processing.
#+++++ Start of AutoPath script head (1 Videostream + 0 or 1 Audiostream) +++++
SetFilterMTMode("DEFAULT_MT_MODE", 2)
SetFilterMTMode("LWLibavVideoSource", 3)
SetFilterMTMode("LWLibavAudioSource", 3)
SetFilterMTMode("DGSource", 3)
scriptextlen=FindStr(RevStr(ScriptFile()),".")
vidextlen=FindStr(RevStr(LeftStr(ScriptFile(),StrLen(ScriptFile())-scriptextlen)),".")
vidfolder=ScriptDir()
audfolder=vidfolder
vidfile=LeftStr(ScriptFile(),(StrLen(ScriptFile())-scriptextlen-vidextlen))
audfile=vidfile
vidext=LeftStr(RightStr(ScriptFile(),scriptextlen+vidextlen),vidextlen)
vidsrc= vidext==".d2v" ? "MPEG2Source" : vidext==".dga" ? "AVCSource" : vidext==".dgi" ? "DGSource" : "LWLibavVideoSource"
audext=vidext==".d2v" ? ".ac3" : vidext==".dgi" ? ".ac3" : vidext
#audext=vidext==".d2v" ? ".dts" : vidext==".dgi" ? ".dts" : vidext
#audext=vidext==".d2v" ? ".wav" : vidext==".dgi" ? ".wav" : vidext
audpid= vidext==".d2v" ? " T80 2_0ch 224Kbps DELAY 0ms" : vidext==".dgi" ? " PID 1100 2.0ch 48KHz 192Kbps DELAY 0ms" :""
#audpid= vidext==".d2v" ? " T81 3_2ch 448Kbps DELAY 0ms" : vidext==".dgi" ? " T81 3_2ch 48KHz 448Kbps DELAY 0ms" :""
audsrc= "LWLibavAudioSource"
Exist(String(vidfolder)+String(vidfile)+String(vidext)) ? Apply(vidsrc,String(vidfolder)+String(vidfile)+String(vidext))\
: Assert(false, "NO SUCH FILE: " + String(vidfolder)+String(vidfile)+String(vidext) + " !")
try {AudioDub(last,Apply(audsrc,String(audfolder)+String(audfile)+String(audpid)+String(audext)))}
catch (err) {last}
# ----- End of AutoPath script head (1 Videostream + 0 or 1 Audiostream) -----

Emulgator
31st May 2023, 23:39
# Need more audio streams ?
# Append AudioMerger
# Maybe you will have to match some lines to the actual situation.

# +++++ Start of AudioMerger (1 to 4 additional audio streams) +++++
audfolder1=audfolder#""
audfolder2=audfolder#""
audfolder3=audfolder#""
audfolder4=""
audfile1=vidfile#""
audfile2=vidfile#""
audfile3=vidfile#""
audfile4=""
audext1=audext
audext2=audext
audext3=".dts"
audext4=""
audpid1=audpid
audpid2=" T81 3_2ch 448Kbps DELAY 0ms"
audpid3=" T8a DELAY 0ms"
audpid4=""
audsrc1="LWLibavAudioSource"
audsrc2="LWLibavAudioSource"
audsrc3="LWLibavAudioSource"
audsrc4="LWLibavAudioSource"
Exist(String(audfolder1)+String(audfile1)+String(audpid1)+String(audext1)) ? MergeChannels(last,Apply(audsrc1,String(audfolder1)+String(audfile1)+String(audpid1)+String(audext1))) : last
Exist(String(audfolder2)+String(audfile2)+String(audpid2)+String(audext2)) ? MergeChannels(last,Apply(audsrc2,String(audfolder2)+String(audfile2)+String(audpid2)+String(audext2))) : last
Exist(String(audfolder3)+String(audfile3)+String(audpid3)+String(audext3)) ? MergeChannels(last,Apply(audsrc3,String(audfolder3)+String(audfile3)+String(audpid3)+String(audext3))) : last
Exist(String(audfolder4)+String(audfile4)+String(audpid4)+String(audext4)) ? MergeChannels(last,Apply(audsrc4,String(audfolder4)+String(audfile4)+String(audpid4)+String(audext4))) : last
# ----- End of AudioMerger (1 to 4 additional audio streams) -----