Well for past few months now i have been doing my research on encryption cipher and i have tested on plane text , its not a problem .
If i have to test the fastness of the cipher i got to try it on movie and audio files and check for processing time .
Is there any way i can process movie / audio files in C++ ? any primitive file format would suffice for now.

Well of course you can, you just have to link a C/C++ library for the codec you want to use :)

I kinda understood vaguely . is there any sample program u can quote ?

> Is there any way i can process movie / audio files in C++ ?
Why would it matter to you?

Like for compression, as far as you're concerned, it's just a meaningless array of bytes to encrypt. So long as you get back what you put in, why do you even care what the file is for?

It should work the same for text, images, movies, audio, executables, word docs etc etc ad nauseum.

How do you test the text is successful? - load the result in a text editor.
How do you test an audio file is successful? - try and play it.

Like for compression, as far as you're concerned, it's just a meaningless array of bytes to encrypt. So long as you get back what you put in, why do you even care what the file is for?

well , thats exactly what i think. But my implacable professor isnt convinced with it.
And wats infinetly worst is i have been told to demonstrate by inputting the mov.audio file name as an argument and asked to show the time for processing that.
I could do that for a text file , but have no idea for the mov/audio files.
Besides , i am not much concerned with compression as of now , just want to make this thing work.

So what's the problem?

In Unix/Linux, there is the time command

time myprog sometextfile.txt
time myprog somemoviefile.mov

Your program just opens the byte stream, does something and closes it again. The type of file (or it's content) matters not.

i am aware of time command ,

But the point is , i have to process the audio / video file which i am inputting as an argument.

for example ,
if i am passing a movie name twlight.avi
it must be something like this

$ ./program twilight.avi

then i must be able to fetch the movie in form of bytes or so .
When i get the movie files in stream of bytes , then i can apply my encryption procedure on it and then again get a stream of bytes that are similar to that of movie but are encrypted.
Thats the complete procedure .

But i have never processed a movie or audio file before , so i want to know how do i proceed with that.

Well if you open the file as a binary stream, I suggest you just try it and see what happens!

well tried opening it , its was kinda successful . but when i try printing the data of the avi file i am getting all junk characters.

#include <iostream.h>
#include <fstream.h>

const char * filename = "twilight.avi";

int main ()
{
  long l,m;
  ifstream file (filename, ios::in|ios::binary);
  l = file.tellg();
  file.seekg (0, ios::end);
  m = file.tellg();
  file.close();
  cout << "size of " << filename;
  cout << " is " << (m-l) << " bytes.\n";
  return 0;
}

i could print the size of the file , but i want to save the data in a buffer array i am getting junk values

#include <iostream.h>
#include <fstream.h>

const char * filename = "twilight.avi";

int main () 
{
  char * buffer;
  long size;
  ifstream file (filename, ios::in|ios::binary|ios::ate);
  size = file.tellg();
  file.seekg (0, ios::beg);
  buffer = new char [size];
  file.read (buffer, size);
  file.close();

  cout << "the complete file is in a buffer";

  cout<<endl;
    int i;
  
for ( i=0;i<size;i++)
  cout<<buffer[i];     // here i am trying to print the data inside buffer where i get all junk values.

  return 0;
}

Well of course it's junk, it's a binary file.
You're still trying to print it as a text file.

You might want to try something like this, and perhaps even just limiting it to printing say the first 256 bytes (just to show proof of concept). std::cout << std::hex << (int)buffer[0] << std::endl; (there's padding and width modifiers to look up as well, for a nicely formatted hex dump)

Like I said, the real test is retrieving the original file, so whatever media player can still play the file.

its working without the hex in the cout statement u gave .
Is that the true data of the movie/audio file. ? I mean is there any other complications of hexadecimal of so .

the changed code instead of simply printing the buffer array i :

cout<< int(buffer[i]) ;

and this worked . I was getting numbers .

any idea for how to proceed for testing ?

> Is that the true data of the movie/audio file. ?
Yes.

> I mean is there any other complications of hexadecimal of so .
Only that in hex, a single byte can always be nicely formatted as two characters.

> any idea for how to proceed for testing ?
Only for you to show that whatever your encryption process is reversible.

> any idea for how to proceed for testing ?
Only for you to show that whatever your encryption process is reversible.

Well thats exactly wat i was looking for . . i got my cipher , so basically in the buffer where i have stored the complete data has to be encrypted and then reversed.

> I mean is there any other complications of hexadecimal of so .
Only that in hex, a single byte can always be nicely formatted as two characters.

Well as of now i am getting in numbers right ..?
Ur saying if i convert into hex , things will be more organized .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.