Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

VideoCapture with Unity2017.2.0b11

Discussion in 'VR' started by ITALIANI, Sep 19, 2017.

  1. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27
    Hi,

    I am working on a Hololens Headset and I want to capture with VideoCaptureAPI.
    I have following this:
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/XR.WSA.WebCam.VideoCapture.html

    My project build completed and I launch the build with VS2017. The parameters are Release, x86 and RemoteDevice.
    My build launched correctly on the Hololens Headset and after 1 min, I quit the app but I don't find my video in Video Folder.

    I have Unity2017.2.0b11 and VS2017 v15.3.4

    I think this is where I backup my video which is the problem.
     
  2. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    Are you checking for the video file in %userprofile%\AppData\Local\Packages\<productname>\LocalState? That's where video files are saved when using Application.persistantDataPath. You can also do a debug log line into your output which will print out the path where the file is saved.

    Also make sure you're cleanly stopping and cleaning up your recording, otherwise the HoloLens will end up in a weird state.
     
  3. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27

    Thx for your answer.

    I know but I don't succeed to access this folder with the Hololens. How can I ?

    For clean the record, can I use the commented lines ?
    upload_2017-9-20_8-27-13.png
     
    Last edited: Sep 20, 2017
  4. JasonCostanza

    JasonCostanza

    Unity Technologies

    Joined:
    May 23, 2017
    Posts:
    404
    yes, the commented out line will dispose _videoCapture.

    Is it failing to save to the folder because access is denied or is it not letting you access it through WebB when you try to retrieve the file?
     
  5. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27
    I met "VideoLibrary" , " AudioLibrary" , etc in the unity capabilities for UWP and the access is denied for the folder VideoLibrary.
     
  6. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27
    I try to copy the record video, who is in LocalState, in the VideoFolder with a copy func async
     
  7. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27
  8. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27
    My log says me that the file copied but when I opened the Video app, there was not any video.
     
  9. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27
    I capture my video but I have not holographic elements.
     
  10. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Hello,

    Hopefully this will help you solve your issues with file path and Holograms for video capture.

    Here is an example to the file path of the video, you appear to be missing some parts of the file path to the app data folder.
    example:
    string timeStamp = Time.time.ToString().Replace(".", "").Replace(":", "");
    string filename = string.Format("TestVideo_{0}.mp4", timeStamp);
    string filepath = System.IO.Path.Combine(Application.persistentDataPath, filename);
    filepath = filepath.Replace("/", @"\");

    To show holograms in a capture you need to set the bool showHolograms in the VideoCapture.CreateAysnc call to true.
    example:
    *
    VideoCapture.CreateAsync(false, delegate(VideoCapture videoCapture)

    https://docs.unity3d.com/2017.2/Doc...e/XR.WSA.WebCam.VideoCapture.CreateAsync.html
    https://docs.unity3d.com/2017.2/Documentation/ScriptReference/XR.WSA.WebCam.VideoCapture.html

    Hopefully this helps, let us know if you have questions.

    Thank you,
    Wesley
     
  11. ITALIANI

    ITALIANI

    Joined:
    Sep 18, 2017
    Posts:
    27
    I solved my problems, thx for your answers :)
     
  12. mashiro11

    mashiro11

    Joined:
    Dec 2, 2017
    Posts:
    7
    Hello there,

    I can see this is an old post, but I've been trying to get VideoCapture to work, with no results. Maybe there is something I'm missing?
    - Installed Unity 2017.3
    - checked windows IL2CPP
    - using reference script VideoCaptureExample
    - add script on game object on scene

    - switched build to windows universal platform
    - can see camera resolution and framerate informations
    - try to run playMode
    on unity interface
    - m_VideoCapture never get instantiated (from reference script mentioned above), always null

    Doesn't VideoCapture work on playMode? Only on build?
     
    damayor11 likes this.
  13. damayor11

    damayor11

    Joined:
    Oct 12, 2015
    Posts:
    3
    Hello! Could you to resolve it? I've done everything you said and m_videoCapture is always null, in build mode too. Moreover there's no much information about this bug on internet.
     
  14. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    Can you verify that you have the capabilities set correctly and have the Windows MR SDK enabled? Need a little bit more information on your setup. Although video or photo or video capture works in play mode they are not technical supported in editor for Windows MR / HoloLens
     
  15. rickblacker

    rickblacker

    Joined:
    May 1, 2014
    Posts:
    266
    I'm trying to do something similar.
    https://docs.unity3d.com/ScriptReference/XR.WSA.WebCam.VideoCapture.html

    All I have done is :
    • Created a brand new Unity project.
    • Created a new script based on the URL above
    • Placed the script on a Cube
    However, I'm just trying to capture video from the onboard webcam on my laptop. My issues however is different. I'm not able to get the VideoCapture object to get created on the Asyc call. It fails right here.

    Code (CSharp):
    1. VideoCapture.CreateAsync(false, delegate (VideoCapture videoCapture)
    2.         {
    3.             if (videoCapture != null)
    4.             {
    5.                 m_VideoCapture = videoCapture;
    6.                 Debug.Log("Created VideoCapture Instance!");
    7.  
    8.                 CameraParameters cameraParameters = new CameraParameters();
    9.                 cameraParameters.hologramOpacity = 0.0f;
    10.                 cameraParameters.frameRate = cameraFramerate;
    11.                 cameraParameters.cameraResolutionWidth = cameraResolution.width;
    12.                 cameraParameters.cameraResolutionHeight = cameraResolution.height;
    13.                 cameraParameters.pixelFormat = CapturePixelFormat.BGRA32;
    14.  
    15.                 m_VideoCapture.StartVideoModeAsync(cameraParameters, VideoCapture.AudioState.ApplicationAndMicAudio, OnStartedVideoCaptureMode);
    16.             }
    17.             else
    18.             {
    19.                 Debug.LogError("Failed to create VideoCapture Instance!");
    20.             }
    21.         });

    Does this ONLY work with Hololens or can this work with a Webcam? And if it CAN work with a Webcam, is there something I must to to get it to connect and create the video stream? Some settings?
     
  16. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    These API's are meant for Windows MR specifically on the HoloLens, the are not supported anywhere else. Also, you need to have the capabilities set in your project to allow access to the camera.
     
  17. rickblacker

    rickblacker

    Joined:
    May 1, 2014
    Posts:
    266
    HI Wesley, thanks for the feedback, much appreciated.