Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. Problem with compression of a DirectShow video filter

Problem with compression of a DirectShow video filter

Scheduled Pinned Locked Moved Graphics
helpcode-reviewworkspace
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 4 Offline
    4 Offline
    4288
    wrote on last edited by
    #1

    I'm experiencing problems in setting compression parameters for a directshow video filter for a video and audio grabbed from a usb webcam. The code I am using (adapted from various websites on the internet) is the following (removed error checking to improve readability):

    //... various code before
    hr=m\_pGraph->AddFilter(m\_pVidDeviceFilter,L"Vid Capture Filter");
    hr=m\_pGraph->AddFilter(m\_pAudDeviceFilter,L"Aud Capture Filter");
    
    hr = CoCreateInstance(CLSID\_WMAsfWriter,NULL,CLSCTX\_INPROC\_SERVER, 
                      IID\_IBaseFilter, (void \*\*) &m\_pWMASFWritter); 
    
    
    
    //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    // !!! Try to add compression from now on !!!!
    
    DWORD dwBitRate = 2670000; // I tried almost everything here
    DWORD dwQuality = 50; // in range\[0-100\]
    DWORD dwSecPerKey = 5000;
    
    // Initialize a new Profile Manager
    IWMProfileManager\* pIPM = 0;
    WMCreateProfileManager(&pIPM);
    
    // Create a new empty profile
    IWMProfile\* pIProf = 0;
    pIPM->CreateEmptyProfile(WMT\_VER\_9\_0,&pIProf);
    pIProf->SetName(L"Window Media Video 9 Profile");
    pIProf->SetDescription (L"Window Media Video 9 Custom Encoding");
    
    // Create a new video stream
    IWMStreamConfig\* pVideoStream = 0;
    pIProf->CreateNewStream(WMMEDIATYPE\_Video,&pVideoStream);
    
    pVideoStream->SetStreamName(L"videostream");;
    pVideoStream->SetConnectionName(L"video");
    pVideoStream->SetBitrate(662144); // This causes problems
    pVideoStream->SetBufferWindow(3000);
    pVideoStream->SetStreamNumber(1);
    
    IWMVideoMediaProps\* pVideoMediaProps = 0;
    
    // Get this Interface from pVideoStream...
    hr = pVideoStream->QueryInterface(IID\_IWMMediaProps, (void\*\*)&pVideoMediaProps);
    
    WM\_MEDIA\_TYPE sMediaType;
    WMVIDEOINFOHEADER sVideoInfoHeader;
    memset(&sMediaType, 0, sizeof(sMediaType));
    sMediaType.majortype = WMMEDIATYPE\_Video;
    sMediaType.subtype = WMMEDIASUBTYPE\_MPEG2\_VIDEO;
    sMediaType.bFixedSizeSamples = FALSE;
    sMediaType.bTemporalCompression = TRUE;
    sMediaType.formattype = WMFORMAT\_VideoInfo;
    sMediaType.cbFormat = sizeof(WMVIDEOINFOHEADER);
    sMediaType.pbFormat = (BYTE \*)&sVideoInfoHeader;
    
    // Setup the Video Info Header
    memset(&sVideoInfoHeader, 0, sizeof(sVideoInfoHeader));
    sVideoInfoHeader.rcSource.left = 0;
    sVideoInfoHeader.rcSource.top = 0;
    sVideoInfoHeader.rcSource.right = 352;
    sVideoInfoHeader.rcSource.bottom = 240;
    sVideoInfoHeader.rcTarget.left = 0;
    sVideoInfoHeader.rcTarget.top = 0;
    sVideoInfoHeader.rcT
    
    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups