简体   繁体   中英

Get Video from frames in Xuggler

I am trying to encode a list of images into a video using xuggler. I have got an array of buffered images. I am using the following code.

public void encodeImage(BufferedImage originalImage, long timestamp) 
{

    //  BufferedImage worksWithXugglerBufferedImage = convertToType(originalImage, BufferedImage.TYPE_3BYTE_BGR);

    BufferedImage worksWithXugglerBufferedImage = convertToType(originalImage, BufferedImage.TYPE_3BYTE_BGR);

    IPacket packet = IPacket.make();
    IConverter converter = ConverterFactory.createConverter(worksWithXugglerBufferedImage, IPixelFormat.Type.YUV420P);

    IVideoPicture outFrame = converter.toPicture(worksWithXugglerBufferedImage, timestamp * 1000);
    outFrame.setQuality(0);


    outStreamCoder.encodeVideo(packet, outFrame, 0);

    if (packet.isComplete()) 
        outContainer.writePacket(packet); 

}

The problem is its returning me the following error..

[WARN] [NioProcessor-1] com.xuggle.xuggler - Got error: picture is not of the same width as this Coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1204)
[WARN] [NioProcessor-1] com.xuggle.xuggler - Got error: picture is not of the same width as this Coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1204)
[WARN] [NioProcessor-1] com.xuggle.xuggler - Got error: picture is not of the same width as this Coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1204)
[WARN] [NioProcessor-1] com.xuggle.xuggler - Got error: picture is not of the same width as this Coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1204)
[WARN] [NioProcessor-1] com.xuggle.xuggler - Got error: picture is not of the same width as this Coder (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:1204)

The error is generated due to outFrame , I have checked the width and height of the frame created and the picture its the same. Can any one help me out here or give me a hint..

I used the source present here. Thank you.

http://wiki.xuggle.com/Encoding_Video_from_a_sequence_of_Images

The problem is sir, You must be setting the height and width of your outstream wrongly. eg

outStreamCoder.setHeight(height);
outStreamCoder.setWidth(width); 

You should put your video height correctly here and so does your width.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM