~ thanks to ffmpeg developers (specially Stefano Sabatini) tika's media handling is basically done. ~ All that is needed is using a schema based xml handling to get the metadata, which IMHO is the nicest way we could have dreamed of having metadata served to tika ~ lbrtchx
On 12/31/11, Albretch Mueller <[email protected]> wrote: > guys, > ~ > I just wanted to let you know that I haven't forgotten working on > tika's media branch. The thing is that ffmpeg developers (specially > Stefano Sabatini) have been nicely receptive and helpful: > ~ > http://ffmpeg-users.933282.n4.nabble.com/ > ~ > : getting some xml-ish dump while ffprobing a media file's metadata? > ~ > : standard err or out? > ~ > and also, well, you know, we are all busy doing other things ;-), so. > I have had to change my starting code a few times. I just went monkey > and did things the way I thought (without reading your code base), > because I wanted to thoroughly test ffmpeg output first (to the extent > that java would let you). Basically I used some thread-base code to > get the standard output and error stream > ~ > // __ > class StreamGrabber02 extends Thread{ > InputStream IS; > private String aStringedStream; > private final int iSz = 8192; > // __ > StreamGrabber02(InputStream IS, String aThrdNm){ > this.IS = IS; > setName(aThrdNm + "_" + this); > } > // __ > public void run(){ > int iL = 0; > ByteArrayOutputStream BAOS = null; > byte[] bAr = new byte[iSz]; > try{ > BAOS = new ByteArrayOutputStream(); > while ((iL = IS.read(bAr, 0, iSz)) != -1){ BAOS.write(bAr, 0, iL); > } BAOS.flush(); > this.aStringedStream = new String(BAOS.toByteArray()); > }catch(IOException IOX){ > System.err.println("// __ thread name: |" + getName() + "|"); > IOX.printStackTrace(System.err); > } > } > // __ > public String getStringedStream(){ return(this.aStringedStream); } > } > ~ > and running ffprobe like this > ~ > Process Prx = RTm.exec((new String[]{”ffprobe”, "-unit", > "-show_streams", "-show_format", "-loglevel", "-loglevel", <media > input file>})); > ~ > InputStream ISErr = Prx.getErrorStream(); > ~ > StreamGrabber02 SGrbErr = new StreamGrabber02(ISErr, aThrdNm + > ".err"); SGrbErr.start(); > ~ > InputStream ISIn= Prx.getInputStream(); > StreamGrabber02 SGrbIn = new StreamGrabber02(ISIn, aThrdNm + ".in"); > SGrbIn.start(); > // __ > iExitVal = Prx.waitFor(); > SGrbErr.join(); SGrbIn.join(); > ISIn.close(); ISErr.close(); > Prx.destroy(); > ~ > then, depending on there being errors or not, the exit code of the > errors and the extension of the file, I logged the stream outputs to > different folders/files > ~ > // __ > if(iExitVal != 0){ > ODir = new File(ODirErrs, (new Integer(iExitVal)).toString()); > if(!ODir.exists()){ ODir.mkdirs(); } > OFl = new File(ODir, "_" + aX + ".log.txt"); > OSWrtr = new OutputStreamWriter(new FileOutputStream(OFl, true), > "UTF-8"); > OSWrtr.write(aB.toString()); > OSWrtr.close(); > } > else{ > ODir = new File(ODirOK, (new Integer(iExitVal)).toString()); > if(!ODir.exists()){ ODir.mkdirs(); } > OFl = new File(ODir, "_" + aX + ".log.txt"); > OSWrtr = new OutputStreamWriter(new FileOutputStream(OFl, true), > "UTF-8"); > OSWrtr.write(aB.toString()); > OSWrtr.close(); > // __ > ++lFlsOK; > } > ~ > In order to do functional and stress testing, I had no option but > abusing http://samples.mplayerhq.hu/00-README. I wouldn't provide you > with stress test results right now, because ffmpeg developers have > including a flag to ffprobe's output as schema-based xml and I am > again/still streamlining things > ~ > I think I should work next on making this starting code more kosher > and align it with tika's base. I notice there is going to be > "cultural" issues (other than offering/maintaining the code) if the > decision is made to go ahead and use ffmpeg as our underlying library > for users of the supported operating systems (how to install it and > such things) > ~ > Can you just tell me which class/documentation based on a similar > library should I use as example? > ~ > Is it OK for me to just post the whole code listing here or some > public site before you decide (or not) to make me one of that code > base committers? > ~ > Any other advice about how to proceed next? > ~ > lbrtchx >
