iVidCapPro – Unity Plugin

iVidCapPRO_ico (arm)iVidCapPro is a plugin that enables you, the Unity developer, to capture video and audio from your Unity iOS application.

It’s great for recording video trailers, demos and in-app footage for your Unity-based game or app.  It’s fast, flexible and easy to use.  It runs wholly on the device and does not require a network connection.

When the video is recorded you decide how it’s handled.  Give your users complete freedom to share it, restrict it to playback from within your app, or anything in between.

Download Unity Package FileDownloading the Unity package file gives you everything you need to use iVidCapPro in your app. The docs are included in a zip file in Assets->Plugins->iVidCapPro.
Download Xcode Project FileThe Xcode project contains the source code for the native side of the plugin (libiVidCapPro.a). You only need this if you want to change the underlying operation of the plugin.
View DocumentationThe same documentation that is included in the Unity package. Preview it here to see if iVidCapPro meets your needs.

iVidCapPro gives you choices.

Choices and features–here are some of them:

  • Record real time footage.
    • Great for demos, trailers, and replays.
  • Record at any resolution.
    • Record your app in 720p or even 1080p. Need 512×512 for a special project? You got it.
  • Record at fixed framerate.
    • If you don’t need real time rendering, but want a really high quality recording, you can pick your target framerate. 30fps? 60fps? Your choice.
  • Record from multiple cameras simultaneously.
    • Have a separate camera for the GUI and the game character and want to record them simultaneously for a demo? You can do that.
  • Record from multiple cameras in sequence.
    • Switch between cameras during the recording session to show the action from different vantage points.
  • Record from rendertexture.
    • If you have your own secret recipe for cooking up a video source, iVidCapPro gets out of your way. Just point it at a rendertexture and it’ll make a video out of it. No cameras required.
  • Record scene audio.
    • Choose an audio listener and capture it. The audio capture component has its own gain control, so you can get the video volume just right without disturbing your in-app mix.
  • Record a voice over
    • Maybe you’re making a demo of your app or game and want to add commentary. Just tell iVidCapPro to record from the mic in addition to the scene. Use the device’s built-in mic or a headset mic.
  • Supply prerecorded audio.
    • Have prerecorded audio that you want to add to the video? iVidCapPro lets you choose up to two audio files to mix with the finished video.
  • Adjust video quality settings.
    • Configure the bitrate and keyframe interval to get the balance you need between video file size and quality.
  • Adjust video gamma.
    • Need to tweak the video brightness to get the right look? It’s here.
  • Slide show mode.
    • Throttled framerate capture lets you turn your app into a slideshow.
  • Full destination control
    • Have the finished video copied to the device Photo Album. Or store it in your app’s Documents folder. Control of the video is in your hands and those of your customer. No servers. No accounts. Use of the videos from your app can be totally unlimited or fully restricted. You decide.
  • H.264 video encoding.

It’s Free

iVidCapPro is available free of charge.  You can use it in your apps, commercial or otherwise.  You may not repackage it and sell it as a Unity asset.  You are encouraged to modify it according to your needs.  If you find bugs or have enhancements you’d like to share, feel free to post your changes on the Unity forums in the iVidCapPro thread or send them to support@eccentric-orbits.com.  If there is sufficient interest we may, in the future, create a public source code repository for the project.

Because it’s free, there is no official support for iVidCapPro. If you’d like more details about this, view this post.

Requirements

iVidCapPro requires Unity Pro. iVidCapPro is known to work with the following versions of Unity:

  • Unity Pro and iOS Pro – 3.5, 4.0, 4.1, 4.2, 4.3, 4.5

It also requires:

  • iOS SDK 5.0 or higher

 

161 thoughts on “iVidCapPro – Unity Plugin

  1. Wow! So generous!! The source code for iOS is something I’ve been stuck on for months: you are literally helping me get past a limitation of my iOS knowledge with OpenGL rendering for avcapture sessions.

    So…. Where do I donate you some cash? 😉

    • I’m really pleased it’s helpful to you. :)

      No need for cash, I’d just ask you to consider paying it forward. If you devise a cool addition to iVidCapPro, think about sharing it with the community.

      Cheers!
      Mal

  2. Awesome job, really useful source code, good documentation and easy to use!

    I think you should reconsider to accept some cash donations.. all the assets you can find for unity are quiet expensive.

    Thanks a lot!

  3. This comment was received from OPtoss at an obsolete location. I’ve moved it here.

    =====================
    As a member of the Unity Community, I’d like to thank you for making a free and useful plugin for us all to benefit from! Very cool of you, and I’ll try to do the same sometime.

    I previously did such a video recorder for one of my apps, and had to test a variety of methods. Encoding speed was an important factor to me, so I tried to find the fastest option available.

    I tried using GetPixels and passing that information directly to XCode without going to disk. That was quite slow, using both a native call and passing a large amount of data.

    I also tried writing a png to disk manually, then reading it back on the XCode side. That was better, but still not great.

    I ended up using CaptureScreenshot to read and write the frames to disk and then read them back on the XCode side and compiled them into a video. This was still not very fast, but it was the fastest solution I found.

    All that to say, what do you need the RenderTextures for? Which method are you using? Have you tried CaptureScreenshot?

    Thanks,
    -OPtoss

    • Thanks for commenting and sharing your experiences.

      I also tried several different approaches while developing iVidCap/iVidCapPro. In each case I was seeking better performance.

      The current version uses Rendertextures because that allows me to pass the native texture id from Unity to the iOS native plugin. With that texture id a polygon is rendered using the texture. That polygon has its texture bound to a high speed access buffer (CVOpenGLESTextureCache) which can feed directly into the video encoding pipeline.

      Compared to approaches that rely on intermediate video frame files, the technique I mention is pretty fast. Recent changes to Unity hold out the promise of an even faster solution, since Unity now has the ability to accept a native texture id as input (i.e. as created by a native plugin) and render into that texture. This could save the intermediate step of rendering to a polygon that is used in iVidCapPro.

      I hope this makes sense. It’s a brief rendition of a considerable amount of code. 8^)

      Cheers,
      James

  4. Super Cool of you to share this awesome plugin. I’ve been scratching my head trying to figure out how to this for a while. Big Thank You.

    btw: I’m really curious about your comment:

    “Recent changes to Unity hold out the promise of an even faster solution, since Unity now has the ability to accept a native texture id as input (i.e. as created by a native plugin) and render into that texture”

    Can you give some pointers where I can find this new functionality in Unity. Is it in unity 4.3?

    Cheers.

    • You’re very welcome. 8^)

      Actually, I already use Texture.GetNativeTextureID in the iVidCapPro plugin. This allows one to pass the “hardware” id of a rendertexture from the Unity runtime to the native plugin. The native plugin can then work with this texture directly from the GPU memory, rather than copy it into CPU memory. This is how iVidCapPro avoids the use of techniques that involve SetPixels, which is pretty slow.

      In fact, I was referring to Texture2D.CreateExternalTexture.

      This allows Unity to make use of a texture that is created by the native code plugin. This texture could be created using the CVOpenGLESTextureCache in the plugin, which means it can be accessed rapidly for input to the video encoding stream. This would avoid iVidCapPro’s current need to re-render the texture from Unity onto a polygon whose texture was created using CVOpenGLESTextureCache.

      The reason it’s only a “promise” right now is that the CreateExternalTexture method is only present on a Texture2D. I don’t know of any way to render directly to a Texture2D. I think what we really want is to have this method on RenderTexture. I haven’t studied this, though, so something might be possible that’s not obvious at first glance.

      The above explanation makes a lot of assumptions about what you already know. If it doesn’t make sense, remember you can always download the source for iVidCapPro and study it. 8^)

      Cheers,
      James

  5. Thanks James for the detailed explanation. Clearly your answer is from a veteran perspective. Many hard-earned IOS/Unity Video integration merits.

    I have downloaded the code and been studying the code. Ayah, my head is hurting because I’m trying to learn Objective-C at the same time. This is the best way to learn.. jump right in.

    ” This would avoid iVidCapPro’s current need to re-render the texture from Unity onto a polygon whose texture was created using CVOpenGLESTextureCache.”

    If you don’t mind, can you point me to area of the code where the polygon is created. This will help me a loads because I tried to find it but could not.

    Another little question: It seems that IVidCapPro has a very complete framework for working with video. I would like to play back a recorded movie to a renderTexture in unity instead of using IOS player. If you have some thoughts about this, would love to get some advice.

    • Hey Tim,

      You can find the render I referred to in the file GPUImageMovieWriter.m, in the method renderAtInternalSize. On or about line 547 you’ll see the call to glDrawArrays, which renders a polygon with the texture that got passed from Unity into the plugin.

      The path to get here is not necessarily obvious. It runs something like:

      ivcp_CaptureFrameFromRenderTexture
      writeVideoFrameFromRenderTexture
      GPUImageTextureInput – processTextureWithFrameTime
      GPUImageMovieWriter – newFrameReadyAtTime
      GPUImageMovieWriter – renderAtInternalSize

      The framework used in iVidCapPro is called GPUImage and is a modified version of the framework by that name developed by Brad Larson and others. You can find their current version at https://github.com/BradLarson/GPUImage

      It’s definitely worth studying as well. I believe GPUImageMovie provides the ability to load a movie and process it through the image framework. This means it should be possible to use the framework to to read the movie and render each of its frames into a rendertexture that was created in Unity. How hard it is to do this at the proper playback speed it not clear. Actually there are many details here left to the imagination. 😛 But perhaps this will be enough to get you started.

      Here’s another useful URL: http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework

      Best of luck!
      James

  6. I found some info in the Unity forum about

    http://forum.unity3d.com/threads/214310-Texture2D-CreateExternalTexture-and-Texture2D-UpdateExternalTexture

    “The basic idea is that you’ll have a native code plugin that does something with DX11, most likely creating textures. You’d pass a System.IntPtr from the plugin into the Unity script code and call Texture2D.CreateExternalTexture. Unity then fakes up a Texture2D for you to use in your script code, but, in reality, it’s using your texture from your plugin. As an when you’d want this texture to change, you would call UpdateExternalTexture on it, passing in a new IntPtr from your plugin”

  7. James,

    Been studying GPUImage and IVidCapPro intensively for the past few days. Quite a lot to take in, especially trying to compare your changes with GPUImage base code. As a example project, I decided to take your existing code and try to play a movie into unity texture. I took your code as an example and created the following:

    //
    // IVidPlayer.mm
    // iVidCapPro

    #import
    #import
    #import
    #import

    #import
    #import
    #import
    #import
    #import

    #import “IVidPlayer.h”

    // Use this to get the Unity GL context.
    extern “C” EAGLContext* ivcp_UnityGetContext();

    // Use this to send messages to the iVidCapPro plugin on the Unity-side.
    extern “C” void UnitySendMessage(const char* obj, const char* method, const char* msg);

    @implementation ivcp_VideoPlayer

    – (id)init
    {
    self = [super init];

    if (self) {

    NSURL *sampleURL = [[NSBundle mainBundle] URLForResource:@”sample_iPod” withExtension:@”m4v”];

    movieFile = [[GPUImageMovie alloc] initWithURL:sampleURL];
    movieFile.runBenchmark = YES;
    movieFile.playAtActualSpeed = NO;

    }
    return self;
    }

    – (void) setTextureID: (GLuint)texID {
    textureID = texID;
    }

    – (GLuint) getTextureID {
    return textureID;
    }

    -(BOOL) beginPlayingSession {

    NSURL* movieFileURL;

    // Save the Unity GL context to restore after initializing GPUImage.
    //glFlush();
    glFinish();
    EAGLContext* unity_context = ivcp_UnityGetContext();

    //NSError* error = nil;

    NSLog(@”beginPlayingSession called…”);

    // Setup GL texture from which we will be capturing images.
    textureInput = [[GPUImageTextureInput alloc] initWithTexture:textureID size:frameSize];

    // Pipe the texture directly to the movie Player.

    [textureInput addTarget:movieFile];

    // Restore to Unity’s context.
    //glFlush();
    glFinish();
    [EAGLContext setCurrentContext: unity_context];

    return YES;
    }

    @end

    /* ——————————————————————————–
    — Plugin External Interface —

    ——————————————————————————– */

    extern “C” {

    static ivcp_VideoPlayer *vp;
    static bool ivcp_showDebug = true;

    // Display the specified message using NSLog.
    void ivcp_Log(const char* message)
    {
    NSString *nString = [NSString stringWithCString:message encoding:NSUTF8StringEncoding];

    NSLog(@”%@”, nString);
    }

    // Initialize a recording session.
    void ivcp_BeginPlayingSession(GLuint textureID)
    {
    vp = [[ivcp_VideoPlayer alloc] init];

    [vp setTextureID:textureID];

    [vp beginPlayingSession];

    }

    }

    ————————————-
    /Users/iVidCapProLib/iVidCapPro/IVidPlayer.mm:77:29: Incompatible pointer types sending ‘GPUImageMovie *’ to parameter of type ‘id’

    at this line: [textureInput addTarget:movieFile];

    I’m a bit confused about how to use GPUImage to render to a Unity RenderTexture. Would greatly appreciate if you could share your insights.

    Thanks so much.

    • Hi Tim,

      Before saying anything else, I should be clear: I don’t know how to make GPUImage render to a Unity rendertexture. 😛

      That being said, I do believe it’s possible. I think a change to the internals of GPUImage may be needed to allow an application specified texture id to be bound to a render target. Looking at the GPUImageOutput class may be the place to start.

      As regards reading loading a movie and processing it, this example may be useful: https://github.com/BradLarson/GPUImage/blob/master/README.md#filtering-and-re-encoding-a-movie

      You are definitely venturing into unknown territory. It’s heroic and I wish you the best of luck! 8^)

      Cheers,
      James

  8. James,

    I do very much appreciate for all the help you’ve so kindly provided.
    I will continue to forge ahead with the new tips that you’ve given. Should I be lucky enough to find the missing DaVinci Code to this GPUimage->Unity you will definitely be the first to know.

    Thanks you again for sharing your project and your knowledge.

    Cheers,
    Tim

  9. James,

    Thank you so much for the incredible plugin. I am a long time iOS dev, but new to unity, and this took all of about 15 minutes to get up and demoed in our app… simply amazing! I made some modifications to the SampleManager and was able to get microphone recording along with the video – it synced very nicely. The only issue we have seen, and I hope you can shed some light on where we went wrong, is that when a video is saved to the photo album, the preview icon is blank (err.. black). It seems there is 3 – 5 frames of flat black before the video starts. Any suggestions on why that may be? Again – thank you so much for your incredible (and generous) work.

    • Hi Matt,
      Thanks for stopping by and commenting. I’m glad your finding iVidCapPro easy to integrate. That was one of my goals from the outset. It was originally even simpler, but when I added the ability to record from multiple cameras it became slightly more complex. Still…15 minutes seems a reasonable integration time. 8^)

      I don’t have a ready answer for the first few starting frames being blank. Hmm… are you using a dedicated camera to perform your recording? If so, and if the camera is only enabled when recording begins, there could be a race between the rendering pipeline and the plugin, with the result being a few blank frames at the start. This is pure speculation, but it seems possible. One way to check it would be to enable the recording camera and delay the call to BeginRecordingSession by a few frames (e.g. using a coroutine).

      I hope this helps. Feel free to post back here either way.

      Cheers,
      James

  10. Hi James,

    I am not using a dedicated camera, but I went ahead and added a co-routine that enables the camera anyway and delays by .2f seconds, a still no luck, the first few frames are blank for some strange reason. Perhaps I am not enabling the camera correctly? I do it with the following co-routine:
    IEnumerator waitForIVid(){
    vrController.videoCameras[0].enabled = true;
    yield return new WaitForSeconds(.2f);
    }

    Any thoughts here? Anyway I could trim blank frames from the video or anything else I should look at?

    • Hi Matt,

      I am (no pun intended) drawing a blank on this one. When you start recording, I assume the camera being recorded is already rendering something that is not blank? An obvious question, I know, but I had to ask.

      The only suggestion I have at the moment is to put the SampleManager script in your scene and wire it up to the camera you want to record. If you do this, and use the “Start Rec” button on the SampleManager UI, do you still get the blank frames?

      You could, of course, trim the blank frames from the video, but that would have to be done in some external program. I’m guessing that’s not what you’re after.

      BTW, what device are you testing on?

      Cheers,
      James

  11. Hi James, thanks as always for the response. I am on an iPhone 5S and iPad 2. I think the issue is I am running a pose estimation (head tracking) lib as well, and I think that this is causing an initial slowdown when I start the recording. I tested without the pose estimation lib and it seems to work well. I had the same issue when integrating the sampleManager. Its very odd as it only misses the first 3 – 5 frames, and everything else is perfect. It would not even be an issue except when the video is saved to the camera roll, all the thumbnails are blank. There is a small but noticeable jitter right as a press record and unity loads the Native Plugin. Is there anyway to load this at start (ie.. not when the record button is pressed) and that is where it is missing the frames. Very odd, I’m unsure of how to proceed. Thanks again for your comments, I sincerely appreciate it!

    matt

  12. Hi Matt,

    So, if I understand what you’re saying… when you run with the pose tracking plugin you get the blank frames. When you run without the pose tracking plugin, you do *not* get the blank frames at the start. Is this correct?

    If so, I’m wondering if there is some way you can delay the iVidCapPro call to BeginRecordingSession until after the pose tracking plugin has time to perform its initialization. I don’t understand, though, how the pose tracking could be affecting the rendering. Does it have any kind of visual element that is rendered to the screen? Is it possible that it is actually causing a handful of blank frames to be rendered when it starts up?

    I realize I may be confused about the order of processing in your app and that my questions may not actually make any sense. 😛

    James

  13. Hi there,
    First of all, this is an amazing package that works amazing.
    I’ve installed it a few weeks ago and was super pleased with how easy it was to get it to work, and the rendering performance.
    I did however, upgraded to Unity 4.5 and now I’m getting post build errors.
    iVidCapPro_PostBuild ERROR: Could not find insertion point.
    UnityEngine.Debug:LogError(Object)
    iVidCapPro_PostBuild:OnPostprocessBuild(BuildTarget, String) (at Assets/Editor/iVidCapPro/iVidCapPro_PostBuild.cs:119)
    UnityEditor.HostView:OnGUI()
    Did you Unity change something again?
    Thanks,
    Eyal

    • Yep, after looking a bit into it, I found that unity removed the insertionPoint // — AppController
      But when I’m adding it manually , I’m still getting error
      _mainDisplay undeclared variable;

      • I was able to build by manually adding

        // Added for use by iVidCapPro.
        extern “C” EAGLContext* ivcp_UnityGetContext()
        {
        DisplayConnection* display = GetAppController().mainDisplay;
        return display->surface.context;
        }

        after

        void UnityInitJoysticks();

        Hope this helps.

    • Hey Eyal,

      Thanks for the kind words and for digging into the problem you encountered!

      I haven’t installed Unity 4.5 yet, but it doesn’t surprise me that it broke iVidCapPro’s post-build processing. It’s rather sensitive to changes in AppController.mm.

      I’m glad you were able to find a workaround. I have a looming deadline at the day job right now (just returned home after a 16 hour day :P) and it may be some days before I can release a fixed version.

      Thanks very much for posting your solution here!

      Cheers,
      James

  14. Hi James,
    So Unity just released 4.5.0f6 and things have changed again :)
    I was using 4.5 developer beta before.
    Anyways to fix this again just add the following lines to the end of UnityAppController.mm

    extern “C” EAGLContext* ivcp_UnityGetContext()
    {
    DisplayConnection* display = GetAppController().mainDisplay;
    return display->surface.context;
    };
    Cheers,
    Eyal.

  15. Hi,

    I have enabled recording for my iOS game, if I enable iVidProVideo on one camera everything works fine (avg 50 fps) but if I enable iVidProVideo to the GUI camera I get 5 fps. Profiler says its GetPixels function that is causing the delay

    I believe this http://forum.unity3d.com/threads/unity-4-2-camera-aaresolve-ios-onrenderimage.197666/ can be the root cause

    is it viable to change the iVidProVideo behavior to use ‘OnPreRender/OnPostRender’ instead ‘OnRenderImage’ if so what changes do I have to do?

    Also how can I set the rendering order of the two cameras? my level camera allways draws on top on the final video occluding the GUI camera.

    • Hi Alejandro,

      Sorry for the delayed response. I’ve been travelling and have just returned.

      Someone else encountered what may be a similar issue. It turns out that if you use OnRenderImage on a camera that has a target rendertexture assigned, performance problems are likely. Are you doing this?

      When setting up iVidCapPro it’s important to either assign iVidCapProVideo to a camera OR use pass a rendertexture to iVidCapPro (SetCustomRenderTexture) but not both.

      If that’s not your problem, I suggest trying to use the custom rendertexture approach anyway. You could have both your cameras render to the same target rendertexture (you would need to render them manually each frame) and setup iVidCapPro to use that rendertexture.

      As far as using iVidCapPro to use OnPostRender… I’m not sure. The problem I see is that OnPostRender doesn’t give you access to the image being rendered by the camera.

      For the rendering order, that should be controlled by the camera depth. That’s the way it has worked for me. The camera with the greater depth value should render on top of the camera with the lesser depth, in the video as well as on the screen.

      Hope this helps.

      Cheers,
      James

  16. Hi James,
    Sometimes, after recording 20 sec of 1024*768 on iPad Air, and saving the video to library I’m getting memory warnings but the app continue to run with no issues.
    However, if I exit the app and return back to it. the app resets itself ( crashed and relaunch).
    I was just wondering if we need to free up the memory taken by the video in unity, or you are already doing it behind the scenes?
    Thanks,
    Eyal

    • Hi Eyal,

      iVidCapPro should be releasing any memory it is using for the video when the recording session is ended. I did verify this when I originally developed iVidCapPro, using Instruments in Xcode and also the Unity development build debug (actually, I think there’s a #define to uncomment in one of Unity’s xcode files, but I don’t recall the name right now).

      That being said, a bug is always a possibility. For checking your app’s memory usage, I’d recommend using the techniques mentioned above. That should help pin down the location.

      Regards,
      James

  17. Pingback: Announcement: iVidCapPro 1.2 Available | eOe

  18. HI , First of all thanks alot for this great asset , May GOD bless you.

    I am trying to build for IOS 7 with xcode 5 , but while building the project i am getting linking error something to do with arm library.
    I have set up orientation to auto rotate as its an IPAD App.
    Please help me to resolve this issue

    ld: file is universal (2 slices) but does not contain a(n) armv7s slice: /Users/unbounded/Desktop/Optimed-IOS/Libraries/libiPhone-lib.a file ‘/Users/unbounded/Desktop/Optimed-IOS/Libraries/libiPhone-lib.a’ for architecture armv7s
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

  19. Hi Kashif,

    Thanks for trying out iVidCapPro and stopping by to comment.

    The link problem you’re experiencing does not appear to be related iVidCapPro, but rather to the Player settings in Unity. If your version of Unity contains a “Target Platform” field in the Player settings, try setting it to armv7.

    Also, you might try searching the Unity forums for the linker message. There may be something useful there.

    Good luck!

    Cheers,
    James

  20. Hi Sir,
    How to access the location when you choose to save to documents ,,, where is it stored and how to access the location that is used by iTunes file sharing… please help

    • Hi Kashif,

      Look at the GetDocumentsPath() method in the iVidCapPro C# script. This will show you one way the path to the Documents directory for your app can be obtained. This is the location where video files will be stored when you select Save_Video_To_Documents.

      This is also the place from which files are accessed when you enable iTunes file sharing for your app. To learn how to do that, have a look at this link:

      http://answers.unity3d.com/questions/468298/writing-files-and-reading-them-in-itunes-or-other.html

      Cheers,
      James

      • Thanks alot,

        SIr , is there any way to store these files externally and then make video out of it ,, i mean store in a raw format and then some other program can render that.

        Regards
        Kashif

        • Hi Kashif,

          I’m not sure I understand what you are asking. What do you mean by “raw” format and “some other program can render that”?

          If you mean create an uncompressed video, you might be able to do this by changing the native plugin code. I don’t know if the iOS video framework supports an uncompressed format. Such a video would have a very large file size if it was of any significant length.

          Cheers,
          James

  21. HI,

    First of all thanks for excellent plugin , and that awsome , May be you can shed some light on the situation i have and can guide me in right direction.

    I need to store the images on an external server rather than internally , my client has a requirment where he wants to render the videos recorded by unity IOS/PC (although this Awsome plugin for IOS only) on his server and store them on his server rather than locally on device , Is it possible to do that any way around , or you can guide me to a better way , like storing locally and somehow then transfer the file to a server.

    I have searched alot of internet for this and could not find answer to it and my knowledge about OPENGL is very limited .

    Please also shed light how are you storing the recording , are you recording the frames or images and playing them sequentially , If its OPENGL Frames cant it be rendered by any other OPENGL renderer if provided that information .

    ALL you help is highly appreciated .,, Thanks for helping the mankind and humaity .

    Once again its awesome product and if i can make any good of it i would like to provide the code to you so other community can also benifit from it.

    • Hi Patrick,

      You’re welcome. I hope the plugin proves useful to you.

      If I understand what you’re asking, I would recommend that you use the videos as they are currently being written by the plugin today, and transfer them to the target network server after recording is complete. You could do this from the C# scripting side in Unity, possibly using the Unity “www” class or your own custom network code. It’s possible to register a C# delegate to be notified when the video recording is complete. See the iVidCapPro docs for more info on that. If you use the Save_Video_To_Documents option when you end the recording session the video files will be stored in the apps Documents folder. This will prevent them from being placed in the device’s photo album/camera roll. See the GetDocumentsPath() method in the iVidCapPro C# script to see how to get the path to the Documents folder.

      The videos are stored using H.264 compressed QuickTime movie files. There is no relationship between this format and openGL.

      Hope this helps!

      Cheers,
      James

  22. Pingback: Announcement: iVidCapPro 1.3 Available | eOe

  23. quick question. When I render video into the photo library , what is the path that it saves to on IOS? I’m trying to upload this file automatically to S3. I can do it when saving to documents, but then it’s not accesible in photo library.
    Thanks,
    Eyal.

  24. Hey Eyal,

    Quick answer – I don’t know! 😛

    Longer answer… When moving into the photo album, the plugin (native side) uses the method UISaveVideoAtPathToSavedPhotosAlbum that is part of UIKit. It takes care of doing the actual copying so the application never knows the explicit destination. I suspect this is deliberate on Apple’s part so they can change where the photo album is stored and applications don’t care.

    Sounds like you need an explicit iVidCapPro method to move a video to the photo album. This would allow you to first have it written to your app’s Documents folder, upload it to your server and then you call the new method to move it to the photo album.

    This would be a reasonably straightforward modification to the plugin. The method to look for in the native code is moveVideoToPhotoAlbum. You would create a C++ wrapper for this, something like ivcp_MoveVideoToPhotoAlbum. The only tricky bit here is to be careful with the copyToPhotoAlbumCompleteFromVideo “delegate” that gets called when the copy is complete.

    Then on the Unity side, a comparable C# method in iVidCapPro.cs. You can always get the path to your apps document directory using GetDocumentsPath.

    Hope this helps.

    Cheers,
    James

  25. Pingback: Joel Herber » Recording and Playing Back Gameplay In Unity

  26. Hi Author,

    I want to capture video for my mac and PC stand-alone builds. Is there any way to create a video from iVidCapPro without using iOS stuffs.
    If yes, please let me know soon.

    It would be really helpful for me.

    • Hi Pratap,

      No, iVidCapPro targeted specifically for iOS devices. For other platforms you will need to find a different solution. The Unity forums and Unity Answers may be useful places to look for solutions for those platforms.

      Regards,
      James

    • Hi,

      Is it your intention to capture audio from the microphone while recording? If not, make sure you specify the CaptureAudio setting to “Audio” and not “Audio_Plus_Mic” on BeginRecordingSession().

      If you do need to capture audio from the scene and the mic, try using the MuteSceneAudio property on the iVidCapProAudio component. The scene audio will still be captured, but it won’t be played through the device speaker. This should eliminate the echo.

      The only other option is to use a headset with a mic.

      Regards,
      James

      • Is there anyway to keep playing a sound of my choice in the scene and still having the mic input added to the video file without appearing as an echo to the voice while recording?

        • Is the voice you are recording also being played back while recording? That’s the only reason I can think of that would cause a voice echo. If that’s happening you need to ensure that the voice is recorded but not played back during the recording.

          • When I use the Audio and mic parameter when starting recording apparently the default is that the mic ecchos in game, I am doing some sort of a karaoke game where I need the player to sing along an audio file while recording himself via cam. So I cant and I dont want to have his voice to ecchoo while he is recording but I want him to hear the music while recording and finally here his voice, hear the music and see himself in the final video file.

  27. ASaher,

    I think I understand the problem now. In order for the incoming audio from the mic to be recorded, the mic’s audio clip is being played into the scene during the recording. This allows it to be picked-up by the AudioListener component that is creating the audio track for the video. It also means that it will be played over the device speaker. This works fine if you are using a headset, but not so well if you’re using the device’s built-in speaker and mic, since it sets up a feedback loop.

    The only solution I’m seeing right now is that the audio from the mic needs to be recorded to a separate audio file and that audio file then be merged with the video after the recording is complete. iVidCapPro can handle the merging of the audio file with the video. You just need to get the user voice audio file created.

    I’d recommend you look at the code in Plugins/eOe/iVidCapProAudio.cs. This has all the code you need to write a .wav file from an AudioListener. Instead of using an AudioListener, however, you will need to source the audio from the mic’s audio clip. The Unity docs and forums can help you there.

    A rough outline of your flow looks like this:

    1) Start video recording. Call BeginRecordingSession(), capturing audio from just the scene.
    2) Start recording audio from the mic (copy the code from iVidCapProAudio.cs and modify it to write a separate audio file into the app’s Documents folder using the mic as the audio source)
    3) User sings
    4) Stop recording. Call EndRecordingSessionWithAudioFiles() and pass it the name of the user’s vocal audio file.

    Best of luck,
    James

    • I just got this working, but I bumped into another problem. When streaming audio using the Load type “Stream from disc” in the import settings the audio is stopped when starting to record. The only solution I have found so far is to pause the streaming audio clip while setting up the recording session and start playing it again when its done.

      You have any experience with this ?

      • Hi Fille,

        Ugh. That is ugly. :(

        When you say “pause the streaming audio clip while setting up the recording session and start playing it again when its done”… does that mean until the recording session is complete or until after you perform the setup? In other words, does this entirely prevent you from using streamed audio during a recording session?

        Unfortunately I have no experience with streamed audio. Does it seem to be related specifically to recording from the mic and using streamed audio at the same time?

        Cheers,
        James

        • I am not entirely sure, but it works if I just pause the streaming audio and after the recording is setup I resume it again.

          I am not sure if I will investigate further or just settle for this solution.

  28. Pingback: Announcement: iVidCapPro 1.4 Available | eOe

  29. Hello Malveka,

    Your plugin is working perfectly for the IOS version of our app, But I wanted to know if you can recommend something that we can use to record videos on Android?

    Best regards,
    Abdelrahman Saher

  30. Hi there,
    I was wondering if there’s a way to specify compression type and output format (.mp4, etc..).
    I know we can change the quality (bitrate) but was wondering about the other options.
    I’m trying to upload a video that I’ve rendered using iVidCap 480*480 to vine and getting an error. I was wondering if it’s a compression of extension issue.
    Thanks.

    • Hey Eyal,

      The compression type is H.264, which is very standard. I doubt that’s the problem. MP4 and MOV can be interchangeable when using H.264. Have you tried simply renaming your file to have .mp4 extension? That’s worth a shot.

      I’ve never used Vine, but I understand it really only wants videos that have been created in the Vine app. So there may be some trickiness involved in getting other videos to be accepted. Are you able to get any other video accepted by Vine that was not created in Vine? If so, how was it created?

      To answer your question directly, no, there is currently no way to produce a .mp4 from iVidCapPro. I remember experimenting with this at some point and encountering some issues. Unfortunately I don’t recall the problems specifically. 😛 The AVFoundation framework supports producing mp4, so it is theoretically possible.

      Good luck! Let me know how it goes.

      Cheers,
      James

  31. Pingback: Announcement: iVidCapPro 1.5 Available | eOe

  32. i want to change some of this package code :
    1) i want to feed the encoder from .png files on disk
    2)i want to feed the audio source from .mp3 file
    can anyone please help me ?

  33. Thank you for nice plugin!

    Can I ask you for advice?
    I need to record two small videos and it’s really easy by your amazing package but how can I join this videos together to send it to the server? I don’t find anything in documentation about captured video source

    Cheers,
    Leo

    • Hi Leo,

      Thanks for stopping by. The videos you record will be stored in the Documents folder of your app on the device if you use the VideoDisposition.Save_Video_To_Documents setting when you call EndRecordingSession. They will be named “.mov” where is the value you passed to BeginRecordingSession.

      I’m not sure this is what you were asking, but iVidCapPro does not currently have a means to concatenate videos to create a single video. This is a feature I’m likely to add to a future version, but I can’t say when that will be. In the meantime perhaps you can copy the videos to the server separately and join them there.

      Hope this helps!

      James

  34. Hi Malveka,
    This is a great plugin to record videos from what I read. I am stuck with an error, iVidCapPro BeginRecordingSession was called with an unsupported frame size 1536*2048. I have this build on an ipad

    Thanks,
    Anish

    • I also tried with different resolution
      vr.BeginRecordingSession(“video”, 512, 512, 30,
      iVidCapPro.CaptureAudio.No_Audio, iVidCapPro.CaptureFramerateLock.Unlocked);

      I do not get any error but either the screen is stuck or there is nothing happening when I click record and then end video

      Thanks,
      Anish

      • Got through the issue, had not fixed the frames appropriately, got all the answers looking at the sample file.
        Great application, and thank you for sharing it to the community

        Best,
        Anish

        • Hi Anish,

          Thanks for stopping by! I’m glad you were able to figure out the issue you were experiencing.

          The max video size is currently limited to 1920×1080. This is essentially a limitation in iOS (at least when I last checked).

          Cheers,
          James

  35. The video is now working great, is it possible to save the screenshot in jpeg/ png to the camera roll.
    I tried to use the CopyVideoFileToPhotoAlbum method from the iVidCapProEdit, but could not succeed.
    Any help on this would be great

    Thanks,
    Anish

    • Hi Anish,

      When you say “screenshot” I’m not sure what you mean. Are you creating a screenshot? Or are you referring to the thumbnail image that is used to represent the video in the photo album?

      iVidCapPro does not currently provide support for manipulating still images. CopyVideoFileToPhotoAlbum is only useful for copying a video file from your app’s Documents directory to the photo album/camera roll.

      If you are attempting to use CopyVideoFileToPhotoAlbum to copy a video file from the Documents directory to the photo album and it’s not working for you, please give me some more details on your setup and I’ll try to help.

      Cheers,
      James

  36. Ahh got it, had to tweak the SampleManager Start method:

    public void Start() {

    // For handling messages from the video edit plugin.
    veController.RegisterNotificationDelegate(EditNotificationHandler);

    // GAW Added Jan 23, 2014 — init the array and set the only element to Main Camera
    vrController.videoCameras = new iVidCapProVideo[1];
    vrController.videoCameras[0] = (iVidCapProVideo)mainCamera.GetComponent();
    }

    • Hi Geoff,

      Thanks for stopping by. The typical method for setting the videoCameras array is to assign a value to it in the Unity editor. videoCameras is a property that shows up in the inspector for the iVidCapPro component. Still, assigning the value in a script also works perfectly well.

      Good luck with your project. I hope iVidCapPro proves useful to you.

      Cheers,
      James

  37. Thanks, yes, I see the other way now, new to Unity, didn’t get the metaphor of assigning a size to the array, THEN having the appropriate field(s) show up, long time programmer, Unity noob, thanks for a such a professional grade product.

  38. Hi

    I was wondering if it’s possible to record the video in different format, as the file is currently in .mov after recording. Do I have to process the video outside using stuff like ffmpeg?

    • Hi,

      Thanks for looking at iVidCapPro.

      There is currently no way to produce a .mp4. I remember experimenting with this at some point and encountering some issues. Unfortunately I don’t recall the problems specifically. 😛 The AVFoundation framework supports producing mp4, so it is theoretically possible.

      iVidCapPro uses H.264 for compression and I understand, though I have not verified, that it is sometimes possible to simply rename a .mov to .mp4 when using this compression scheme. It may be worth a try if you really need .mp4.

      Cheers,
      James

      • Hi James,
        Thanks for replying my question. I did try to manage simply change the file extensions to .mp4. It did work as you stated H.264 is interchangeable for mov and mp4.

        However i running into another problem is that the recording file seem to be compressed with High profile, so when i uploaded it to server and view it on android device, it just wont play(android only plays mp4 compressed with Baseline profile, the BP, 66). Can you please tell me if you did specific instruct an compression profile when generate the video or it’s somehow set default to high profile.

        Thanks

        • Hi,

          I don’t specify an explicit profile by name. You might try using the ConfigureVideoSettings method of the plugin and adjust the compression settings. Perhaps a setting of 500K to 1000K will work for you.

          Cheers,
          James

  39. Hi!

    I’m having some issues with the plugin when i build a project with the new IL2CPP in Unity, is it compatible?.

    Thank you very much for the help and for creating this awesome plugin,
    Regards.

      • Hi James,

        I’m having the same issue as Al comments in the next comment, when i stop recording xcode raises this error:

        Uncaught exception: NSRangeException: *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
        (
        0 CoreFoundation 0x29cbb60f + 150
        1 libobjc.A.dylib 0x37985c77 objc_exception_throw + 38
        2 CoreFoundation 0x29bcf157 + 230
        3 MyApp 0x011eeff5 -[ivcp_VideoRecorder ComposeTracksToURL:] + 1232
        4 MyApp 0x011ee813 -[ivcp_VideoRecorder mixAudioFiles:UserAudioFile1:UserAudioFile2:VideoFile:ToOutput:] + 738
        5 MyApp 0x011ed913 -[ivcp_VideoRecorder createVideoWithAudioUserFile1:userFile2:] + 606
        6 MyApp 0x011ed4a3 -[ivcp_VideoRecorder endRecordingSession:AddAudioFile1:AddAudioFile2:] + 834
        7 MyApp 0x011f106d ivcp_EndRecordingSession + 128

        I’m working with Unity 4.6.2p1.

        Thank you very much 😉
        Regards.

  40. Hi James,

    When running under iOS 64bit mode, I’m getting a NSRangeException error:
    Uncaught exception: NSRangeException: *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array

    This happens consistently on stopping the recording:

    0 CoreFoundation 0x00000001861ee5b8 + 160
    1 libobjc.A.dylib 0x0000000196cf40e4 objc_exception_throw + 60
    2 CoreFoundation 0x00000001860d362c + 0
    3 VideoRecorder 0x00000001010511f8 -[ivcp_VideoRecorder ComposeTracksToURL:] + 1192
    4 VideoRecorder 0x0000000101050930 -[ivcp_VideoRecorder mixAudioFiles:UserAudioFile1:UserAudioFile2:VideoFile:ToOutput:] + 840
    5 VideoRecorder 0x000000010104f9ec -[ivcp_VideoRecorder createVideoWithAudioUserFile1:userFile2:] + 664
    6 VideoRecorder 0x000000010104f4c0 -[ivcp_VideoRecorder endRecordingSession:AddAudioFile1:AddAudioFile2:] + 1064
    7 VideoRecorder 0x0000000101053198 ivcp_EndRecordingSession + 124

    Have tried re-building libiVidCapPro.a in 64bit mode with the latest Unity 4.6.2p1 (released yesterday) but getting the same error. Works fine in non-64bit builds.
    Any help would be appreciated! Needless to say – great plugin and thanks for making it free!

    Cheers, Al.

    • Hi Al,

      Thanks for providing the detailed info. It’s very helpful. I haven’t tried the 64-bit support myself yet, but I’ll look into it as soon as I can and let you know what I find.

      Cheers,
      James

      • Hi James,
        Have found that the exception is being raised by iVidCap.mm, line 979:
        [mixedAudioTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:[[mixedAudioAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0] atTime:kCMTimeZero error:&trackError];

        It appears that mixedAudioAsset is not nil, yet the objectAtIndex:0 is out of range. As a temporary workaround, I have for now used enclosed that code with a try…catch to handle the exception but unfortunately it does tackle the root of the problem.

        Cheers,
        Al.

  41. Pingback: Announcement: iVidCapPro 1.6 Available | eOe

  42. Hi James-
    Plugin is awesome :) I was thinking of attempting to rewrite the iVidCapProAudio so that it would just record from the mike, and keep the scene audio unmuted. Keep getting the echo w/mike unless I use your mute scene feature. Anyway, before I start, was curious if you had attempted this and ran into problems? I was looking into the Unity Microphone class and thought it could work…
    Thx- Alex

    • Hi Alex,

      I haven’t investigated that in any depth. It would be a great feature, though! Several people have requested it and I know I would find it useful myself. 8^)

      The problem to be overcome, as I see it, is that the iVidCapProAudio component uses the OnAudioFilterRead delegate of the AudioListener component to capture the audio for recording. So what we need is for the mic audio to be captured in the recorded audio stream, but not sent to the speakers. I’m not sure how to do that.

      In Unity 5 we’ll be getting the AudioMixer. I had a brief look at that, and it’s possible it could help, but I’m still not seeing an obvious solution.

      If you figure this out and would be willing to share it, that would be awesome!

      Cheers,
      James

  43. Hi James, thanks for your great plugin!
    I have one question related to integration, what I’m trying to do right now is: I’m adding one game object and it persists on all scenes, it has iVidCapPro script and VideoRecordingManager script on it. In Video Recording Manager script I have OnLevelWasLoaded function in which I’m trying to update render targets – specifically I’m searching for all cameras on scene and adding iVidCapProVideo component to them (if one is missing), then I set videoCameras property of iVidCapPro. The issue I have is that performance has been dropped significantly – like from 30 to 3 fps even – and by the way this happens even when I’m not starting recording process at all, I suspect that I’m doing something wrong, can you please help me with the setup. Thanks!

    • Hi Nick,

      Unfortunately, you aren’t doing anything wrong. Multi-camera support is currently working properly only when none of the recording cameras are set to depth-only or clear. It appears that in these cases the Unity rendering engine reloads the full screen texture into the input texture to OnRenderImage, causing a massive framerate impact. Also, it appears the camera depth is not honored in the calling order to OnRenderImage. As you noted, all it takes to trigger the performance issue is the presence of OnRenderImage (used in iVidCapProVideo) on more than one camera.

      It seems to me that this behavior was introduced by Unity sometime in the last 18 months or so, but I’m not certain about that. I hope to address these issues in a future version of iVidCapPro, but I don’t have a specific plan at this time.

      For now, if you need to record from multiple cameras simultaneously, your only practical option is to render the cameras explicitly into a rendertexture and then configure iVidCapPro to use that rendertexture. In this case you would not use the iVidCapProVideo component at all. Have a look in the docs under Classes->iVidCapPro->SetCustomRenderTexture.

      I hope this helps!

      Cheers,
      James

  44. Dear James,

    Many thanks for this great package! It is so refreshing to see someone altruistically release such a complex project.

    I am hoping you can help me figure out the direction to solve my problem. I need to “stream” the screen from an iOS device to another (could be iOS, Android, Win or Mac) over the network. I’ve tried the pure Unity methods of copying pixels into a RenderTexture, encoding the Bytes and streaming over the network. As you can imagine, this is extremely slow. So I thought of capturing the screen and streaming on the native side and that is how I came across your package.

    Could I use iVidCap to capture, encode and then stream the bytes over network? To be honest, I haven’t checked out the package because I’m on a deadline and am working on other bits and will invest the time in this if it can solve my problem. If only I had the liberty of time, I would have played around with this to contribute.

    Cheers!

  45. Hi James,

    I’m using Unity 5.0.2 and Xcode 6.2 and I’ve got your latest plugin version from about two weeks ago. Unfortunately it seems that I am getting the same error that you and others have been aware of and may have been fixed in Unity 4.6 but doesn’t seem to be fixed in 5.

    I’m getting NSRangeException when I attempt to record audio.

    Anyway ideas? Audio is pretty important for my project.

  46. Hi Mark,

    Sorry for the delayed response. It’s been a busy week. 😛

    I’m wondering if the problem could be due to the setup in the editor. One thing to make sure of is that the iVidCapProAudio component is at the bottom of the list of components on the object where it resides. This is especially true if you happen to have the audio source on the same object as the audio listener, but should be adhered to regardless. As you are probably aware, audio is processed in a chain down the audio components on an object, from top to bottom.

    If that doesn’t help, try turning on the plugin debug (SetDebug(true)) and/or uncommenting the Debug.Log call in the method onAudioFilterRead() in the iVidCapProAudio file. That may show something interesting.

    Recording audio is working for me in Unity5, though I haven’t upgraded to 5.0.2 yet. If you continue to have difficulty let me know and we’ll see if we can get iVidCapPro working with your project.

    Cheers,
    James

  47. I too have been getting the now infamous :) out-of-range error in Unity 5.0.2f1 and Xcode 6.3.2 and i found that changing backend scripting to IL2CPP and architecture to arm64 (was armv7) seems to have fixed things up nicely when deploying on iPhone6. I’m posting this just so that others may find this works for them.

    • I’ve been having some luck with the unity 5 patch releases. I think 5.0.2 p2 has fixed this problem for me. And Unity 5.1 just cake out so maybe give that a shot and we if it fixes the problem in a more stable way.

      Ps. Thanks for getting back to me James. I’ve been too busy to say what finally worked for me me till now.

  48. Thanks for the input guys! If anybody gives 5.1 a try it would be much appreciated if you could post your results here. I’ll be giving it a look myself in the near future.

    Cheers!
    James

  49. Hi, thanks so much for this incredible asset! I really find it useful, but like many others have been struggling to get it to work with the new 64 bit apple store guidelines.
    I’m trying to record a video in Unity 4.6.3, but am getting the following error:

    @synthesize surfaceGLES;
    – (UnityDisplaySurfaceGLES*)surfaceGLES { assert(_surface->api != apiMetal); return (UnityDisplaySurfaceGLES*)_surface; }

    Has anyone encountered this?

    • In case it’s helpful, this also doesn’t work on Unity5.1.1f1

      It’s happening pretty much the moment BeginRecordingSession is called:

      iVidCapPro_ivcp_BeginRecordingSession_m83(NULL /*static, unused*/, L_74, L_75, L_76, (((int32_t)L_77)), L_79, L_80, L_81, L_82, L_83, L_84, L_86, L_87, /*hidden argument*/NULL);

    • Hi GT,

      It looks like you may have the Graphics API set to Metal in the Unity editor. iVidCapPro doesn’t support the Metal interface. It should work with OpenGLES2 API. As far as I know that will not prevent release on the app store, though it may have performance implications.

      Cheers,
      James

  50. Great plugin. Thanks a bunch.
    I have a question.
    Does the plugin integration in Unity would get any problem with iStore app submission?

    • Hi Andy,

      I released an app in February on the Apple app store and there was no issue. Others here might have more recent experiences.

      Cheers,
      James

      • That’s very reassuring. This is going to add very nice touch to my app.
        Thank you very much James.
        You rock!

  51. Hi James. Great plugin! And works very good in Unity 5.1, but in Unity 4.6.5 i found some problems with linking in XCode. Why this happens? Is this plugin incompatible with Unity 4.6.5?

    Undefined symbols for architecture arm64:
    “_ivcp_UnityGetContext”, referenced from:
    -[ivcp_VideoRecorder beginRecordingSession] in libiVidCapPro.a(iVidCap.o)
    -[ivcp_VideoRecorder endRecordingSession:AddAudioFile1:AddAudioFile2:] in libiVidCapPro.a(iVidCap.o)
    ___52-[GPUImageTextureInput processTextureWithFrameTime:]_block_invoke in libiVidCapPro.a(GPUImageTextureInput.o)
    -[GPUImageOpenGLESContext context] in libiVidCapPro.a(GPUImageOpenGLESContext.o)
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    • Hi Alexander,

      That’s odd. I just built a test project in Unity 4.6.6 and it worked fine. Have a look in your Unity-iPhone.xcodeproj and look in UnityAppController.mm.

      You should see this at the very end of the file:

      // Added for use by iVidCapPro.
      extern “C” EAGLContext* ivcp_UnityGetContext()
      {
      return UnityGetMainScreenContextGLES();
      }

      Is that present? This needs to be there in order for the project to link.

      Cheers,
      James

      • Hi James. Thank you for the answer. I’m sorry. It’s my fault. I recreate the project from empty sheet and it work now on unity 465. It’s something mystic i think ).

  52. Hi, James, Thanks for the great plugin.

    BTW, I got
    Uncaught exception: NSRangeException: *** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array
    ….
    ivcp_VideoRecorder ComposeTracksToURL:]

    mentioned above several times with my project.
    I’m working on latest Unity4 (4.6.8p2) and iVicap 1.6.

    my situation is:
    1. I can start and stop recording at first time.
    2. second time I try video recording, it starts normally. but when I try to close recording , it crashes with errors above.

    I’m using
    extern “C” EAGLContext* ivcp_UnityGetContext()
    {
    return UnityGetMainScreenContextGLES();
    }

    and opengl3.0 as graphic api.

    Any walkaround I can make second recording works?

    • The exception above can happen for several reasons, but I discovered that this happened due to synch issues. I created this short workaround. Try replacing the existing LoadVideoAsset method in iVidCap.mm with this:

      – (BOOL)LoadVideoAsset:(NSURL*)videoURL {

      // TODO: due to timing issues, sometimes we call this method before the video file is ready.
      // this is a workaround to wait until the file is ready. The correct solution is to use a callback
      // that will be triggerred once the file creation is complete.
      // the relevant call is to finishRecording (look in GPUImageMovieWriter.cs):
      // it is calling finishWritingWithCompletionHandler, which I believe is asynchronous
      int attempts = 10;

      while (attempts > 0) {
      videoAsset = [[AVAsset assetWithURL:videoURL] retain];
      if (videoAsset == nil)
      return false;

      if ([[videoAsset tracksWithMediaType:AVMediaTypeVideo] count] > 0)
      return true;

      attempts–;

      if (showDebug)
      NSLog(@”ComposeTracksToURL: WARNING! Empty videoAsset AVMediaTypeVideo (attempts left=%d). Sleeping and Retrying…”, attempts);

      [NSThread sleepForTimeInterval: 0.1f];
      }

      return false;
      }

  53. Hi James.
    This question is little unrelated to the plugin.
    I capture a video and save the video from local app documents to the photos album with the iVidEdit save to album function. I have implemented a plugin which can directly share and email the captured video file from local app documents.
    Now the issue is that the video saved in the photos album have less file size than the video file shared directly from the apps local documents storage.
    I have checked the encoding properties info of both the files and it appears to be same except the video stream size % to be different. The album video had a stream size of 217kb (87%) and direct emailed video had stream size of 217kb (36%).
    Does iOS changes the size of the video while saving the album?
    If yes, can we change the encoding parameter for stream size.

  54. Hi Andy,

    I’m not sure what you mean by “stream size %”. Where does this number come from?

    The copy from the app documents directory to the photo album is a monolithic operation provided by UISaveVideoAtPathToSavedPhotosAlbum in the UIKit framework. It does not allow any control over the copying process. I have always assumed it copied the full video without changes.

    I have observed that whenever a video is exported from the photo album/camera roll, say via e-mail or other sharing options, that it will be re-encoded to make it smaller in file size, hence generally losing quality in the process.

    Cheers,
    James

  55. Adrian… I tried to respond to your e-mail, but my reply keeps getting bounced. Hopefully you’ll see it here on this thread.
    ==============================================
    Hi Adrian,

    Hey, thanks, I’m glad you are finding the plugin useful. 8^)

    One question about your setup. Are you using the RegisterSessionCompleteDelegate() method and insuring that a subsequent recording session can’t be started before the previous one was entirely complete? If not, that might explain the kind of symptom you are seeing.

    If you are using RegisterSessionCompleteDelegate(), could you share with me the version of iOS, Unity and the device you are using?

    Thanks very much for the code update. This looks like a good addition, regardless of the underlying cause, to prevent crashes. I’ll add it to the next version.

    Cheers!
    James
    =======================

    Hi there,

    First of all I just wanted to say thank you for creating such a great piece of software, and being so generous to give both the software and source code away for free.

    Additionally, I found a bug in iVidCapPro which, under the right circumstances, causes the app to crash. Unfortunately I’m not 100% sure the exact circumstances to recreate the problem, but we found once every 20 or so times recording the video the app would crash. It came down to line 1017 in iVidCap.mm:

    [videoTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, videoAsset.duration) ofTrack:[[videoAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:&trackError];

    Which tries to get video track 0 of the recorded video file. On the occasions the code would crash the app, the video file would not contain any video tracks – I suspect perhaps the encoding thread hadn’t finished yet due to some hold up in the I/O process – and then when the code tried to get “objectAtIndex:0” it would have an array out of bounds error.

    To work around this, in the LoadVideoAsset function, I added an additional check if the videoAsset was able to load properly that there was at least one video track, if not it releases the video asset, calls AbortRecordingSession with “Failed_SessionExport”, and returns false from the function. The new function looks like this:

    – (BOOL)LoadVideoAsset:(NSURL*)videoURL {
    videoAsset = [[AVAsset assetWithURL:videoURL] retain];
    if (videoAsset == nil) {
    if (showDebug) NSLog(@”LoadVideoAsset: Could not load video asset”);
    return false;
    } else {
    if ([[videoAsset tracksWithMediaType:AVMediaTypeVideo] count]<1) {
    if (showDebug) NSLog(@"LoadVideoAsset: Video asset contains no video track");
    [videoAsset release];
    videoAsset = nil;
    [self abortRecordingSession: Failed_SessionExport];
    return false;
    } else {
    return true;
    }
    }
    }

    I also made similar changes for all the functions which load Audio Assets, although I haven't had issues with them crashing the app, I felt it would be better to be safe than sorry.

    Please feel free to include the changes into your next update for iVidCapPro, and thanks again for making a great piece of software.

    Cheers,

    Adrian

  56. Hey James,

    Video looks great, and I’m loving it. However, I’m having two problems – 1. I can’t get microphone audio to record. I’m using Unity 5.1.2. Not getting any errors. Audio Source is created and microphone is set, then a tempAudio.wav file gets written to my user directory on my drive, but its just silence.
    – 2. When I try to record with audio_plus_mic, not only is it silent, but the file won’t save once I’ve recorded it.

    I’ve tried all kinds of stuff. Read the documentation, tried the SampleManager, reordered the objects, separated the AudioListener form the source, but I’m just getting the same effect every time. I’ve gotten a few intermittent writes to the tempAudio file of crazy feedback after a significant delay after pressing record (since mute scene audio wasn’t checked), but then it would go away, and I couldn’t repeat it.

    Also can’t figure out why writing audio goes to the Documents folder, but the temp audio goes to my user home directory. Seems like the paths are the same in the code? Maybe that’s part of my saving issue?

    I’d be happy to send you my session if that helps.

    Thanks for your hard work and help,

    Shaw

  57. Hi Shaw,

    Shaw said in e-mail:

    “Scratch that. Made a new project, did the samplemanager, stripped the code I needed out and got it working perfectly. Not sure what I was doing wrong before, but it works now. So, never mind, but thanks so much for making an awesome plug-in!”

    Glad you got it working! Good luck with your project.

    Cheers,
    James

  58. Hi,

    Am I understanding correctly that there is no support for Metal? If so, is that something you’re planning on implementing?

    Thanks very much, what an amazing resource to be offering!

    Adam

    • Hi Adam,

      You are correct. iVidCapPro does not support Metal at this time. It’s something I would like to investigate, but I’m not actively developing iVidCapPro right now owing to other projects, so I can’t offer any kind of timeline.

      If you are ambitious the source code is available, so… 8^)

      Best of luck with your project!
      James

  59. Regarding the out-of-range exception, I’ve started getting this when running on iOS 9.2. Tried various things to try and fix it, but found that by changing the file extension from .mp4 to .mov the problem goes away!

  60. Hi,
    I didn’t get all plugin features for Unity, so would like to clarify – is it possible to combine 2 and more videos in user gallery (or video recorded in the app) to 1 single video?

  61. Hi Roman,

    iVidCapPro lets you add audio tracks to the video, but not merge video tracks. So no, using iVidCapPro you cannot combine multiple videos into a single video.

    Cheers,
    James

  62. Hi James,

    I have been working on getting your plugin to record video to work for a while now, and so far I have only been getting out a black video with audio. I have tried various settings and assignments in unity, as well as updating deprecated functions in the plugin itself for the newer ios versions. Do you maybe have any advice please?

    Thanks,
    Ben

    • Hi Ben,

      Sorry I didn’t reply sooner. Missed this post somehow.

      If you’re still interested… make sure that the iVidCapProVideo component is placed on a camera and that the iVidCapPro component property VideoCameras includes the camera that contains the iVidCapProVideo component.

      Also, try using the SetDebug() method to see if any helpful information is produced in the Xcode output log.

      Cheers,
      James

  63. Hi,
    First of all thanks for your work, it’s amazing! =D

    I just want to let you know that in the documentation I think there is a mistake in the examples. You have written:

    vr.EndRecordingSession(
    iVidCapPro.VideoDisposition.Save_To_Album, // where to put the finished video
    out framesRecorded); // # of video frames recorded

    But when I copied this in my project it fails. Looking for into the code I found that there is not “Save_To_Album” element inside of “VideoDisposition” enum. Instead, there is “Save_Video_To_Album”. I do not know if you have changed it or it just a mistake. I changed it and everything works great.

    Cheers,
    Nestor

  64. Hi,

    This plugin is perfect working with my device, but not with simulator. An error pops up when running in simulator:

    dyld: Symbol not found: _ivcp_BeginRecordingSession

    My environment is:
    Xcode 7.3.1 + Unity 5.4.3f1 (also tried Unity 5.3.2f1)

    Steps to compile is:
    1) In Unity3D set Target SDK to “Simulator SDK” and build out Xcode project.
    2) In Xcode build project with Simulator set to iPhone6, and run it with Simulator popping up.
    3) Then error comes. (if manually click the app, no content is loaded)

    Currently Apple has rejected the app review with reason: “Upon launch no content is loaded.” I suspect it is because they are using simulator to do review. But there is no solution so far to fix this after trying changing the settings, upgrade unity version.

    Is there anybody encounter the same issue? Or let me know what it is wrong with simulator. I will be very appreciated.

    Cheers,
    Tuani88

  65. Hi,

    Does the session complete delegate get called just when saving video, or when discarding it as well? Because I don’t seem to be getting callbacks when discarding…

    Thanks!

  66. Hello James,

    First, thank you for this excellent plug-in. Unfortunately I am seeing some broken behavior and I am hoping you can shed some light on what I can do about it.

    The issue seems to be related to something other users have commented on, namely that “sometimes” iVidCapPro will give an out-of-bounds error regarding the created audio file. I.e., if I record a video with audio I get this out-of-bounds error under certain circumstances, which seem to be:

    1) On any iPhone device, starting a recording stream and then immediately stopping it
    2) On iPhone 6S devices (but NOT 6S Plus), starting a recording stream and then stopping it after ~7+ seconds have gone by

    Following the advice of other posters, I modified the iVidCapPro library in Xcode to “handle” the issue by checking for the out of bounds issue and exiting / calling AbortRecordingSession with “Failed_SessionExport”.

    This prevents a crash, but has the unfortunate side effect of rendering users unable to record further video. I.e., iVidCapPro will no longer start recording after this issue occurs, and I am not sure why. Furthermore since the issue occurs every time under the above circumstances, just preventing the crash isn’t “enough” since this breaks functionality.

    Any insight would be greatly appreciated. The app is built using Unity 5.1.2.

  67. Hi!
    I think its a great plugin. But I can not get it to work :(
    i had this crash exception

    *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[GPUImageMovieWriter initWithMovieURL:size:fileType:gammaEnable:outputSettings:]: unrecognized selector sent to instance 0x1636c97e0’

    What can you advise in this regard?

    I tested on Ipad Air 2 with Unity 5.3.5f1 and Xcode Version 7.3.1 in IOS 9

    I would really like to plug worked and I need this functionality.
    Great thanks!!

  68. Hi James – and everybody else,

    First of thanks for a great plugin which easily could be monitized so very cool you’re keeping it free.

    Are you maintaining the code in a CVS repo somewhere where it is possible to contribute by creating issues and pull requests?

    The best,
    Martin

  69. Hi,

    As someone discovering this plugin at what appears to be a time where you may not have time to maintain it, I think it would be very beneficial if you put the source code in a public repository like Github. Allow others to contribute fixes and improvements, and hopefully prevent others having to figure out how to make the plugin compatible with the latest versions of Unity/Xcode. I’ve read through many comments on here from people saying how great it is and easy to setup, but I don’t think that’s entirely the case anymore, especially when using services like Unity Cloud-build where modifying Xcode files like the Unity App Controller isn’t much of an option.

    I am looking forward to seeing this in action!

    Cheers

  70. Pingback: Announcement: iVidCapPro 1.7 Available | eOe

    • Due to your recent inactivity I was under the assumption that this project is dead, and was working hard to removing the dust off of it. After a major breakthrough today, I posted a hack in hope of assisting other users, and right after doing so, I discovered that you have created an update version, which seems, in addition to other things, to solve this exact issue. So I would like to take this opportunity to thank you for this AMAZING plug-in!!! You, dear Sir, Rock!

      • Hi Mort,

        Yes, the project was definitely on low-level life support for a time. But I have recently become more involved again and I’m investigating the possibility of a major overhaul in the upcoming year.

        Thanks for the vote of confidence! 8^)

        Cheers,
        James

  71. In case you’re interested, I have a couple of small things I added to the project which might be of interest:
    1. Solving the audio threading issue (I noticed that you made a small change, but I believe that my (tiny) change is better: In a sentence, in iVidCapProAudio.cs, I moved _numStreamSamples += samples.Length inside the lock in ConvertAndWrite.
    2. I’ve added a simple “pause” feature for real-time recording.
    Both are very easy to implement and I’d be more than happy to share…

    Any news regarding working with Metal? I am using OpenGLES2 which works great, but I guess Metal is more future proof…

    • 1. Agreed! Comment on _locker var declaration really should read “We need to serialize access to any resources in this file that are accessed by both the main thread and the audio thread.” I’ll make that change.

      2. Sounds cool! I’ve often thought about adding this feature but never got it done.

      Updating to use Metal, assuming it is possible, would be part of the rewrite I’m considering.

      Here’s the deal on the rewrite – if it happens, the resultant asset will be placed on the Unity asset store for sale.

      When I originally developed this plugin I was working a full-time day job. Now I’m self-employed. The only way I can afford to spend the time to perform significant enhancements to iVidCapPro is to be able to earn some income from it.

      I’m sharing this information now in case it affects your decision about sharing any code. I think it’s important to be transparent about where the project could be headed.

      If you still want to share, that would be great. In fact, if I have time, I will consider a version 1.8 of the existing iVidCapPro to incorporate the pause/resume feature. If you want to discuss any of this privately, feel free to contact me here:

      support “that at thingy” eccentric-orbits.com

      Regardless, I appreciate your enthusiasm for iVidCapPro!

      Cheers,
      James

    • that sounds great, I’ve implemented the “pause” function as well but isn’t really working as expected.
      Would love to use your pause feature if you’re willing to share (or if 1.8 will integrate it anytime soon).

      my email is
      me “that at thingy” changemod.com

      😛

      THANKS!
      Jiannis

  72. Hello, this is a nice plugin but I’m quite confused about how to implement in my scene, I followed your code in the doc and nothing seems to happen.

    Could you provide an example scene with the plugin working? you should include it in the unity package, is way more easier to follow.

    Anyway the plugin looks really amazing and actually is saving my life at work D: (I hope you could release and Android version of it too… because I haven’t found one on that platform)

    Regards

Leave a Reply

Your email address will not be published. Required fields are marked *