Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xuggler MediaWriter Operation Not Permitted Issue

Tags:

java

xuggler

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(); 
    } 
like image 914
user1249283 Avatar asked Nov 03 '22 22:11

user1249283


1 Answers

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(); 
    }
like image 133
user3301869 Avatar answered Nov 12 '22 19:11

user3301869