VideoHelp Forum




+ Reply to Thread
Results 1 to 2 of 2
  1. Hi all,

    I capture from USB camera and encode with xvid codec then use avi mux into file, when I capture in graphEdit, it's ok, but when I capture in my program, the captured file has color distortion, anyone know the reason?

    Image
    [Attachment 53514 - Click to enlarge]


    IPin pRaw = null;
    IPin pSmart = null;

    // Add a splitter
    IBaseFilter iSmartTee = (IBaseFilter)new SmartTee();

    hr = m_FilterGraph.AddFilter(iSmartTee, "SmartTee");
    DsError.ThrowExceptionForHR(hr);

    // Find the find the capture pin from the video device and the
    // input pin for the splitter, and connnect them
    pRaw = DsFindPin.ByCategory(capFilter, PinCategory.Capture, 0);
    pSmart = DsFindPin.ByDirection(iSmartTee, PinDirection.Input, 0);

    hr = m_FilterGraph.Connect(pRaw, pSmart);
    DsError.ThrowExceptionForHR(hr);

    // Now set the capture and still pins (from the splitter)
    previewPin = DsFindPin.ByName(iSmartTee, "Preview");
    capturePin = DsFindPin.ByName(iSmartTee, "Capture");

    m_FilterGraph.Render(previewPin);

    x264Filter = new XVID() as IBaseFilter;
    hr = m_FilterGraph.AddFilter(x264Filter, "x264 encoder");
    DsError.ThrowExceptionForHR(hr);
    x264In = DsFindPin.ByDirection(x264Filter, PinDirection.Input, 0);
    x264Out = DsFindPin.ByDirection(x264Filter, PinDirection.Output, 0);

    aviMux = new AVIMUXFILTER() as IBaseFilter;
    hr = m_FilterGraph.AddFilter(aviMux, "avi mux");
    DsError.ThrowExceptionForHR(hr);
    aviIn = DsFindPin.ByDirection(aviMux, PinDirection.Input, 0);
    aviOut = DsFindPin.ByDirection(aviMux, PinDirection.Output, 0);

    fileWriter = new FileWriter() as IBaseFilter;
    IFileSinkFilter fileSinkFilter = fileWriter as IFileSinkFilter;
    hr = m_FilterGraph.AddFilter(fileWriter, "file writer");
    DsError.ThrowExceptionForHR(hr);
    AMMediaType media = new AMMediaType();
    media.majorType = MediaType.Stream;
    media.subType = MediaSubType.Avi;
    fileSinkFilter.SetFileName("123.avi", media);
    fileWriterIn = DsFindPin.ByDirection(fileWriter, PinDirection.Input, 0);

    hr = m_FilterGraph.Connect(capturePin, x264In);
    DsError.ThrowExceptionForHR(hr);

    hr = m_FilterGraph.Connect(x264Out, aviIn);
    DsError.ThrowExceptionForHR(hr);

    hr = m_FilterGraph.Connect(aviOut, fileWriterIn);
    DsError.ThrowExceptionForHR(hr);

    ConfigVideoWindow(hControl);


    Thanks in advance
    Quote Quote  
  2. Is this a webcam or some kind of composite capture device. That chroma noise looks like what you get from composite video with high frequency detail. If the video is supposed to be all greyscale you could always force Xvid to encode in greyscale mode.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!