Add ConvertToYV12() right after AviSource():
I couldn't reproduce that error message. But it looks like the debayer filter requires a mod 32 frame size (integer multiple of 32) to work properly. You would either have to add 24 or subtract 8 from the 392 pixel width with AddBorders(0,0,24,0) or Crop(0,0,-8,-0). If you AddBorders() you can crop that border away after debayering:AviSource("RGB.AVI")
ConvertToYV12()
FlipVertical()
FlipHorizontal()
DebayerFilter(swap=0)
FlipHorizontal()
Gavino mentioned this earlier in this thread:AviSource("Y800.avi") #392x288 video
ConvertToYV12() #if necessary
AddBorders(0,0,24,0)
FlipVertical()
FlipHorizontal()
DebayerFilter(swap=0)
FlipHorizontal()
Crop(0,0,-24,0)
You have to explicitly load the plugin at the start of the clip. Starting with his sample script:
The script for your Y800.AVI:LoadCPlugin("C:\Program Files\AviSynth 2.5\plugins\demosaic.dll")
ImageSource("image.jpg")
ConvertToYV12()
Demosaic(xoffset = 1, yoffset = 0, method = "bilinear")
RGBAdjust(r=1.0, g=1.1, b=1.8, a=1.0, rb=0.0, gb=0.0, bb=0.0, ab=0.0, rg=1.00, gg=1.00, bg=1.00, ag=1.00, analyze=false)
Bilinear or Nearest Neighbor is slightly inferior to what the DeBayer() filter does. On the other hand Demosaic() gives you the ability to specify where the subpixels are located and doesn't require mod 32 frame sizes. The color adjustment he does after debayering appears to be correct(ish) for his sample image but adds a very blue cast to your Y800 video. I disabled the color adjustment in the above script to match the colors DeBayer() is delivering.LoadCPlugin("C:\Program Files\AviSynth 2.5\plugins\demosaic.dll")
AviSource("Y800.avi")
Demosaic(xoffset = 1, yoffset = 1, method = "bilinear")
#RGBAdjust(r=1.0, g=1.1, b=1.8, a=1.0, rb=0.0, gb=0.0, bb=0.0, ab=0.0, rg=1.00, gg=1.00, bg=1.00, ag=1.00, analyze=false)
+ Reply to Thread
Results 31 to 41 of 41
-
Last edited by jagabo; 14th Feb 2011 at 07:15.
-
I don't think Crop(0,0,-8,-0) will work for this problem because by default Crop() leaves the pitch unchanged. You would need to use Crop(0,0,-8,-0, align=true).
Edit: In fact, to make it work with Crop you would have to crop off the left hand side (to change the starting alignment), as well as using align=true (to force a copy to a newly aligned frame):
Crop(8,0,0,0, align=true)
But as you say, AddBorders is a better approach anyway as (unlike a crop) it can be reversed after the debayering.Last edited by Gavino; 14th Feb 2011 at 12:15. Reason: more on Crop()
-
Gavino and Jugabo,
Thank you so much for all this information. It will take me a while to digest it and experiment, which I will!
In the meantime, and for the sake of completeness in this thread on Y800, 2 additional ways to DeBayer have emerged from discussions elsewhere.
1. There is an excellent DeBayering filter available for VirtualDub. http://www.inf.ethz.ch/personal/lballan/demo.html
Very simple to use and gives excellent results.
The VirtualDub plugin supposedly uses a very advanced algorithm (Demosaicing with Directional Filtering and a Posteriori Decision), see http://www.danielemenon.netsons.org/pub/dfapd/dfapd.php.
2. A new tool (stand alone) as part of a freeware astronomy image capture program called Firecapture: http://firecapture.wonderplanets.de/help/debayer.html
The Debayer Tool is located in the program folder. It's quite interesting in that it allows the selection of several different DeBayering methods. My experiments thus far are very favorable towards "AdaptiveSmoothHue." -
That's the same method mentioned by the author of the Avisynth DebayerFilter plugin (although it's not 100% clear that the final implementation uses it since there is no source code). Since one of the authors of the VirtualDub plugin (Daniele Menon) is also a co-author of the original algorithm, you can have more confidence in that implementation.
Note in passing that VirtualDub plugins can be used in an Avisynth script, using LoadVirtualDubPlugin(). -
Last edited by jagabo; 16th Feb 2011 at 07:23.
-
Revisiting this, does the issue of 'TV' v 'PC' levels come into play at any stage?
I presume the raw sensor output is 0-255 - is that what is recorded in the Y800 file?
When VirtualDub converts Y800 to RGB, does it assume the input is 16-235 (as it would for YUY2 or YV12), or does it treat it specially as 0-255?
The issue also arises when opening the Y800 file in Avisynth. If the source filter or codec delivers RGB, it is important that the conversion is done correctly. Similarly, any YUV<->RGB conversions in the script itself may need to be done with a 'PC' matrix rather than the default 'TV' one. -
As far as I can tell, yes. The sensor is RGB.
The "Y" plane is raw RGB values, not YUV luma. The Debayer filter simply fills in the holes.
But you're right, the ConvertToYV12() in the earlier AVS scripts might need to be changed to ConvertToYV12(matrix="PC.601") or ConvertToYV12(matrix="PC.709") to keep from compressing the contrast. I didn't notice how the AviSynth debayer filters handled the colorspace.Last edited by jagabo; 19th Feb 2011 at 08:03.
-
You and I know that, but does VirtualDub know?
I was referring to using VirtualDub to convert Y800 to RGB prior to Debayering:
This seems to be the method 201flyer used in the end to avoid problems opening Y800 in Avisynth.
Does this conversion conserve the full input range? -
It looks like you're right. Experimentally, VirtualDub is handling the Y800 data as Y and applying the usual rec.601 contrast expansion on conversion to RGB. AviSource("filename.avi", pixel_type="RGB32") doesn't apply the contrast expansion (although this may depend on the Y800 decoder that's being used).
Opening the Y800 AVI file directly in VirtualDub and debayering:
Using AviSource("y800.avi", pixel_type="RGB32") and debayering in VirtualDub:
Last edited by jagabo; 19th Feb 2011 at 08:51.
-
I was just asking a question - thanks for answering it.
Experimentally, VirtualDub is handling the Y800 data as Y and applying the usual rec.601 contrast expansion on conversion to RGB. AviSource("filename.avi", pixel_type="RGB32") doesn't apply the contrast expansion (although this may depend on the Y800 decoder that's being used).
Values in the range 16-235 would be expanded to 0-255 and those outside 16-235 would be lost (ie crushed to 16 or 235).
It seems the only correct way would be to open the Y800 file using AviSource with pixel_type="YV12" or "YUY2" (or another source filter which delivers YUV), which is what he had trouble getting to work.
Similar Threads
-
DebugMode frameserver output: RGB24, RGB32 or YUY2 ?
By codemaster in forum EditingReplies: 8Last Post: 6th Jan 2011, 13:09 -
Convert YUY2 to RGB
By jrivord in forum Video Streaming DownloadingReplies: 8Last Post: 19th Aug 2010, 10:21 -
YUY2 Codec for Quicktime?
By EZ-Fan in forum Software PlayingReplies: 1Last Post: 12th May 2009, 08:07 -
YUY2 Vs. UYVY Capture
By W_Eagle in forum Capturing and VCRReplies: 2Last Post: 11th Jul 2008, 10:15 -
Raw YUY2 to YV12 format?
By allyli2007 in forum ProgrammingReplies: 8Last Post: 2nd Jun 2007, 12:43