-1

I'm receiving the following as an argument in a callback function in C++.

byte const* Buffer()

The Buffer is a pointer to a buffer containing video frame. How can I save that to a file?

Thanks

  • 8
    Open a file stream, write data to it & then close the file stream, If you need to ask the steps, What you really need is to pick up a [good C++ book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). – Alok Save Feb 25 '12 at 14:36

1 Answers1

1

The pointer shows that C solution will be more appropriate:

FILE * videoFile;
byte buffer*; //you already received it
int buffer_len; // you receive that too
videoFile = fopen ( "myvideo.mp4" , "wb" );
fwrite (buffer , 1 , buffer_len , videoFile);
fclose (videoFile);
Boris Strandjev
  • 46,145
  • 15
  • 108
  • 135
  • 2
    Why would you provide a `C` solution to a `C++` Question? – Alok Save Feb 25 '12 at 14:41
  • C++ question featuring pointers? Hmm. It seems like the question is not that C++ after all... – Boris Strandjev Feb 25 '12 at 14:43
  • @Als people frequently don't strictly differentiate between C and C++ when they look for answers. I see nothing wrong with a C answer to a C++ question (that's not really C++ to begin with). – xxbbcc Feb 25 '12 at 14:44
  • 4
    I hate this "if you write C++, you'd better use every single C++ feature in the spec" mentality. C++ isn't a superset of C just for the hell of it. – James M Feb 25 '12 at 14:44
  • @JamesMcLaughlin: I can only just hope with time You will learn to judge better. Peace :) – Alok Save Feb 25 '12 at 14:57
  • Also this is obviously C++ code. Just look at the comments :P – s3rius Feb 25 '12 at 15:27
  • Thanks it works although I can't fig it out the format it sending.... meaning I can't open the file saved. – Siva Kumar Feb 26 '12 at 14:22
  • You just receive the bytes and save them as they are to a file. The only thing that might be failing you is if the extension I specified is not the correct one. Please choose appropriate extension (e.g. avi, mp4 etc). – Boris Strandjev Feb 26 '12 at 14:24