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 Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 13th May 2020, 15:30   #1  |  Link
wthreex
Registered User
 
Join Date: Oct 2015
Posts: 97
How to use RegEx in avisynth ?

Excuse me i'm newbie in avisynth, Which function used for regex ? I want to get filename in <input> variable which megui provide

When i put the <input> variable into Subtitle function like
Code:
Subtitle(<input>)
it become and return:


Code:
Subtitle(LoadPlugin("C:\Users\Downloads\Programs\MeGui\tools\ffms\ffms2.dll")
FFVideoSource("C:\Users\Downloads\Video\file.mkv", cachefile="C:\Users\Downloads\file.mkv.ffindex", fpsnum=24000, fpsden=1001, threads=1))
So my plan is to get path of file which is "C:\Users\Downloads\Video\file.mkv"

Last edited by wthreex; 13th May 2020 at 16:02.
wthreex is offline   Reply With Quote
Old 13th May 2020, 15:54   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Not sure what you are trying to do here or what regex has to do with it.
Your question would seem to have been better suited for MeGUi thread anyway.

but,
Quote:
Subtitle(<input>)
would seem to want path to a SUBTITLE file, not a plugin.

I dont have MeGUI set up at the moment on this machine, but presume you need something like this.

Code:
LoadPlugin("C:\Users\Downloads\Programs\MeGui\tools\ffms\ffms2.dll")
FFVideoSource("C:\Users\Downloads\Video\file.mkv", cachefile="C:\Users\Downloads\Blinded by the Light 2019.mkv.ffindex", fpsnum=24000, fpsden=1001, threads=1))
and if you are wanting to supply a the name of subtitle file, then
add the file path in below where it says <input>. [Just copy and paste it]

Code:
Subtitle(<input>) # replace <input> with your subtitle file pathname, eg, Subtitle("D:\mdir\mySub.srt")
EDIT: If you have Avisynth installed as an individual program on your system, and you also have ffms2.dll in your plugins, then you will not need the
LoadPlugin line at all, it would be auto loaded for you anyway.
__________________
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; 13th May 2020 at 16:16.
StainlessS is offline   Reply With Quote
Old 13th May 2020, 16:21   #3  |  Link
wthreex
Registered User
 
Join Date: Oct 2015
Posts: 97
Ok I did https://forum.doom9.org/showthread.php?p=1911775

I think i couldn't explain enough, When i open a file in MeGui, There is a variable inside of avisnyth which is "<input>" it will translated to:

Code:
Subtitle(LoadPlugin("C:\Users\Downloads\Programs\MeGui\tools\ffms\ffms2.dll")
FFVideoSource("C:\Users\Downloads\Video\file.mkv", cachefile="C:\Users\Downloads\file.mkv.ffindex", fpsnum=24000, fpsden=1001, threads=1))
I need this part: "C:\Users\Downloads\Video\file.mkv" and i wanna put it into variabe, So i though it would be nice if i use Regular Expression to get that part
wthreex is offline   Reply With Quote
Old 13th May 2020, 20:02   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Well that translation inserting LoadPlugin into Subtitle() is clearly wrong, dont know what MeGUI thinks its doing.
Anyways, I'm sure that the guys in MeGUI thread will sort out what has gone wrong.
__________________
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; 14th May 2020 at 22:43.
StainlessS is offline   Reply With Quote
Old 14th May 2020, 08:01   #5  |  Link
wthreex
Registered User
 
Join Date: Oct 2015
Posts: 97
I was using Subtitle just want to know what would be the result (echo it out)
wthreex is offline   Reply With Quote
Old 14th May 2020, 08:10   #6  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Sorry, cant help, I have never used any of the fancy MeGUI stuff, I only ever load final Avs file into it where everythng already
setup exaclty how I want it. I use AutoEncode, and if I do want to add a subtitle I just tick the "Add Additional Content (audio, subs, chapters)" box and add the subtitle.

If by 'echo it out' you mean comment it out, then I say yes if you dont want subtitles.

EDIT: Your thread title in MP4 encoder forum, "How to get full path of current file as string ?",
maybe add the word "MeGUI" somewhere would get more views.
__________________
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; 14th May 2020 at 08:12.
StainlessS is offline   Reply With Quote
Old 14th May 2020, 15:31   #7  |  Link
wthreex
Registered User
 
Join Date: Oct 2015
Posts: 97
@StainlessS first of all thank you so much to come along with me, In last attempt i recorded my issue: https://streamable.com/cdkk1d i hope it make sense now xD, In video one thing i didnt mention that megui can queue all files in folder and encode them as i mentioned in previous posts ("Select Folder") but the problem is it only pick one script in the queue, So the " get current file path" means the file which megui pick for encode in the queue.

Last edited by wthreex; 14th May 2020 at 15:49.
wthreex is offline   Reply With Quote
Old 15th May 2020, 12:20   #8  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Hi wthreex,
The thing with the '<input>' stuff is an Avisynth script template, it just allows you to add some avisynth scripting.
It might be possible to convert the source file name into a subtitle file eg "D:\myfile.avi' to 'D:\myfile.srt' if you had access to the
sourcefile name from within avisynth called via MeGUI, however I am not aware that the source filename is available to avisynth script.
Additionally, even if you did have access to the source filename, and hence a similar subtitle filename, all you could do from within
avisynth would be to add a 'Hard Coded' subtitle to the video, ie always there and could not switch off subtitle as it is part of the video.
I'm guessing that what you want is to be able to auto add eg myfile.srt to the files to be multiplexed together at the final encode stage.
I dont think that this is possible, (and the avisynth script template has nothing to do with that type of functionality).
I can only suggest that you ask in MeGUI forum if it is possible to auto add an associated subtitle file (eg myfile.srt) to the files to be
multiplexed together and the end of encode. [I doubt that this is currently possible, I wish it were otherwise as I would also like to be able
auto do that, and for more than a single subtitle file].

