Xuggler MediaWriter Operation Not Permitted Issue

1.4k Views Asked by At

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(); 
    } 
1

There are 1 best solutions below

0
On

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