[FFmpeg-user] Runtime conversion from byte array

Mike Scheutzow mike.scheutzow at alcatel-lucent.com
Thu Mar 15 13:48:47 CET 2012


Jeff wrote:
>> Jeff Mihalik wrote:
>>> I am creating a java project where the goal is to receive byte arrays of
>>> mpeg-2 videos from the database and convert them at runtime to mpeg-4
>>> videos (also as byte arrays, to pass to another application for display).
> 
> I have two years experience with C, and I have experience with JNI as well
> so that is a viable option (as well as java's Runtime.exec()).  Whichever
> option has the simplest implementation works for me.  I will look through
> the C API - are there certain files you could point me to to work with byte
> arrays?  Otherwise, if java's Runtime.exec() is simpler, how would it work
> with byte arrays?

The simplest method, by far, is to write the byte array to a temp file, 
create the correct command line, call Runtime.exec(), then read the 
result from the output temp file.

A slightly more elegant approach is to connect to the stdin and stdout 
of the exec'ed process. This avoids the need for temp files. The ffmpeg 
app can be told to read stdin and write stdout.

Using Runtime.exec() is also the easiest to comply with, license-wise.


Mike Scheutzow


More information about the ffmpeg-user mailing list