I keep getting an exception when I close an IMediaWriter doing a simple transcode. The exception is "java.lang.RuntimeException: error Operation not permitted, failed to write trailer to test.mp3" I get this whenever I call IMediaWriter.close(),Any ideas why I would be getting this for a simple transcoding? Here's the sample code:
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();
}
This will work surely because I was facing same problem. Thank you. If You want more clarification please ask...
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();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With