title: Read/write to stream with JavaCV
body: <p>I'm trying to make use of JavaCV for android. I would like to create a video stream composed of screenshots. I found out that I can write a file using FFmpegFrameRecorder, but I can't write to a stream, array, buffer, or anything else, other than a file.</p>
  
  <p>Next thing is that I found a piece of code featuring custom FrameRecorder using 'avio_alloc_context' and read/write/seek callbacks. Unfortunately it's only a snippet and it's in C++. 'avio_alloc_context' method on android takes Read_packet, Read_packet and Seek callbacks, so I cannot pass a Write_packet callback. Moreover, right after 'avio_alloc_context' call, I get 'finalize' called on all objects passed to 'avio_alloc_context'.</p>
  
  <pre><code>final VideoOutputStream videoOutputStream = new VideoOutputStream(stream);
  
  Read_packet read_packet = new Read_packet() {
      @Override
      public int call(Pointer arg0, BytePointer arg1, int arg2) {
          VideoOutputStream videoStream = (VideoOutputStream) arg0;
          try {
              videoStream.write(arg1.getStringBytes());
          } catch (IOException e) {
              e.printStackTrace();
          }
          return arg2;
      }
  };
  
  AVIOContext pb = avio_alloc_context(new MBytePointer(av_malloc(video_outbuf_size)), video_outbuf_size, 1,videoOutputStream, null, read_packet, null);
  
  oc.pb(pb);
  </code></pre>
  
  <p>Using the above code nothing crashes nor reports errors. I just keep getting empty files.</p>
  
  <p>My question is - does anyone of you guys managed to get it working? Do you know a correct way to initialize custom reading/writing in FrameRecorder/Grabber in JavaCV?</p>