EDIT:
When I use AutoEncode and want to add multiple subtitle [single subs file can be added quite easily by ticking the 'Add additional content' box],
I have to encode normal, and then use the Tools/Muxer/MP4 Muxer tool to mux the separate video, audio and subtitle streams together.
EDIT: Similar where multiple audio files require adding to the final encode. [DIrectors commentary, Cast commentary, Video Effects crew commentary etc]
__________________
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; 15th May 2020 at 12:55.
StainlessS is offline   Reply With Quote
Old 15th May 2020, 13:34   #9  |  Link
wthreex
Registered User
 
Join Date: Oct 2015
Posts: 97
Yeah, You got my point, Its really annoying me to create a script for each files with same structure just imagine 50 file with 50 srt file i have to create 50 script just manipulate the file path... I created multiple threads around the internet hope it gets somewhere xD
wthreex is offline   Reply With Quote
Old 15th May 2020, 14:34   #10  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Maybe take peek at RipBot, dont know if it supports such functionality, but given that Atak_Snajpera goes to great lengths to make a mass production tool, so maybe he has
also provided similar auto add subs type functionality.
Some Guides on Videohelp:- https://www.videohelp.com/guides?tools=1039&archive=%25
D9 thread:- https://forum.doom9.org/showthread.php?t=127611

If it does support auto subs, then say so here in thread. thanks.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 15th May 2020, 14:48   #11  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,420
Code:
for n in *.mkv ; do echo "FFVideoSource(\"$n\") > "$n".avs ; done
If the files aren't all in the same directory, have the list of filepaths in a text file, then use a while loop that reads from the text file instead of a for loop.

Or do it the manual way and have the list of filepaths in a text file, but use a regex-aware text editor to apply the AviSynth syntax around the paths, including the command to dump each line to an external file. Then run it as either a batch or shell script. All the scripts get generated in less than a second.
qyot27 is offline   Reply With Quote
Old 16th May 2020, 02:53   #12  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,915
If all of you need is create a bounch of .avs files for your .mkv and .jpg files, you can create a .bat file like this:

FOR %%A IN (*.mkv) DO echo I=ImageSource("%%~dpnA.jpg",end=0) > "%%~nA.avs"
FOR %%A IN (*.mkv) DO echo v=FFvideoSource("%%~fA") >> "%%~nA.avs"
FOR %%A IN (*.mkv) DO echo v=v.Trim(0,0).ConvertToYV12() >> "%%~nA.avs"
FOR %%A IN (*.mkv) DO echo ...

The first one create (>) a .avs with the same name than mkv
The next lines add (>>) avs lines to the same .avs files
__________________
BeHappy, AviSynth audio transcoder.
tebasuna51 is offline   Reply With Quote
Old 16th May 2020, 10:25   #13  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
In staxrip the easiest way would be using macros:

TextSubMod("%source_dir%%source_name%.srt")
stax76 is offline   Reply With Quote
Old 16th May 2020, 14:09   #14  |  Link
wthreex
Registered User
 
Join Date: Oct 2015
Posts: 97
Thanks guys, Some dude in videohelp forum solved my issue https://forum.videohelp.com/threads/...ly#post2583330

@qyot27, @tebasuna51 The problem is if i want to generate avisynth script I have to manaully encode audio, merge , etc ... by my self, Besides the batch encoding only apply one script at the time...

@stax76 wish something like that was in Megui...

Last edited by wthreex; 16th May 2020 at 14:18.
wthreex is offline   Reply With Quote
Old 16th May 2020, 14:45   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
@Hello_Hello, that was some real fancy footwork, keeping copy of that Videohelp post, thanks very much.
__________________
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 ???
StainlessS is offline   Reply With Quote
Old 16th May 2020, 16:39   #16  |  Link
qyot27
...?
 
qyot27's Avatar
 
Join Date: Nov 2005
Location: Florida
Posts: 1,420
Quote:
Originally Posted by wthreex View Post
@qyot27, @tebasuna51 The problem is if i want to generate avisynth script I have to manaully encode audio, merge , etc ... by my self, Besides the batch encoding only apply one script at the time...
Just set up an encoding for loop to do those steps every time.
Code:
for n in *.avs ; do
x264 --preset ultrafast --crf 18 -o "${n%.*}.mp4" "$n"
ffmpeg -i "$n" -vn -acodec libopus -b:a 192k "${n%.*}.opus"
mkvmerge -o "${n%.*}.mkv" "${n%.*}.mp4" "${n%.*}.opus"
done
or not bothering with encoding anything separately
Code:
for n in *.avs ; do
ffmpeg -i "$n" -vcodec libx264 -preset ultrafast -crf 18 -acodec libopus -b:a 192k "${n%.*}.mkv"
done
Or even combine the script generation and encoding loops into one:
Code:
for n in *.mkv ; do
echo "FFVideoSource(\"$n\")" > "${n%.*}.avs"

ffmpeg -i "${n%.*}.avs" -vcodec libx264 -preset ultrafast -crf 18 -acodec libopus -b:a 192k "${n%.*}-reencoded.mkv"
done
qyot27 is offline   Reply With Quote
Reply


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 23:59.


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