View Full Version : Resolution not a multiple of 2
juGGaKNot
2nd November 2009, 16:05
I want to add a crop to the video ( using autocrop ) in case its resolution is not a multiple of 2, 1184x665 for ex ( in testing using it ) but i have a problem :
AVIsource("C:\x264\movie.avi")
LoadPlugin("C:\x264\bin\autocrop.dll")
AutoCrop(0, 2, 2, threshold=0)
ConvertToYV12(matrix="PC.601")
Autocrop needs YV12 so ConvertToYV12 first.
AVIsource("C:\x264\movie.avi")
ConvertToYV12(matrix="PC.601")
LoadPlugin("C:\x264\bin\autocrop.dll")
AutoCrop(0, 2, 2, threshold=0)
The video can not be converted to yv12 because its not mod2.
Any other plugin that works on rgb32 uncompressed imput and allows simple crop if the source is not mod2 ?
poisondeathray
2nd November 2009, 16:21
Can you resize first to even dimensions?
Gavino
2nd November 2009, 16:39
You don't need a plugin to do this!
Crop(0, height%2, -width%2, 0)
juGGaKNot
2nd November 2009, 17:44
Great, thnx!
No i can't resize first, i'm not the one that is going to use the app, i want to make it idiot proof.
juGGaKNot
2nd November 2009, 18:05
Does not work
echo AVIsource("%mypath%\%mymovie%.avi",audio=false) >> "%mypath%\%mpath%\T1\%mymovie%3.avs"
echo WriteFile("%mypath%\%mpath%\T1\res.txt", "WIDTH") >> "%mypath%\%mpath%\T1\%mymovie%3.avs"
"%mypath%\bin\ffmpeg.exe" -i "%mypath%\%mpath%\T1\%mymovie%3.avs"
set /p myres=<"%mypath%\%mpath%\T1\res.txt"
cls
echo AVIsource("%mypath%\%mymovie%.avi",audio=false) >> "%mypath%\%mpath%\T1\%mymovie%3.avs"
echo WriteFile("%mypath%\%mpath%\T1\res2.txt", "HEIGHT") >> "%mypath%\%mpath%\T1\%mymovie%3.avs"
"%mypath%\bin\ffmpeg.exe" -i "%mypath%\%mpath%\T1\%mymovie%3.avs"
set /p myres2=<"%mypath%\%mpath%\T1\res2.txt"
pause
echo AVIsource("%mypath%\%mymovie%.avi") >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo crop(0, %myres2%%2, -%myres%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo ConvertToYV12() >> "%mypath%\%mpath%\T3\%mymovie%.avs"
set /p myavs=<"%mypath%\%mpath%\T3\%mymovie%.avs"
=
AVIsource("C:\x264\movie.avi")
crop(0, 665, -1185, 0)
ConvertToYV12()
%2 might be the problem, i need it in bat.
LE :
echo AVIsource("%mypath%\%mymovie%.avi") >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo crop(0, %myres2%%%2, -%myres%%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo ConvertToYV12() >> "%mypath%\%mpath%\T3\%mymovie%.avs"
=
AVIsource("C:\x264\movie.avi")
crop(0, 665%2, -1185%2, 0)
ConvertToYV12()
in the avs.
XhmikosR
2nd November 2009, 18:19
Have you tried to use the escape character "^"?
http://ss64.com/nt/syntax-esc.html
http://ss64.com/nt/setlocal.html
Try something like this:
echo AVIsource("%mypath%\%mymovie%.avi") >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo crop(0, %myres2%^%%2, -%myres%^%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo ConvertToYV12() >> "%mypath%\%mpath%\T3\%mymovie%.avs"
juGGaKNot
2nd November 2009, 18:26
Have you tried to use the escape character "^"?
http://ss64.com/nt/syntax-esc.html
http://ss64.com/nt/setlocal.html
Try something like this:
echo AVIsource("%mypath%\%mymovie%.avi") >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo crop(0, %myres2%^%2, -%myres%^%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo ConvertToYV12() >> "%mypath%\%mpath%\T3\%mymovie%.avs"
Used it, result is
AVIsource("C:\x264\movie.avi")
crop(0, 665, -1185, 0)
ConvertToYV12()
So it does not work.
XhmikosR
2nd November 2009, 18:31
I edited my post. Try again.
The following:
SETLOCAL EnableDelayedExpansion
echo AVIsource("mypath\mymovie.avi") >> "mymovie.avs"
echo crop(0, myres2^%%2, -myres^%%2, 0) >> "mymovie.avs"
echo ConvertToYV12() >> "mymovie.avs"
ENDLOCAL
gives me this:
AVIsource("mypath\mymovie.avi")
crop(0, myres2%2, -myres%2, 0)
ConvertToYV12()
It also works without EnableDelayedExpansion, read the links I gave you and decide if you need it or not.
juGGaKNot
2nd November 2009, 18:32
yes, i tried %%2 without ^ so it might work, testing
le :
AVIsource("C:\x264\movie.avi")
crop(0, 665%2, -1185%2, 0)
ConvertToYV12()
no dice, give me the same as %%2
LE2 : dawn, it works with : x264 bla bla movie.avs but not with
set /p myavs=<"%mypath%\%mpath%\T3\%mymovie%.avs"
x264 bla bla %myavs%
XhmikosR
2nd November 2009, 18:35
So what it the problem? You needed this:
Crop(0, height%2, -width%2, 0)
and this is what you get.
SETLOCAL
SET myres=528
SET myres2=1024
echo AVIsource("mypath\mymovie.avi") >> "mymovie.avs"
echo crop(0, %myres%^%%2, -%myres2%^%%2, 0) >> "mymovie.avs"
echo ConvertToYV12() >> "mymovie.avs"
ENDLOCAL
AVIsource("mypath\mymovie.avi")
crop(0, 528%2, -1024%2, 0)
ConvertToYV12()
You need to describe better. What is LE?
juGGaKNot
2nd November 2009, 18:43
Yes, seems to work fine
1185x665 = 1184x664
1184x666 = 1184x666
echo AVIsource("%mypath%\%mymovie%.avi") >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo crop(0, %myres2%^%%2, -%myres%^%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo ConvertToYV12(matrix="%rangepc%") >> "%mypath%\%mpath%\T3\%mymovie%.avs"
echo VideoLeft = AVIsource("%mypath%\%mymovie%.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo VideoRight = AVIsource("%mypath%\%mymovie%3D.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo VideoStacked = StackHorizontal(VideoRight,VideoLeft) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo crop(0, %myres2%^%%2, -%myres%^%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo ConvertToYV12(VideoStacked, matrix="%rangepc%") >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
SET myavs="%mypath%\%mpath%\T3\%mymovie%.avs"
if EXIST "%mypath%\%mymovie%3D.avi" SET myavs="%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo AVIsource("%mypath%\%mymovie%.avi") >> "%mypath%\%mpath%\T3\%mymovie%divx.avs"
echo crop(0, %myres2%^%%2, -%myres%^%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%divx.avs"
echo ConvertToYV12(matrix="%rangepc%") >> "%mypath%\%mpath%\T3\%mymovie%divx.avs"
echo LoadPlugin("%mypath%\bin\autocrop.dll") >> "%mypath%\%mpath%\T3\%mymovie%divx.avs"
echo AutoCrop(0, 8, 8, threshold=0) >> "%mypath%\%mpath%\T3\%mymovie%divx.avs"
echo VideoLeft = AVIsource("%mypath%\%mymovie%.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3Ddivx.avs"
echo VideoRight = AVIsource("%mypath%\%mymovie%3D.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3Ddivx.avs"
echo VideoStacked = StackHorizontal(VideoRight,VideoLeft) >> "%mypath%\%mpath%\T3\%mymovie%3Ddivx.avs"
echo crop(0, %myres2%^%%2, -%myres%^%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%3Ddivx.avs"
echo ConvertToYV12(VideoStacked, matrix="%rangepc%") >> "%mypath%\%mpath%\T3\%mymovie%3Ddivx.avs"
echo LoadPlugin("%mypath%\bin\autocrop.dll") >> "%mypath%\%mpath%\T3\%mymovie%3Ddivx.avs"
echo AutoCrop(0, 8, 8, threshold=0) >> "%mypath%\%mpath%\T3\%mymovie%3Ddivx.avs"
All is well, THNX!
LE : LE = later edit
juGGaKNot
2nd November 2009, 19:50
Ups, looks like it does not work for a 3D movie
echo VideoLeft = AVIsource("%mypath%\%mymovie%.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo VideoRight = AVIsource("%mypath%\%mymovie%3D.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo VideoStacked = StackHorizontal(VideoRight,VideoLeft) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo ConvertToYV12(VideoStacked, matrix="%rangepc%") >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
i used :
echo VideoLeft = AVIsource("%mypath%\%mymovie%.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo crop(0, %myres2%^%%2, -%myres%^%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo VideoRight = AVIsource("%mypath%\%mymovie%3D.avi", audio=false) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo crop(0, %myres2%^%%2, -%myres%^%%2, 0) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo VideoStacked = StackHorizontal(VideoRight,VideoLeft) >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
echo ConvertToYV12(VideoStacked, matrix="%rangepc%") >> "%mypath%\%mpath%\T3\%mymovie%3D.avs"
resulting in :
VideoLeft = AVIsource("C:\x264\movie.avi", audio=false)
crop(0, 666%2, -1184%2, 0)
VideoRight = AVIsource("C:\x264\movie3D.avi", audio=false)
crop(0, 666%2, -1184%2, 0)
VideoStacked = StackHorizontal(VideoRight,VideoLeft)
ConvertToYV12(VideoStacked, matrix="PC.601")
i cannot use crop in the VideoStacked because i cannot get the resolution unless i use avs2avi to make it avi.
How can i use it here ?
Gavino
2nd November 2009, 20:27
Can't you just use "width" and "height" literally in the script you create, rather than writing them out to a file, reading them in as variables (myres and myres2) and putting the actual numerical values in the script? There's no need to go to all that bother unless your batch file actually needs to know the width and height for some other reason.
As I now see you are using this operation on multiple videos, it would be better to declare a function, eg
function Mod2(clip c) {
cropW = c.width%2
cropH = c.height%2
return (crop1 == 0 && crop2 == 0 ? c : c.Crop(0, cropH, -cropW, 0))
}
which you can apply as VideoLeft = VideoLeft.Mod2(), etc.
PS If you want to avoid using %, you can replace x%2 by x-(x/2*2)
juGGaKNot
2nd November 2009, 21:11
Can't you just use "width" and "height" literally
You can ? great, will try now.
Gavino
2nd November 2009, 23:23
You can ?
Sure, you were already using them in the other part of your script:
echo WriteFile("%mypath%\%mpath%\T1\res.txt", "WIDTH") ...
...
echo WriteFile("%mypath%\%mpath%\T1\res2.txt", "HEIGHT") ...
http://avisynth.org/mediawiki/Clip_properties
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.