V
Vince
Hi all
I've been developing a customer application for quite a while now and
we're reaching the point where the application will be tested. Anyway,
one part of the application allows the user to upload movies in
different formats (mpg, avi etc) which will be converted automatically
into the FLV format (plus a preview picture of it will be created).
I was researching for a while to find an adequate Java API/Tool for this
purpose and bumped into different available frameworks like at example
JMF. After further investigations regarding JMF and others, I realized
quickly that I would break a fly on the wheel and I decided to switch
over to FFMPEG (http://en.wikipedia.org/wiki/FFmpeg) even though it's
not a native but Java external tool.
I basically wrote a wrapper class to parameterize and execute FFMPEG using:
....
int exitValue = -1;
Process process = Runtime.getRuntime().exec(convertCommand);
exitValue = doWaitFor(process);
....
I had to use a sort of hack (doWaitFor(process)) to check when the
process ends since FFMPEG doesn't return and exit values and since there
is a documented problem on Win32 platforms with the native
process.waitFor() function. For those who are interested I'll append the
doWaitFor method at the bottom of this post.
Anyway, coming closer to the application integration testing, I start
worrying a bit regarding the performance of that whole conversion
method. Since the hardware is running on multi processor and has enough
RAM I'm not really concerned about that, I'm more concerned regarding
the application performance when let's say 100 user do upload and
convert movies at the same time. So my questions at this point are:
1. Did everyone ever had to deal with Flash Movie Conversion, and if yes
which approach did you take
2. How will my way of conversion affect the overall application performance
Obviously there are some more questions but I guess I'll post them bit
by bit in accordance with your replies...
Thanks for any contribution!
Vince
PS: Following my doWaitFor Method:
private static int doWaitFor(Process p) {
int exitValue = -1; // returned to caller when p is finished
try {
InputStream in = p.getInputStream();
InputStream err = p.getErrorStream();
boolean finished = false; // Set to true when p is finished
while (!finished) {
try {
while (in.available() > 0) {
// Print the output of our system call
Character c = new Character((char) in.read());
System.out.print(c);
}
while (err.available() > 0) {
// Print the output of our system call
Character c = new Character((char) err.read());
System.out.print(c);
}
// Ask the process for its exitValue. If the process
// is not finished, an IllegalThreadStateException
// is thrown. If it is finished, we fall through and
// the variable finished is set to true.
exitValue = p.exitValue();
finished = true;
} catch (IllegalThreadStateException e) {
// Process is not finished yet;
// Sleep a little to save on CPU cycles
Thread.currentThread().sleep(500);
}
}
} catch (Exception e) {
// unexpected exception! print it out for debugging...
System.err.println("doWaitFor(): unexpected exception - "
+ e.getMessage());
}
// return completion status to caller
return exitValue;
}
I've been developing a customer application for quite a while now and
we're reaching the point where the application will be tested. Anyway,
one part of the application allows the user to upload movies in
different formats (mpg, avi etc) which will be converted automatically
into the FLV format (plus a preview picture of it will be created).
I was researching for a while to find an adequate Java API/Tool for this
purpose and bumped into different available frameworks like at example
JMF. After further investigations regarding JMF and others, I realized
quickly that I would break a fly on the wheel and I decided to switch
over to FFMPEG (http://en.wikipedia.org/wiki/FFmpeg) even though it's
not a native but Java external tool.
I basically wrote a wrapper class to parameterize and execute FFMPEG using:
....
int exitValue = -1;
Process process = Runtime.getRuntime().exec(convertCommand);
exitValue = doWaitFor(process);
....
I had to use a sort of hack (doWaitFor(process)) to check when the
process ends since FFMPEG doesn't return and exit values and since there
is a documented problem on Win32 platforms with the native
process.waitFor() function. For those who are interested I'll append the
doWaitFor method at the bottom of this post.
Anyway, coming closer to the application integration testing, I start
worrying a bit regarding the performance of that whole conversion
method. Since the hardware is running on multi processor and has enough
RAM I'm not really concerned about that, I'm more concerned regarding
the application performance when let's say 100 user do upload and
convert movies at the same time. So my questions at this point are:
1. Did everyone ever had to deal with Flash Movie Conversion, and if yes
which approach did you take
2. How will my way of conversion affect the overall application performance
Obviously there are some more questions but I guess I'll post them bit
by bit in accordance with your replies...
Thanks for any contribution!
Vince
PS: Following my doWaitFor Method:
private static int doWaitFor(Process p) {
int exitValue = -1; // returned to caller when p is finished
try {
InputStream in = p.getInputStream();
InputStream err = p.getErrorStream();
boolean finished = false; // Set to true when p is finished
while (!finished) {
try {
while (in.available() > 0) {
// Print the output of our system call
Character c = new Character((char) in.read());
System.out.print(c);
}
while (err.available() > 0) {
// Print the output of our system call
Character c = new Character((char) err.read());
System.out.print(c);
}
// Ask the process for its exitValue. If the process
// is not finished, an IllegalThreadStateException
// is thrown. If it is finished, we fall through and
// the variable finished is set to true.
exitValue = p.exitValue();
finished = true;
} catch (IllegalThreadStateException e) {
// Process is not finished yet;
// Sleep a little to save on CPU cycles
Thread.currentThread().sleep(500);
}
}
} catch (Exception e) {
// unexpected exception! print it out for debugging...
System.err.println("doWaitFor(): unexpected exception - "
+ e.getMessage());
}
// return completion status to caller
return exitValue;
}