All times are UTC + 2 hours



Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Encoding video to ColorCode anaglyph format?
PostPosted: 10 Aug 2010, 14:02 

Joined:
10 Aug 2010, 13:39
Posts: 7
Hi, I've encoded a 3d blu-ray to yellow and blue anaglyph using an avisynth script and Pantarheon. I wondered if any one knew of some tweaks to make it look a bit more like colorcode, or like stereoscopic player's yellow and blue optimizied? Or is there any other method, doesn't have to be avisynth. Thanks


 Profile  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 10 Aug 2010, 14:11 
Site Admin
User avatar

Joined:
29 Apr 2010, 17:51
Posts: 3148
Location: Sofia, Bulgaria
If you find a description on how videos are encoded for colorcode you might be able to implement that with an Avisynth script yourself. Have you also tried the official ColorCode editor software, there is a free demo available for download on their website: http://www.colorcode3d.com/Editor.html


 Profile WWW  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 10 Aug 2010, 14:28 

Joined:
10 Aug 2010, 13:39
Posts: 7
I've tried understanding how to do it and came across this http://www.tomtroceen.com/3d/super-bowl-intru3d-glasses-photoshop-tutorial-w-colorcode but I don't understand it and I hoped that maybe someone did understand it and came up with a good script. I've tried ColorCode Editor but I only managed to convert 1 image at a time. Do you know if there's a way of automatically converting a group of images? That would be perfect.


 Profile  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 11 Aug 2010, 00:03 

Joined:
31 Jul 2010, 06:33
Posts: 51
Anyone know how to de-anaglyph a colorcode video into seperate full color left and right frames like you can with red/cyan sources?

I want to get the Chuck 3D episode in full color 3D.


 Profile  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 11 Aug 2010, 11:25 

Joined:
10 Aug 2010, 13:39
Posts: 7
Has anybody tried this script for colorcode encoding? Found here: http://forum.doom9.org/showthread.php?t=155849&highlight=colorcode

Scroll down to: #################### OUTPUT TO GLASSES: #############################

Code:
################################################################
#                           2D to 3D CONVERSION 
#  Copyright (C) 2010   under GPL by    Branko Jermanis        <branko.jermanis@hi.hinet.hr>
#  My web pages: "Nikola Tesla and My Thoughts":   http://free-ri.htnet.hr/Branko/index.html
#
# This codes are based on 2d-to-3d-03b.avs script from Anton Belev at 3D Vision Blog (http://www.3dvision-blog.com),
# and some ideas from fauxD code from eslave,
# and Caleb Davis ideas with light depth detection codes,
# with indirect help of all that create this Avisynth language and useful plugin functions. Thanks to all...
# Tools that I use:
#  1.  Avisynth video scripting language
#  2.  AvsP script editor
#  3.  VirtualDub video editor (I use xvid compression for avi output)
#  4.  Media Player Classic
#  5. Download helper for Firefox browser (download from YouTube...)
#  6. WinFF convertor (flv to xvid conversion ...)
# For multimedia linux, I sugest Mint audio/video distribution:
# (I add real time kernel, JACK, Ardour, Hidrogen, Rosegarden... with M-Audio 1010LT sound card)
# Tip: press ESC for Grub, add gksudo in properties of icons, disable Timidity server on start and add starting line in JACK
#############

SetMTMode(4, 1)  # For multicore procesor (you need copy MT.dll and its avisynth.dll in .../windows/system32 directory)
# It can crash...
#Technical info from MT documentation:
#It contains the two new functions SetMTMode() and GetMTMode() and is needed by MT.dll.
#Install it by overwriting avisynth.dll in your c:\windows\system32 (and remember to take a backup of the old file first)
#On linux with Wine, I have with standard Avisynth version around 4 frame for second (Phenom II 4x)  without MT version (MT don't work on linux for me) with DVD quality (~480p)

LoadPlugin ("mvtools2.dll")   # Movement detector (some old version has problem with blksize=32)
# Input file ( minimum DVD: 480p video)
video=FFVideoSource("C:\Video031.mp4").ConvertToYV12
audio=FFAudioSource("C:\Video031.mp4")
fl = AudioDub(video,audio)

# Input on linux (it need Wine for VirtualDub, and disable DirectX in preference if you have black screen like me):
#fL = AVISource("Voyager-S1-10.avi").ConvertToYV12    # For linux input I use xvid avi format, because DirectShow don't work. With dvd-rip I transcode to xvid with 480p quality. Sometimes it need recompress XVID or 'normal recompress mode' conversion,  if 'full processing mode' don't work.

# Try to chose right bright, contrast and saturation for bad looking video:
#fL = Tweak(fL, bright=10, cont=1.25, sat=1.25, coring=false)       # Dark video correction ( disable this line if video look good, and is not dark)

W = width(fL)
H = height(fL)

fR = DeleteFrame(fL, 0)  # Set the right frame with one frame difference

# If W is less than 640, algorithm for light depth will not work good enough (integer number will eat pixels, because it depend of dW/2).
dW =  W / 128   # More depth perception, but little more artifact on details (it is usefull for me on 640x480 video)

fL = ConvertToRGB32(fL)   # Input in RGB, because of 'crop-even' problem with YV12 (on some movie)


######################    M O T I O N    D E P T H     D E T E C T I O N    ###############


## Motion mask:
super = MSuper(fR)
bvectors = MAnalyse(super, isb = true, blksize=32)  #  greatest blocksize, less problem with picture and best speed (I have been reported that on Vista 64 bit has error with 32 with some old version of mvtools2.dll).

m = MMask(fR, bvectors, kind=3, ml=1)
m = RGBAdjust(ConvertToRGB32(m),1,1,1,1,-127,-255,-255)
m1 = RGBAdjust(ShowRed(m), .5, .5, .5, 1,0,0,0,0,255,255,255,1).Invert

fR = ConvertToRGB32(fR)

# Replace moving object on frame with oposite movement from next frame (copy/paste from R to L):
m = Layer( fL, Mask(fR, m1) )
fL = Layer( fR, Mask(fL, m1) )
fR = m

# Posible improvement in this part of code :
# 1. Some detection when  camera  rotate around object create oposite Pulfrich effect, and then it need oposite switching left/right frames (rare condition)
# 2. With high speed vertical movement, frames are too different and create bad visual overlap, and it will be better switch off this cut/paste system


######################  LIGHTING    DEPTH    DETECTION   ( ideas from Caleb Davis code)  ####################

# On 0.5 version I replace Overlay with Layer function. It is faster function (2x)...

# Add more pixels for less than HD video resolution because quality and depth improvement (for HD can be disabled, because of speed):
W = 2*W
fL = LanczosResize(fL, W, H)
fR = LanczosResize(fR, W, H)

#Create L mask:
fG = Greyscale(fL)
m1 = RGBAdjust(fG, 1,1,1,1, -127,-255,-255)  # For light  scenes
m2 = RGBAdjust(fG, 1,1,1,1, -60,-255,-255)    # For dark scenes
m = ConditionalFilter(m1, m1, m2, "AverageLuma(fG.ConvertToYV12)", ">", "60")  # Switch light/dark scenes

m1 = RGBAdjust(ShowRed(m), .5, .5, .5, 1,0,0,0,0,255,255,255,1)
m2 = Layer(m1, Mask(m1, m1), x= -1*dW, op="add")       # Resize mask to left
m12 = Layer(m2, Mask(m1, m1), x= dW, op="add")          # Resize mask to right

fL = Layer(fL, Mask(fL, m12), x= dW/2)                  # move light part of picture to right on L frame (and remove borders too)
fL = Layer(fL, Mask(fL, m12.Invert), x= -1*dW/2)  # move dark part of picture to left on L frame

#Create R mask:
fG = Greyscale(fR)
m1 = RGBAdjust(fG, 1,1,1,1, -127,-255,-255)
m2 = RGBAdjust(fG, 1,1,1,1, -70,-255,-255)
m = ConditionalFilter(m1, m1, m2, "AverageLuma(fG.ConvertToYV12)", ">", "70")

m1 = RGBAdjust(ShowRed(m), .5, .5, .5, 1,0,0,0,0,255,255,255,1)
m2 = Layer(m1, Mask(m1, m1), x= -1*dW, op="add")       # Resize mask to left
m12 = Layer(m2, Mask(m1, m1), x= dW, op="add")          # Resize mask to right

fR = Layer(fR, Mask(fR, m12.Invert), x= dW/2)  # move dark part of picture to right on R frame
fR = Layer(fR, Mask(fR, m12), x= -1*dW/2)       # move light part of picture to left on R frame

# Going back to standard input Width (for HD can be disabled, because of speed):
W = W/2
fL = LanczosResize(fL, W, H)
fR = LanczosResize(fR, W, H)

# Posible improvement in this part of code :
# 1. Sometimes background is more white than foreground. Then it will be better if this is in reverse.

####################  OUTPUT TO GLASSES:  #############################


### UNIVERZAL FILE FORMAT OUTPUT (FOR ENCODING):
# If you need ColorCode format output from this file, you can use my YouTube3D.avs script to convert with VirtualDub
##side by side L/R
#return StackHorizontal(fL, fR)
##above below
#return StackVertical(fL, fR)
# Or found some standard format (Colorcode?) with some differences information (put around picture)...

