Skip to content

Instantly share code, notes, and snippets.

@LunNova
Created April 17, 2012 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LunNova/2409659 to your computer and use it in GitHub Desktop.
Save LunNova/2409659 to your computer and use it in GitHub Desktop.
## 2D to 3D Realtime Video Conversion Avisynth script v0.3b
## Made by Anton Belev at 3D Vision Blog
## http://www.3dvision-blog.com
## Additionally extended by Martin Haverland at audiomh.de for quality resize
## and different output modes including interlaced format for use in non-3d specific players e.g. windows media player.
#modified by /u/nallar
#Replace all LanczosResize to LanczosResize if performance is bad.
#SetMTMode(2,0)#Uncomment if you have multithreaded avisynth!
factor3D = 20 # Reduce to increase attempt to add 3D.
inputFile = "mlp1.mkv" # Set to filename
## Open the video file for conversion, change the video file name
video2d = DirectShowSource(inputFile)
## Increase video brightnes on dark videos, good for 3D Vision owners
# video2d = video2d.Tweak(Bright=10)
## Convert to RGB32 to avoid the width restrictions
video2d = ConvertToRGB32(video2d)
## Get video width/height and set the frame stretch factor
## Lower the value 100 to increase frame stretch, may introduce ghosting
videoW = width(video2d)
videoH = height(video2d)
ResW = videoW + (videoW / factor3D)
videoH = videoH + (videoH / factor3D)
video2d = LanczosResize(video2d, videoW, videoH)
CropW = (ResW - videoW) / 2
## Create variables for left and right frame with one frame difference
## This is the Plufrich-like simulation that creates illusion of depth from movement
f1 = video2d
f2 = DeleteFrame(video2d, 0)
## Stretch the right frame to further the depth effect
f1 = LanczosResize(f1, ResW, videoH)
f1 = Crop(f1, 0, 0, videoW, videoH)
## Stretch the left frame to further the depth effect
f2 = LanczosResize(f2, ResW, videoH)
f2 = Crop(f2, CropW, 0, videoW, videoH)
## Output the two video frames in a side-by-side / parallel format
## Use this as a default for playing back on 3D Vision (Side by Side L/R)
StackHorizontal(f2, f1)
## Output the two video frames in a Above/Below format (like Sony?)
# StackVertical(f2,f1)
## Output the two video frames in a page flipping format for shutter glasses etc.
## The Tweak as proposed by eslave is for brighter image, modify the value 30
# f1 = f1.ConvertToYV12.Tweak(Bright=30)
# f2 = f2.ConvertToYV12.Tweak(Bright=30)
# Interleave(f2,f1)
## Output the two video frames in anaglyph red-cyan as proposed by eslave
# MergeRGB(f2.ShowRed, f1.ShowGreen, f1.ShowBlue)
## For reversed anaglyph i.e. cyan-red
# MergeRGB(f1.ShowRed, f2.ShowGreen, f2.ShowBlue)
## Output the two video frames in anaglyph yellow-blue as proposed by eslave (untested)
# f1 = f1.ConvertToYV12(matrix="PC.601").tweak(bright=12.5, sat=1.25, coring=false)
# f1 = f1.ConvertToRGB32
# f1 = f1.Levels(0, 1.05, 255, 0, 255, coring=false)
# MergeRGB(f2.ShowRed, f1.ShowGreen, f1.ShowBlue)
## Output the two video frames in anaglyph blue-Yellow as proposed by eslave (untested)
# f2 = f2.ConvertToYV12(matrix="PC.601").tweak(bright=12.5, sat=1.25, coring=false)
# f2 = f2.ConvertToRGB32
# f2 = f2.Levels(0, 1.05, 255, 0, 255, coring=false)
# MergeRGB(f1.ShowRed, f2.ShowGreen, f2.ShowBlue)
## Output two video frames in Interlaced mode
## Ueed for Zalman Trimon, Acer Aspire 3D etc.
# f1 = SeparateFields(f1)
# f1 = SelectEven(f1)
# f2 = SeparateFields(f2)
# f2 = SelectOdd(f2)
# interleave(f2,f1)
# AssumeFieldBased()
# weave()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment