Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 675197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:47:29+00:00 2026-05-14T00:47:29+00:00

The new webcam stuff in Silverlight 4 is darned cool. By exposing it as

  • 0

The new webcam stuff in Silverlight 4 is darned cool. By exposing it as a brush, it allows scenarios that are way beyond anything that Flash has.

At the same time, accessing the webcam locally seems like it’s only half the story. Nobody buys a webcam so they can take pictures of themselves and make funny faces out of them. They buy a webcam because they want other people to see the resulting video stream, i.e., they want to stream that video out to the Internet, a lay Skype or any of the dozens of other video chat sites/applications. And so far, I haven’t figured out how to do that with

It turns out that it’s pretty simple to get a hold of the raw (Format32bppArgb formatted) bytestream, as demonstrated here.

But unless we want to transmit that raw bytestream to a server (which would chew up way too much bandwidth), we need to encode that in some fashion. And that’s more complicated. MS has implemented several codecs in Silverlight, but so far as I can tell, they’re all focused on decoding a video stream, not encoding it in the first place. And that’s apart from the fact that I can’t figure out how to get direct access to, say, the H.264 codec in the first place.

There are a ton of open-source codecs (for instance, in the ffmpeg project here), but they’re all written in C, and they don’t look easy to port to C#. Unless translating 10000+ lines of code that look like this is your idea of fun 🙂

const int b_xy= h->mb2b_xy[left_xy[i]] + 3;
const int b8_xy= h->mb2b8_xy[left_xy[i]] + 1;
*(uint32_t*)h->mv_cache[list][cache_idx ]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[0+i*2]];
*(uint32_t*)h->mv_cache[list][cache_idx+8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy + h->b_stride*left_block[1+i*2]];
h->ref_cache[list][cache_idx ]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[0+i*2]>>1)];
h->ref_cache[list][cache_idx+8]= s->current_picture.ref_index[list][b8_xy + h->b8_stride*(left_block[1+i*2]>>1)];

The mooncodecs folder within the Mono project (here) has several audio codecs in C# (ADPCM and Ogg Vorbis), and one video codec (Dirac), but they all seem to implement just the decode portion of their respective formats, as do the java implementations from which they were ported.

I found a C# codec for Ogg Theora (csTheora, http://www.wreckedgames.com/forum/index.php?topic=1053.0), but again, it’s decode only, as is the jheora codec on which it’s based.

Of course, it would presumably be easier to port a codec from Java than from C or C++, but the only java video codecs that I found were decode-only (such as jheora, or jirac).

So I’m kinda back at square one. It looks like our options for hooking up a webcam (or microphone) through Silverlight to the Internet are:

(1) Wait for Microsoft to provide some guidance on this;

(2) Spend the brain cycles porting one of the C or C++ codecs over to Silverlight-compatible C#;

(3) Send the raw, uncompressed bytestream up to a server (or perhaps compressed slightly with something like zlib), and then encode it server-side; or

(4) Wait for someone smarter than me to figure this out and provide a solution.

Does anybody else have any better guidance? Have I missed something that’s just blindingly obvious to everyone else? (For instance, does Silverlight 4 somewhere have some classes I’ve missed that take care of this?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:47:30+00:00Added an answer on May 14, 2026 at 12:47 am

    I thought I’d let interested folks know the approach I actually took. I’m using CSpeex to encode the voice, but I wrote my own block-based video codec to encode the video. It divides each frame up into 16×16 blocks, determines which blocks have sufficiently changed to warrant transmitting, and then Jpeg-encodes the changed blocks using a heavily modified version of FJCore. (FJCore is generally well done, but it needed to be modified to not write the JFIF headers, and to speed up initialization of the various objects.) All of this is being passed up to a proprietary media server using a proprietary protocol roughly based on RTP.

    With one stream up and four streams down at 144×176, I’m currently getting 5 frames per second, using a total of 474 Kbps (~82 Kbps / video stream + 32 Kbps / audio), and chewing up about 30% CPU on my dev box. The quality’s not great, but it’s acceptable for most video chat applications.

    Since I posted my original question, there have been several attempts to implement a solution. Probably the best is at the SocketCoder website here (and here).

    However, because the SocketCoder motion JPEG-style video codec translates the entirety of every frame rather than just the blocks that have changed, my assumption is that CPU and bandwidth requirements are going to be prohibitive for most applications.

    Unfortunately, my own solution is going to have to remain proprietary for the foreseeable future :-(.

    Edit 7/3/10: I just got permissions to share my modifications to the FJCore library. I’ve posted the project (without any sample code, unfortunately) here:

    http://www.alanta.com/Alanta.Client.Media.Jpeg.zip

    A (very rough) example of how to use it:

        public void EncodeAsJpeg()
        {
            byte[][,] raster = GetSubsampledRaster();
            var image = new Alanta.Client.Media.Jpeg.Image(colorModel, raster);
            EncodedStream = new MemoryStream();
            var encoder = new JpegFrameEncoder(image, MediaConstants.JpegQuality, EncodedStream);
            encoder.Encode();
        }
    
    
        public void DecodeFromJpeg()
        {
            EncodedStream.Seek(0, SeekOrigin.Begin);
            var decoder = new JpegFrameDecoder(EncodedStream, height, width, MediaConstants.JpegQuality);
            var raster = decoder.Decode();
        }
    

    Most of my changes are around the two new classes JpegFrameEncoder (instead of JpegEncoder) and JpegFrameDecoder (instead of JpegDecoder). Basically, the JpegFrameEncoder writes the encoded frame without any JFIF headers, and the JpegFrameDecoder decodes the frame without expecting any JFIF headers to tell it what values to use (it assumes you’ll share the values in some other, out-of-band manner). It also instantiates whatever objects it needs just once (as “static”), so that you can instantiate the JpegFrameEncoder and JpegFrameDecoder quickly, with minimal overhead. The pre-existing JpegEncoder and JpegDecoder classes should work pretty much the same as they always have, though I’ve only done a very little bit of testing to confirm that.

    There are lots of things I’d like to improve about it (I don’t like the static objects — they should be instantiated and passed in separately), but it works well enough for our purposes at the moment. Hopefully it’s helpful for someone else. I’ll see if I can improve the code/documentation/sample code/etc. if I have time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the list of new features in Silverlight 4 you will find following: Webcam
New to silverlight. Traditionally if I were to design a wizard-like process where a
I am doing video capturing through webcam using jmf. i am very new to
I have made a simple webcam based application that detects the edges of motion
New class is a subclass of the original object It needs to be php4
New to javascript/jquery and having a hard time with using this or $(this) to
New to xml. Looking for XPath to search a xml file with python ElementTree
New to both Ruby and Rails but I'm book educated by now (which apparently
New to WCF, but familiar with COM+ - can I wrap a WCF service
New to Linux programming in general. I am trying to communicate with a kernel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.