View Single Post
Old 01 November 2013, 17:40   #39
pandy71
Registered User
 
Join Date: Jun 2010
Location: PL
Posts: 1,546
Avisynth http://avisynth.nl/index.php/Main_Page script can help with color reduction. It require http://ldesoras.free.fr/prod.html#src_ditheravsi package and related, yadif http://avisynth.org.ru/yadif/yadif.html plugin is required if antialiasing is activated, script have some limited "flexibility" (hires and interlace "support"), it can be extended by adding framerate conversion http://avisynth.org.ru/mvtools/mvtools2.html to reduce fps in smarter way due Amiga limitations.

This is relatively slow script and have own limitations (rounding errors?), perhaps due ditheravsi and it require tweak for different color depth - it is best to use some grayscale picture pattern - for example Click image for larger version

Name:	G8.png
Views:	123
Size:	6.6 KB
ID:	37619


Code:
#Load_Stdcall_plugin ("C:\Program Files\AviSynth 2.5\plugins\yadif.dll")

########

src="Studio Killers - Ode To The Bouncer (official video).mp4"

########

bits = 4.0 # Valid range: 0 - 8 (Float)
mul=String (Pow (2, 8 - (bits - (22.0/256.0))))

########

m0de=6 # Valid range: (-1..8) (Int)
nlev=0.00 # Valid range: 0..4 (Float)
slev=(15.0/16.0) # Valid range: 0..4 (Float)
ordyn=true # True or False

Lace=0 # Valid range: (0 or 1) (Int)
Hires=0 # Valid range: (0 or 1) (Int)
A=(16.0/9.0)
H_SIZ=320
V_SIZ=INT((ROUND(((H_SIZ/A)/2))*2)*(1+Lace))

########

V=FFVideoSource(src, cache = true, cachefile = src + ".ffindex", fpsnum = -1, fpsden = 1, pp = "vb:a/hb:a/dr", colorspace = "YV12", threads = -1, seekmode = 1)
A=FFAudioSource(src, cache = true, cachefile = src + ".ffindex")
AudioDub(V,A)
#AmplifydB (-24.0)
#KillAudio()

####

#ColorYUV(gamma_y=8, cont_y=32, cont_u=32, cont_v=32)

####

ConvertToRGB24(Interlaced=False, matrix="rec709")

#### Test
#ImageSource("G8.png",pixel_type="RGB32",end=24,fps=25.0)
####
Blur(-0.75,-0.5)
#ReduceBy2()

####

Interleave(ShowRed("YV12"),ShowGreen("YV12"),ShowBlue("YV12")).Limiter(0,255, 128, 128)

####

Spline36Resize(H_SIZ*(1+Hires),V_SIZ)

####

#Merge((Merge(Yadif(2,0),Yadif(2,1),0.5)),(TurnRight(TurnLeft(Merge(Yadif(2,0),Yadif(2,1),0.5)))),0.5)

####

Dither_convert_8_to_16()
Dither_lut16 (expr="x "+mul+" /")
DitherPost (mode=m0de, staticnoise=true,ampo=slev, ampn=nlev, dyn=ordyn, pat=1, prot=true, y=3, u=1, v=1)
mt_lut ("x "+mul+" *", y=3, u=1, v=1)
MergeRGB(SelectEvery (3, 0),SelectEvery (3, 1),SelectEvery (3, 2))

####

#PointResize(640, V_SIZ*(2-Lace))#.Blur(0.25,0.25)
for fixed pallete animation ImageMagick http://www.imagemagick.org/script/index.php batch can be helpful.

Code:
convert -quiet source.avi -ordered-dither o2x2,12 -delay 1x10 -dither Riemersma -colors 256 +map -type optimize source_od2.gif
convert source_od2.gif  -delay 1x10 -layers OptimizeTransparency +map source.gif
Later conversion from gif to anim should be easy... for this script uncompressed (raw) RGB avi file is required

feel free to modify and improve - reading documentation for plugins or imagemagick can be helpful as there is many options to change
pandy71 is offline  
 
Page generated in 0.09158 seconds with 10 queries