public static long optimize(InputStream in,OutputStream out,Configuration configuration) throws IOException {
  Movie movie=new Movie();
  TagDecoder tagDecoder=new TagDecoder(in);
  MovieDecoder movieDecoder=new MovieDecoder(movie);
  tagDecoder.parse(movieDecoder);
  optimize(movie,configuration);
  TagEncoder handler=new TagEncoder();
  MovieEncoder encoder=new MovieEncoder(handler);
  encoder.export(movie);
  ByteArrayOutputStream baos=new ByteArrayOutputStream();
  handler.writeTo(baos);
  out.write(baos.toByteArray());
  return baos.size();
}

public static long optimize ( InputStream in , OutputStream out , Configuration configuration ) throws IOException { Movie movie = new Movie ( ) ; TagDecoder tagDecoder = new TagDecoder ( in ) ; MovieDecoder movieDecoder = new MovieDecoder ( movie ) ; tagDecoder . parse ( movieDecoder ) ; optimize ( movie , configuration ) ; TagEncoder handler = new TagEncoder ( ) ; MovieEncoder encoder = new MovieEncoder ( handler ) ; encoder . export ( movie ) ; ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ; handler . writeTo ( baos ) ; out . write ( baos . toByteArray ( ) ) ; return baos . size ( ) ; }
this method is used by toolkit .
