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

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd October 2013, 15:14   #1  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
weird resizing trouble



Hi,

I'm using a dj video mix software that has bugs that make sometime some videos I play not being centered well and have bad size.

The only solution i found was to use the resize function of ffdshow. Unfortunately i need GPU hardware acceleration so i use Lav filters. The solution someone on the forumotion gave me was to use avisynth and have a resize script that would be triggered each time i play a video. I would have to create a .avs for each video files.

I tried ResizePar script but i get the error :

Script error : invalid arguments to function "IsRGB"

Could you help me having something simple to ensure that all the videos i play will fit the screen resolution ?

The simplest seems to be to have .avs for each video and that the .avs would trigger a more general .avsi file that contains the resizing code

Thank you for your time
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 15:46   #2  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
What is ResizePar script, without it, IsRGB problem not solvable ?

Is Pixel aspect ratio 1:1 ?
__________________
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 23rd October 2013, 15:49   #3  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
Oh sorry it was that that was adviced :

resize.avsi
CODE:
function ResizeKeepAR(clip c, int width, int height)
{
BackgroundColor = $000000
ResizeMethod = "BilinearResize"

ratioS = Float(width(c))/Float(height(c))
ratioD = Float(width)/Float(height)
newW = Round(height*ratioS/2)*2
newH = Round(width/ratioS/2)*2

BorderH = Round((height-newH)/2)
BorderW = Round((width-newW)/2)

#Dest Higher Then Source; Dest Wider Then Source; Same Ratio
c =
\ (ratioS>ratioD) ?
\ Eval(ResizeMethod + "(c, " + String(width) + ", " + String(newH) + ")").
\ AddBorders(0, BorderH, 0, BorderH, BackgroundColor) :
\ (ratioS<ratioD) ?
\ Eval(ResizeMethod + "(c, " + String(newW) + ", " + String(height) + ")").
\ AddBorders(BorderW, 0, BorderW, 0, BackgroundColor) :
\ (ratioS==ratioD) ?
\ Eval(ResizeMethod + "(c, " + String(width) + ", " + String(height) + ")" ) :
\ nop()

#fix 1px changes, works only with 4:4:4
c =
\ (IsRGB(c)) && (width>width(c)) ? c.AddBorders(0, 0, 1, 0) :
\ (IsRGB(c)) && (height>height(c)) ? c.AddBorders(0, 0, 0, 1) :
\ c
return c
}

function ResizeFile(string filename)
{
DirectShowSource(filename).ConvertToRGB32.ResizeKeepAR(640,360)
}

videofile.avs
CODE:
Import("c:\videos\resize.avsi")
ResizeFile("c:\videos\example.mp4")
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 16:00   #4  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
You can wrap code like this:


[CODE]
Some code
[/CODE]


Assuming 1:1 pixel aspect ratio, you might just try something like

Code:
 DirectShowSource(c:\videos\example.mp4)
 RoboCrop(WMOD=4,Laced=false) # EDIT: Added Laced=false, might not need WMOD=4
And let your player resize to suit.

RoboCrop: http://forum.doom9.org/showthread.ph...light=robocrop

EDIT: Also, Avisynthesizer_Mod would allow you to create a template and so when you right click on a video file and select
"send to Avisynthesizer", it will create an avs file for you.
http://forum.doom9.org/showthread.ph...ynthesizer_Mod

If NOT 1:1 Pixel Aspect Ratio, then you could create multiple Avisynthesizer templates, below eg 640x480 4:3 Display Aspect Ratio

DirectShowSource_640x480_43.avst
Code:
#ASYNTHER DirectShowSource_640x480:43
[DirectShowSource("___FILE___")]
RoboCrop(WMod=4,Laced=false)
Spline36Resize(640,480)
EDIT: This part of first line
Quote:
DirectShowSource_640x480:43
will be shown and selectable in Avisynthesize_Mod to choose which template to use when creating avs file.
__________________
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 October 2013 at 17:19.
StainlessS is offline   Reply With Quote
Old 23rd October 2013, 16:32   #5  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
Thanks very much for your help.

What about the : Script error : invalid arguments to function "IsRGB" ?
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 16:40   #6  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
my videos resolution are 1280x720 (720p) 720x480 and 640x360. I want all to fit my 720p or 1080p HDMI LCD TV.

As i'm a noob in avisynth could tell me exactly what i need to do. Where do i copy the .avsi file, what to i put in it ? etc...

Last edited by itsonlyjustincase; 23rd October 2013 at 16:43.
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 16:43   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
See above EDIT:

Quote:
What about the : Script error : invalid arguments to function "IsRGB"
I would just forget that, as you want to get rid of borders, your posted script is unlikely to be of any use.

Avsi files and Avisynth plugin dll's go in the Avisynth plugins folder in Program Files.

The avst files go in the Avisynthesize_Mod Template directory.
__________________
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 October 2013 at 16:53.
StainlessS is offline   Reply With Quote
Old 23rd October 2013, 16:50   #8  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
So when you wrote :

Code:
Some code
you meant using RoboCrop script ? If yes would you mind creating the .avsi file for me with the good code ?

Regarding Avisynthesizer_Mod. Same question. Do i have to copy all the code in an avsi file that i have to put in plugin directory ? How do i use it ?

