All times are UTC + 2 hours



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Anaglyph to true color SBS rendering
PostPosted: 22 Apr 2011, 01:13 

Joined:
22 Apr 2011, 00:48
Posts: 3
Hi guys.

I'm @rica or @ricabullah from doom9 or avs forums.

I think this is the best place to re-release my post here and this is the wy of " How to Convert Our Existing Anaglyph BluRays and DVDs to Full Color Real 3D videos "
(quoted from doom9)

Quote:
Hi, after lots of work i think i'm ready to introduce Tony Asch's tool.
Why this thread is opened here?
Final movies are encoded with x264 as SBS or TB and further i didn't want this topic to be lost under "aviscript" corner.
This thread is based on Tony's "Dump Those Silly Colored 3D Glasses!"

http://www.vrtifacts.com/how-to-teardowns-tutorials/dump-those-silly-colored-3d-glasses/

You will find an educational movie on the same link as well.

And most of the quotes from Tony have been taken from DV Info Net forum.


Tony says :

Quote:
Some of the functionality and ideas came from earlier scripts from Olivier Amato and Blackhole of Soul's
My thanks for their hard work.


You may enter the parameters on xx-DeAna.avs and AnaExtract.avs will use those parameters.
You will find detailed explanation on how to use it on given scripts.
But i want to make a basic summary:

Quote:
The basic idea is to pull two luminance channels from red and cyan (or green and magenta.) [COLOR="Red"]Or even better, if you have a 2D version of the movie, you already have one eye's view, and just need to pull the luminance from one anaglyph color. With stereoscopic luminance in hand, you then create a blurry version of just the chroma info. This can come from the 2D version, or lacking a 2D copy, just blur the original anaglyph. Finally, you apply the blurred chroma onto the two luminance channels you created as the first step, and then arrange them side by side (or top and bottom.)[/COLOR]

This technique takes advantage of the human vision system characteristic of perceiving color in much lower resolution than the eye sees luminance (rods vs. cones.) Given clean anaglyph source, especially where the convergence/divergence is not too severe, the technique works surprisingly well.

[COLOR="Blue"]The quality of the source material is paramount. Each generation of lossy encoding/decoding degrades the color space, and thus degrades any conversion. Blu-ray sources work quite well, while the VCD anaglyphs that circulate on Usenet and Torrents are useless.[/COLOR] from Tony


Prerequisites:
The anaglyph movie you have has to be shot as real stereoscopic.
You should have a 2D copy of the same movie. (i insist it is an obligation.)
The best results have been taken in case of using original anaglyph blus and DVDs.



How to use:

The best way is to use VirtualDubMod to change the parameter script and see immediately what has been changed. Hit F5 in the script editor to automatically save the script and reload it in VirtualDubMod, thus revealing the newly processed images.

And after being sure you're ready to fully process the movie, just encode it to 264 using x264; internally or externally.
I always prefer to encode it externally.

Then what we need?

DirectX End-User Runtime
DirectShowSpy.dll
Proppage.dll

AviSynth
VirtualDubMod
AC3ACM Codec
ffmpeg
Haali Splitter (latest version: 03.03.2011)
FfdShow
GraphStudio
TSMuxer
MKVMerge Gui
x264 (or MeGui)

AnyDVD/AnyDVD HD (commercial)
eac3to
Video ReDo (for mpeg2 frame accurately cutting) (commercial)
Video ReDo TV Suite (for mpeg2 or h264 frame accurately cutting) (commercial)

Stereoscopic Player or TMT5 (commercial) (for playing resulting SBS files.)

Lets start:

Step by step:

1) Decrypt anaglyph BD or DVD via AnyDVD.
2) Analize decrypted DVD or BD (you may use BD Info for BDs) and find what videos are 3D or 2D.
3) Demux 2D and 3D videos with eac3to and remux to m2ts via TSMuxer.
4) Cut -if needed- to syncronize 2D and 3D videos with VideoReDo/Video ReDo TV Suite. (if the source file is VC1 cut and demux with TS Muxer and remux to mkv with MKVMerge Gui.)
5) Find the video is RC or GM.
6) Explore the 2D video is left or right.
7) Input the parameters to xx-De-Ana.avs.
8) Re-encode with x264 to SBS or TB.


