2011-12-29 104 views
1

我試圖使用xuggler將圖像列表編碼成視頻。我有一系列緩衝圖像。我正在使用下面的代碼。從Xuggler中的幀中獲取視頻

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); 

} 

的問題是它的返回我以下錯誤..

[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) 

產生由於outFrame該錯誤,我已經檢查所創建的幀的寬度和高度和圖象其相同的。任何一個人可以幫我在這裏或給我一個提示..

我用這裏的來源。謝謝。

http://wiki.xuggle.com/Encoding_Video_from_a_sequence_of_Images

回答

0

的問題是,先生,你一定會被錯誤設置你outstream的高度和寬度。例如

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

您應該在此處正確放置視頻高度,寬度也應該正確。