Last edited by itsonlyjustincase; 23rd October 2013 at 16:53.
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 17:04   #9  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
Forget Avsi files, you dont need your supplied script for anything.

As far as the some code thing is concerned, I was pointing out how to embed code in your post, as indeed you just did.

The example Avisynthesizer template avst in post #4 is just that, create as many as you like for whatever resolution and aspect ratio,
name them suitably and copy them into the Avisynthesizer template directory.

Quote:
How do i use it ?
Read post #4 again.
__________________
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 October 2013 at 17:07.
StainlessS is offline   Reply With Quote
Old 23rd October 2013, 17:05   #10  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
Do i have to pick you version of Avisynthesize_Mod or version from the website ? There is an .exe provided to install on the website
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 17:08   #11  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
Quote:
Originally Posted by StainlessS View Post
Forget Avsi files, you dont need your supplied script for anything.

As far as the some code thing is concerned, I was pointing out how to embed code in your post, as indeed you just did.

The example Avisynthesizer template avst in post #4 is just that, create as many as you like for whatever resolution and aspect ratio,
name them suitably and copy them into the Avisynthesizer template directory.



Read post #4 again.
Thank you. In that case, if i don't have to use avsi how to i use RoboCrop ?
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 17:09   #12  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
I'm really sorry to bother you with questions that may sound stupids but it's just that i'm a noob of avisynth. I discovered it yesterday. I'm not used to programs that doesn't load with and executable file
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 17:14   #13  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
Put the RoboCrop dll in the "C:\Program Files\AviSynth 2.5\plugins" on XP, or whatever folder does the same on W7.

I would avoid the original Avisynthesizer as it is bugged and has other problems, you can follow the instructions to use
the Mod version, ie copy the DIRECTORY somewhere and execute the bat install file.
(EDIT: eg copy the Avisynthesizer FOLDER to "C:\Program Files\", then execute the install bat in-situ, this will
accomplish what the Setup.Exe file does for the original Avisynthesizer).
__________________
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 October 2013 at 17:47.
StainlessS is offline   Reply With Quote
Old 23rd October 2013, 17:17   #14  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
Perfect now got it !
Thank you. i'm going to test that and report to you.

Just a question. Will the resize use lot of CPU ? can this be achieve with the GPU ?
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 17:27   #15  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
Quote:
Originally Posted by itsonlyjustincase View Post
Just a question. Will the resize use lot of CPU ? can this be achieve with the GPU ?
Let me know

For smaller videos it might be better just to crop them and let
your player resize (EDIT: perhaps with GPU), ie no Spline36Resize() line in template, give it a try (for 1:1 pixel aspect ratio only).

EDIT: Or you could just crop (no resize) and select aspect ratio in Player, perhaps using GPU capable player.
__________________
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 October 2013 at 18:20.
StainlessS is offline   Reply With Quote
Old 23rd October 2013, 17:44   #16  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
My player resizing is the problem . The video can be read fine with all the other players :s. The bug appears particulary when i jump from a 720p video file to a 640x360 one......

I tested with MPC-HC and it's working. It seems to be eating CPU too load the video so i think it won't be OK with my software . I thought it wouldn't use that much CPU. ideal would have been a quicksync version or dxva version of avisynth.

I also tested and it's not working with WMP. It doesn't react to .avs files......so i fear it won't work with my software neither.......

Thank you very much for your help whatever
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 17:58   #17  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
You could perhaps try Spline16Resize instead, (faster) or any of the other resizer's. (see documentation).

Quote:
not working with WMP. It doesn't react to .avs files
you could try
Right Click "Open With/Choose Program" and choose WMP.

VLC will not play avs files, it only uses internal decoder and knows nothing of avs files.
__________________
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 23rd October 2013, 18:19   #18  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
Quote:
Originally Posted by StainlessS View Post
You could perhaps try Spline16Resize instead, (faster) or any of the other resizer's. (see documentation).

you could try
Right Click "Open With/Choose Program" and choose WMP.

VLC will not play avs files, it only uses internal decoder and knows nothing of avs files.
You're really good. It's working like that. Unfortunately my dj software is more complex. It need to analyze the files before being played to build waveform, bpm, and process the file to allow modification of speed, add effects etc...in real-time. So i won't be able to just make an "open with"

Can't thank you enough anyway for the time you took to help me. I have already made a bid on a coder website to find someone who could develop a resizing function in lav filters but no one placed a bid for this project :'(
itsonlyjustincase is offline   Reply With Quote
Old 23rd October 2013, 18:38   #19  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 6,053
It might still be worth trying avs with your dj thing, may work so long as it does not use internal decoders.

Players are in a better position to use GPU than Avisynth.
If you can render to AVI (eg UT Video or HuffYUV Lossless Codecs) then use Avisynth to Crop and perhaps resize to 1:1 pixel Aspect Ratio,
and render in eg MeGUI, then you would not have this problem in the first place.
You would not need to resize bigger, only to correct 1:1 PAR, let the player resize.
__________________
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 23rd October 2013, 23:58   #20  |  Link
itsonlyjustincase
Registered User
 
Join Date: Nov 2009
Posts: 152
not working .......too bad.........
itsonlyjustincase 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 00:19.


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