Index: /trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp
===================================================================
--- /trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp	(revision 68451)
+++ /trunk/src/VBox/Main/src-client/DrvAudioVideoRec.cpp	(revision 68452)
@@ -149,5 +149,5 @@
             /** Time (in ms) an (encoded) frame takes.
              *
-             *  For Opus, valid frame size are:
+             *  For Opus, valid frame sizes are:
              *  ms           Frame size
              *  2.5          120
@@ -233,5 +233,5 @@
 {
     uint32_t uHz       = pCodecParms->uHz;
-    uint8_t  cBits     = 16; /** @ŧodo Make this configurable? */
+    uint8_t  cBits     = pCodecParms->cBits;
     uint8_t  cChannels = pCodecParms->cChannels;
     uint32_t uBitrate  = pCodecParms->uBitrate;
@@ -297,6 +297,4 @@
                     {
                         /** @todo Add sink name / number to file name. */
-
-                        LogRel2(("VideoRec: Recording audio to file '%s'\n", szFile));
 
                         pSink->Con.WebM.pWebM = new WebMWriter();
@@ -534,9 +532,10 @@
 
     AVRECCONTAINERPARMS ContainerParms;
-    ContainerParms.enmType = AVRECCONTAINERTYPE_WEBM; /** @todo Make this configurable. */
+    ContainerParms.enmType = AVRECCONTAINERTYPE_MAIN_CONSOLE; /** @todo Make this configurable. */
 
     AVRECCODECPARMS CodecParms;
     CodecParms.uHz       = AVREC_OPUS_HZ_MAX;  /** @todo Make this configurable. */
     CodecParms.cChannels = 2;                  /** @todo Make this configurable. */
+    CodecParms.cBits     = 16;                 /** @todo Make this configurable. */
     CodecParms.uBitrate  = 196000;             /** @todo Make this configurable. */
 
@@ -637,4 +636,5 @@
     const uint32_t cbFrame = csFrame * pSink->Codec.Parms.cChannels * (pSink->Codec.Parms.cBits / 8 /* Bytes */);
 
+    /* Only encode data if we have data for the given time period (or more). */
     while (RTCircBufUsed(pCircBuf) >= cbFrame)
     {
@@ -686,14 +686,11 @@
 # ifdef VBOX_WITH_STATISTICS
             /* Get overall frames encoded. */
-            uint32_t cEncFrames          = opus_packet_get_nb_frames(abDst, cbDst);
-            uint32_t cEncSamplesPerFrame = opus_packet_get_samples_per_frame(abDst, pSink->Codec.Parms.uHz);
-            uint32_t csEnc               = cEncFrames * cEncSamplesPerFrame;
+            const uint32_t cEncFrames     = opus_packet_get_nb_frames(abDst, cbWritten);
 
             pSink->Codec.STAM.cEncFrames += cEncFrames;
-            pSink->Codec.STAM.msEncTotal += 20 /* Default 20 ms */ * cEncFrames;
-
-            LogFunc(("%RU64ms [%RU64 frames]: cbSrc=%zu, cbDst=%zu, cEncFrames=%RU32, cEncSamplesPerFrame=%RU32, csEnc=%RU32\n",
-                     pSink->Codec.STAM.msEncTotal, pSink->Codec.STAM.cEncFrames,
-                     cbSrc, cbDst, cEncFrames, cEncSamplesPerFrame, csEnc));
+            pSink->Codec.STAM.msEncTotal += pSink->Codec.Opus.msFrame * cEncFrames;
+
+            LogFunc(("%RU64ms [%RU64 frames]: cbSrc=%zu, cbDst=%zu, cEncFrames=%RU32\n",
+                     pSink->Codec.STAM.msEncTotal, pSink->Codec.STAM.cEncFrames, cbSrc, cbDst, cEncFrames));
 # endif
             Assert((uint32_t)cbWritten <= cbDst);
