I'm living issues with DGNVTools while converting anaglyph to SBS.
The main reference scrypts are Tony Ash's scrypts.
While they are working with DirectShowSource or with FFVideoSource, i haven't been able to use DGSource.
Here are the scrypts and please help me; what is wrong?
# XX-DeAna.avs
# Tone at VRtifacts.com
# V 0.9 June 27, 2010
#
#
# Copyright (C) 2010 Tony Asch
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# Parameter file for converting Anaglyph video
# into pure left and right video streams
# Using AviSynth (tested with v2.58)
#
# Features:
#
# 1. Supports conversion from red/cyan and green/magenta
#
# 2. If your Anaglyph source has a matching (time synced)
# 2D version which is either the left or right eye view
# the 2D version can be copied into the appropriate eye
# of your output. Also this 2D version will improve the
# processing of the other eye (extracted from the anaglyph)
#
# 3. Can swap the right and left output for crosseyed or parallel viewing
#
# 4. Can correct for leakage between the left and right videos
# which often occurs with poor anaglyph encoding
#
# 5. Can reduce edge fringing due to excessive video peaking in the source
#
# 6. Outputs a single video stream, either side-by-side or top-bottom
# with your choice of left/right in each position
#
# 7. Source audio from any file (including one of your input videos)
#
# 8. Works with any DirectShow compatible input video. With the proper codecs
# you should be able to use: avi, wmv, mkv, mpg (1 and 2)
# Recommend installing K-Lite codecs
#
# 9. Can resize the output video.
#
# 10. Can adjust the tradeoffs in color restoration
#
# 11. Can adjust final brightness, contrast, and saturation
# of both left and right output
#
#
# USAGE:
#
# 1. Requires AVISynth
#
# 2. Easiest to use with VirtualDubMod
#
# 3. This file is where you setup one of your movies to
# decode an anaglyph video into pure left and right color video.
# You'll probably have one of these for every movie you process.
# It might be a good idea to name each copy of this file
# according to the movie it refers to, and to put it in
# a folder with the original movie
#
# 4. There is a separate AVS file (AnaExtract.avs) which does
# all the work. It is referenced at the bottom of this
# parameter file and you must make sure that reference
# is pointing to the correct location on your disc.
#
# 5. So far AVISynth is Windows only, and therefor so is this script
# I tested on Win 7 x64, but it should work on XP, Vista, or Win7, either x32 or x64
#
# 6. It is much more fun to use with a powerful computer
# I tested on an overclocked I5-750.
# Got pretty close to real-time on DVD resolution previews.
#
# 7. So... set all the parameters below as instructed in the comments.
#
# 8. Run VirtualDubMod, File->Open Video, select this file
# Scrub and preview various frames in the video
# Use the VirtualDubMod script editor to change the
# various parameters...hit F5 in the script editor
# to automatically save the script and reload it in
# VirtualDubMod, thus revealing the newly processed images.
# When you're ready to fully process the movie and save it as
# a video file, use VirtualDubMod's File->Save As...
#
# 9. Playback with your favorite viewing software,
# perhaps Stereoscopic Player or YouTube 3D
#
#
# CREDITS
#
# Some of the functionality and ideas came from earlier
# scripts from Olivier Amato and Blackhole of Soul's
# My thanks for their hard work.
#
#
SetMemoryMax (64)
# Setup our input files
anaglyphName = "E:\jtoc\3D_cut.dgi" # Anaglyph video
PureColName = "E:\jtoc\2D_cut.dgi" # Video with color info (either Anaglyph or 2D)
monoName = "E:\jtoc\2D_cut.dgi" # Possible 2D video for one eye, if not set to "nothing
# Anaglyph input format, either RC or GM, i.e red/cyan or green/magenta
inputFormat = "GM"
# Maybe we already have one eye's version in 2D already,
# i.e. the DVD or BR has both 2D and 3D versions
# Set to: monoRight or monoLeft or monoNone
isMono = "monoRight"
# Swap eyes: either Yes or No
# Note: it is industry standard to put Red on the left eye for RC glasses
# and Green on the left eye for GM glasses
# It would be unusual to set this parameter to Yes
# since the un-swapped arrangement is either Red=Left or Green=Left
swapAnaglyph = "No"
# Output formatting:
# Choices are:
# SBS_Left_First, SBS_Right_First, TB_Left_Top, TB_Right_Top
#
# Meaning Side-by-Side (SBS) or Top-Bottom (TB)
# And choosing which eye is in which position
# This happens after the optional swap (above)
# and is somewhat redundant, but makes the eye choices clearer.
outputFormat = "SBS_Left_First"
# Resize the output video? Either Yes or No
# If set to No, then the output video is either
# twice the width of the input (for SBS)
# or twice the height of the input (for TB)
outputResize = "No"
# If we are resizing the output, specify the dimensions (Int)
# These dimensions apply to the stacked video size
outputWidth = 500
outputHeight = 200
# In case one anaglyph eye has leaked into the other
# We can try to remove that leakage by subtraction
# Expressed as percentage (int or float) (-100 to 100) (0 means none)
leakCorrectR = 0 # Leakage of left into the right eye
leakCorrectL = 0 # Leakage of right into the left eye
# How much to blur the color information (Int or Float)
# This is done by shrinking the color video down in size
# and then resizing it back up to full resolution
# producing a blurred full resolution image
# The two decimate numbers are expressed as percentages
# i.e. a percentage of the full resolution to calculate
# the shrunk size. 100 means no shrink, 10 means 1/10 the
# resolution of the original, etc.
# Anaglyphs are only offset horizontally, so the color blur
# should be strong horizontally, but weak vertically
# For films where the cameras were misaligned vertically
# you will need to make the vertical blur greater.
decimateHoriz = 8.0 # Horizontal shrinkage
decimateVert = 6.0 # Vertical shrinkage - can usually be much bigger than decimateHoriz
# Final brightness and contrast adjustments
tweakBrightL = 0 # Left brightness, integer to add to each pixel (pixels are 0-255)
tweakContL = 1.0 # Left contrast adjustment (1.0 means no contrast adjustment)
tweakSatL = 1.0 # Left saturation adjustment (1.0 means no saturation adjustment)
tweakBrightR = -30 # Right brightness, integer to add to each pixel (pixels are 0-255)
tweakContR = 1.2 # Right contrast adjustment
tweakSatR = 1.5 # Right saturation adjustment
# Option to horizontally blur the left and right videos,
# just before the color is restored (before optional LR swap)
# Helps remove some of the fringing that appears in poor DVD encodes
# Set to exactly 1.0 for no processing (faster!!),
# > 1.0 blurs... try 1.5 to 4.0
blurLeft = 1.0
blurRight = 1.0
# Common code to do the conversion
# Make sure this file path points to
# the file on your system.
import("E:\jtoc\AnaExtract.avs")
# AnaExtract.avs
# Tone at VRtifacts.com
# V 0.91 Feb 6, 2011
#
# Copyright (C) 2010 Tony Asch
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#
# Core processing for converting Anaglyph video
# into pure left and right video streams
# Using AviSynth (tested with v2.58)
#
# Features:
#
# 1. Supports conversion from red/cyan and green/magenta
#
# 2. If your Anaglyph source has a matching (time synced)
# 2D version which is either the left or right eye view
# the 2D version can be copied into the appropriate eye
# of your output. Also this 2D version will improve the
# processing of the other eye (extracted from the anaglyph)
#
# 3. Can swap the right and left output for crosseyed or parallel viewing
#
# 4. Can correct for leakage between the left and right videos
# which often occurs with poor anaglyph encoding
#
# 5. Can reduce edge fringing due to excessive video peaking in the source
#
# 6. Outputs a single video stream, either side-by-side or top-bottom
# with your choice of left/right in each position
#
# 7. Source audio from any file (including one of your input videos)
#
# 8. Works with any DirectShow compatible input video. With the proper codecs
# you should be able to use: avi, wmv, mkv, mpg (1 and 2)
# Recommend installing K-Lite codecs
#
# 9. Can resize the output video.
#
# 10. Can adjust the tradeoffs in color restoration
#
# 11. Can adjust final brightness, contrast, and saturation
# of both left and right output
#
#
# USAGE:
#
# 1. Requires AVISynth
#
# 2. Easiest to use with VirtualDubMod
#
# 3. This file is "imported" by your parameter AVS file.
# Unless you're a programmer, you shouldn't mess with
# this file. Put this file somewhere safe on your system
#
# 4. There is a separate AVS file which contains all your
# parameter settings, including the name(s) of the input
# video files and how you want to do the conversion.
# This parameter file automatically uses the processing
# in this file (you just have to let the parameter file
# know where this file is located on your disc.
#
# 5. So far AVISynth is Windows only, and therefor so is this script
# I tested on Win 7 x64, but it should work on XP, Vista, or Win7, either x32 or x64
#
# 6. It is much more fun to use with a powerful computer
# I tested on an overclocked I5-750.
# Got pretty close to real-time on DVD resolution previews.
#
#
# CREDITS
#
# Some of the functionality and ideas came from earlier
# scripts from Olivier Amato and Blackhole of Soul's
# My thanks for their hard work.
#
#
# Snag our video files
LoadPlugin("E:\DG\DGDecodeNV.dll")
vidL = DGSource(anaglyphName)
vidOrig = DGSource(anaglyphName)
# We need these for later
# Skip if we've already got a Mono Left source
# Red/Cyan?
(inputFormat == "RC") && (isMono != "monoLeft") ? Eval("""
vidL = ConvertToRGB(vidL)
vidL = MergeRGB(vidL.ShowRed("YV12"), vidL.ShowRed("YV12"), vidL.ShowRed("YV12"))
vidL = Greyscale(vidL)
""") : Eval(""" """)
# Green/Magenta?
(inputFormat == "GM") && (isMono != "monoLeft") ? Eval("""
vidL = ConvertToRGB(vidL)
vidL = MergeRGB(vidL.ShowGreen("YV12"), vidL.ShowGreen("YV12"), vidL.ShowGreen("YV12"))
vidL = Greyscale(vidL)
""") : Eval(""" """)
# Skip if we've already got a Mono Right source
# Red/Cyan?
(inputFormat == "RC") && (isMono != "monoRight") ? Eval("""
vidR = ConvertToRGB(vidOrig)
vidR = MergeRGB(vidR.ShowGreen("YV12"), vidR.ShowGreen("YV12"), vidR.ShowGreen("YV12"))
vidR = Greyscale(vidR)
""") : Eval(""" """)
# Green/Magenta?
(inputFormat == "GM") && (isMono != "monoRight") ? Eval("""
vidR = ConvertToRGB(vidOrig)
vidR = MergeRGB(vidR.ShowRed("YV12"), vidR.ShowRed("YV12"), vidR.ShowBlue("YV12"))
vidR = Greyscale(vidR)
""") : Eval(""" """)
# Prepare color information by resizing the image down and back up,
# creating a blurred version of the source for color restoration
# Note: the decimateHoriz/Vert values are percentages (1-100)
# defining the size of the shrunken version. Small numbers give more blur
# Code has a hack to make sure the shrunk version dimensions are even numbers
vidColor = DGSource(PureColName)
vidColor = BicubicResize(vidColor, Int((width(vidL) * decimateHoriz) / 200.0) * 2, Int((height(vidL) * decimateVert) / 200.0) * 2)
vidColor = BicubicResize(vidColor, width(vidL), height(vidL))
# Maybe we already have a 2D version for one of the eyes
isMono == "monoRight" ? Eval("""
vidR = ConvertToRGB(DirectShowSource(monoName))
""") : Eval(""" """)
# Undoubtedly a little bit of the wrong eye has leaked over during the Anaglyph encoding process
# Subtract out a bit of the wrong eye. Specified in percentage (0-100)
vidL = Overlay(vidL, vidR, mode="subtract", opacity=(leakCorrectL / 100.0))
vidL = Levels(vidL, 0, 1.0, Int(255 * (1.0 - (leakCorrectL / 100.0))), 0, 255, coring=false)
vidR = Overlay(vidR, vidL, mode="subtract", opacity=(leakCorrectR / 100.0))
vidR = Levels(vidR, 0, 1.0, Int(255 * (1.0 - (leakCorrectR / 100.0))), 0, 255, coring=false)
# Horizontally blur if needed - reduces fringing from excessive video peaking.
# Skip if = 1.0 (no blur). Otherwise larger value produce more blur
blurRight != 1.0 ? Eval("""
vidR = BicubicResize(vidR, Int(width(vidOrig) / (blurRight * 2.0)) * 2, height(vidOrig))
vidR = BicubicResize(vidR, width(vidOrig), height(vidOrig))
""") : Eval(""" """)
blurLeft != 1.0 ? Eval("""
vidL = BicubicResize(vidL, Int(width(vidOrig) / (blurLeft * 2.0)) * 2, height(vidOrig))
vidL = BicubicResize(vidL, width(vidOrig), height(vidOrig))
""") : Eval(""" """)
# YUV color space for chroma operations
vidR = ConvertToYV12(vidR)
vidL = ConvertToYV12(vidL)
vidColor = ConvertToYV12(vidColor)
# Use our blurred color video to restore colors to greyscale Right and Left videos
# Skip if we've already got a Mono Right source
isMono != "monoRight" ? Eval("""
vidR = mergechroma(vidR, vidColor)
""") : (""" """)
# Skip if we've already got a Mono Left source
isMono != "monoLeft" ? Eval("""
vidL = mergeChroma(vidL, vidColor)
""") : (""" """)
# Final brightness and contrast tweak
vidR = Tweak(vidR, bright=tweakBrightR, cont=tweakContR, sat=tweakSatR, coring=false)
vidL = Tweak(vidL, bright=tweakBrightL, cont=tweakContL, sat=tweakSatL, coring=false)
# Maybe we already have a 2D version for one of the eyes
isMono == "monoRight" ? Eval("""
vidR = ConvertToRGB(DirectShowSource(monoName))
""") : Eval("""
vidR = ConvertToRGB(vidR)
""")
isMono == "monoLeft" ? Eval("""
vidL = ConvertToRGB(DirectShowSource(monoName))
""") : Eval("""
vidL = ConvertToRGB(vidL)
""")
# Swap if needed
swapAnaglyph == "Yes" ? Eval("""
vidTemp = vidL
vidL = vidR
vidR = vidTemp
""") : (""" """)
# Build the Side by Side (SBS) or Top Bottom (TB) combination of Left and Right video
outputFormat == "SBS_Left_First" ? Eval("""
StackHorizontal(vidL, vidR)
""") : Eval(""" """)
outputFormat == "SBS_Right_First" ? Eval("""
StackHorizontal(vidR, vidL)
""") : Eval(""" """)
outputFormat == "TB_Left_Top" ? Eval("""
StackVertical(vidL, vidR)
""") : Eval(""" """)
outputFormat == "TB_Right_Top" ? Eval("""
StackVertical(vidR, vidL)
""") : Eval(""" """)
# Optionally resize the output video
outputResize == "Yes" ? Eval("""
BicubicResize(outputWidth, outputHeight)
""") : Eval(""" """)