Re: Flash Movie Conversion with Java (FFMPEG)
Mark first I wanna thank you for your non negligible efforts and time
you did put with your replies...
...rather than a single String, so you can avoid extra
quoting if the parameters have spaces or special characters in them ...
I recall now having used the ProcessBuilder when I was struggling with
the waitFor at one stage but must have come back to the Runtime version
because it didn't solve my problem. With your approach below I gotta
reconsider my code...
In your simple case, you can also redirectErrorStream(true) before starting
the process, and then you won't have to read the error stream from the
Process.
I do not understand this point yet but I'll read about it and get clued up..
Right, but polling for output is pretty gross.
I thought it wasn't very nice to solve it this way, but good you hammer
the nail further in ;-) As said above I'll reconsider this whole part..
// WARNING: partial and not tested, so errors are likely
builder.setRedirectErrorStream(true);
Process p = builder.start();
I guess at this stage that builder is from type ProcessBuilder...
final InputStream procStdOut = p.getInputStream();
// start a thread to read the stdout
new Thread("process InputStream handler for " + processName) {
public void run() {
byte[512] buf; // deal with larger blocks than 1 char at a time!
int amtRead;
try {
// read until EOF, blocking when there's nothing to read
while ((amtRead = procStdOut.read(buf) != -1) {
// do something with amtRead bytes of buf
System.out.write(buf, 0, amtRead);
}
} catch (IOException e) {
// shouldn't ever happen for this type of stream
// note failure, queue to retry or whatever you want.
LOGGER.error("impossible IOException!", e);
}
}
}.run();
int exitCode = p.waitFor();
I'll test it and give you a feedback. By just reading the code though,
it all makes sense to me and looks pretty complete..
Oh. Why not? Video conversion is a slow, expensive process, and you
shouldn't try to do it all at once.
....
I'd call that a broken design. It's just plain not going to scale well.
I'm glad to hear that from you. We had long discussions with the
customer and he refuses to queue and thus delay the conversion. The
application is done for regional / International journalists which need
to redact their articles online and thus also need instant access to
their uploaded medias. There is no human process in place between the
time where the journalist releases his article and it gets visible on
the portal. Basically if the journalist prepares his article in word,
quickly copies the content into the portal and pushes the release
button, the article is visible for the public. If the media content
appears now only 10 minutes later because it has been queued for
conversion... no comment...
... That separate system can work
on N files at once, so you can optimize the memory, cpu, and disk usage for
large numbers of requests.
That's exactly why I'm concerned about the testing and performance... So
basically what can I do?
Thanks Vince
--
Posted via a free Usenet account from http://www.teranews.com