5

I am using the VP8 .NET library to convert a video stream from my laptop webcam and i would like to store it in a webm file (no audio needed). To do so, I'm using the code provided as example in the documentation of the library and I added a few lines of code to write the encoded stream to a file. Here's the code:

class EncodingSession
{
    private readonly VP8.Encoder Encoder;
    static FileStream fs = new FileStream("provavideo.webm", FileMode.CreateNew);
    BinaryWriter w = new BinaryWriter(fs);

    public EncodingSession(int width, int height, int fps)
    {
        Encoder = new VP8.Encoder(width, height, fps);

    }

    public byte[] Encode(Image frame)
    {
        Encoder.ForceKeyframe();
        byte[] array = Encoder.Encode((Bitmap)frame);
        w.Write(array);
        return array;
    }

}

However, this does not produce a valid webm file, probably because the webm headers are missing. My question is: how do I add a valid webm header (if this is really what is needed)? Are there other stuff needed to be added to my file?

csharpwinphonexaml
  • 3,659
  • 10
  • 32
  • 63
breathe0
  • 573
  • 1
  • 7
  • 21

0 Answers0