Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 46522)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageControlVM.cpp	(revision 46523)
@@ -1340,21 +1340,51 @@
             RTFileClose(pngFile);
         }
-        else if (   !strcmp(a->argv[1], "enablevideocapture")
-                 || !strcmp(a->argv[1], "disablevideocapture"))
+        else if (   !strcmp(a->argv[1], "vcpenabled"))
+        {
+            if (a->argc != 3)
+            {
+                errorArgument("Missing argument to '%s'", a->argv[1]);
+                rc = E_FAIL;
+                break;
+            }
+            if (!strcmp(a->argv[2], "on"))
+            {
+                CHECK_ERROR_RET(sessionMachine, COMSETTER(VideoCaptureEnabled)(TRUE), 1);
+            }
+            else if (!strcmp(a->argv[2], "off"))
+            {
+                CHECK_ERROR_RET(sessionMachine, COMSETTER(VideoCaptureEnabled)(FALSE), 1);
+            }
+            else
+            {
+                errorArgument("Invalid state '%s'", Utf8Str(a->argv[2]).c_str());
+                rc = E_FAIL;
+                break;
+            }
+        }
+        else if (   !strcmp(a->argv[1], "videocapturescreens"))
         {
             ULONG cMonitors = 64;
             CHECK_ERROR_BREAK(machine, COMGETTER(MonitorCount)(&cMonitors));
             com::SafeArray<BOOL> saScreens(cMonitors);
-            bool fEnable = !strcmp(a->argv[1], "enablevideocapture");
-            if (a->argc < 3)
-            {
-                /* default: handle all screens */
+            if (   a->argc == 3
+                && !strcmp(a->argv[2], "all"))
+            {
+                /* enable all screens */
                 for (unsigned i = 0; i < cMonitors; i++)
                     saScreens[i] = true;
             }
+            else if (   a->argc == 3
+                     && !strcmp(a->argv[2], "none"))
+            {
+                /* disable all screens */
+                for (unsigned i = 0; i < cMonitors; i++)
+                    saScreens[i] = false;
+            }
             else
             {
-                /* handle selected screens */
-                CHECK_ERROR_BREAK(machine, COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(saScreens)));
+                /* enable selected screens */
+                for (unsigned i = 0; i < cMonitors; i++)
+                    saScreens[i] = false;
                 for (int i = 2; SUCCEEDED(rc) && i < a->argc; i++)
                 {
@@ -1373,5 +1403,5 @@
                         break;
                     }
-                    saScreens[iScreen] = fEnable;
+                    saScreens[iScreen] = true;
                 }
             }
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 46522)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp	(revision 46523)
@@ -470,6 +470,6 @@
                      "                                              [<xorigin> <yorigin>]]] |\n"
                      "                            screenshotpng <file> [display] |\n"
-                     "                            enablevideocapture <screen>,[<screen>...]\n"
-                     "                            disablevideocapture <screen>,[<screen>...]\n"
+                     "                            vcpenabled on|off |\n"
+                     "                            vcpscreens all|none|<screen>,[<screen>...] |\n"
                      "                            setcredentials <username>\n"
                      "                                           --passwordfile <file> | <password>\n"
Index: /trunk/src/VBox/Main/idl/VirtualBox.xidl
===================================================================
--- /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 46522)
+++ /trunk/src/VBox/Main/idl/VirtualBox.xidl	(revision 46523)
@@ -4263,15 +4263,23 @@
       <desc>
         This setting determines the filename VirtualBox uses to save
-        the recorded content.</desc>
+        the recorded content. This setting cannot be changed while video
+        capturing is enabled.
+      </desc>
     </attribute>
 
     <attribute name="VideoCaptureWidth" type="unsigned long" default="640">
       <desc>
-        This setting determines the horizontal resolution of the recorded video.</desc>
+        This setting determines the horizontal resolution of the recorded
+        video. This setting cannot be changed while video capturing is
+        enabled.
+      </desc>
     </attribute>
 
     <attribute name="VideoCaptureHeight" type="unsigned long" default="480">
       <desc>
-        This setting determines the vertical resolution of the recorded video.</desc>
+        This setting determines the vertical resolution of the recorded
+        video. This setting cannot be changed while video capturing is
+        enabled.
+      </desc>
     </attribute>
 
@@ -4280,5 +4288,6 @@
         This setting determines the bitrate in kilobits per second.
         Increasing this value makes the video look better for the
-        cost of an increased file size.
+        cost of an increased file size. This setting cannot be changed
+        while video capturing is enabled.
       </desc>
     </attribute>
@@ -4289,5 +4298,6 @@
         Frames with a higher frequency will be skipped. Reducing this
         value increses the number of skipped frames but reduces the
-        file size.
+        file size. This setting cannot be changed while video capturing
+        is enabled.
       </desc>
     </attribute>
@@ -14691,5 +14701,5 @@
   <interface
     name="IDisplay" extends="$unknown"
-    uuid="0598a3df-3dc0-43c7-a79c-237fb5bb633d"
+    uuid="23efdcab-1ae5-47ee-951e-e0f9a3935f2a"
     wsmap="managed"
     >
@@ -14896,15 +14906,4 @@
         <desc>
           Array with resulting screen data.
-        </desc>
-      </param>
-    </method>
-
-    <method name="enableVideoCaptureScreens">
-      <desc>
-        Start/stop video capture on selected screens.
-      </desc>
-      <param name="screens" type="boolean" safearray="yes" dir="in">
-        <desc>
-          The screens to start/stop capturing.
         </desc>
       </param>
Index: /trunk/src/VBox/Main/include/DisplayImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/DisplayImpl.h	(revision 46522)
+++ /trunk/src/VBox/Main/include/DisplayImpl.h	(revision 46523)
@@ -30,5 +30,6 @@
 struct VIDEORECCONTEXT;
 
