3D Vision Blog

A normal user's look into the world of 3D Stereo Technologies

3D Vision Blog header image 2

2D to 3D Realtime Video Conversion with Avisynth v0.2b

January 1st, 2010 · 53 Comments · 2D to 3D Conversion

3d-vision-realtime-2d-3d-convert


Maybe I should start by wishing you all a Happy New Year 2010 and right after that comes the new updated version 0.2b of the Avisynth script I wrote about realtime conversion of 2D video to 3D. The first version of the script was a bit rough and not very functional, but it was more like a proof of concept. The new version is a bit more complete as it works not only with a 720p videos, but with just about anything you give it in terms of resolution. I’ve also addressed another drawback of the first version and that is the fact that the script can now take advantage of multi-core CPUs as the first version was only using just one of the cores. The multithreaded script however is a different one, because it requires a bit of additional work on Avisynth in order to be used and maybe a bit unstable at times, but if you have a dual or quad core processor and get slower framerates you should definitely try it. Just as a reminder, this script is to be opened instead of a video file from 3D Vision Stereoscopic Player or the Stereoscopic Player in a Side by Side format and is designed to be viewed on a computer that is equipped with a 120Hz display and Nvidia’s GeForce 3D Vision. You may however be able to play it on other stereoscopic 3D setup you have if it is capable of playing back videos in side by side stereosopic format…


# 2D to 3D Realtime Video Conversion Avisynth script v0.2b
# Made by Anton Belev at 3D Vision Blog
# www.3dvision-blog.com

# Load the Reform plugin for the skew function
LoadPlugin ("Reform.dll")

# Open the video file for conversion, change the video file name
video2d = DirectShowSource("avatar_trailer_720p.mov")
video2d = ConvertToRGB32(video2d)
videoW = width(video2d)
videoH = height(video2d)
ResW = videoW + (videoW / 16)
CropW = (ResW - videoW) / 2

# Create variables for left and right frame with one frame difference
f1 = video2d
f2 = DeleteFrame(video2d, 0)

# Add the perspective effect to the second frame and crop it
f1 = Spline16Resize(f1, ResW, videoH)
bg = BlankClip(f1, color = $000000)
f1 = skew(f1, bg, ltopx=2, ltopy=2, lbotx=CropW-4, lboty=videoH-2, rtopx=ResW-2, rtopy=2, rbotx=ResW-CropW, rboty=videoH-2, resize = "point")
f1 = Crop(f1, CropW, 0, videoW, videoH) 

# Output the two video frames in a side by side format
StackHorizontal(f2, f1)

The new singlethreaded version of the script requires you to download and install AviSynthon your PC, and then you also need to download V. C. Mohan ‘s Reform plugin for AviSynth and extract it at the same folder when you have the AVS script and the video file you are going to play and convert from 2D to 3D in real time. In version 0.2b of the script you can replace the video file name to just about any file, no matter what is the resolution, although with HD videos over 720p you might have some trouble playing them with normal framerate, so for this the multithreading version of the script might help if you have a processor with multiple cores or even multiprocessor PC. And don’t forget to save the code above with AVS file extension and to replace the avatar_trailer_720p.mov with the name of your video file.


# 2D to 3D Realtime Video Conversion Avisynth script v0.2b MultiThreading
# Made by Anton Belev at 3D Vision Blog
# www.3dvision-blog.com

# For this to work you need to have AviSynth with MT mod 0.7 installed!!!
SetMTMode(2,0)

# Load the Reform plugin for the skew function
LoadPlugin ("Reform.dll")

# Open the video file for conversion, change the video file name
video2d = DirectShowSource("avatar_trailer_720p.mov")
video2d = ConvertToRGB32(video2d)
videoW = width(video2d)
videoH = height(video2d)
ResW = videoW + (videoW / 16)
CropW = (ResW - videoW) / 2

# Create variables for left and right frame with one frame difference
f1 = video2d
f2 = DeleteFrame(video2d, 0)

# Add the perspective effect to the second frame and crop it
f1 = Spline16Resize(f1, ResW, videoH)
bg = BlankClip(f1, color = $000000)
f1 = skew(f1, bg, ltopx=2, ltopy=2, lbotx=CropW-4, lboty=videoH-2, rtopx=ResW-2, rtopy=2, rbotx=ResW-CropW, rboty=videoH-2, resize = "point")
f1 = Crop(f1, CropW, 0, videoW, videoH) 

# Output the two video frames in a side by side format
StackHorizontal(f2, f1)

For the multithreading version, besides the need for Avisynth and the Reform plugin, you’ll also need to download the latest Avisynth MT 0.7 mod and then apply it. This means extracting the MT.dll library in the plugins folder of the Avisynth installation and then overwriting the original avisynth.dll with the modified one (\Windows\System32 for 32-bit OS or \Windows\SysWOW64 for 64-bit OS). After that you’ll be ready to run the script and see that all the available cores of the CPU are being used for processing and thus get a better framerate than with the singlethreading version of the script.

I’ll continue to work on the 2D to 3D conversion script with Avisynth, although I’m actually quite new to using this tool, but it is really very easy to use and can be quite useful at times for different kinds of video processing. So next will probably be a version of the conversion script that will output directly an anglyph video and then maybe even an interlaced image so that you’ll be able to watch these in your favorite video player and not have to use a specific stereoscopic video player. And as always don’t forget to share your comments if you try the scripts and any ideas for further improvements are more than welcome too, especially if they are related to improving the performance as this is a bit of an issue at the moment.

Download the 2D to 3D conversion scripts and all the needed installation files…

Tags: ··········


53 responses so far ↓

  • 51 Bloody // May 19, 2010 at 10:16

    And have you tried if the single threaded version is working fine, or it also does not want to run? We need to figure out if the problem is withing AviSynth or the MT plugin…

  • 52 Guest // May 19, 2010 at 10:50

    The single threaded version worked without a problem for me. I think its the MT pluging.

  • 53 joe w // Nov 15, 2010 at 09:33

    how do i record the 3d out put of the avs and avi file in stereoscopic as 1 file so i can upload it on you tube

Leave a Comment

Current ye@r *