How to create a MediaClip from RenderTargetBitmap in an efficent way?

Try something like this:

Same as you have done.

using (var soft = SoftwareBitmap.CreateCopyFromBuffer(pixels, BitmapPixelFormat.Bgra8, renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight, BitmapAlphaMode.Premultiplied))
{
   CanvasBitmap canvas = CanvasBitmap.CreateFromSoftwareBitmap(CanvasDevice.GetSharedDevice(), soft); 

   MediaClip m = MediaClip.CreateFromSurface(canvas, DateTime.Now - previousFrame); 
   composition.Clips.Add(m); 
}

Remember to catch the device lost exceptions and create a new device