Solved

Video Codec for DirectShow application

Posted on 2009-03-30
6
453 Views
Last Modified: 2013-12-08
Hi all,

i have an application built in Win32Api using DirectShow for Live Video Broadcasting.(right now it works locally).

Now i want to compress and de-compress it using MJPEG Compressor Filter.

i cant find any Relevant informatin on MSDN.

So can any one suggest me how to implement this Compression filter in DirectShow.

Thanks
Kishan
0
Comment
Question by:kishan66
  • 3
  • 3
6 Comments
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24024573
http://www.free-codecs.com/download/FFDshow.htm

Install this codec

Using GraphEdit insert this Codec into your graph after the source. Or if you are doing it in Code use its GUID and dynamically insert it.

I assume you know DirectShow
0
 

Author Comment

by:kishan66
ID: 24031395
Hi,

Thanks for the reply.

Can you tell me more clearly how to do it ?(like compression & decompression).
example would definitely help me.

Thanks
kishan.
0
 
LVL 12

Expert Comment

by:williamcampbell
ID: 24034828

  DirectShow is a Filter graph, a pipeline of sorts. A source comes in (bytes) and passes through several filters and is rendered at the other end.

  FILTER1: live video and audio stream as the source.
  FILTER2: Compress the video (JMPEG)
  FILTER3: Multiplex To go over  Network
 
   === NETWORK ===

  FILTER4: Demultiplex Stream
  FILTER5: Uncompress Video (JMPEG)
  FILTER6: Render Video

  Right now you may have a filter where FILTER 2 and 5 are  (MPEG4/ or MPEG2) and you need to replace it with the JMPEG one.

 If you open GraphEdit run your app you dynamically hook into the graph and see how the filters are connected.

 To Have your JMPEG filter used there are several things you can do.

 So let me know if you understand what I have said an we can take it form there.

 


0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:kishan66
ID: 24043292
Hi WilliamCambell,

Thank you so much for your reply.

I understood the concept and steps.
but i only have the Step 1 done till now.( i am just in the learning mode of Direct Show).

i feel its better to do that step by step,................

 i am using a Timer () to get/show the images continuously from the WebCam and showing it on the screen (locally).  

-my next step is to compress and Decompress these DIB's using MJPEG( initially both operations locally)

So can you tell me how to call or assign this filter.(MJPEG Compressor & DeCompressor)

Thanks,
Kishan
0
 

Author Comment

by:kishan66
ID: 24051394
Hi William,

here is my sample code where i am getting the image(Bitmap) and constructing the Bitmap Header.


I am developing a win32api using 'C'.

-------code----

GetFrame(&pImage); // gets the Bitmap image into BytePointer pImage
        m_pImageBytes = pImage;
MakeBMPHeader(); // construct the header .
.......
......
 void MakeBMPHeader()
{  
    DWORD  dwBitmapInfoSize;
    dwBitmapInfoSize = sizeof(BITMAPINFO);
    m_pBmp   = (BITMAPINFO *)new BYTE [dwBitmapInfoSize];
    m_pBmp->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
    m_pBmp->bmiHeader.biWidth = m_un32ImageWidth;
    m_pBmp->bmiHeader.biHeight = m_un32ImageHeight*-1;  
    m_pBmp->bmiHeader.biPlanes = 1;
    m_pBmp->bmiHeader.biBitCount =(unsigned short) m_un32ImageBits;
    m_pBmp->bmiHeader.biCompression = BI_RGB;
    m_pBmp->bmiHeader.biSizeImage = 0;
    m_pBmp->bmiHeader.biXPelsPerMeter = 0;
    m_pBmp->bmiHeader.biYPelsPerMeter = 0;
    m_pBmp->bmiHeader.biClrUsed = 0;
    m_pBmp->bmiHeader.biClrImportant = 0;          
}

Now i have Image and Header.

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

can you please explain me " how to compress using MJpeg"?

thanks
0
 
LVL 12

Accepted Solution

by:
williamcampbell earned 500 total points
ID: 24051804
Capturing the bitmaps as you are doing now is very slow...

Take a look at this sample program AMCap

http://msdn.microsoft.com/en-us/library/ms778964.aspx

It does all the Capture part and displays the video. Once you are able to get that working you can download the JMPEG codec and insert it into  the filter chain.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question