Log in

View Full Version : weird resizing trouble


itsonlyjustincase
23rd October 2013, 15:14
http://img11.hostingpics.net/thumbs/mini_86872844127notcentered.png (http://www.hostingpics.net/viewer.php?id=86872844127notcentered.png)

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

StainlessS
23rd October 2013, 15:46
What is ResizePar script, without it, IsRGB problem not solvable ?

Is Pixel aspect ratio 1:1 ?

itsonlyjustincase
23rd October 2013, 15:49
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")

StainlessS
23rd October 2013, 16:00
You can wrap code like this:



Some code



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


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.php?t=168053&highlight=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.php?t=166820&highlight=Avisynthesizer_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

#ASYNTHER DirectShowSource_640x480:43
[DirectShowSource("___FILE___")]
RoboCrop(WMod=4,Laced=false)
Spline36Resize(640,480)


EDIT: This part of first line DirectShowSource_640x480:43
will be shown and selectable in Avisynthesize_Mod to choose which template to use when creating avs file.

itsonlyjustincase
23rd October 2013, 16:32
Thanks very much for your help.

What about the : Script error : invalid arguments to function "IsRGB" ?

itsonlyjustincase
23rd October 2013, 16:40
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...

StainlessS
23rd October 2013, 16:43
See above EDIT:

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.

itsonlyjustincase
23rd October 2013, 16:50
So when you wrote :


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 ?

StainlessS
23rd October 2013, 17:04
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.

How do i use it ?

Read post #4 again.

itsonlyjustincase
23rd October 2013, 17:05
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
23rd October 2013, 17:08
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
23rd October 2013, 17:09
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 :p

StainlessS
23rd October 2013, 17:14
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).

itsonlyjustincase
23rd October 2013, 17:17
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 ?

StainlessS
23rd October 2013, 17:27
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.

itsonlyjustincase
23rd October 2013, 17:44
My player resizing is the problem :p. 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

StainlessS
23rd October 2013, 17:58
You could perhaps try Spline16Resize instead, (faster) or any of the other resizer's. (see documentation).

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.

itsonlyjustincase
23rd October 2013, 18:19
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 :'(

StainlessS
23rd October 2013, 18:38
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.

itsonlyjustincase
23rd October 2013, 23:58
not working :(.......too bad.........

itsonlyjustincase
24th October 2013, 11:45
Do you know someone that would take 100 dollars to implement fit to screen in the lav video decoder ?

kypec
25th October 2013, 10:51
Do you know someone that would take 100 dollars to implement fit to screen in the lav video decoder ?
Fit to screen is resize in other words and that is the job for renderer, not decoder.

itsonlyjustincase
25th October 2013, 12:02
I understand that. My problem is that my soft http://serato.com/video is opengl and doesn't support ffdshow dxva neither intel GPUs. So the only way to get gpu hardware acceleration is to use Lav video decoder. Problem is that some videos (i mix video so have more than 400 clips) have bad resizing problems and are displayed not centered. This is fixed with the resizing function of ffdshow but unfortunatly mixing 2 videos in real-time without GPU assitance results in high CPU usage and bad performances. That is why my UNIQUE solution would be to have a resizing function in lav or a dxva2 or cuvid option for H264 videos in ffdshow like the intel quick sync one. That is why i'm ready to pay if someone can do that for me

itsonlyjustincase
28th October 2013, 11:12
I finally managed to find what was triggering the size bug in my Serato Video software. It's when i was going from 16:9 AR to another one like 1:2. That is why even after recompressing 720x480 to 640x360 then testing both 16:9 and 1:2 videos i still had problems. All the clips just have to be 16:9 (like most of the new ones) and it's ok.