After decripting and analizing files, the extraction is very important.
Tony says:
Quote:
The most important thing is that I have not re-compressed the DVD video before the conversion. Both the 2D and 3D DVDs were extracted to MPEG2 with VOB2MPG, which does not recompress. If the colors are distorted, it becomes very hard to recover the left and right luminance videos because a simple Green or Magenta filter won't work with distorted colors.

And he prefers to use MakeMKV for BluRay extraction.

And i recommend you to use eac3to to demux and remux to mkv with MKV MergeGui. (if you will need to cut to synch videos, you should remux to m2ts with TSMuxer first.)

After extracting non-re-encoded 2D and 3D videos you may need to make them cut if your Anaglyph source has not a matching (time synced) 2D version which is either the left or right eye view.
This cutting must be frame accurately and i use Video ReDo Tv Suite for this.
And after cutting we have to make sure both videos have the same frame number.
The best way is to write basic scripts to check it on VirtualDubMod:

Code:
DirectShowSource("C:\bloody\2D-cut.m2ts", fps=23.976, audio=false, convertfps=true)
info()


Image

Code:
DirectShowSource("C:\bloody\3D-cut.m2ts", fps=23.976, audio=false, convertfps=true)
info()


Image

And we should test both videos whether they were really synchronized: (I use GraphStudio to open both videos at the same time.)

Image


Or you may find more handy to see them as SBS on VirtualDubMod if they are 1920*1080. (just right click on the screen and select 50%.)
Or just open the same script with GraphStudio.

Code:
VidR = DirectShowSource("C:\bloody\test\2D.mkv", fps=23.976, audio=false, convertfps=true)
VidL = DirectShowSource("C:\bloody\test\3D.mkv", fps=23.976, audio=false, convertfps=true)

StackHorizontal(vidL, vidR)


Image




Now lets have a look at our parameter avs:

Step by step:

Code:
# Setup our input files
anaglyphName = "C:\bloody\3D-cut.m2ts" # Anaglyph video
PureColName = "C:\bloody\2D-cut.m2ts" # Video with color info (either Anaglyph or 2D)
monoName = "C:\bloody\2D-cut.m2ts" # Possible 2D video for one eye, if not set to "nothing
SoundName = "C:\bloody\2D-cut.m2ts" # Video with the sound track we want


Entered our input files...

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


How do we know whether the anaglyph is RC or GM?

Easy to understand:

RC:

Image

GM:

Image

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


Yes, this is the most critical point to be undestood very well since selecting the false view will be resulting with no stereoscopic video.
And how do we know 2D video is right or left?

Lets have a look before we decide.

Perspective look:

Left Angle:

Image


Right Angle:

Image

Left eye means what our left eye sees only when our right eye is closed and the reverse is true.

And compare what our left or right eyes see when the video is shot as right or left angle.

Hidden Stuff:

Quote:
Load up the anaglyph version in any media player and find a frame where there is a good 3D effect. Put on your anaglyph glasses. You'll notice that your right eye can "look around" the right edge of objects in the foreground and see parts of the background that are hidden from your left eye. Do the same thing with your left eye "looking around" the left edge of foreground objects. Remember what was hidden from one eye, but visible to the other eye.

Then load up the 2D version and seek to the same frame. You should be able to notice what is hidden behind the foreground object and compare this to the left and right anaglyph views that you previously observed. The 2D version should match either the left or right anaglyph view. Then you will know. from Tony




And finally the best way i found is to open both anaglyph and 2D videos at the same time with GraphStudio and to find which is matching to left or right. You may use the above script as well.

OK, here are some samples:

Image

Put your Red-Cyan glasses on and close your left and right eyes and find out what eye matches to 2D video?

When your right eye is closed down, you can see both videos (as red) matches to each other, right; which means 2D is left.
(have you noticed hidden stuff here?)




Image

Put your Green-Magenta glasses on and close your left and right eyes and find out what eye matches to 2D video?

When your left eye is closed down , you can see both videos (as magenta) matches to each other, right; which means 2d is right.
(have you noticed hidden stuff here?)




Resulting files just to compare:

Image


Image

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


It is normally "No"

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


I prefer SBS_Left_First.

Code:
# 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


I don't prefer resizing.

Code:
# 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


Normally you wouldn't need that; leave it as is.

Code:
# 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)
hueL = 0      # Left hue adjustment (-180.0 (greener) to +180.0 (redder) 0=none)

tweakBrightR = 0   # Right brightness, integer to add to each pixel (pixels are 0-255)
tweakContR = 1.2   # Right contrast adjustment
tweakSatR = 1.5      # Right saturation adjustment
hueR = 0      # Right hue adjustment


This is what you need to play with to get the best final video.
Trial and error. Remember:

Quote:
The best way is to use VirtualDubMod to change the parameter script and see immediately what has been changed. Hit F5 in the script editor to automatically save the script and reload it in VirtualDubMod, thus revealing the newly processed images


Code:
# 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.5
blurRight = 1.0


Leave it as is.

Code:
# Common code to do the conversion
# Make sure this file path points to
# the file on your system.

import("C:\bloody\AnaExtract.avs")


You must show the parameter avs where the main file is.

OK, we finished to input parameters and check whether it works on VirtualDubMod.


And the final stage: encoding.

I prefer to encode to 264 externally via x264.

I put all related files under one folder including x264.exe.

A very basic encoding code: (selecting the detailed encoding parameters is up to you.)

Code:
C:\bloody>x264 --fps 24000/1001 --level 4.1 --sar 1:1 -o test.264 XX-deana.avs


After remuxing to video and audio via TS Muxer or MKV MergeGui, now we are ready to watch this SBS video with Stereoscopic Player or TMT5 on our 3D ready hardware using shutter glasses.

Thanks for reading.


EDIT: Test files (raw) for whom interested in:

http://www.mediafire.com/?26ecy89v2cujhg7

http://www.mediafire.com/?mv2wqzq9y9h7w2d


_ _ _ _ __ _


Attachments:
AnaExtract.rar [2.94 KiB]
Downloaded 454 times
XX-DeAna.rar [3.34 KiB]
Downloaded 484 times


Last edited by rica on 24 Apr 2011, 10:46, edited 3 times in total.
 Profile  
 
 Post subject: Re: Anaglyph to true color SBS rendering
PostPosted: 22 Apr 2011, 01:21 

Joined:
22 Apr 2011, 00:48
Posts: 3
And this was the second post of mine:

Quote:
Quote:
Now i'm adding a general purpose AnaExtract.avs.
You may select DirectShowSource, FFVideoSource or DGSource on xx-deana.avs.

XX-DeAna.avs:

DG:
Code:
 
#   XX-DeAna.avs
#   Tone at VRtifacts.com
#   V 0.9   June 27, 2010
#       Modified by @rica April 6, 2011 (source options included and selectable)

# Select our input method (Source); DS (DirectShow Source), FF (FFVideo Source), DG (DGSource)
inputMethod = "DG"

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


DS or FF:
Code:
 inputMethod = "FF"

# Setup our input files
anaglyphName = "C:\bloody\3D-cut.mkv" # Anaglyph video
PureColName = "C:\bloody\2D-cut.mkv" # Video with color info (either Anaglyph or 2D)
monoName = "C:\bloody\2D-cut.mkv" # Possible 2D video for one eye, if not set to "nothing
SoundName = "C:\bloody\2D-cut.mkv" # Video with the sound track we want


You might need to add this line first to xx-deana.avs if you live memory issues when you select DirectShowSource: (while encoding.)

Code:
 SetMemoryMax (64)





Attachments:
AnaExtract_G.rar [1.71 KiB]
Downloaded 430 times
 Profile  
 
 Post subject: Re: Anaglyph to true color SBS rendering
PostPosted: 23 Apr 2011, 10:43 

Joined:
04 May 2010, 07:55
Posts: 108
This looks great.
Do you need any side L/R with you to work with it?
Or you can get L/R from any anaglyph movie?

Rahu


 Profile  
 
 Post subject: Re: Anaglyph to true color SBS rendering
PostPosted: 24 Apr 2011, 10:45 

Joined:
22 Apr 2011, 00:48
Posts: 3
You should have any L/R 2D true color copy of the video besides anaglyph one.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 2 hours


Who is online

Registered users: Bing [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron