Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. how to create an AVI stream in memory?

how to create an AVI stream in memory?

Scheduled Pinned Locked Moved C#
performancehelptutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DK KiloDunse
    wrote on last edited by
    #1

    Is there any way to create an AVIStream in memory? without having to write to disk? I’ve tried using the AVIStreamCreate function from avifil32.dll, but it keeps returning an error. I need to capture video from a webcam, to a compressed avistream. And then send the compressed stream over an LAN. This is the code: AVISTREAMINFOW aviStreamInfo = new AVISTREAMINFOW(); aviStreamInfo.fccType = _fccType; aviStreamInfo.fccHandler = _fccHandler; aviStreamInfo.dwScale = 1; aviStreamInfo.dwRate = _frameRate; aviStreamInfo.dwSuggestedBufferSize = _height * _stride; aviStreamInfo.dwQuality = 0xffffffff; aviStreamInfo.rect_bottom = _height; aviStreamInfo.rect_right = _width; //_result = AviFile.AVIFileCreateStream(_aviFile, out _aviStream, ref aviStreamInfo); _result = AviFile.AVIStreamCreate(out _aviStream, 0, 0, ref aviStreamInfo); _result returns -2147221164

    J 1 Reply Last reply
    0
    • D DK KiloDunse

      Is there any way to create an AVIStream in memory? without having to write to disk? I’ve tried using the AVIStreamCreate function from avifil32.dll, but it keeps returning an error. I need to capture video from a webcam, to a compressed avistream. And then send the compressed stream over an LAN. This is the code: AVISTREAMINFOW aviStreamInfo = new AVISTREAMINFOW(); aviStreamInfo.fccType = _fccType; aviStreamInfo.fccHandler = _fccHandler; aviStreamInfo.dwScale = 1; aviStreamInfo.dwRate = _frameRate; aviStreamInfo.dwSuggestedBufferSize = _height * _stride; aviStreamInfo.dwQuality = 0xffffffff; aviStreamInfo.rect_bottom = _height; aviStreamInfo.rect_right = _width; //_result = AviFile.AVIFileCreateStream(_aviFile, out _aviStream, ref aviStreamInfo); _result = AviFile.AVIStreamCreate(out _aviStream, 0, 0, ref aviStreamInfo); _result returns -2147221164

      J Offline
      J Offline
      Judah Gabriel Himango
      wrote on last edited by
      #2

      Most likely you're not properly marshalling these types, or are using incorrect types during the AVIStreamCreate method. 2 questions I would ask, is are you sure that _aviStream should be an out parameter instead of a ref (i.e. do you need to create it first?). Second question, what type is _aviStream? Windows Media SDK specifies it should be a pointer to a PAVISTREAM. Make sure you've marshalled this type correctly, it should be the address of a pointer to an IAVIStream interface. After looking further at the MSDN documentation, I see Microsoft recommends "you should not need to call this function. Some functions, such as CreateEditableStream and AVIMakeCompressedStream, use it internally." You ought to use one of those methods instead.

      Tech, life, family, faith: Give me a visit. Judah Himango

      D 1 Reply Last reply
      0
      • J Judah Gabriel Himango

        Most likely you're not properly marshalling these types, or are using incorrect types during the AVIStreamCreate method. 2 questions I would ask, is are you sure that _aviStream should be an out parameter instead of a ref (i.e. do you need to create it first?). Second question, what type is _aviStream? Windows Media SDK specifies it should be a pointer to a PAVISTREAM. Make sure you've marshalled this type correctly, it should be the address of a pointer to an IAVIStream interface. After looking further at the MSDN documentation, I see Microsoft recommends "you should not need to call this function. Some functions, such as CreateEditableStream and AVIMakeCompressedStream, use it internally." You ought to use one of those methods instead.

        Tech, life, family, faith: Give me a visit. Judah Himango

        D Offline
        D Offline
        DK KiloDunse
        wrote on last edited by
        #3

        Question 1. I've tryed this [DllImport("avifil32.dll")] public static extern int CreateEditableStream(out IntPtr ppsEditable, int psSource); private IntPtr _aviEditable; private IntPtr _aviEditableCompressed; _result = AviFile.CreateEditableStream(out _aviEditable, 0); if(_result != 0) { throw new AviException("Failed to create editable AVI stream.", _result); } And it returns an address (eg. no error) So i don't think i need to create it first. BUT! it wont do AVICOMPRESSOPTIONS EditablecompressionOptions = new AVICOMPRESSOPTIONS(); EditablecompressionOptions.fccType = _fccType; EditablecompressionOptions.fccHandler = _fccHandler; EditablecompressionOptions.lpFormat = new IntPtr(0); EditablecompressionOptions.lpParms = new IntPtr(0); _result = AviFile.AVIMakeCompressedStream(out _aviEditableCompressed, _aviEditable, ref EditablecompressionOptions, 0); if(_result != 0) { throw new AviException("Failed to create editable compressed AVI stream.", _result); } But, if it is a file based avistream it works :confused: Question 2. The _aviStream is IntPtr

        J 1 Reply Last reply
        0
        • D DK KiloDunse

          Question 1. I've tryed this [DllImport("avifil32.dll")] public static extern int CreateEditableStream(out IntPtr ppsEditable, int psSource); private IntPtr _aviEditable; private IntPtr _aviEditableCompressed; _result = AviFile.CreateEditableStream(out _aviEditable, 0); if(_result != 0) { throw new AviException("Failed to create editable AVI stream.", _result); } And it returns an address (eg. no error) So i don't think i need to create it first. BUT! it wont do AVICOMPRESSOPTIONS EditablecompressionOptions = new AVICOMPRESSOPTIONS(); EditablecompressionOptions.fccType = _fccType; EditablecompressionOptions.fccHandler = _fccHandler; EditablecompressionOptions.lpFormat = new IntPtr(0); EditablecompressionOptions.lpParms = new IntPtr(0); _result = AviFile.AVIMakeCompressedStream(out _aviEditableCompressed, _aviEditable, ref EditablecompressionOptions, 0); if(_result != 0) { throw new AviException("Failed to create editable compressed AVI stream.", _result); } But, if it is a file based avistream it works :confused: Question 2. The _aviStream is IntPtr

          J Offline
          J Offline
          Judah Gabriel Himango
          wrote on last edited by
          #4

          Have you looked at this page? I see that it uses some of the functions we're talking about, maybe you can gain some understanding from it.

          Tech, life, family, faith: Give me a visit. Judah Himango

          D 1 Reply Last reply
          0
          • J Judah Gabriel Himango

            Have you looked at this page? I see that it uses some of the functions we're talking about, maybe you can gain some understanding from it.

            Tech, life, family, faith: Give me a visit. Judah Himango

            D Offline
            D Offline
            DK KiloDunse
            wrote on last edited by
            #5

            Yep....I know it.....It's the lib i use.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups