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
0
Question by Afamuefuna · Feb 27, 2020 at 11:04 PM · unity 5iosaugmented-reality

How do I add a screen recorder in my AR/VR/Game in unity without using an asset?

Hello everyone, please how do I add a screen recording Functionality on my AR app? I have tried using this script VideoCapture below but it gave me an error plus I do not know if it will achieve what I wanted

 using UnityEngine;
 using System.Collections;
 using System.Linq;
 using UnityEngine.Windows.WebCam;
 
 public class VideoCaptureExample : MonoBehaviour
 {
     static readonly float MaxRecordingTime = 5.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);
     }
 }

This is the error

ArgumentNullException: Value cannot be null. Parameter name: source

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

0 Replies

· Add your reply
  • Sort: 

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

250 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 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 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 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

can't profile ios device 0 Answers

NativePlugin c++ Android sample and self build pcl not loading,Native Plugins c++ "dll not found" 2 Answers

How to add Unity iOS project into existing Swift project 0 Answers

Native Rendering Plugin not working for iOS 0 Answers

Activity Indicator Centered 0 Answers


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