当我关闭IMediaWriter时,我一直遇到异常 简单的转码。 例外是“java.lang.RuntimeException:错误操作不是 允许,未能将预告片写入test.mp3“ 每当我调用IMediaWriter.close()时,我都会得到这个,任何想法为什么我会得到这个简单的转码? 这是示例代码:
IMediaReader reader = null;
IMediaWriter writer = null;
try {
reader = ToolFactory.makeReader("test.wav");
writer = ToolFactory.makeWriter("test.mp3", reader);
reader.addListener(writer);
while (reader.readPacket() == null) ;
reader.close();
writer.close();
} catch (Exception ex) {
ex.printStackTrace();
}
答案 0 :(得分:2)
这肯定会起作用,因为我遇到了同样的问题。谢谢。如果您想要更多说明,请询问......
IMediaReader reader = null;
IMediaWriter writer = null;
try {
reader = ToolFactory.makeReader("sijo.mp4");
writer = ToolFactory.makeWriter("Thomas.flv", reader);
reader.addListener(writer);
while (reader.readPacket() == null) ;
//Should IMediaReader automatically call close(), only if ERROR_EOF (End of File) is returned from readPacket().
reader.setCloseOnEofOnly(false);
//If false the media data will be left in the order in which it is presented to the IMediaWriter.
//If true IMediaWriter will buffer media data in time stamp order, and only write out data when it has at least one same time or later packet from all streams.
writer.setForceInterleave(false);
System.out.println("closed...");
} catch (Exception ex) {
ex.printStackTrace();
}