I have a LinkedList< BufferedImage > imgList object. When I add BufferedImage I can create video. When I use
BufferedImage tmp1 = img.getSubimage(0,0,500,500);
imgList.add(temp1);
img is BufferedImage with a loaded image.
I get this error:
Exception in thread "main" java.nio.BufferOverflowException
at java.nio.DirectByteBuffer.put(DirectByteBuffer.java:363)
at java.nio.ByteBuffer.put(ByteBuffer.java:859)
at com.xuggle.xuggler.video.BgrConverter.toPicture(BgrConverter.java:132)
at com.xuggle.mediatool.MediaWriter.convertToPicture(MediaWriter.java:970)
at com.xuggle.mediatool.MediaWriter.encodeVideo(MediaWriter.java:805)
at xuggler.CreateVideo.<init>(CreateVideo.java:61)
at xuggler.CreateGraphics.<init>(CreateGraphics.java:108)
at xuggler.Main.main(Main.java:12)
Here is the class in which I create the video:
public class CreateVideo {
private static final double framerate = 30;
private static final String outputFilename = "outputvideo.mp4";
public CreateVideo(LinkedList<BufferedImage> imgList) {
final IMediaWriter writer = ToolFactory.makeWriter(outputFilename);
writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_MPEG4, bordwidth/2, bordheight/2);
long startTime = System.nanoTime();
for (BufferedImage imgs : imgList){
writer.encodeVideo(0, imgs, System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
try {
Thread.sleep((long) ((1000)/ framerate));
}
catch (InterruptedException e) {
}
}//End for
writer.close();
}//end CreateVideo
}
Could you check the size of imgList and writer. It looks your writer object can not handle all images in imageList object? Check if this helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.