locked
Problem Recording Video from WebCam

    Question

  • I am developing the C++ version of the the link below .
    I am able to capture the Image from the WebCam, Now I trying to to Record video But I Am getting Empty file.
    I have Noticed that while capturing the Image LED  Light in webcam Starts but when I press Record Button No light turns on.
    void Sample4::MainPage::btnVideo_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
     {
    encodingProfile = MediaEncodingProfile::CreateMp4(VideoEncodingQuality::Qvga);
    auto var = KnownFolders::VideosLibrary->CreateFileAsync("cameraCapture.mp4", CreationCollisionOption::GenerateUniqueName);
     
    var->Completed = ref new AsyncOperationCompletedHandler<StorageFile^>([=](IAsyncOperation<StorageFile^>^ op)
    {
    StorageFile^ strgFile= op->GetResults();
     
    auto res = mediaCaptureMgr->StartRecordToStorageFileAsync(encodingProfile,strgFile);
    res->Completed = ref new AsyncActionCompletedHandler([](IAsyncAction ^action)
    {
     
    //action->GetResults();
    //action->Status
    });
    res->Start();
    });
    var->Start();
     }
            
         
    This code same as the code in Java Script and I haven't missed anything.
    Please Help on this. 



    • Edited by chris_vr Thursday, November 17, 2011 11:26 AM
    Thursday, November 17, 2011 11:18 AM

All replies

  • Now I able to Record video for Default Device i.e. Embedded camera of my laptop. Now the Problem it is Not able to Record from USB camera although Capture is working fine for USB camera.

    I am calling initCaptureSettings each time user select any of the two camera.

     

     

    void MainPage::initCaptureSettings()

            //captureInitSettings = null; 

            captureInitSettings = ref new MediaCaptureInitializationSettings(); 

            captureInitSettings->AudioDeviceId = ""; 

            captureInitSettings->VideoDeviceId = ""; 

     captureInitSettings->StreamingCaptureMode = StreamingCaptureMode::AudioAndVideo; 

            captureInitSettings->PhotoCaptureSource = PhotoCaptureSource::VideoStream; 

            captureInitSettings->DeviceExtensionEnabled = true; 

            captureInitSettings->HardwareAccelerationEnabled = true; 

     

     //  Here VidDev is Selected Camera ID

    if (VidDev->Length() != 0)

    captureInitSettings->VideoDeviceId = VidDev;

     

        } 

    Am I missing Something for USb Camera ??



    • Edited by chris_vr Friday, November 18, 2011 7:30 AM
    Friday, November 18, 2011 7:27 AM
  • Problem is resolved.The Problem was due to file format.I was using .MP4 to record video from WebCam HD 1080p.When I changed the Extension to .wmv file I am able to record it.

     

    Does this mean .mp4 file donot support HD Video is it???

     

     

    • Marked as answer by chris_vr Saturday, November 19, 2011 4:53 PM
    • Unmarked as answer by chris_vr Thursday, November 24, 2011 12:47 PM
    Friday, November 18, 2011 7:25 PM
  • Hi Chris,

    Due to certain restrictions not all of the codecs that ship with Windows 7 are available in the Windows 8 developer preview. Please continue to monitor the upcoming Windows 8 preview releases for a complete list of codecs that will ship with the final RTM version of the operating system.

    Thanks,

    James

    Tuesday, November 22, 2011 10:34 PM
    Moderator
  • Thanks James

    I would like to know which all codec are shipped with Windows 8 Developer Preview so that I can Confirm that with the result I am getting in my code. 

    I found that for my embedded camera supports both the format H264(.mp4 file) and WVC1(.wmv file).

    I tried with USB camera 1080p, it supports WVC1(.wmv file) but not H264(.mp4).

    Please Clarify is this because of codec ?


    • Edited by chris_vr Thursday, November 24, 2011 5:42 AM Added facts
    Wednesday, November 23, 2011 6:19 PM
  • I have enumerated VideoEncodingProfile
    I got Profile Info(Frame Rate,Resolution etc..) for my USB Camera.The Camera Supports H264 SubType.
     I tried Different Option and found that .MP4 is now working but the condition we have to make
    encodingProfile->Video->Subtype = "WVC1".
    If I do encodingProfile->Video->Subtype = "H264" it is not getting recording.
    If you do encodingProfile = MediaEncodingProfile::CreateMp4(VideoEncodingQuality::HD1080p);
    Subtype will be "H264".
    I am not using CreateMp4(), infect I am allowing user to choose the Profile (Resolution,Frame Rate etc)and Creating MediaEncodingProfile reference and assigned the Profile Info along with Subtype as "WVC1".
    It is Working but I endup in another problem i.e. I am not getting Preview if I am make file extension as .mp4.Is this codec related problem??? 
    For Embedded camera both the format is working fine.
    Friday, November 25, 2011 8:57 PM