-enum {
+enum
+{
     ResizeStatus_Void,
     ResizeStatus_InProgress,
@@ -68,5 +69,6 @@
     bool fDefaultFormat;
 
-    struct {
+    struct
+    {
         /* The rectangle that includes all dirty rectangles. */
         int32_t xLeft;
@@ -76,5 +78,6 @@
     } dirtyRect;
 
-    struct {
+    struct
+    {
         bool fPending;
         ULONG pixelFormat;
@@ -90,5 +93,6 @@
     bool fVBVAEnabled;
     uint32_t cVBVASkipUpdate;
-    struct {
+    struct
+    {
        int32_t xLeft;
        int32_t yTop;
@@ -129,5 +133,5 @@
 
     // public methods only for internal purposes
-    int handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h, uint16_t flags);
+    int  handleDisplayResize(unsigned uScreenId, uint32_t bpp, void *pvVRAM, uint32_t cbLine, int w, int h, uint16_t flags);
     void handleDisplayUpdateLegacy(int x, int y, int cx, int cy);
     void handleDisplayUpdate(unsigned uScreenId, int x, int y, int w, int h);
@@ -146,16 +150,17 @@
         return maFramebuffers[VBOX_VIDEO_PRIMARY_SCREEN].pFramebuffer;
     }
-    void getFramebufferDimensions(int32_t *px1, int32_t *py1, int32_t *px2,
-                                  int32_t *py2);
-
-    int handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
-    int handleQueryVisibleRegion(uint32_t *pcRect, PRTRECT pRect);
-
-    int VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory);
+    void getFramebufferDimensions(int32_t *px1, int32_t *py1, int32_t *px2, int32_t *py2);
+
+    int  handleSetVisibleRegion(uint32_t cRect, PRTRECT pRect);
+    int  handleQueryVisibleRegion(uint32_t *pcRect, PRTRECT pRect);
+
+    int  VideoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory);
     void VideoAccelFlush(void);
-
     bool VideoAccelAllowed(void);
-
     void VideoAccelVRDP(bool fEnable);
+
+    int  VideoCaptureStart();
+    void VideoCaptureStop();
+    int  VideoCaptureEnableScreens(ComSafeArrayIn(BOOL, aScreens));
 
     // IEventListener methods
@@ -170,5 +175,4 @@
     STDMETHOD(TakeScreenShotToArray)(ULONG aScreenId, ULONG width, ULONG height, ComSafeArrayOut(BYTE, aScreenData));
     STDMETHOD(TakeScreenShotPNGToArray)(ULONG aScreenId, ULONG width, ULONG height, ComSafeArrayOut(BYTE, aScreenData));
-    STDMETHOD(EnableVideoCaptureScreens)(ComSafeArrayIn(BOOL, aScreens));
     STDMETHOD(DrawToScreen)(ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
     STDMETHOD(InvalidateAndUpdate)();
@@ -213,6 +217,6 @@
     static DECLCALLBACK(void)  displayCrHgsmiControlProcess(PPDMIDISPLAYCONNECTOR pInterface, PVBOXVDMACMD_CHROMIUM_CTL pCtl, uint32_t cbCtl);
 
-    static DECLCALLBACK(void) displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
-    static DECLCALLBACK(void) displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
+    static DECLCALLBACK(void)  displayCrHgsmiCommandCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
+    static DECLCALLBACK(void)  displayCrHgsmiControlCompletion(int32_t result, uint32_t u32Function, PVBOXHGCMSVCPARM pParam, void *pvContext);
 #endif
 
@@ -227,5 +231,4 @@
 #endif
 
-
     static DECLCALLBACK(void)  displaySSMSaveScreenshot(PSSMHANDLE pSSM, void *pvUser);
     static DECLCALLBACK(int)   displaySSMLoadScreenshot(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass);
@@ -245,10 +248,10 @@
 
     /* arguments of the last handleDisplayResize() call */
-    void *mLastAddress;
-    uint32_t mLastBytesPerLine;
-    uint32_t mLastBitsPerPixel;
-    int mLastWidth;
-    int mLastHeight;
-    uint16_t mLastFlags;
+    void       *mLastAddress;
+    uint32_t    mLastBytesPerLine;
+    uint32_t    mLastBitsPerPixel;
+    int         mLastWidth;
+    int         mLastHeight;
+    uint16_t    mLastFlags;
 
     VBVAMEMORY *mpVbvaMemory;
@@ -264,5 +267,5 @@
 
     uint8_t    *mpu8VbvaPartial;
-    uint32_t   mcbVbvaPartial;
+    uint32_t    mcbVbvaPartial;
 
 #ifdef VBOX_WITH_CRHGSMI
@@ -279,22 +282,22 @@
     volatile uint32_t mfu32PendingVideoAccelDisable;
 
-    int vbvaLock(void);
+    int  vbvaLock(void);
     void vbvaUnlock(void);
     
     RTCRITSECT mSaveSeamlessRectLock;
-    int SaveSeamlessRectLock(void);
+    int  SaveSeamlessRectLock(void);
     void SaveSeamlessRectUnLock(void);
     
 public:
-    static int displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height);
+    static int  displayTakeScreenshotEMT(Display *pDisplay, ULONG aScreenId, uint8_t **ppu8Data, size_t *pcbData, uint32_t *pu32Width, uint32_t *pu32Height);
 
 private:
     static void InvalidateAndUpdateEMT(Display *pDisplay, unsigned uId, bool fUpdateAll);
-    static int drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
-
-    int videoAccelRefreshProcess(void);
+    static int  drawToScreenEMT(Display *pDisplay, ULONG aScreenId, BYTE *address, ULONG x, ULONG y, ULONG width, ULONG height);
+
+    int  videoAccelRefreshProcess(void);
 
     /* Functions run under VBVA lock. */
-    int videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory);
+    int  videoAccelEnable(bool fEnable, VBVAMEMORY *pVbvaMemory);
     void videoAccelFlush(void);
 
@@ -310,14 +313,9 @@
 
 void gdImageCopyResampled(uint8_t *dst, uint8_t *src,
-                          int dstX, int dstY,
-                          int srcX, int srcY,
+                          int dstX, int dstY, int srcX, int srcY,
                           int dstW, int dstH, int srcW, int srcH);
 
-
-void BitmapScale32(uint8_t *dst,
-                       int dstW, int dstH,
-                       const uint8_t *src,
-                       int iDeltaLine,
-                       int srcW, int srcH);
+void BitmapScale32(uint8_t *dst, int dstW, int dstH,
+                   const uint8_t *src, int iDeltaLine, int srcW, int srcH);
 
 int DisplayMakePNG(uint8_t *pu8Data, uint32_t cx, uint32_t cy,
Index: /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 46522)
+++ /trunk/src/VBox/Main/src-client/ConsoleImpl.cpp	(revision 46523)
@@ -5108,12 +5108,25 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
+    BOOL fEnabled;
+    HRESULT rc = mMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
     SafeArray<BOOL> screens;
-    HRESULT rc = mMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens));
+    if (SUCCEEDED(rc))
+        rc = mMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens));
     if (mDisplay)
     {
+        int vrc = VINF_SUCCESS;
         if (SUCCEEDED(rc))
-            rc = mDisplay->EnableVideoCaptureScreens(ComSafeArrayAsInParam(screens));
-        if (SUCCEEDED(rc))
-            fireVideoCaptureChangedEvent(mEventSource);
+            vrc = mDisplay->VideoCaptureEnableScreens(ComSafeArrayAsInParam(screens));
+        if (RT_SUCCESS(vrc))
+        {
+            if (fEnabled)
+                vrc = mDisplay->VideoCaptureStart();
+            else
+                mDisplay->VideoCaptureStop();
+            if (RT_SUCCESS(vrc))
+                fireVideoCaptureChangedEvent(mEventSource);
+            else
+                rc = E_FAIL;
+        }
     }
 
Index: /trunk/src/VBox/Main/src-client/DisplayImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/DisplayImpl.cpp	(revision 46522)
+++ /trunk/src/VBox/Main/src-client/DisplayImpl.cpp	(revision 46523)
@@ -123,8 +123,8 @@
     int rc = RTCritSectInit(&mVBVALock);
     AssertRC(rc);
-    
+
     rc = RTCritSectInit(&mSaveSeamlessRectLock);
     AssertRC(rc);
-    
+
     mfu32PendingVideoAccelDisable = false;
 
@@ -150,5 +150,5 @@
         memset (&mVBVALock, 0, sizeof (mVBVALock));
     }
-    
+
     if (RTCritSectIsInitialized(&mSaveSeamlessRectLock))
     {
@@ -837,6 +837,6 @@
         LogRelFlow(("[%d]: default format %d\n", uScreenId, pFBInfo->fDefaultFormat));
 
-        /* Handle the case if there are some saved visible region that needs to be 
-         * applied after the resize of the framebuffer is completed 
+        /* Handle the case if there are some saved visible region that needs to be
+         * applied after the resize of the framebuffer is completed
          */
         SaveSeamlessRectLock();
@@ -1125,5 +1125,5 @@
                  * for the new region (THis is checked in the above if condition ). With 0 intersection,
                  * cRectVisibleRegions = 0  is returned to the GUI and if GUI has invalidated its
-                 * earlier region then it draws nothihing and seamless mode doesn't display the 
+                 * earlier region then it draws nothihing and seamless mode doesn't display the
                  * guest desktop.
                  */
@@ -1423,15 +1423,15 @@
     RTCritSectLeave(&mVBVALock);
 }
- 
+
 int Display::SaveSeamlessRectLock(void)
 {
     return RTCritSectEnter(&mSaveSeamlessRectLock);
 }
-    
+
 void Display::SaveSeamlessRectUnLock(void)
 {
     RTCritSectLeave(&mSaveSeamlessRectLock);
 }
-    
+
 
 /**
@@ -2509,5 +2509,5 @@
                       tr("Could not take a screenshot (%Rrc)"), vrc);
 
-    LogRelFlowFunc(("rc=%08X\n", rc));
+    LogRelFlowFunc(("rc=%Rhrc\n", rc));
     return rc;
 }
@@ -2587,5 +2587,5 @@
     RTMemFree(pu8Data);
 
-    LogRelFlowFunc(("rc=%08X\n", rc));
+    LogRelFlowFunc(("rc=%Rhrc\n", rc));
     return rc;
 }
@@ -2670,9 +2670,9 @@
     RTMemFree(pu8Data);
 
-    LogRelFlowFunc(("rc=%08X\n", rc));
+    LogRelFlowFunc(("rc=%Rhrc\n", rc));
     return rc;
 }
 
-STDMETHODIMP Display::EnableVideoCaptureScreens(ComSafeArrayIn(BOOL, aScreens))
+int Display::VideoCaptureEnableScreens(ComSafeArrayIn(BOOL, aScreens))
 {
 #ifdef VBOX_WITH_VPX
@@ -2680,7 +2680,91 @@
     for (unsigned i = 0; i < Screens.size(); i++)
         maVideoRecEnabled[i] = Screens[i];
-    return S_OK;
+    return VINF_SUCCESS;
 #else
-    return E_NOTIMPL;
+    return VERR_NOT_IMPLEMENTED;
+#endif
+}
+
+/**
+ * Start video capturing. Does nothing if capturing is already active.
+ */
+int Display::VideoCaptureStart()
+{
+#ifdef VBOX_WITH_VPX
+    if (VideoRecIsEnabled(mpVideoRecCtx))
+        return VINF_SUCCESS;
+
+    int rc = VideoRecContextCreate(&mpVideoRecCtx, mcMonitors);
+    if (RT_FAILURE(rc))
+    {
+        LogFlow(("Failed to create video recording context (%Rrc)!\n", rc));
+        return rc;
+    }
+    ComPtr<IMachine> pMachine = mParent->machine();
+    com::SafeArray<BOOL> screens;
+    HRESULT hrc = pMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens));
+    AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
+    for (unsigned i = 0; i < RT_ELEMENTS(maVideoRecEnabled); i++)
+        maVideoRecEnabled[i] = i < screens.size() && screens[i];
+    ULONG ulWidth;
+    hrc = pMachine->COMGETTER(VideoCaptureWidth)(&ulWidth);
+    AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
+    ULONG ulHeight;
+    hrc = pMachine->COMGETTER(VideoCaptureHeight)(&ulHeight);
+    AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
+    ULONG ulRate;
+    hrc = pMachine->COMGETTER(VideoCaptureRate)(&ulRate);
+    AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
+    ULONG ulFps;
+    hrc = pMachine->COMGETTER(VideoCaptureFps)(&ulFps);
+    AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
+    BSTR strFile;
+    hrc = pMachine->COMGETTER(VideoCaptureFile)(&strFile);
+    AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
+    for (unsigned uScreen = 0; uScreen < mcMonitors; uScreen++)
+    {
+        char *pszAbsPath = RTPathAbsDup(com::Utf8Str(strFile).c_str());
+        char *pszExt = RTPathExt(pszAbsPath);
+        if (pszExt)
+            pszExt = RTStrDup(pszExt);
+        RTPathStripExt(pszAbsPath);
+        if (!pszAbsPath)
+            rc = VERR_INVALID_PARAMETER;
+        if (!pszExt)
+            pszExt = RTStrDup(".webm");
+        char *pszName = NULL;
+        if (RT_SUCCESS(rc))
+        {
+            if (mcMonitors > 1)
+                rc = RTStrAPrintf(&pszName, "%s-%u%s", pszAbsPath, uScreen+1, pszExt);
+            else
+                rc = RTStrAPrintf(&pszName, "%s%s", pszAbsPath, pszExt);
+        }
+        if (RT_SUCCESS(rc))
+            rc = VideoRecStrmInit(mpVideoRecCtx, uScreen,
+                                  pszName, ulWidth, ulHeight, ulRate, ulFps);
+        if (RT_SUCCESS(rc))
+            LogRel(("WebM/VP8 video recording screen #%u with %ux%u @ %u kbps, %u fps to '%s' enabled!\n",
+                   uScreen, ulWidth, ulHeight, ulRate, ulFps, pszName));
+        else
+            LogRel(("Failed to initialize video recording context #%u (%Rrc)!\n", uScreen, rc));
+        RTStrFree(pszName);
+        RTStrFree(pszExt);
+        RTStrFree(pszAbsPath);
+    }
+    return rc;
+#else
+    return VERR_NOT_IMPLEMENTED;
+#endif
+}
+
+/**
+ * Stop video capturing. Does nothing if video capturing is not active.
+ */
+void Display::VideoCaptureStop()
+{
+#ifdef VBOX_WITH_VPX
+    VideoRecContextClose(mpVideoRecCtx);
+    mpVideoRecCtx = NULL;
 #endif
 }
@@ -2848,5 +2932,5 @@
 //    }
 
-    LogRelFlowFunc(("rc=%08X\n", rc));
+    LogRelFlowFunc(("rc=%Rhrc\n", rc));
     return rc;
 }
@@ -2970,5 +3054,5 @@
                       tr("Could not invalidate and update the screen (%Rrc)"), rcVBox);
 
-    LogRelFlowFunc(("rc=%08X\n", rc));
+    LogRelFlowFunc(("rc=%Rhrc\n", rc));
     return rc;
 }
@@ -4330,6 +4414,5 @@
         AutoWriteLock displayLock(pThis->pDisplay COMMA_LOCKVAL_SRC_POS);
 #ifdef VBOX_WITH_VPX
-        VideoRecContextClose(pThis->pDisplay->mpVideoRecCtx);
-        pThis->pDisplay->mpVideoRecCtx = NULL;
+        pThis->pDisplay->VideoCaptureStop();
 #endif
 #ifdef VBOX_WITH_CRHGSMI
@@ -4443,68 +4526,11 @@
     ComPtr<IMachine> pMachine = pDisplay->mParent->machine();
     BOOL fEnabled = false;
-    pMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
+    HRESULT hrc = pMachine->COMGETTER(VideoCaptureEnabled)(&fEnabled);
+    AssertComRCReturn(hrc, VERR_COM_UNEXPECTED);
     if (fEnabled)
-    {
-        rc = VideoRecContextCreate(&pDisplay->mpVideoRecCtx, pDisplay->mcMonitors);
-        if (RT_FAILURE(rc))
-        {
-            LogFlow(("Failed to create video recording context (%Rrc)!\n", rc));
-            return E_FAIL;
-        }
-        com::SafeArray<BOOL> screens;
-        HRESULT hrc = pMachine->COMGETTER(VideoCaptureScreens)(ComSafeArrayAsOutParam(screens));
-        AssertComRCReturnRC(hrc);
-        for (unsigned i = 0; i < RT_ELEMENTS(pDisplay->maVideoRecEnabled); i++)
-            pDisplay->maVideoRecEnabled[i] = i < screens.size() && screens[i];
-        ULONG ulWidth;
-        hrc = pMachine->COMGETTER(VideoCaptureWidth)(&ulWidth);
-        AssertComRCReturnRC(hrc);
-        ULONG ulHeight;
-        hrc = pMachine->COMGETTER(VideoCaptureHeight)(&ulHeight);
-        AssertComRCReturnRC(hrc);
-        ULONG ulRate;
-        hrc = pMachine->COMGETTER(VideoCaptureRate)(&ulRate);
-        AssertComRCReturnRC(hrc);
-        ULONG ulFps;
-        hrc = pMachine->COMGETTER(VideoCaptureFps)(&ulFps);
-        AssertComRCReturnRC(hrc);
-        BSTR strFile;
-        hrc = pMachine->COMGETTER(VideoCaptureFile)(&strFile);
-        AssertComRCReturnRC(hrc);
-        for (unsigned uScreen = 0; uScreen < pDisplay->mcMonitors; uScreen++)
-        {
-            char *pszAbsPath = RTPathAbsDup(com::Utf8Str(strFile).c_str());
-            char *pszExt = RTPathExt(pszAbsPath);
-            if (pszExt)
-                pszExt = RTStrDup(pszExt);
-            RTPathStripExt(pszAbsPath);
-            if (!pszAbsPath)
-                rc = VERR_INVALID_PARAMETER;
-            if (!pszExt)
-                pszExt = RTStrDup(".webm");
-            char *pszName = NULL;
-            if (RT_SUCCESS(rc))
-            {
-                if (pDisplay->mcMonitors > 1)
-                    rc = RTStrAPrintf(&pszName, "%s-%u%s", pszAbsPath, uScreen+1, pszExt);
-                else
-                    rc = RTStrAPrintf(&pszName, "%s%s", pszAbsPath, pszExt);
-            }
-            if (RT_SUCCESS(rc))
-                rc = VideoRecStrmInit(pDisplay->mpVideoRecCtx, uScreen,
-                                      pszName, ulWidth, ulHeight, ulRate, ulFps);
-            if (RT_SUCCESS(rc))
-                LogRel(("WebM/VP8 video recording screen #%u with %ux%u @ %u kbps, %u fps to '%s' enabled!\n",
-                        uScreen, ulWidth, ulHeight, ulRate, ulFps, pszName));
-            else
-                LogRel(("Failed to initialize video recording context #%u (%Rrc)!\n", uScreen, rc));
-            RTStrFree(pszName);
-            RTStrFree(pszExt);
-            RTStrFree(pszAbsPath);
-        }
-    }
+        rc = pDisplay->VideoCaptureStart();
 #endif
 
-    return VINF_SUCCESS;
+    return rc;
 }
 
Index: /trunk/src/VBox/Main/src-server/MachineImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 46522)
+++ /trunk/src/VBox/Main/src-server/MachineImpl.cpp	(revision 46523)
@@ -1516,5 +1516,5 @@
     mHWData->mCpuExecutionCap = aExecutionCap;
 
-    /* Save settings if online - todo why is this required?? */
+    /** Save settings if online - @todo why is this required? -- @bugref{6818} */
     if (Global::IsOnline(mData->mMachineState))
         saveSettings(NULL);
@@ -1727,11 +1727,14 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc;
-
     setModified(IsModified_MachineData);
     mHWData.backup();
-
     mHWData->mVideoCaptureEnabled = fEnabled;
+
+    /** Save settings if online - @todo why is this required? -- @bugref{6818} */
+    if (Global::IsOnline(mData->mMachineState))
+        saveSettings(NULL);
+
+    alock.release();
+    rc = onVideoCaptureChange();
 
     return rc;
@@ -1777,4 +1780,6 @@
         if (FAILED(rc)) return rc;
         setModified(IsModified_MachineData);
+
+        /** Save settings if online - @todo why is this required? -- @bugref{6818} */
         if (Global::IsOnline(mData->mMachineState))
             saveSettings(NULL);
@@ -1802,6 +1807,6 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    HRESULT rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc; 
+    if (mHWData->mVideoCaptureEnabled)
+        return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));
 
     if (strFile.isEmpty())
@@ -1832,6 +1837,6 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    HRESULT rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc; 
+    if (mHWData->mVideoCaptureEnabled)
+        return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));
 
     setModified(IsModified_MachineData);
@@ -1859,6 +1864,6 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    HRESULT rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc; 
+    if (mHWData->mVideoCaptureEnabled)
+        return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));
 
     setModified(IsModified_MachineData);