### ColorCode, Intel InTrue3d ( brown/blue glasses for best color viewing with standard 60-70 Hz LCD monitors):
# Plastic glasses from xinan8888 (China) on eBay is 9 $ for 6 pair (I didn't try it yet, but look good. ColorCode plastic is around 40$ for 1 pair.)
# Improvement in blue color: Need less blue color  when blue is not part of other color ( R and/or G ).
# Example: blue sky with white clouds.

#fRa = MergeRGB(fR.ShowBlue, fR.ShowBlue, fR.ShowBlue)
#m = Subtract(fRa, Greyscale(fR)).Levels(220, 1, 222, 0, 255)  # Diference of blue and greyscale can extract just blue places
#fRb=RGBAdjust(fR, 1, 1, 1, 1, 0, 0, -50)     # Corection on blue intensity if blue is not part of other colors
#fR = Layer(fR, Mask(fRb, m))

# Mask for reducing yellow and blue ghosting:
#m1=RGBAdjust(Subtract(fL, fR), 1, 1, 1, 1, 0, 0, 0).Levels(200, 1, 202, 0, 255).Greyscale  # Yellow
#m2=RGBAdjust(Subtract(fL, fR).Invert, 1, 1, 1, 1, 0, 0, 0).Levels(200, 1, 202, 0, 255).Greyscale   # Blue

#fL=RGBAdjust(fL, 1, 1, 1, 1, 0, -10, -255) # Going down with all green color because of difference on amber filter
#fR=RGBAdjust(fR, 1, 1, 1, 1, -255, -255, 10) # Going up with all blue color because of dark blue filter
#fR = Greyscale(fR)

#out = MergeRGB(fL.ShowRed, fL.ShowGreen, fR.ShowBlue)   # Output before blue/yellow line intensity correction

#out1=RGBAdjust(out, 1, 1, 1, 1, -20, -20, 0).Levels(0, 1, 255, 30, 250)   # Correction inside yellow depth lines
#out2 = Layer(out, Mask(out1, m1))

#out3=RGBAdjust(out, 1, 1, 1, 1, 0, 0, -30).Levels(0, 1, 255, 0, 220)      # Correction inside blue depth lines
#out = Layer(out2, Mask(out3, m2))  # Main output after blue/yellow line intensity correction

# Posible improvement in this part of code :
# Need better filters for blue (green passing problem) and yellow (blue passing problem).
# I am optimize this code for card glasses. I wait for china plastic glasses, to see its filters.
# China glasses are come after 1 month of waiting. Nice look and feel, better transparancy, but little more ghosting. On version 0.75, I try to optimize it.
# On my 2Dto3D conversion look good, but with real 3D it has ghost problem with high depth part of scenes.
# Because of that ghosting, I reduce blue and yellow line intensity. Scenes in focus look good and for my low-level depth conversion this glasses are good enough.
# Solutions: maybe metalic filters on glass (like filters in Dolby glasses with 6 color) will improve this viewing system. But I can't find this 'perfect' filter glasses...

#return out

### Red-cyan glasses (because of red color problem, I don't use them):
fL = Greyscale(fL)
return MergeRGB(fL.ShowRed, fR.ShowGreen, fR.ShowBlue)


##################      TECHNOLOGICAL INFO:       #########################


### Good FPS conversion algorithm:
#super = MSuper(video)
#bvectors = MAnalyse(super, isb = true, blksize=4, chroma=true, truemotion=true, search = 3)
#fvectors = MAnalyse(super, isb = false, blksize=4, chroma=true, truemotion=true, search = 3 )
#video = MFlowFps(video, super, bvectors, fvectors, num=60, den=1)     # going to  60 fps


# Interesting setup:
# 1. DLP projector (ViewSonic 120Hz PJD6211 or better)
# 2. DLP-link active switching glasses without connection or emitters: XpanD X102
# 3. We need white LED emmiters (and electronic) for simulate this white flash from projector for possible using this kind of glasses on 120 Hz monitors.
# (white flash sync is when active glasses are in switching position, and both eyes are black)
# VirtualDub can open this script. Chose video-compress-xvid, and than Save as AVI, can create useful output file.
# You need lot of CPU power...
ConvertToYV12()


The only thing is it's for 2D to 3D conversion and I can't make sense of what i'm meant to comment out etc. What would be the exact script for a left and right input (left.m2ts and right.m2ts) for colorcode conversion based on this script? Appreciate if anyone could help :)


 Profile  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 11 Aug 2010, 13:40 
Site Admin
User avatar

Joined:
29 Apr 2010, 17:51
Posts: 3148
Location: Sofia, Bulgaria
You can probably use the code available here for colorcode output, however as I do not have a pair of colorcode glasses it is hard to tell how well it works... other than that you can use the left and right input and skip the processing part for the 2D to 3D conversion and feed the left and right frames directly to the colorcode output.


 Profile WWW  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 12 Aug 2010, 12:32 

Joined:
10 Aug 2010, 13:39
Posts: 7
I managed to work out how to use that code but a certain part of the code made the colours look horrible and the blue and yellow anaglyph effect dissapear. Instead, I used part of the code from here:

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


Full script locatd here: http://3dvision-blog.com/2d-to-3d-realtime-video-conversion-script-for-avisynth-v0-3/

But when i did that the anaglyph colours were red and cyan. So I used part of the code from the other script i posted:

Code:
#out = MergeRGB(fL.ShowRed, fL.ShowGreen, fR.ShowBlue)   # Output before blue/yellow line intensity correction


and it did turn out yellow and blue :) So here's my complete script.

Code:
LoadPlugin("H264StereoSource.dll")

f2 = DirectShowSource("left.m2ts").ConvertToRGB
f1 = H264StereoSource("decoder.cfg",2410).ConvertToRGB

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)

f1 = MergeRGB(f1.ShowBlue, f1.ShowBlue, f1.ShowBlue)
out = MergeRGB(f2.ShowRed, f2.ShowGreen, f1.ShowBlue)

return out

ConvertToYV12()


Does that look right? Do i need this line:

Code:
f1 = MergeRGB(f1.ShowBlue, f1.ShowBlue, f1.ShowBlue)


It looks good after conversion, the tweaks make it look better than basic yellow and blue.
I get a warning from x264: resize [warning]: converting from bgra to yuv420p, is that anything to worry about?

Thanks


 Profile  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 12 Aug 2010, 13:01 
Site Admin
User avatar

Joined:
29 Apr 2010, 17:51
Posts: 3148
Location: Sofia, Bulgaria
You don't need the line: f1 = MergeRGB(f1.ShowBlue, f1.ShowBlue, f1.ShowBlue)

Also what is the need to convert the output with: ConvertToYV12()


 Profile WWW  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 12 Aug 2010, 13:21 

Joined:
10 Aug 2010, 13:39
Posts: 7
Bloody wrote:
You don't need the line: f1 = MergeRGB(f1.ShowBlue, f1.ShowBlue, f1.ShowBlue)


Ok thanks :)

Bloody wrote:
Also what is the need to convert the output with: ConvertToYV12()


When i've opened the script into MEGUI it tell's me it needs to be YV12 and would I like to convert it to YV12. I opened it in MEGUI to see what it looks like, is this not neccasary if I use x264 with the command prompt?


 Profile  
 
 Post subject: Re: Encoding video to ColorCode anaglyph format?
PostPosted: 13 Aug 2010, 10:44 

Joined:
10 Aug 2010, 13:39
Posts: 7
I've altered my script and got rid of the "out =" part and "return out". MEGUI still tells me to convert to yv12 so I do but I don't get a warning anymore :D So for anyone looking to do the same thing as me you could try this, my final working script:

Code:
LoadPlugin("H264StereoSource.dll")

f2 = DirectShowSource("left.m2ts").ConvertToRGB
f1 = H264StereoSource("decoder.cfg",129312).ConvertToRGB

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, f2.ShowGreen, f1.ShowBlue)
ConvertToYV12()


H264StereoSource is a decoder for the right eye video on 3D blu-rays, it is needed because the right eye video uses MVP decoding, there's a guide for how to use it here: http://forum.doom9.org/showthread.php?t=155246 If you have a left and right video eg. "left.m2ts" & "right.m2ts", your script would be this:

Code:
f2 = DirectShowSource("left.m2ts").ConvertToRGB
f1 = DirectShowSource("right.m2ts").ConvertToRGB

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, f2.ShowGreen, f1.ShowBlue)
ConvertToYV12()


For side by side input you can create a left and right avs, crop the right half and save as "left.avs" then crop the left half and save as "right.avs", then your script would be this:

Code:
f2 = DirectShowSource("left.avs").ConvertToRGB
f1 = DirectShowSource("right.avs").ConvertToRGB

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, f2.ShowGreen, f1.ShowBlue)
ConvertToYV12()


From what I can tell, the tweaks make the image a bit brighter and adds a tiny bit more colour, there's probably other improvements aswel.


 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2, 3  Next

All times are UTC + 2 hours


Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [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: