Friday, August 31, 2007

Directshow Things learnt from exp and thru newsgroup

Knowledge base :


1.what the IStreamBufferSink interface will do ?...
The IStreamBufferSink interface is exposed by the Stream Buffer Sink filter. Use this interface to lock the filter before capture and to create new recordings.

2.How to convert rgb24 to i420? Pls help me if you know. ?

RGB to YUV Conversion
Y = 0.299R + 0.587G + 0.114B
U = (B-Y)*0.565
V = (R-Y)*0.713
YUV to RGB Conversion
R = Y + 1.403V
G = Y - 0.344U - 0.714V
B = Y + 1.770U

3. I use directshow.net and pushfilter.
I connect pushfilter to videorenderer.
Same code works well when I use videoinfoheader. But if I chance it to
videoinfoheader2
(I need 16:9 flag for dv avi) filters does not connect. Fox. it connects to
smarttee but not to any renderer.
VideoInfoHeader2 format is not supported by the video Renderer.
we have to use Overlay Mixer for supporting VideoInfoHeader2 structure.
From Overlay Mixer onwards we have to connect it to the Video Renderer.

4. When I registered my mpeg decoder filter and use a third-party real-
time DV player software, the render windows becomes strange. The
decoded picture should be displayed limited in the fixed window, but
sometimes the picture becomes three the same picture as original, and
the center one lies the right position in the fixed window, the left
two arrange the left and the right.
what's wrong with my decode filter?

Decoder filter's Output image size is larger than the actual image size (output from the decoder)
So For the rest of the places, the directshow will copy more than one according to the window.



w can see the list of codecs installed in a system by doing following things :
1.Start ->Settings ->ControlPanel ->Sounds and Audio devices
2.Select hardware tab.
3.Select audio codecs and video codecs to see the list of codecs installed in a system


Pinnacle Directshow Filters :
C:\Program Files\Pinnacle\Shared Files\Filter\AllocatorAdaptor.ax
C:\Program Files\Pinnacle\Shared Files\Filter\AudioGrab.ax
C:\Program Files\Pinnacle\Shared Files\Filter\AudioResampler.ax
C:\Program Files\Pinnacle\Shared Files\Filter\AVI_PASS.ax
C:\Program Files\Pinnacle\Shared Files\Filter\axmpeg_av.ax
C:\Program Files\Pinnacle\Shared Files\Filter\axwavrender.ax
C:\Program Files\Pinnacle\Shared Files\Filter\ColorConvert.ax
C:\Program Files\Pinnacle\Shared Files\Filter\COMScript_Server5.dll -
C:\Program Files\Pinnacle\Shared Files\Filter\CSCSaFX.dll
C:\Program Files\Pinnacle\Shared Files\Filter\DeInterlace.ax
C:\Program Files\Pinnacle\Shared Files\Filter\DVDSampleSink.ax
C:\Program Files\Pinnacle\Shared Files\Filter\DWVideoResampler.ax
C:\Program Files\Pinnacle\Shared Files\Filter\ESink.ax
C:\Program Files\Pinnacle\Shared Files\Filter\ESinkAudio.ax
C:\Program Files\Pinnacle\Shared Files\Filter\FrameGrab.ax
C:\Program Files\Pinnacle\Shared Files\Filter\FrameNotify.ax
C:\Program Files\Pinnacle\Shared Files\Filter\iammixer2.dll
C:\Program Files\Pinnacle\Shared Files\Filter\MPADecoder.ax
C:\Program Files\Pinnacle\Shared Files\Filter\mpegdecoder2.dll
C:\Program Files\Pinnacle\Shared Files\Filter\MPEGEdit.ax
C:\Program Files\Pinnacle\Shared Files\Filter\mpegencoderlib.dll
C:\Program Files\Pinnacle\Shared Files\Filter\mpegrender.ax
C:\Program Files\Pinnacle\Shared Files\Filter\MPG1_2Decoder_Seekable.ax
C:\Program Files\Pinnacle\Shared Files\Filter\MSAudioRender.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PcleDatabase.dll
C:\Program Files\Pinnacle\Shared Files\Filter\pcledemux2.ax
C:\Program Files\Pinnacle\Shared Files\Filter\pcledemux4.ax
C:\Program Files\Pinnacle\Shared Files\Filter\pclediag.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PCLEDVBox.ax
C:\Program Files\Pinnacle\Shared Files\Filter\pcleDVcd.dll
C:\Program Files\Pinnacle\Shared Files\Filter\pcleDVdc.dll
C:\Program Files\Pinnacle\Shared Files\Filter\PCLEFileReader.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PCLEFileWriter.ax
C:\Program Files\Pinnacle\Shared Files\Filter\pcleIScl.dll
C:\Program Files\Pinnacle\Shared Files\Filter\PCLEMPADecoder.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PCLEMPAEncoder.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PcleMpegDec.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PCLEMPEGDemux4.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PcleMpegEnc.AX
C:\Program Files\Pinnacle\Shared Files\Filter\PcleMPGDemux.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PcleScriptInterface.dll
C:\Program Files\Pinnacle\Shared Files\Filter\PCLESync.ax
C:\Program Files\Pinnacle\Shared Files\Filter\pcleti4.dll
C:\Program Files\Pinnacle\Shared Files\Filter\pcleUtil.dll
C:\Program Files\Pinnacle\PCTV USB2\PCLEVideo25.ax
C:\Program Files\Pinnacle\Shared Files\Filter\pcle_ovr.ax
C:\Program Files\Pinnacle\Shared Files\Filter\pinftee.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PushSink.ax
C:\Program Files\Pinnacle\Shared Files\Filter\PushSource.ax
C:\Program Files\Pinnacle\Shared Files\Filter\RawDump.ax
C:\Program Files\Pinnacle\Shared Files\Filter\SaFireU.dll
C:\Program Files\Pinnacle\Shared Files\Filter\SampleScaler.ax
C:\Program Files\Pinnacle\Shared Files\Filter\server.exe
C:\Program Files\Pinnacle\Shared Files\Filter\SimpleSource.ax
C:\Program Files\Pinnacle\Shared Files\Filter\TimeshiftFileBox.ax
C:\Program Files\Pinnacle\Shared Files\Filter\VideoProvider.dll
C:\Program Files\Pinnacle\Shared Files\Filter\videoresampler2.ax
C:\Program Files\Pinnacle\Shared Files\Filter\wavtompa.ax
C:\Program Files\Pinnacle\Shared Files\Filter\wmvrenderer.ax
C:\Program Files\Pinnacle\Shared Files\Filter\XSync.ax
Video Codecs :
1.iccvid.dll - cinepak
2.ir32_32.dll -
3.iyuv_32.dll
4.msrle32.dll
5.msvidc32.dll
6.msyuv.dll


//Change the compressed data size then check whether the ICCompressGetFormat() fn...
//HEAP[SampleGrabberWithAVI.exe]: Invalid allocation size - FFFFFFFE (exceeded 7ffdefff) error...
Uncompressed data size : 230400
Cinepak compressed Data size :29700
Intel Indeo Video 3.2 compressed Data size :230400
IYUV codec compressed data size :230400
MRLE code compressed data size : 230400
Microsoft Video 1 compressed data size : 96002 or Bit count :16


AVI supported codecs with the AVI functions :
------------------------------------------------
1.Full Frames ( Uncompressed)
2.Cinepak
3.Intel Indeo Video 3.2
4.IYUV codec
5.Microsoft RLE
6.Microsoft Video 1
VCM compression codecs :
------------------------------
1.Cinepak
2.Microsoft Video 1
For all other codecs, it displays an error...

For Intel Indeo Video 3.2 ( IV32) , we may try with the ICImageCompress...

1.Use WriteAVI project, it supports more codecs...


C:\DXSDK\Samples\C++\DirectShow\BaseClasses\Debug_Unicode
"Writing specifications is like writing a novel. Writing code is like writing poetry."

Compilation of VC++ 6.0 with Directshow

I got this following error codes......already i put strmiids.lib and build the baseclasses after that add the strmbasd.lib in link tab (settings)...
c:\dxsdk\samples\c++\directshow\baseclasses\wxutil.h(530) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(437) : error C2504: 'IBasicVideo2' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2146: syntax error : missing ';' before identifier 'm_dwAdvise'
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\ctlutil.h(904) : error C2501: 'm_dwAdvise' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(286) : error C2061: syntax error : identifier 'LONG_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(951) : error C2504: 'IPinFlowControl' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(982) : error C2061: syntax error : identifier 'IGraphConfig'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2143: syntax error : missing ';' before '*'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2501: 'IGraphConfig' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1067) : error C2501: 'm_pGraphConfig' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1340) : error C2504: 'IMemAllocatorCallbackTemp' : base class undefined
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2143: syntax error : missing ';' before '*'
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2501: 'IMemAllocatorNotifyCallbackTemp' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1444) : error C2501: 'm_pNotify' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\amfilter.h(1506) : error C2061: syntax error : identifier 'IMemAllocatorNotifyCallbackTemp'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(68) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2146: syntax error : missing ';' before identifier 'm_dwAdvise'
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\renbase.h(78) : error C2501: 'm_dwAdvise' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\winctrl.h(103) : error C2061: syntax error : identifier 'LONG_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(24) : error C2146: syntax error : missing ';' before identifier 'AddAdvisePacket'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(24) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(26) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2146: syntax error : missing ';' before identifier 'm_dwAdviseCookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(47) : error C2501: 'm_dwAdviseCookie' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(85) : error C2146: syntax error : missing ';' before identifier 'Cookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(85) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(86) : warning C4183: 'Cookie': member function definition looks like a ctor, but name does not match enclosing class
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(96) : error C2146: syntax error : missing ';' before identifier 'm_dwNextCookie'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(96) : error C2501: 'm_dwNextCookie' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(102) : error C2146: syntax error : missing ';' before identifier 'AddAdvisePacket'
c:\dxsdk\samples\c++\directshow\baseclasses\dsschedule.h(102) : error C2501: 'DWORD_PTR' : missing storage-class or type specifiers
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(103) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(111) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\refclock.h(121) : error C2061: syntax error : identifier 'DWORD_PTR'
c:\dxsdk\samples\c++\directshow\baseclasses\sysclock.h(20) : error C2504: 'IAMClockAdjust' : base class undefined
fSnake.cpp


I got the Error like urs :

I did the following things :
1. open the Directshow baseclasses .dsw (which gives output as strmbasd.lib)file in an VC++6.0 and compiled it.
( Make sure whether the VC++ 6.0's compiled strmbasd.lib included in a directshow application)
2. Next I included this strmbasd.lib in Linker's Input option.
3. in Tools ->options->Include Files option,
Included the C:\DXSDK\Include directory in Tools ->options
after the inclusion of this directory also I got an error.
Solution :
I rearranged the directories order in an ascending order
Previously the Directory order is as follows :
C:\Program Files\ Visual studio \ lib
C:\DXSDK\Include
4.Add the C:\DXSDK\Lib directory in Tools->options ->Library Files
5.Now compiling the filter works well.

this gives the problem so I rearranged it in an ascending order as follows :
C:\DXSDK\Include
C:\Program Files\ Visual studio \ lib
4. Added the following directory in a Tools->options->Include Files option ( related to Directx);
C:\DXSDK\Include\DShowIDL

Tuesday, August 28, 2007

Modify the Grabber filter to work with Sample Grabber

I modified the grabber Directshow filter in MSDN sample.

This grabber is used in our WMINTF application.

The modification is as follows :

typedef HRESULT (*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged);

the above code is changed as follows :

typedef HRESULT (*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged,
void* pInstanceData);


MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F")
IGrabberSample : public IUnknown
{

public:



virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback) = 0;// this code is changed as follows :


virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;

}



class CSampleGrabber: public IGrabberSample
{
public:

HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback) = 0;// this code is changed as follows :

HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;
private:

// Newly added code...
void* m_pInstanceData;
};


SetCallback(SAMPLECALLBACK Callback,void* pInstanceData)
{
m_Callback = Callback;
m_pInstanceData = pInstanceData; //Newly added code
}

within the Grabber filter,

m_Callback( ) fn is called as follows :


HRESULT hr = m_callback( pms, &StartTime, &StopTime, *pTypeChanged); //I modified this code as follows :

HRESULT hr = m_callback( pms, &StartTime, &StopTime, *pTypeChanged,m_pInstanceData);

Afterwards I compiled the Grabber filter.

and copied the following code (Client's)grabber.h as follows:The user class argument is used...

Client must aware of the interface IGrabberSample .

This is done thru the client's grabber.h file.


class CGraph;
typedef HRESULT (CGraph::*SAMPLECALLBACK) (
IMediaSample * pSample,
REFERENCE_TIME * StartTime,
REFERENCE_TIME * StopTime,
BOOL TypeChanged,
void *pInstanceData);


// We define the interface the app can use to program us
MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F")
IGrabberSample : public IUnknown
{
public:

virtual HRESULT STDMETHODCALLTYPE SetAcceptedMediaType(
const AM_MEDIA_TYPE *pType) = 0;

virtual HRESULT STDMETHODCALLTYPE GetConnectedMediaType(
AM_MEDIA_TYPE *pType) = 0;

virtual HRESULT STDMETHODCALLTYPE SetCallback(
SAMPLECALLBACK Callback,void* pInstanceData) = 0;

virtual HRESULT STDMETHODCALLTYPE SetDeliveryBuffer(
ALLOCATOR_PROPERTIES props,
BYTE *pBuffer) = 0;
};

Monday, August 27, 2007

GUID Error

Error while using GUIDs :
-------------------------------------
I defined the guids using DEFINE_GUID() macro
and static const GUID identifier as a GUID variable...

Both of them give me an error at the CLSID .

For Example I used the CLSID_GrabberSample.

DEFINE_GUID(CLSID_GrabberSample,
0x2fa4f053, 0x6d60, 0x4cb0, 0x95, 0x3, 0x8e, 0x89, 0x23, 0x4f, 0x3f, 0x73);

During the reference of CLSID_GrabberSample , I got the unresolved symbol linker error in CLSID_GrabberSample.


I changed the GUID as follows :

static const GUID CLSID_GrabberSample = {0x2F, 0xA4,0xF0,0x53,0x6D,0x60,0x4C,0xB0,0x95,0x3,0x8E,0x89,0x23,0x4F,0x3F,0x73};

-Once again I got an error too many initializers for static const GUID...


Solution :
I included the "initguid.h" header file afterwards it is working fine.

Friday, August 24, 2007

BDL VideoQuality Filter Seeking problem

check whether the seeking is working with BDL video Quality Filter ?
How I fixed the problem in back ward Seeking ?...

Solution steps :

1 I Read Media time(Current Position) for the samples and added it to the ArrayList ...
2. From the List, Set the Seeking Position
3. Play the Filter graph again...
4. Then the Video is running, then the problem lies with setting proper media time
5. I Identified this problem, I have allocated the time boxinglimit( 7.15 pm to 8.10 pm)
6.Previously I set the media time somewhat truncated media time obtained from the Track Bar % value...


(and then use the IVideoFrameStep interface with the video Quality client, else the BDL video quality Filter is a problem)

Thursday, August 23, 2007

Video Softwares List

1.Windows Movie Maker
2.Avid Free DV
3.jahShaka

Video editing software is application software which handles the editing of video

sequences on a computer. It usually includes the ability to import and export video, cut

and paste sections of a video clip, and add special effects and transitions; and it

sometimes includes the ability to encode the video for creation of a DVD, Web video,

mobile phone video, or video podcast. Video editing software generally also allows for

some limited editing of the audio clips which accompany the video, or at least the ability

to sync the audio with the video.

Media100, Lightworks, Sony Vegas, Avid, Adobe Premiere, Ulead VideoStudio and

Apple's Final Cut Pro are pioneers in video editing software and have a great influence

on how films and TV programs are edited. These systems use custom hardware for

video processing.

Several other software programs can be classified in this category, including Microsoft's

Windows Movie Maker, iMovie, NERO 7 Ultra, GEAR Software's GEAR Video,

Pinnacle Systems' MediaSuite, muvee Technologies' muveeNow and autoProducer,

and Sherif.



Video Conversion Software :

DVD Ripper
FLV Converter
Moyea FLV to Video Converter

Windows :

1.Abobe Premiere Pro
2.Adobe Premiere elements
3.Avid Free DV
4.Avid Express DV
5.Avid Express Pro HD
6.Avid Liquid
7.Avid media composer
8.Cinrella
9.EDIUS Pro / EDIU Broadcast
10.Final Cut Express
11.Final Cut Studio
12.ForScene
13.iMovieHD
14.LiVES
15.MainActor
16.Pinnacle Studio Media Suite
17.Serif Movie Plus
18.Sony Vegas
19.Ulead Media Studio Pro
20,Ulead Video Studio plus
21.VCube
22.Video Edit Magic/ Express
23.Windows movie maker

http://en.wikipedia.org/wiki/Category:Free_video_software

Develop mws like filter

mws.RingBuffer.tlb
mws.servlet.tlb
mws.Icf
mwssource.ax - MWS Source Filter
mws.exe

How to make the media player to support new URL type like
mws://localhost:8080/NNS100_H


Process of playing the Custom File Format in a windows media player :

Here the new protocol or own file format is specified in mws.reg.

They also specify the Source Filter for the MWS in a registry.
So that whenever the user enters the mWS URL the windows media player
creates the Source Filter instance and passes the URL to the specified source Filter.


It is just the process of playing our own format on windows media player.

mws.reg file is as follows :

REGEDIT4

[HKEY_CLASSES_ROOT\mws]
@="MWS : Media WAN Server Protocol"
"EditFlags"=hex:02,00,00,00
"URL Protocol"=""
"Source Filter"="{0641BDB6-FBB3-446a-AFC5-C49F64B276B3}"

[HKEY_CLASSES_ROOT\mws\DefaultIcon]
@="c:\\Program Files\\Windows Media Player\\wmplayer.exe,0"

[HKEY_CLASSES_ROOT\mws\QuickView]
@="*"

[HKEY_CLASSES_ROOT\mws\Shell]
@=""

[HKEY_CLASSES_ROOT\mws\Shell\open]
"EditFlags"=hex:01,00,00,00

[HKEY_CLASSES_ROOT\mws\Shell\open\command]
@="C:\\Program Files\\Windows Media Player\\wmplayer.exe %1"


we can define our own network protocol or file writer...



Custom File Formats :

If you have a custom mux or file-writer filter that supports your own file format, you can specify the CLSID as the first parameter of the SetOutputFileName method:

IBaseFilter *pMux = 0;
IFileSinkFilter *pSink = 0;
hr = pBuild->SetOutputFileName(&CLSID_MyCustomMuxFilter,
L"C:\\VidCap.avi", &pMux, &pSink);

For more information about this usage, see ICaptureGraphBuilder2::SetOutputFileName.


mws registry entries:
--------------------------------
1.mws.client.MWSClient class
2.mws.DiskRingBuffer.DiskRingBuffer
3.mws.protocol.cmd
4.mws.protocol.PrmAVBufferingStatus
5.mws.protocol.PrmAVEndOfStream
6.mws.protocol.PrmBeginRead
7.mws.protocol.PrmCreateStream
8.mws.protocol.PrmDeleteStream
9.mws.protocol.PrmError
10.mws.protocol.PrmGetStreamInfos
11.mws.protocol.PrmUpdatableStreamInfos
12.mws.protocol.PrmUpdateDisplayStreamInfos
13.mws.protocol.RbFormatterBuilder
14.mws.protocol.TrackInfos
15.mws.protocol.MemRingBuffer
16.mws.protocol.RingBufferReplicator
17.mws.WmDateTime.WmDateTime

Quicktime components

QuickTime Core Components and APIs :
-------------------------------------------------------
'C:\Program Files\QuickTime\QTSystem\CoreVideo.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTime3GPP.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTime3GPPAuthoring.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTimeAudioSupport.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTimeAuthoring.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTimeCapture.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTimeEffects.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTimeEssentials.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeH264.qtx',
'C:\Program Files\QuickTime\QTSystem\QuickTimeImage.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeInternetExtras.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeMPEG.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeMPEG4.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeMPEG4Authoring.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeMusic.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeQD3D.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeStreaming.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeStreamingAuthoring.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeStreamingExtras.qtx'
'C:\Program Files\QuickTime\QTSystem\QuickTimeVR.qtx'

Develope the sample applications:

1.AVI writer with compressed stream...


http://www.jmcgowan.com/avi.html

Connect mechanism to Build the graph

using System;
using System.Collections.Generic;
using System.Text;

using System.Runtime.InteropServices;
using DirectShowLib;

namespace AddRendererFilter
{
class AddRendererFilter
{
private IGraphBuilder m_pGraphBuilder = null;
private IMediaControl m_pMediaControl = null;
private IMediaEventEx m_pMediaEventEx = null;

private IBaseFilter m_pSourceFilter = null;
private IBaseFilter m_pRendererFilter = null;



public AddRendererFilter()
{
m_pGraphBuilder = new FilterGraph() as IGraphBuilder;
}
~AddRendererFilter()
{
ReleaseGraph();
}

private void ReleaseGraph()
{
if (m_pGraphBuilder != null)
{
Marshal.ReleaseComObject(m_pGraphBuilder);
m_pGraphBuilder = null;
}
GC.Collect();
}

public void Render()
{
int hr = 0;

IPin pOutputPin = null;
IPin pInputPin = null;


hr = m_pGraphBuilder.AddSourceFilter("D:\\hands.avi", "Source Filter", out m_pSourceFilter);
DsError.ThrowExceptionForHR(hr);

hr = AddFilterByCLSID(ref m_pGraphBuilder, typeof(VideoRenderer), "Renderer Filter", out m_pRendererFilter);
DsError.ThrowExceptionForHR(hr);

pOutputPin = DsFindPin.ByDirection(m_pSourceFilter, PinDirection.Output, 0);
pInputPin = DsFindPin.ByDirection(m_pRendererFilter, PinDirection.Input, 0);

hr = m_pGraphBuilder.Connect(pOutputPin, pInputPin);
DsError.ThrowExceptionForHR(hr);

m_pMediaControl = m_pGraphBuilder as IMediaControl;
m_pMediaControl.Run();

}

private int AddFilterByCLSID(ref IGraphBuilder pGraph,
Type comType,
string FilterName,
out IBaseFilter pFilter
)
{
Object comObject = null;
int hr = 0;
try
{
comObject = Activator.CreateInstance(comType);
if (comObject == null)
{
throw new NotSupportedException("\n Invalid Class Id Type");
}
pFilter = comObject as IBaseFilter;
hr = m_pGraphBuilder.AddFilter(pFilter, FilterName);
DsError.ThrowExceptionForHR(hr);
return hr;
}
catch (Exception ex)
{
pFilter = null;
return -1;
}
}
}
}

client Usage :
---------------------
AddRendererFilter m_pAddRendererFilter = null;
m_pAddRendererFilter = new AddRendererFilter();
m_pAddRendererFilter.Render();

RenderFile method Directshow_C#

Render File with C# with Directshow Sample application :



using System;
using System.Collections.Generic;
using System.Text;

using System.Runtime.InteropServices;
using DirectShowLib;

namespace PlayWnd
{
internal enum PlayState
{
Stopped,
Paused,
Running,
Init
};

internal enum MediaType
{
Audio,
Video
}


class PlayWnd
{
private const int WMGraphNotify = 0x0400 + 13;

private IGraphBuilder m_pGraphBuilder = null;
private IMediaControl m_pMediaControl = null;
private IMediaEventEx m_pMediaEventEx = null;
private IMediaSeeking m_pMediaSeeking = null;
private IVideoWindow m_pVideoWindow = null;


public PlayWnd()
{
m_pGraphBuilder = (IGraphBuilder) new FilterGraph();
m_pMediaControl = (IMediaControl) m_pGraphBuilder;
m_pMediaEventEx = (IMediaEventEx) m_pGraphBuilder;
m_pMediaSeeking = (IMediaSeeking) m_pGraphBuilder;

}
~PlayWnd()
{
CloseInterfaces();
}

public int RenderFile(IntPtr handle,string filename)
{
int hr = 0;
hr = m_pGraphBuilder.RenderFile(filename,null);
DsError.ThrowExceptionForHR(hr);
m_pVideoWindow = m_pGraphBuilder as IVideoWindow;
hr = m_pMediaEventEx.SetNotifyWindow(handle, WMGraphNotify, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);

return 0;
}

public void Start()
{
int hr = 0;
hr = m_pMediaControl.Run();
DsError.ThrowExceptionForHR(hr);
}
public void Pause()
{
int hr = 0;
hr = m_pMediaControl.Pause();
DsError.ThrowExceptionForHR(hr);
}
public void Stop()
{
int hr = 0;
hr = m_pMediaControl.Stop();
DsError.ThrowExceptionForHR(hr);
}

public void SetWindowPosition(IntPtr hwnd,int x, int y, int width, int height)
{
int hr = 0;
if (m_pVideoWindow != null)
{
hr = m_pVideoWindow.SetWindowPosition(
x,
y,
width,
height
);
DsError.ThrowExceptionForHR(hr);
}
hr = m_pVideoWindow.put_Owner(hwnd);
DsError.ThrowExceptionForHR(hr);

hr = m_pVideoWindow.put_WindowStyle(WindowStyle.Child |

WindowStyle.ClipSiblings | WindowStyle.ClipChildren);
DsError.ThrowExceptionForHR(hr);

hr = m_pVideoWindow.put_Visible(OABool.True);
DsError.ThrowExceptionForHR(hr);


}

public void CloseInterfaces()
{
int hr = 0;
try
{
lock (this)
{
hr = this.m_pVideoWindow.put_Visible(OABool.False);
DsError.ThrowExceptionForHR(hr);
hr = this.m_pVideoWindow.put_Owner(IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);

if (m_pMediaEventEx != null)
{
hr = m_pMediaEventEx.SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero);
DsError.ThrowExceptionForHR(hr);
}

if (m_pMediaControl != null)
{
m_pMediaControl = null;
}
if (m_pMediaSeeking != null)
{
m_pMediaSeeking = null;
}
if (m_pVideoWindow != null)
{
m_pVideoWindow = null;
}

if (m_pGraphBuilder != null)
{
Marshal.ReleaseComObject(m_pGraphBuilder);
m_pGraphBuilder = null;
}
GC.Collect();
}


}
catch
{
}
}

}
}


Client Usage :
-----------------------
PlayWnd m_pPlayWnd = null;

void btnRender_Click()
{
m_pPlayWnd.RenderFile(pnlVideo.Handle, "D:\\hands.avi");
m_pPlayWnd.SetWindowPosition(pnlVideo.Handle, 0, 0,

pnlVideo.Width, pnlVideo.Height);
}


private void btnStart_Click(object sender, EventArgs e)
{
m_pPlayWnd.Start();
}

private void btnPause_Click(object sender, EventArgs e)
{
m_pPlayWnd.Pause();
}

private void btnStop_Click(object sender, EventArgs e)
{
m_pPlayWnd.Stop();
}

Render method

we have to add Directshow.net as a reference.
( download it from sourceforge.net)

Render Method Sample application in C# with directshow :
--------------------------------------------------------------------------------------

using System.Runtime.InteropServices;
using DirectShowLib;

namespace RenderMethod
{
class RenderMethod
{
private IGraphBuilder m_pGraphBuilder = null;
private IMediaControl m_pMediaControl = null;
private IMediaEventEx m_pMediaEventEx = null;
private IMediaSeeking m_pMediaSeeking = null;

private IBaseFilter m_pSourceFilter = null;
private IPin m_pOutputPin = null;


public RenderMethod()
{
m_pGraphBuilder = (IGraphBuilder)new FilterGraph();
}

~RenderMethod()
{
CloseInterfaces();
}

public int AddSourceFilter(string sourceFilename)
{
int hr = 0;

if (m_pGraphBuilder == null)
{
return DsResults.E_CannotRender;
}

hr = m_pGraphBuilder.AddSourceFilter(sourceFilename, sourceFilename, out m_pSourceFilter);
DsError.ThrowExceptionForHR(hr);
return hr;

}
public int Render()
{
int hr = 0;
m_pOutputPin = DsFindPin.ByDirection(m_pSourceFilter, PinDirection.Output, 0);
hr = m_pGraphBuilder.Render(m_pOutputPin);
DsError.ThrowExceptionForHR(hr);

m_pMediaControl = m_pGraphBuilder as IMediaControl;
m_pMediaEventEx = m_pGraphBuilder as IMediaEventEx;
m_pMediaSeeking = m_pGraphBuilder as IMediaSeeking;


hr = m_pMediaControl.Run();
DsError.ThrowExceptionForHR(hr);
return hr;
}

private void CloseInterfaces()
{
if (m_pGraphBuilder != null)
{
Marshal.ReleaseComObject(m_pGraphBuilder);
}
GC.Collect();
}

}
}


Client Usage of a class :

RenderMethod renderMethod = null;
renderMethod.AddSourceFilter("D:\\hands.avi");
renderMethod.Render();

Microsft supported video codecs with FourCC

http://wiki.multimedia.cx/index.php?title=Main_Page


Registered FOURCCs
FOURCCs are registered with Microsoft by the vendors of the respective multimedia software technologies. The currently registered FOURCCs appear in the following list.
FourCC Description
ANIM Intel - RDX
AUR2 AuraVision - Aura 2 Codec - YUV 422
AURA AuraVision - Aura 1 Codec - YUV 411
BT20 Brooktree - MediaStream codec
BTCV Brooktree - Composite Video codec
CC12 Intel - YUV12 codec
CDVC Canopus - DV codec
CHAM Winnov, Inc. - MM_WINNOV_CAVIARA_CHAMPAGNE
CPLA Weitek - 4:2:0 YUV Planar
CVID Supermac - Cinepak
CWLT reserved
DUCK Duck Corp. - TrueMotion 1.0
DVE2 InSoft - DVE-2 Videoconferencing codec
DXT1 reserved
DXT2 reserved
DXT3 reserved
DXT4 reserved
DXT5 reserved
DXTC DirectX Texture Compression
FLJP D-Vision - Field Encoded Motion JPEG With LSI Bitstream Format
GWLT reserved
H260 Intel - Conferencing codec
H261 Intel - Conferencing codec
H262 Intel - Conferencing codec
H263 Intel - Conferencing codec
H264 Intel - Conferencing codec
H265 Intel - Conferencing codec
H266 Intel - Conferencing codec
H267 Intel - Conferencing codec
H268 Intel - Conferencing codec
H269 Intel - Conferencing codec
I263 Intel - I263
I420 Intel - Indeo 4 codec
IAN Intel - RDX
ICLB InSoft - CellB Videoconferencing codec
ILVC Intel - Layered Video
ILVR ITU-T - H.263+ compression standard
IRAW Intel - YUV uncompressed
IV30 Intel - Indeo Video 3 codec
IV31 Intel - Indeo Video 3.1 codec
IV32 Intel - Indeo Video 3 codec
IV33 Intel - Indeo Video 3 codec
IV34 Intel - Indeo Video 3 codec
IV35 Intel - Indeo Video 3 codec
IV36 Intel - Indeo Video 3 codec
IV37 Intel - Indeo Video 3 codec
IV38 Intel - Indeo Video 3 codec
IV39 Intel - Indeo Video 3 codec
IV40 Intel - Indeo Video 4 codec
IV41 Intel - Indeo Video 4 codec
IV42 Intel - Indeo Video 4 codec
IV43 Intel - Indeo Video 4 codec
IV44 Intel - Indeo Video 4 codec
IV45 Intel - Indeo Video 4 codec
IV46 Intel - Indeo Video 4 codec
IV47 Intel - Indeo Video 4 codec
IV48 Intel - Indeo Video 4 codec
IV49 Intel - Indeo Video 4 codec
IV50 Intel - Indeo 5.0
MP42 Microsoft - MPEG-4 Video Codec V2
MPEG Chromatic - MPEG 1 Video I Frame
MRCA FAST Multimedia - Mrcodec
MRLE Microsoft - Run Length Encoding
MSVC Microsoft - Video 1
NTN1 Nogatech - Video Compression 1
qpeq Q-Team - QPEG 1.1 Format video codec
RGBT Computer Concepts - 32 bit support
RT21 Intel - Indeo 2.1 codec
RVX Intel - RDX
SDCC Sun Communications - Digital Camera Codec
SFMC Crystal Net - SFM Codec
SMSC Radius - proprietary
SMSD Radius - proprietary
SPLC Splash Studios - ACM audio codec
SQZ2 Microsoft - VXtreme Video Codec V2
SV10 Sorenson - Video R1
TLMS TeraLogic - Motion Intraframe Codec
TLST TeraLogic - Motion Intraframe Codec
TM20 Duck Corp. - TrueMotion 2.0
TMIC TeraLogic - Motion Intraframe Codec
TMOT Horizons Technology - TrueMotion Video Compression Algorithm
TR20 Duck Corp. - TrueMotion RT 2.0
V422 Vitec Multimedia - 24 bit YUV 4:2:2 format (CCIR 601). For this format, 2 consecutive pixels are represented by a 32 bit (4 byte) Y1UY2V color value.
V655 Vitec Multimedia - 16 bit YUV 4:2:2 format.
VCR1 ATI - VCR 1.0
VIVO Vivo - H.263 Video Codec
VIXL Miro Computer Products AG - for use with the Miro line of capture cards.
VLV1 Videologic - VLCAP.DRV
WBVC Winbond Electronics - W9960
XLV0 NetXL, Inc. - XL Video Decoder
YC12 Intel - YUV12 codec
YUV8 Winnov, Inc. - MM_WINNOV_CAVIAR_YUV8
YUV9 Intel - YUV9
YUYV Canopus - YUYV compressor
ZPEG Metheus - Video Zipper

The following list shows the FOURCC values for DIB compression.
FourCC Description
CYUV Creative Labs, Inc - Creative Labs YUV
FVF1 Iterated Systems, Inc. - Fractal Video Frame
IF09 Intel - Intel Intermediate YUV9
JPEG Microsoft - Still Image JPEG DIB
MJPG Microsoft - Motion JPEG DIB Format
PHMO IBM - Photomotion
ULTI IBM - Ultimotion
VDCT Vitec Multimedia - Video Maker Pro DIB
VIDS Vitec Multimedia - YUV 4:2:2 CCIR 601 for V422
YU92 Intel - YUV


Registering a FOURCC Code

Registering codes with Microsoft prevents needless duplication of work and helps development of standards. To register a FOURCC code, send e-mail to mmreg@microsoft.com. Please include your name, title, company name, and phone and fax numbers.

Use this e-mail address to register the following:

• Manufacturer IDs. Manufacturer IDs are unique IDs used on device drivers to identify the vendor for the driver. The driver vendor is usually also the hardware vendor.
Example Manufacturer ID: MM_ACME


• Product IDs. Product IDs are used to identify which specific device from a manufacturer is being used. For example, Microsoft has written drivers for the MIDI mapper and the WAVE mapper. Each of these has the (same) Microsoft Manufacturer ID and a unique Product ID. Product IDs and Product Names are assigned by the manufacturer.
The names must be unique; using your company name followed by the product name is suggested. For example, if the Acme Company wanted to register the Super Audio card, which has a synthesizer, MIDI I/O ports, and waveform I/O, appropriate names would be:

MM_ACME_SASYNTH
MM_ACME_SAMIDIIN
MM_ACME_SAMIDIOUT
MM_ACME_SAWAVEIN
MM_ACME_SAWAVEOUT



• Installable Compressor ID. The Installable Compressor interface requires the driver to uniquely identify itself with a FOURCC. In the AVI file, this is stored in the stream header chunk element fccHandler. Please consult the Microsoft DirectShow SDK, available through MSDN Professional subscription, for more information.

The FOURCC should be used to identify state data belonging to the driver. All codecs should use the following convention for defining their state information structure:

typedef struct _stateinfo { FOURCC fcc; .... } STATEINFO;
Then, when the state info in a SET_STATE_INFO message is received, you should check the FOURCC to verify that it has state information for the driver.




FOURCC Data Formats :

Data formats for FOURCC include: RBG, YUV, and compressed formats. RGB describes the colors produced by emitting light, such as on a video monitor. YUV formats can be either packed or planar. In packed YUV formats, Y, U, and V samples are packed together in macropixels and stored in a single array. Planar formats store each component in a separate array and then fuse the three separate planes to create the final image.

Tables of formats are available at the following sites:
YUV formats - http://www.webartz.com/fourcc/indexyuv.htm
RGB formats - http://www.webartz.com/fourcc/indexrgb.htm
Compressed formats - http://www.webartz.com/fourcc/indexcod.htm

Monday, August 20, 2007

COM interface and .NET interoperability



VC++ COM interface in a DLL :

-------------------------------

interface IModuleConfig

{

HRESULT SetValue(

const GUID* pParamID, VARIANT* pValue);

};

DLL component Id is

9C9A2859-C76B-4205-A52A-3ADBA54458B7.

DLL component implements this interface...

 

C# code :

I created the instance for the DLL component as follows :

[

ComImport, Guid ("9C9A2859-C76B-4205-A52A-3ADBA54458B7")]

public class DLLComponent

{

}

 

This is like defining the CLSID in VC++...

 

How to create an instance for the specified Guid ?

 

Type t = typeof(DLLComponent);

DLLComponent dllComponent;

dllComponent = Activator.CreateInstance(t);

 

 

How to Query the interface from the DLL component Instance ?

IModuleConfig config = null;

config = dllComponent as IModuleConfig;

or

config = (IModuleConfig) dllComponent;

But we have to declare the IModuleConfig interface in the C# as follows ;

[

ComImport, System.Security.SuppressUnmanagedCodeSecurity ,

Guid("486F726E-4D43-49b9-8A0C-C22A2B0524E8" ),

InterfaceType(ComInterfaceType .InterfaceIsIUnknown)]

public interface IModuleConfig

{

[PreserveSig]

int SetValue([In , MarshalAs(UnmanagedType .LPStruct)]Guid guid, ref Object obj);

}

Afterwards we can call the interface method using its object with dot operator...

IModuleConfig config = null;

config = dllComponent as IModuleConfig;

config.SetValue(guid, ref obj);

 

Now it is working well.

Wrong code:

==============

Previously I defined the C# interface as follows :

[

ComImport, System.Security.SuppressUnmanagedCodeSecurity ,

Guid("486F726E-4D43-49b9-8A0C-C22A2B0524E8" ),

InterfaceType(ComInterfaceType .InterfaceIsIUnknown)]

public interface IModuleConfig

{

[PreserveSig]

int SetValue([In , MarshalAs(UnmanagedType .LPStruct)]Guid guid,[In , MarshalAs(UnmanagedType .AsAny) ref Object obj);

}

I got the exception as follows, we can't use the "UnmanagedType

.AsAny" ref types and Array with offset parameters.

  I thank verymuch to muthu pandi anna for helping me to solve this problem.

 
For VARIANT* we have to use the ref type.

 

Thursday, August 09, 2007

List of Video streaming formats

Daily work with

1. WMINTF // for Directshow
2.NNSMediaWan demo ( C# with Directshow)
3.Quicktime (Sample application, Read documents );

download QuickTime SDK and install it in my system.

QuickTime supported codecs :
--------------------------------------------
Audio
1.Apple Lossless
2.Audio Interchange (AIFF)
3.Digital Audio: Audio CD - 16-bit (CDDA), 24-bit, 32-bit integer & floating point, and 64-bit floating point
4.MIDI
5.MPEG-1 Layer 3 Audio (.mp3)
6.MPEG-4 AAC Audio (.m4a, .m4b, .m4p)
7.QDesign Music
8.Qualcomm PureVoice (QCELP)
9.Sun AU Audio
10.ULAW and ALAW Audio
11.Waveform Audio (WAV)

Video
1.3GPP & 3GPP2 file formats
2.AVI file format
3.Bitmap (BMP) codec and file format
4.DV file (DV NTSC/PAL and DVC Pro NTSC/PAL codecs)
5.Flash & FlashPix files
6.GIF and Animated GIF files
7.H.261, H.263, and H.264 codecs
8.JPEG, Photo JPEG, and JPEG-2000 codecs and file formats
9.MPEG-1, MPEG-2, and MPEG-4 Video file formats and associated codecs (such as AVC)
10.Quartz Composer Composition (.qtz, Mac OS X only)
11.QuickTime Movie (.mov) and QTVR movies
12.Sorenson Video 2 and 3 codecs
13.Other video codecs: Apple Video, Cinepak, Component Video, Graphics, and Planar RGB
14.Other still image formats: PNG, TIFF, and TGA
15.Cached information from streams: QTCH
Other file formats that QuickTime supports natively (to varying degrees) include
1.AIFF,
2.WAV,
3.DV,
4.MP3, and
5.MPEG-1.

With additional QuickTime Extensions, it can also support
1.Ogg,
2.ASF,
3.FLV,
4.MKV,
5.DivX Media Format, and others.




Video Compression Formats:
--------------------------------------------------------------------------------
1.MJPEG
2. MPEG-1
3. MPEG-2
4. MPEG-4 ASP
5. MPEG-4/AVC
6.H.261
7. H.262
8. H.263
9. H.264
10.AVS
11. Bink
12. Dirac
13. Indeo
14.MJPEG
15. RealVideo
16.Theora
17. VC-1
18. VP6
19. VP7
20. WMV
Audio Compression Formats :
-----------------------------------------
1.MPEG-1 Layer III (MP3)
2. MPEG-1 Layer II
3. MPEG-1 Layer I
4. AAC
5. HE-AAC
6. HE-AAC v2
7. aacPlus v2 ITU-T
8.G.711
9.G.722
10. G.722.1
11. G.722.2
12. G.723
13. G.723.1
14 G.726
15. G.728
16. G.729
17. G.729.1
18. G.729a Others
19.AC3
20. Apple Lossless
21. ATRAC
22. FLAC ·
23.iLBC ·
24.Monkey's Audio
25. Musepack
26.Nellymoser
27.RealAudio
28. SHN
29. Speex
30. Vorbis
31. WavPack
32. WMA
33.TAK


Image compression formats :
1.JPEG
2. JPEG 2000
3. lossless JPEG
4. JBIG
5. JBIG2
6. PNG
7. WBMP Others
8.APNG
9. ICER
10. MNG
11. BMP
12. GIF
13. ILBM
14.PCX
15. PGF
16. TGA
17. TIFF
18. HD Photo

Media container formats :
1.3GP
2.ASF
3.AVI
4.DMF
5.DPX
6.FLV
7.Matroska
8.MP4
9. MXF
10.NUT
11.Ogg
12.Ogg Media
13.QuickTime
14.RealMedia
15.VOB Audio only
16.AIFF
17.AU
18.WAV





1.Directshow
2.Windows CE
3.QuickTime
4.C#
5.VC++

QuickTime Softwares :
1.Final Cut Express HD
2.Logic Express
3.iLife
4.FxFactory 1.0.7
5.Final Cut Studio



QuickTime technologies :
1.AAC audio
2.MPEG-4
3.Streaming
4.Quicktime VR
5.Effects
6.QD3D Tools
QuickTime Topics :
1.Audio
2.Carbon
3.Cocoa
4.Compression and decompression
5.File Format specification
6.Import and Export
7.Media Types and Media handlers
8.Movie basics
9.Movie Creation
10.Movie internals
11.Quicktime Component creation
12.Quicktime for windows
13.streaming
14.Virtual Reality

we can develope Quicktime application in two ways :
1.Use raw Quicktime
2. use Quicktime with Directshow

Tuesday, August 07, 2007

What I have done so far in my company ( 1.5 years)

Incomplete :
1.MWS to ASF writing problem
2.QT audio Encoding
3.merge Frames Filter ( First Image is displayedbut the successing images are not displayed from the videos )
4.Registry support to DirectX transform Filters
5.Make VideoQualityClient to support YUV formats and make channel selection for performing video quality processing
6.Enable the support of audio codecs in WMINTF ( Ring Buffer returns NULL for audio codecs after the some repeated execution )





Completed :
1.Sample Grabber application developement
2.Sample grabber application with Quicktime video (frame by frame)compression
3.Sample Grabber application with Quicktime temporal video compression
4.QTEncoder class
5.MovieWriter class
6.Null Encoder class
7.Encoder Queue developement for storing the encoded frames in Temporal compression
8.Integrated the QTvideo Encoder class with wmintf...
9.Video board sample application with MainCodec H264 API's
10.Developed the COM wrapper for CEncoder class ( Due to aggregation problem, we stopped the COM wrapper developement for all the encoders)
11. AVi Writer with windows supported codecs
12.AVI writer with Main codec H264 API compression
13.Integrated AVi Writer with WMINTF( uncompressed data is compressed with H264 APIs But we are not added the header to the AVI file. Bala told us that he completed it. But he didnt send it to us yet)

14.Converted the Graphics Object to Win32 Device context for improving IdxGraphApp
15.IdxGraphApp integration to the WMINTF

16.DVB ( DiskRouter)Api application developement (we tested the sample application ...) due to invalid key we give up this development

17. Created the new Catgory "BDL Image processing" for storing the Filters under this category
18.Conversion of NNSTestAgent application as a service
19.NNSTestAgent application developement
20.RemoteServiceController DLL development for NNSTestAgent application
21. HTTP Monitor graph developement and the development of container to hold the list of graph objects
22.Video Quality client application

Directshow Filters Developed :

All the filters have the histogram support.
Filters use OpenCV 1.0 or Gdi+ .

1.Overlay Transform Filter - Overlay text on line path.
2.Zoom Filter
3.Add the Filters with IModuleConfig for setting the Config information
4.RGB Scaling
5.Resize Filter
6.Color To Gray Filter
7.Bitmap Overlay Filter
8.Timecode Burning Filter
9.Blur Filter ( guassian , Pyramid blur) , Blur Effect on line path
10.ChannelBlur
11.ColorBalanceRGB Filter
12.Mirror Filter
13.Morphology Filter
14.Inverse Filter
15.ShiftChannels Filter
16.GammaCorrection Filter
17.Emboss Filter (Emboss Filter implements following techniques :Edge Detect quick, Emboss135 degree, Emboss 90_50, Emboss laplasian, sharpen and Mean removal)
18.Tiles Filter
19.Rotation Filter
20.Mask Filter ( rectangle mask ,Circle and Ellipse mask supported)
21.Rotate 90 Filter ( 90,180,270 degree rotations are supported)
22.Sepia Filter
23.Vortex Filter
24.Water Filter
25.Brightness Filter
26.Random Jitter filter
27.Swirl
28.Sphere
29.Timewarp
30.Pixellate Filter
31.Posterize Filter
32.Threshold
33.Solarize Filter
34.Saturation Filter
35.Hue Filter
36.Luminance Filter
37.Contrast Filter
38.Absolute Difference Filter
39.Video overlay
40.Dyadic Logic Filter
41.Dyadic Arithmetic Filter
42.Image File Source Filter
43.Source Filter for capturing the Desktop screen
44.Motion Detection Filter developement
45. color based motion detection (RGB is more sensitive, if we removed any color component that will affects the entire image,
For motion detection, Color Image is converted to gray scale image and performed the motion detection previosuly )
HSL color H component is responsible for video all other indicates brightness like that. So the normal Image is converted to
the HSL image and then applied the motion detection. it works well.
46.Crop Filter development

47. video Quality Filter currently supports
PSNR,MSAD,Delta, MSE,SSIM and VQM


Histogram have the following options :
1. channel Selection option for creating Histogram
2.Make the source image for Histogam as transform filter's Input or output image and
3.Enable black clipping and White clipping suppport to the histogram property pages.


DirectX transform Filter development : ( uses OpenCV or GDI+ or both gdi+ and OpenCV)
1.Sepia
2.Brightness
3.ColorbalanceRGB
4.Posterize
5.Bitmap overlay filter
6.channel Blur
7.RGB Scaling
8.Vortex Filter
9.Crop Filter developement
10.Gamma correction
11.ShiftChannels
12.Sphere Filter
13.Swirl Filter
14.Random Jitter
15.Pixellate
16.Threshold
17.Water Filter
18.Timewarp filter
19.Emboss ( developed the Sharpen,Removal as a separate filter )
20.Text overlay
21.Dyadic Arithmetic Filter
22.AbsDiff Filter
23.Video overlay Filter

Note :
Read the incomplete things from chat archive...

Monday, August 06, 2007

C# 2.0 New features

C# 2.0 new features (.NET framework SDK):

1.Partial classes allow class implementation across more than one file. This permits breaking down very large classes, or is useful if some parts of a class are automatically generated.
2.Generics or parameterized types. This is a .NET 2.0 feature supported by C#. Unlike C++ templates, .NET parameterized types are instantiated at runtime rather than by the compiler; hence they can be cross-language whereas C++ templates cannot. They support some features not supported directly by C++ templates such as type constraints on generic parameters by use of interfaces. On the other hand, C# does not support non-type generic parameters. Unlike generics in Java, .NET generics use reification to make parameterized types first-class objects in the CLI Virtual Machine, which allows for optimizations and preservation of the type information.
3.Static classes that cannot be instantiated, and that only allow static members. This is similar to the concept of module in many procedural languages.
4.A new form of iterator that provides generator functionality, using a yield return construct similar to yield in Python.
// Method that takes an iterable input (possibly an array) and returns all even numbers.
public static IEnumerable GetEven(IEnumerable numbers)
{
foreach (int i in numbers)
{
if (i % 2 == 0) yield return i;
}
}

5.Anonymous delegates providing closure functionality.

public void Foo(object parameter)
{
// ...

ThreadPool.QueueUserWorkItem(delegate
{
// anonymous delegates have full access to local variables of the enclosing method
if (parameter == ...)
{
// ...
}

// ...
});
}

6.Covariance and contravariance for signatures of delegates
7. The accessibility of property accessors can be set independently. Example:

string status = string.Empty;
public string Status
{
get { return status; } // anyone can get value of this property,
protected set { status = value; } // but only derived classes can change it
}

8.Nullable value types (denoted by a question mark, e.g. int? i = null;) which add null to the set of allowed values for any value type. This provides improved interaction with SQL databases, which can have nullable columns of types corresponding to C# primitive types: an SQL INTEGER NULL column type directly translates to the C# int?.
int? i = null;
object o = i;
if (o == null) Console.WriteLine("Correct behaviour - you have a runtime version from September 2005 or later");
else Console.WriteLine("Incorrect behaviour - you are running a pre-release runtime (from before September)");
When copied into objects, the official release boxes values from Nullable instances, so null values and null references are considered equal.
9. Coalesce operator: (??) returns the first of its operands which is not null
object nullObj = null;
object obj = new Object();
return nullObj ?? obj; // returns obj

The primary use of this operator is to assign a nullable type to a non-nullable type with an easy syntax:

int? i = null;
int j = i ?? 0; // Unless i is null, initialize j to i. Else (if i is null), initialize j to 0.

MFC Slider Control Message Handling

I worked with horizontal slider control in MFC.

in order to receive the slider control messages,
 
 we have to add the HSCROLL or VSCROLL message

I added the following message :

ON_WM_HSCROLL() added it within BEGIN_MESSAGE () macro.

next I added the fn like

afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) ;

while using Slider control, the SCROLL message is posted...

There are two main notification codes are available.

That are

          TB_THUMBTRACK

//Slider movement (the user dragged the slider)

          TB_THUMBPOSITION

//WM_LBUTTONUP following a TB_THUMBTRACK notification message

 

void MFCDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)

{

       CSliderCtrl * pControl = (CSliderCtrl*) pScrollBar);

        switch(nSBCode)

         {

             case TB_THUMBTRACK://Slider movement (the user dragged the slider)

              {

                break;

             }

               case TB_THUMBPOSITION:

                 {

                     //WM_LBUTTONUP following a TB_THUMBTRACK notification message

                      //StopTimer();

                        break;

                  }

         }

}

Slider Control

1.Today I worked with slider control with horizontal attribute
change it as to horizontal and in order to receive the slider control messages we have to add the
HSCROLL or VSCROLL message

I added the following message :

ON_WM_HSCROLL() added it within BEGIN_MESSAGE () macro.

next I added the fn like

afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) ;

while using Slider control, the SCROLL message is posted...
There are two main notification codes are available.

That are
TB_THUMBTRACK //Slider movement (the user dragged the slider)
TB_THUMBPOSITION//WM_LBUTTONUP following a TB_THUMBTRACK notification message


void MFCDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CSliderCtrl * pControl = (CSliderCtrl*) pScrollBar);

switch(nSBCode)
{
case TB_THUMBTRACK://Slider movement (the user dragged the slider)
{
break;
}
case TB_THUMBPOSITION:
{
//WM_LBUTTONUP following a TB_THUMBTRACK notification message
//StopTimer();
break;
}

}


}

Thursday, August 02, 2007

The real use of C++ class concept in MFC :

The real use of C++ class in MFC :

First windows developed the win32 programming model.

But it is so complicated.. It is being simplified by MFC. MFC is nothing but an object oriented framework around WIN32 API.

 

 

 

Take an Example :

 

GetWindowRect( LPRECT lpRect);

these two functions are APIs in windows.

LPRECT is a pointer to the RECT structure .

typedef RECT* LPRECT;

 

In MFC, there is a class CRect for handling rectangles.

in MFC code they may as follows :

CRect rc;

GetWindowRect(rc);

it will works well without any problem. Actually the GetWindowRect() API supports only LPRECT as argument...

Is it possible to develope our own Rectangle class in our application ?... yes...

 

How ?

it is the speciality of Operator conversion.

 

class CRect : public RECT

{

public :

operator LPRECT()

{

return this;

}

};

while executing the following line,

CRect rc;

GetWindowRect(rc);

rc Object is converted to the LPRECT, so the following code in a CRect class will be executed.

operator LPRECT()

{

return this;

}

So the pointer of the RECT derived class is passed as an argument to the GetWindowRect() fn.

 

if we are writing our own rectangle class

class CMyRect : public RECT

{

public:

operator LPRECT()

{

return this;

}

};

what is the purpose of providing wrapper class around RECT like structures in Windows ?

In order to simplify the operation, we are going for the wrapper class.

For Example,

RECT structure has following members

struct RECT

{

int left;

int top;

int bottom;

int right;

};

if we want to idenify the Width of the rectangle every time the user has to calculate it ...

Instead of it we develope the wrapper class method as follows that will be more easy...

LONG CRect :: Width()

{

return right - left;

}

Actually RECT structure is simple ... Windows has so much complicated structures to be passed as an argument to the

Windows API function. At that time, it will be more helpful...

if we want to display two input video and output video in a client application


How we must have to develop the Direct show client application ?.



( 2 In 1 out )


we can use two different ways to this problem .

if we want to display the both input and output video passed to the filter then the following way of graph building is a way to solve the problem.


1. Tee Filter

2. Sample Grabber




Tee filter approach:













Sample Grabber approach:






Series of Steps to be done in GraphEdit For Displaying input and output videos of a Two Input pin Filter :

1.Add the Source Filter1 by Filename

2.Add the Source Filter2 by Filename

3.Render the Source Filter1's output pin, Find the Video Renderer and Remove the video Renderer

4.Insert the Tee Filter at the end of the SourceFilter1 series


//Render the Tee Filter's first output pin ( Tee Filter's Second output pin left as unconnected..)


5.Render The Source Filter2's output pin , Find the Video Renderer and Remove the video Renderer



Here I faced the problem, First Time render the pin and remove the video renderer works... if I tried it in the second time,

then I got the problem that is the video renderer is named as video renderer 004 and we might not be able to identify the

Video Renderer for removing.


Solution :


I solved this problem as follows :

// I added the temporary renderer filter with the Graph.

// Connect the m_pSourceFilter's first output pin to the Temporary Renderer filter's first input pin

// Connect the m_pSourceFilter2's first output pin to the Temporary Renderer filter2's first input pin


// while connecting the intermediate filters are automatically added by the Directshow

//Remove the Temporary Renderer Filter

//Remove the Temporary Renderer Filter2



hr = AddFilterByCLSID(m_pGraph,CLSID_VideoRenderer,L"Temp Renderer 001",&pTempRenderer001);

hr = AddFilterByCLSID(m_pGraph,CLSID_VideoRenderer,L"Temp Renderer 002",&pTempRenderer002);

hr = Connect( m_pGraph,

m_pSourceFilter,

0,

pTempRenderer001,

0

);


hr = Connect( m_pGraph,

m_pSourceFilter2,

0,

pTempRenderer002,

0

);


hr = RemoveRenderer(m_pGraph,&pUnConnectedPin,L"Temp Renderer 001");

hr = RemoveRenderer(m_pGraph,&pUnConnectedPin2,L"Temp Renderer 002");




6.Insert the Tee Filter2 at the end of the SourceFilter2 series


7.Add the Video Renderer 001 filter to the graph


8.Add the Video Renderer 002 filter to the graph

//Render the Tee Filter2's first output pin ( Tee Filter2's Second output pin left as unconnected..)


9.Add the Video Renderer Filter 003 to the graph

10. Connect the Tee Filter's output pin1 to the VideoRenderer 001

11.Connect the Tee Filter2's output pin1 to the VideoRenderer 002


12. Add the two input pin filter

13. Connect the Tee Filter's output pin2 to the Two Input Pin Filter's Input pin1.

14. Connect the Tee Filter2's output pin2 to the Two Input pin Filter's Input Pin 2

15.Connect the Two Input Pin Filter's output pin to the Video Renderer 003




For Filter's First Input Video,Query the video window from the Video Renderer 001

For Filter's Second Input Video,Query the video window from the Video Renderer 002

For Filter's Output Video,Query the video window from the Video Renderer 003








How to create an object for the renderer filter ?


By using the following way we can predict the video renderer easily by using Filter name as follows :


pGraphBuilder->AddFilter(pVideoRenderer, L"Video Renderer 001");


otherwise the graph builder will automatically add the number at the end if the graph have more than one renderer...


So the number is put on the filter name like Video Renderer 001 and so on. if the graph builder automatically adds the Video renderer then we have to use extensive search to identify the filter. To avoid this one it is better to add the renderer filter by the user.







IBaseFilter* pVideoRenderer=NULL;
//Create and add video renderer filter
CoCreateInstance(CLSID_VideoRenderer, NULL, CLSCTX_INPROC_SERVER,
IID_IBaseFilter, (void **)&pVideoRenderer);
pGraphBuilder->AddFilter(pVideoRenderer, L"Video Renderer");


//Querying IVideoWindow interface from pVideoRenderer
pVideoRenderer->QueryInterface(IID_IVideoWindow, (void
**)&pVideoWindow);



Directshow Client :

CTeeVideoRenderer* m_pTeeVideoRenderer;

CRect rc;

m_pTeeVideoRenderer = new CTeeVideoRenderer();

m_pTeeVideoRenderer->InitGraph();

m_pTeeVideoRenderer->AddSourceFilter(L"D:\worksundar.avi");

m_pTeeVideoRenderer->AddSourceFilter(L"D:\work\sundar_1.avi");

m_pTeeVideoRenderer->AddVQFilter();

m_pTeeVideoRenderer->AddTeeFilter();

m_pTeeVideoRenderer->SetNotifyWindow(this ->m_hWnd);

m_pTeeVideoRenderer->Render();



m_pTeeVideoRenderer->SetVideoWindowIn(m_VideoInput1.m_hWnd, 0,0, rc.width(), rc.height());

m_pTeeVideoRenderer->SetVideoWindowIn2(m_VideoInput2.m_hWnd, 0,0, rc.width(), rc.height());

m_pTeeVideoRenderer->SetVideoWindowOut(m_VideoOutput.m_hWnd, 0,0, rc.width(), rc.height());

m_pTeeVideoRenderer->Start();

ReleasePtr ( m_pTeeVideoRenderer);









Wednesday, August 01, 2007

Multiple video Renderer problem

Multiple Renderer in a Single Graph Builder :

if we have multiple renderer in a graph builder ,then

1. we may face the problem as follows


Source 1 video : Video Renderer 001 we can get the video window from VideoRenderer 001 for Source1 video.

Source 2 Video : Video Renderer 002 we can get the video window from the videoRenderer 002 for Source2 video.

output video : Video Renderer 003 we can get the video window from the videoRenderer 003 for Output video.


Normal search like "video Renderer" will not help if the filter have multiple renderers.



http://groups.google.co.in/group/microsoft.public.win32.programmer.directx.video/browse_thread/thread/c5f52fbfa798def4/2eece8fd096b3879?lnk=st&q=SetNotifyWindow+%2B+multiple+render+problem&rnum=1&hl=en#2eece8fd096b3879

IVideoWindow Query failed...

windowless Mode using IVideoWindow :
------------------------------------------------------------
m_pVideoWindow->put_Owner() returns E_NOINTERFACE ...
IVideoWindow method's put_Owner() failed...
The reason is after building the filter graph completely , we can call the put_Owner() method ...
In my application I just followed the sequence of steps ...
i) Add the source filter
ii) Set the video Window...
iii) Render the Source filter's output pin
But I am not able to set my video window to the specified control...
The reason is we can set the video window handle only after the video renderer filter is connected to the filter graph.


One More reason is we actually got the IVideoWindow interface from the renderer filter. So without the renderer filter the

Querying of IVideoWindow from the filter graph failed...