[RESOLVED] Anaglyph to SBS

Support forum for DGDecNV
Post Reply
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

[RESOLVED] Anaglyph to SBS

Post by rica »

Hi,

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(""" """)

User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Anaglyph to SBS

Post by admin »

i haven't been able to use DGSource
Please describe the exact problem you are having, including error messages if any.

I see the script tries to open three instances of DGSource(). Your Nvidia graphics card may not have enough memory for that. What is your graphics card?

This double invocation is inefficient and not required:

vidL = DGSource(anaglyphName)
vidOrig = DGSource(anaglyphName)
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: Anaglyph to SBS

Post by rica »

Hi,

This is the error popup:

Image

As far as i understand, it doesn't accept multiple instances of DGNV.

If you noticed i use this line for SW based source files and it works (and it uses CPU) but for HW based source like yours it doesn't work:
SetMemoryMax (64)]
I use 430 and i will try with 460 later.

But btw, what do you suggest me to use instead of:

Code: Select all

vidL = DGSource(anaglyphName)
vidOrig = DGSource(anaglyphName) 
Thanks Don.

Best.
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Anaglyph to SBS

Post by admin »

That message means that the DGI path/file given to DGSource() could not be opened. Are you sure the index file exists at "E:\jtoc\3D_cut.dgi" as assumed by the script?

To eliminate an instance, you can change the code to this:

...
LoadPlugin("E:\DG\DGDecodeNV.dll")
vidOrig = DGSource(anaglyphName)
vidL = vidOrig
...
DAE avatar
kypec
Posts: 22
Joined: Tue Sep 21, 2010 2:37 am

Re: Anaglyph to SBS

Post by kypec »

rica wrote:As far as i understand, it doesn't accept multiple instances of DGNV.
You can invoke as many instances as your graphics card memory allows...
I use 430 and i will try with 460 later.
...but how much RAM memory is on that card located? 384MB? 512MB? 1GB?
But btw, what do you suggest me to use instead of:

Code: Select all

vidL = DGSource(anaglyphName)
vidOrig = DGSource(anaglyphName) 
What about this approach?

Code: Select all

vidL = DGSource(anaglyphName)
vidOrig = vidL
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: Anaglyph to SBS

Post by rica »

Thanks guys but none of those approaches fixed the issue; i get the same error pupup and yes the index file does exist.
BTW here is the system info:

Code: Select all

Operating System:	Windows 7 Professional, 32-bit
DirectX version:	11.0 
GPU processor:		GeForce GT 430
Driver version:		260.99
CUDA Cores:		96 
Core clock:		700 MHz 
Shader clock:		1400 MHz
Memory clock:		800 MHz (1600 MHz data rate) 
Memory interface:	128-bit 
Total available graphics memory:	2555 MB
Dedicated video memory:	1024 MB DDR3
System video memory:	0 MB
Shared system memory:	1531 MB
Video BIOS version:	70.08.29.00.01
IRQ:			16
Bus:			PCI Express x16 Gen2
I think i have to change my card.

EDIT: btw DGIndexNV is 2037 (32 bit).
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Anaglyph to SBS

Post by admin »

It has nothing to do with the card. The error is SIMPLE...the file in the DGSource() invocation cannot be *opened* [fopen() on the string passed to DGSource() fails]. So either you have the path wrong, or you have the filename wrong.

Code: Select all

	if ((m_decoder.DGI_File = fopen(path, "r")) == NULL)
	{
		env->ThrowError("DGMultiSource: Cannot open index file!");
	}
Have you tried a script with a simple DGSource() line in it that uses the same path/file?
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: Anaglyph to SBS

Post by rica »

neuron2 wrote:So either you have the path wrong, or you have the filename wrong.

Have you tried a script with a simple DGSource() line in it that uses the same path/file?
That was the first thing which i tried. Both individual scrypts work and open 2D or 3D videos:

Code: Select all

LoadPlugin("E:\DG\DGDecodeNV.dll")
DGSource("E:\jtoc\2D-cut.dgi")

Code: Select all

LoadPlugin("E:\DG\DGDecodeNV.dll")
DGSource("E:\jtoc\3D-cut.dgi")
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Anaglyph to SBS

Post by admin »

Then your main script is messed up somehow. Can't you add some debugging to see why? E.g., print the value of the string passed to DGSource().
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: Anaglyph to SBS

Post by rica »

Please tell me how to do it.
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: Anaglyph to SBS

Post by rica »

DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: Anaglyph to SBS

Post by rica »

And?
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Anaglyph to SBS

Post by admin »

I had a look but quickly rather into more problems than just your path problem, like you still haven't fully completed it, e.g., there are still DSS() calls taking DGI files as input. That's pretty clueless.

Sorry, but I just don't have the time to debug your script. It's clear that there is no DGDecNV problem here. Maybe you can get some help at another forum.
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: Anaglyph to SBS

Post by rica »

Thanks,
FYI i finally fixed the issue.

Here are the working scripts:

Code: Select all

#	AnaExtract.avs
#	Tone at VRtifacts.com
#	V 0.91	Feb 6, 2011

#Snag our video files
LoadPlugin("C:\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(DGSource(monoName))
""") : Eval("""   """)
isMono == "monoLeft" ? Eval("""
	vidL = ConvertToRGB(DGSource(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)



# 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("""   """)


Code: Select all

     #	XX-DeAna.avs
#	Tone at VRtifacts.com
#	V 0.9	June 27, 2010
#

# Setup our input files
anaglyphName = "C:\jtoc\3D.dgi" # Anaglyph video
PureColName = "C:\jtoc\2D.dgi" # Video with color info (either Anaglyph or 2D)
monoName = "C:\jtoc\2D.dgi" # Possible 2D video for one eye, if not set to "nothing

# 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"

# Anaglyph input format, either RC or GM, i.e red/cyan or green/magenta
inputFormat = "GM"

# 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 = 12.0	# Horizontal shrinkage
decimateVert = 24.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("C:\jtoc\AnaExtract_DG.avs")
ConvertToYV12()]
User avatar
admin
Posts: 4551
Joined: Thu Sep 09, 2010 3:08 pm

Re: Anaglyph to SBS

Post by admin »

You're still instantiating more instances than are needed. Use the trick we gave you to eliminate one instance.
DAE avatar
rica
Posts: 11
Joined: Tue Jan 18, 2011 4:14 pm

Re: [RESOLVED] Anaglyph to SBS

Post by rica »

OK,
editing the first three lines of "AnaExtract.avs" prevented using multiple instances.
Thanks.

Code: Select all

LoadPlugin("C:\DG\DGDecodeNV.dll")
vidOrig = DGSource(anaglyphName)
vidL = vidOrig
_ _ _ __
Post Reply