How do you compress captured video in Silverlight?

One of the big deals in Silverlight v4 is audio/video capture... but I haven't found an example yet that does what I want to do. So:

How do you capture audio/video with Silverlight (from a webcam), and then save it as a compressed format (WMV or MP4)? The idea here is to upload it after compression.

Have already looked at this blog post for the capture piece, but need to find a way to compress audio/video for upload.


Silverlight does not support video encoding and more likely this won't be implemented at least by Microsoft. To transmit video over network, some people use "pseudo-MJPEG" codec by compressing individual frames as regular JPEG images. Some people even improved that idea by dividing frames into fixed block (say 8x8), and only transmits changed blocks (with lossy comparison).

If you're a veteran programmer and enjoy coding, here is another slightly improved version of "psuedo-MJPEG" idea:

  • Divide current frame into fixed 8x8 block
  • Apply RGB -> YCbCr color space conversion for each block
  • Down sample Cb and Cr plane by half
  • Apply DCT to YCbCr
  • Quantize DCT coefficients with a quantization matrix
  • Compare this DCT coefficients with previous frame's block. This way you make "perceptually lossy" comparison for each consecutive frames.
  • Use a bit-wise range-coder and encode a flag for unchanged blocks
  • For changed blocks, transmit DCT coefficient by modeling them (you can use JPEG's standard zig-zag pattern and zero-run model) and encode them with range coder.
  • This is more or less a standard JPEG algorithm actually. But, actual advantages over standard JPEG are:

  • Perceptually lossy comparison for blocks
  • Stronger compression due to both small overhead and stronger entropy coder (range coder)
  • Another option could be pay for 3rd party software (sorry, I don't know any free software). I find that product. I didn't used it at all. But, I believe it could be useful for you.

    链接地址: http://www.djcxy.com/p/81024.html

    上一篇: 用于silverlight摄像头捕获的H264编码器

    下一篇: 如何在Silverlight中压缩捕获的视频?