View Single Post
Old 20th June 2005, 13:12   #57  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,837
there were a couple of different things that could cause trouble, color space, yv12 decoder, color depth and iirc even screen resolution. The functions taking care of it are:

Code:
		string GetFourCC(int value)
		{
			byte[] bytes = BitConverter.GetBytes(value);
			char[] chars = new char[4];
			
			for (int i = 0; i < bytes.Length; i++)
				chars[i] = Convert.ToChar(bytes[i]);
			
			return new String(chars);
		}
		
		public void Open(string fileName)
		{
			try
			{
				AVIFileInit();
				
				int OF_SHARE_DENY_WRITE = 32;
				
				int result = AVIFileOpen(ref AviFile, fileName,
					OF_SHARE_DENY_WRITE, 0);
				
				if (result != 0)
					throw new Exception("AVIFileOpen failed");
				
				result = AVIFileGetStream(AviFile, out AviStream,
					1935960438 /*FourCC for vids*/, 0);
				
				if (result != 0)
					throw new Exception("AVIFileGetStream failed");
				
				FrameCountValue = AVIStreamLength(AviStream.ToInt32());
				
				StreamInfo = new AVISTREAMINFO();
				
				result = AVIStreamInfo(AviStream.ToInt32(), ref StreamInfo,
					Marshal.SizeOf(StreamInfo));
				
				if (result != 0)
					throw new Exception("AVIStreamInfo failed");
				
				if (GetFourCC(Convert.ToInt32(StreamInfo.fccHandler)) == "YV12")
					FrameObject = AVIStreamGetFrameOpen(AviStream, 1);
				else
					FrameObject = AVIStreamGetFrameOpen(AviStream, 0);
				
				if (FrameObject == IntPtr.Zero) 
					throw new Exception("AVIStreamGetFrameOpen failed");
			}
			catch (Exception ex)
			{
				MessageBox.Show("An error occurred. Maybe no YV12 decoder available, installing XviD, DivX or ffdshow might help.\r\n\r\n" +
					ex.ToString(), Application.ProductName,
					MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
		}
Quote:
GetFrameOpen certainly seems to point to a decoder problem. And I'm wondering why the problem does not ocurr in VDub.. could it be that it's using homebrewn routines rather than standard VfW ones, at least for certain tasks?

I did some more reading and found this: http://www.gamedev.net/reference/pr...ifile/page4.asp Makes me think the conversion to 24bit could be the culprit. http://www.shrinkwrapvb.com/avihelp/avihlp_3.htmseems to confirm that converting to 24 bit can be problematic.
I don't know but you could ask Avery Lee

Last edited by stax76; 20th June 2005 at 13:17.
stax76 is offline   Reply With Quote