int w = 200;
int h = 200;
// create the writer
MediaWriter writer = new MediaWriter(file.toString());
writer.addListener(new MediaViewer(mViewerMode, true));
// add the video stream
ICodec codec = ICodec.findEncodingCodec(ICodec.ID.CODEC_ID_FLV1);
writer.addVideoStream(videoStreamIndex, videoStreamId, codec, w, h);
// create a place for video pictures
IVideoPicture picture = IVideoPicture.make(IPixelFormat.Type.YUV420P, w, h);
// make some pictures
double deltaTheta = (Math.PI * 2) / 200;
for (double theta = 0; theta < Math.PI * 2; theta += deltaTheta)
{
BufferedImage image = new BufferedImage(w, h,
BufferedImage.TYPE_3BYTE_BGR);
Graphics2D g = image.createGraphics();
g.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.RED);
g.rotate(theta, w / 2, h / 2);
g.fillRect(50, 50, 100, 100);
picture.setPts(time);
writer.encodeVideo(videoStreamIndex, image,
time, Global.DEFAULT_TIME_UNIT);
time += deltaTime;
}
// close the writer
writer.close();
assert(file.exists());
assertEquals(file.length(), 291186, 60000);
log.debug("manually check: " + file);
}