View Full Version : Convert File Format

June 18, 2007, 00:10:26

I want to convert the image format to YUV because currently it is not available in IC Imaging. I have APIs available which can convert the frame data to YUV format from any format. I also want to save the converted media file to the disk.

What is the best place and way to achieve these two purposes? I know that I can manipulate image data in frameReady() method by implementing callback but then how can I save it? because if sink type is MediaStreamSink, then I cannot implement callback.


Stefan Geissler
June 18, 2007, 09:43:00
Hello Steven,

You can create the frame handler sink with the eUYVY color format. If you are doing so, the frames you receive in the the frameReady() event are in this format. The available sink color formats are listed here:



m_pSink = DShowLib::FrameHandlerSink::create( DShowLib::eUYVY, 5 );

This video format covers two pixels. You may look here for the format:

You may also write these data to disc. If you write it as BMP file, then the YUV data stay and the image looks a little "psychedelic". If you would need other formats, you should use external libraries like OpenCV or CxImage.

June 18, 2007, 14:20:32
Hi Stefan,

Actually UYVY format is 4:2:2 and I want to convert it to 4:2:0. Also when I create sink as you specified (and I already tried), I receive exception

c:\csource\ic30\core\tisudshl\grabber.cpp(933) :
Exception Debug : Error = startLive failed.
VideoCaptureDevice = DFK 21F04
VideoFormat = UYVY (320x240)
In file : "c:\csource\ic30\core\tisudshl\grabberpimpl.cpp" at line : 580

Error = The sink could not be connected. This may occur if there is no intermediate filters available which can transform the source format to the destination format of the sink.
In file : "c:\csource\ic30\core\tisudshl\grabberpimpl.cpp" at line : 523

Error = Failed to connect the pins. Due to : No combination of intermediate filters could be found to make the connection.
In file : "c:\csource\ic30\core\dshowlib\filtergraph.cpp" at line : 390


But if I create sink with RGB format and later change video format in device settings dialog to UYVY, it works fine. Also I want to save the AVI file not BMP. Thats why combination of MediaStreamSink and Listener implementation does not work. Any suggestion?


Stefan Geissler
June 18, 2007, 15:04:44
Hello Steven,

First of all the AVI Capture and a Listener can not be used together.
Second: The OverlayBitmap must be disabled anyway, then the UYVY format can be used in the sink or for AVI Capture. If the codec wants an YUV format then DirectShow will try to find a matching colorspace transformation.

June 18, 2007, 15:22:37
Hi Stefan,

I have found the solution for saving file. I can save file by grabbing frames in frameReady method.

The problem remains the same even if OverlayBitmap is disabled. I cannot start my app with sink type UYVY.

Stefan Geissler
June 18, 2007, 15:57:32
Hi Steven,

You must disable the overlay bitmap with

m_Grabber.setOverlayBitmapPathPosition(DShowLib ::ePP_NONE);

Then you can use the eUYVY sink format.

June 18, 2007, 22:30:08
Thanks Stefan,

Is filter implementaion a good place to convert the format of image data and then to save it as a yuv file?

Stefan Geissler
June 19, 2007, 08:27:47
Hi Steven

Is filter implementaion a good place to convert the format of image data and then to save it as a yuv file?
Yes, I think so, because you can use the MemBuffer methods to handle these images after you have converted them.