@@ -1886,6 +1891,6 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    HRESULT rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc;
+    if (mHWData->mVideoCaptureEnabled)
+        return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));
 
     setModified(IsModified_MachineData);
@@ -1913,6 +1918,6 @@
     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
 
-    HRESULT rc = checkStateDependency(MutableStateDep);
-    if (FAILED(rc)) return rc;
+    if (mHWData->mVideoCaptureEnabled)
+        return setError(E_INVALIDARG, tr("Cannot change parameters while capturing is enabled"));
 
     setModified(IsModified_MachineData);
@@ -2944,6 +2949,5 @@
 }
 
-STDMETHODIMP
-Machine::COMSETTER(ClipboardMode)(ClipboardMode_T aClipboardMode)
+STDMETHODIMP Machine::COMSETTER(ClipboardMode)(ClipboardMode_T aClipboardMode)
 {
     HRESULT rc = S_OK;
@@ -2963,5 +2967,5 @@
     mHWData->mClipboardMode = aClipboardMode;
 
-    /* Save settings if online - todo why is this required?? */
+    /** Save settings if online - @todo why is this required? -- @bugref{6818} */
     if (Global::IsOnline(mData->mMachineState))
         saveSettings(NULL);
@@ -2984,6 +2988,5 @@
 }
 
-STDMETHODIMP
-Machine::COMSETTER(DragAndDropMode)(DragAndDropMode_T aDragAndDropMode)
+STDMETHODIMP Machine::COMSETTER(DragAndDropMode)(DragAndDropMode_T aDragAndDropMode)
 {
     HRESULT rc = S_OK;
@@ -3003,5 +3006,5 @@
     mHWData->mDragAndDropMode = aDragAndDropMode;
 
-    /* Save settings if online - todo why is this required?? */
+    /** Save settings if online - @todo why is this required? -- @bugref{6818} */
     if (Global::IsOnline(mData->mMachineState))
         saveSettings(NULL);
@@ -3010,6 +3013,5 @@
 }
 
-STDMETHODIMP
-Machine::COMGETTER(GuestPropertyNotificationPatterns)(BSTR *aPatterns)
+STDMETHODIMP Machine::COMGETTER(GuestPropertyNotificationPatterns)(BSTR *aPatterns)
 {
     CheckComArgOutPointerValid(aPatterns);
@@ -3032,6 +3034,5 @@
 }
 
-STDMETHODIMP
-Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns)
+STDMETHODIMP Machine::COMSETTER(GuestPropertyNotificationPatterns)(IN_BSTR aPatterns)
 {
     AutoCaller autoCaller(this);
@@ -3049,6 +3050,5 @@
 }
 
-STDMETHODIMP
-Machine::COMGETTER(StorageControllers)(ComSafeArrayOut(IStorageController *, aStorageControllers))
+STDMETHODIMP Machine::COMGETTER(StorageControllers)(ComSafeArrayOut(IStorageController *, aStorageControllers))
 {
     CheckComArgOutSafeArrayPointerValid(aStorageControllers);
@@ -3065,6 +3065,5 @@
 }
 
-STDMETHODIMP
-Machine::COMGETTER(TeleporterEnabled)(BOOL *aEnabled)
+STDMETHODIMP Machine::COMGETTER(TeleporterEnabled)(BOOL *aEnabled)
 {
     CheckComArgOutPointerValid(aEnabled);
@@ -6805,5 +6804,5 @@
     mHWData->mCPUAttached[aCpu] = true;
 
-    /* Save settings if online */
+    /** Save settings if online - @todo why is this required? -- @bugref{6818} */
     if (Global::IsOnline(mData->mMachineState))
         saveSettings(NULL);
@@ -6846,5 +6845,5 @@
     mHWData->mCPUAttached[aCpu] = false;
 
-    /* Save settings if online */
+    /** Save settings if online - @todo why is this required? -- @bugref{6818} */
     if (Global::IsOnline(mData->mMachineState))
         saveSettings(NULL);
