Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by GuzmanJunity · Jan 24, 2018 at 11:27 PM · videonamespacewebcamcapture

Recording video from webCam

Hello, I'm trying to use the script from VideoCapture, on editor mode doesn't reflect any issue but when it comes to the deployment on PC standalone, it tells me: The type or namespace name WebCam' does not exist in the namespace UnityEngine.XR.WSA'. Are you missing an assembly reference? and I know it changed from VR to XR but I'm not missing any name space. using Unity 2017.3 Here is my code:

using UnityEngine; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine.XR.WSA.WebCam; using UnityEngine.SceneManagement;

public class WebCamera : MonoBehaviour {

 static readonly float MaxRecordingTime = 15.0f;

 VideoCapture m_VideoCapture = null;
 float m_stopRecordingTimer = float.MaxValue;

 // Use this for initialization
 void Start() {
     StartVideoCaptureTest();
 }

 void Update() {
     if (m_VideoCapture == null || !m_VideoCapture.IsRecording) {
         return;
     }

     if (Time.time > m_stopRecordingTimer) {
         m_VideoCapture.StopRecordingAsync(OnStoppedRecordingVideo);
     }
 }

 void StartVideoCaptureTest() {
     Resolution cameraResolution = VideoCapture.SupportedResolutions.OrderByDescending((res) => res.width * res.height).First();
     Debug.Log(cameraResolution);

     float cameraFramerate = VideoCapture.GetSupportedFrameRatesForResolution(cameraResolution).OrderByDescending((fps) => fps).First();
     Debug.Log(cameraFramerate);

     VideoCapture.CreateAsync(false, delegate (VideoCapture videoCapture) {
         if (videoCapture != null) {
             m_VideoCapture = videoCapture;
             Debug.Log("Created VideoCapture Instance!");

             CameraParameters cameraParameters = new CameraParameters();
             cameraParameters.hologramOpacity = 0.0f;
             cameraParameters.frameRate = cameraFramerate;
             cameraParameters.cameraResolutionWidth = cameraResolution.width;
             cameraParameters.cameraResolutionHeight = cameraResolution.height;
             cameraParameters.pixelFormat = CapturePixelFormat.BGRA32;

             m_VideoCapture.StartVideoModeAsync(cameraParameters,
                 VideoCapture.AudioState.ApplicationAndMicAudio,
                 OnStartedVideoCaptureMode);
         }
         else {
             Debug.LogError("Failed to create VideoCapture Instance!");
         }
     });
 }

 void OnStartedVideoCaptureMode(VideoCapture.VideoCaptureResult result) {
     Debug.Log("Started Video Capture Mode!");
     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("/", @"\");
     m_VideoCapture.StartRecordingAsync(filepath, OnStartedRecordingVideo);
 }

 void OnStoppedVideoCaptureMode(VideoCapture.VideoCaptureResult result) {
     Debug.Log("Stopped Video Capture Mode!");
 }

 void OnStartedRecordingVideo(VideoCapture.VideoCaptureResult result) {
     Debug.Log("Started Recording Video!");
     m_stopRecordingTimer = Time.time + MaxRecordingTime;
 }

 void OnStoppedRecordingVideo(VideoCapture.VideoCaptureResult result) {
     Debug.Log("Stopped Recording Video!");
     m_VideoCapture.StopVideoModeAsync(OnStoppedVideoCaptureMode);
 }

 public void TheEnd() {
     SceneManager.LoadScene("End");
 }

}

I been having this issue for over 3 days and I search for any issue related without any luck. Thanks for the help.

Have a good one!!!!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by bunkie · Feb 01, 2018 at 10:57 AM

I am having the same problem on Unity 2017.2. I am just looking for a way to record a video using the webcam, does any one have suggestions on how to do it or alternative ways?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Webcam Support in Unity (iSight or USB Camera) 8 Answers

What is required from a device to be read in a WebcamTexture? 0 Answers

Write Webcam Capture Tp Specific Folder 1 Answer

Unity 5 image-based lighting skybox from webcam video 0 Answers

Video call in Unity? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges