java.lang.RuntimeException: error Operation not permitted, failed to write trailer to C:\\OC_Downloaded_Output\\WindowsScreeshots\\customer2\\476830_3155_4050321_6417/Movie.mov

597 views
Skip to first unread message

Suman Singh

unread,
May 19, 2014, 9:20:30 AM5/19/14
to xuggle...@googlegroups.com
Hi all,

trying to create movie using xuggler library in java out of .png images ,it throws the following exception on write.close().


SEVERE: java.lang.RuntimeException: error Operation not permitted, failed to write trailer to C:\\OC_Downloaded_Output\\WindowsScreeshots\\customer2\\476830_3155_4050321_6417/Movie.mov
at com.xuggle.mediatool.MediaWriter.close(MediaWriter.java:1306)
at com.tcs.XugglerMovie.UsingXuggler.createMovie(UsingXuggler.java:87)
at tcs.opsconsole.servlets.ClosingRDPServlet.processRequest(ClosingRDPServlet.java:65)
at tcs.opsconsole.servlets.ClosingRDPServlet.doGet(ClosingRDPServlet.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:687)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at tcs.opsconsole.servlets.LoggingFilter.doFilter(LoggingFilter.java:78)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
at java.lang.Thread.run(Thread.java:722)


here is mine sample code.

public int createMovie(String outputFilename, String pngFilesPath) throws IOException, InterruptedException {
opsLogger.debug("reached here---------pngFilesPath------------1"+pngFilesPath);
ResizingImage rg=new ResizingImage();
boolean imageFound=rg.resizeAllImages(pngFilesPath);

if(!imageFound)
{
opsLogger.debug("no image found to create movie.....");
return -1;
}
opsLogger.debug("returned from resized images......");
final IMediaWriter writer = ToolFactory.makeWriter(outputFilename);
writer.addVideoStream(0, 0, ICodec.ID.CODEC_ID_MPEG4,
720, 304);//720, 304
long nextFrameTime = 0;
final long frameRate = 1;
// long startTime = System.nanoTime();
noOfFiles = getNoFiles(pngFilesPath);
opsLogger.debug("no of file before processing images----"+noOfFiles);
ArrayList files = getListOfFiles(pngFilesPath);

while (indexVideo < noOfFiles) {
BufferedImage videoImage = null;
opsLogger.debug("Current file name = "+ files.get(indexVideo).toString()+" indexVideo="+indexVideo);
String finalpath = pngFilesPath + "/" + files.get(indexVideo).toString();
videoImage = getVideoImage(finalpath);

try
{
if(videoImage!=null)
{
writer.encodeVideo(0, videoImage, nextFrameTime,
TimeUnit.MILLISECONDS);
nextFrameTime += frameRate;
}else
{
opsLogger.debug("videoImage is null");
return -1;
}
}catch(Exception e)
{
e.printStackTrace();
deleteCurruptedMove(pngFilesPath);
AppZip appZip = new AppZip(pngFilesPath, pngFilesPath);
appZip.generateFileList(new File(pngFilesPath));
opsLogger.debug("zip file path="+pngFilesPath+".zip");
appZip.zipIt(pngFilesPath+".zip");
opsLogger.debug("Zipping is done.........here...............");
return 1;
}

}

boolean exceptionOccured=false;
try
{
// writer.setForceInterleave(false);
writer.close();


}catch(Exception e)
{
exceptionOccured=true;
opsLogger.debug("exception occured while (writing)creating movie so creating ZIP of images......");
opsLogger.debug(e.getMessage());
e.printStackTrace();
}
if(exceptionOccured)
{
deleteCurruptedMove(pngFilesPath);
AppZip appZip = new AppZip(pngFilesPath, pngFilesPath);
appZip.generateFileList(new File(pngFilesPath));
appZip.zipIt(pngFilesPath+".zip");
opsLogger.debug("Zipping is done......................");
return 1;
}else
{
deleteImagesFromFolder(pngFilesPath);
}
return 0;


}


please ignore the irrelevant part.
Any help is appriciated.

Thanks

Nikita

unread,
May 20, 2014, 5:44:22 PM5/20/14
to xuggle...@googlegroups.com
Take a look at balls example in xuggler jar. I did similar program with xuggler and it was very helpful. May be something is wrong with image types.. who knows. If you create a runnable project on github may be someone(may be even me?) will be able to find a solution for you.

понедельник, 19 мая 2014 г., 8:20:30 UTC-5 пользователь Suman Singh написал:

Michael Jordan

unread,
May 22, 2014, 9:05:48 AM5/22/14
to xuggle...@googlegroups.com
Hi Suman,
              
- Try flushing the writer before closing. I have a feeling if there's pending data you'll get an exemption thrown.
- Check to see if the streams are already closed for some reason (they shouldn't be, or the call to close will fail)
- Check to see if the object you're writing on has a header (it should, or the call to write a trailer will fail)


- Code snippet and comments from the Xuggler code (pretty much detailing what's above) are included below:

MediaWriter
    if ((rv = getContainer().writeTrailer()) < 0)
      throw new RuntimeException("error " + IError.make(rv) +

        ", failed to write trailer to "
        + getUrl());

IContainer:
/**
 * Adds a trailer, if needed, for this container. 
 * Call this AFTER you've written all data you're going to write 
 * to this container but BEFORE you call 
 * {@link IStreamCoder#close()} on your {@link IStreamCoder} 
 * objects. 
 * <p> 
 * You must call {@link #writeHeader()} before you call 
 * this (and if you don't, the {@link IContainer} 
 * will warn loudly and not 
 * actually write the trailer). 
 * </p> 
 * <p> 
 * If you have closed any of the {@link IStreamCoder} objects 
 * that were open when you called 
 * {@link #writeHeader()}, then this method will fail. 
 * </p><p>If the current thread is interrupted while this blocking method
 * 
 * is running the method will return with a negative value. 
 * To check if the method exited because of an interruption 
 * pass the return value to {@link IError#make(int)} and then 
 * check {@link IError#getType()} to see if it is 
 * {@link IError.Type#ERROR_INTERRUPTED}. 
 * </p> 
 * @return    0 if successful. < 0 if not. Always <0 if this is 
 * a READ container. 
 */
  public int writeTrailer() {
    return XugglerJNI.IContainer_writeTrailer(swigCPtr, this);
  }


Thanks,
MJ


--
You received this message because you are subscribed to the Google Groups "xuggler-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xuggler-user...@googlegroups.com.
To post to this group, send email to xuggle...@googlegroups.com.
Visit this group at http://groups.google.com/group/xuggler-users.
For more options, visit https://groups.google.com/d/optout.

Ed St Louis

unread,
May 24, 2014, 11:42:08 PM5/24/14
to xuggle...@googlegroups.com
I believe that when I use the Media Tools API that I cannot do direct manipulation with a writer or close a writer manually. You usually implement the media tool interface and chain tools together to do whatever manipulation you need. Then you just read through whatever source you have and the implemented interfaces are called automatically.

To do what you're doing I'd manually create my own output container. As Nikita suggested, I'd look at some of the demos provided in the source code. There are examples using the Media Tools paradigm and the more manual way. I have created movies from images using Xuggler, but I didn't use the Media Tools API.


--
You received this message because you are subscribed to the Google Groups "xuggler-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xuggler-user...@googlegroups.com.
To post to this group, send email to xuggle...@googlegroups.com.
Visit this group at http://groups.google.com/group/xuggler-users.
For more options, visit https://groups.google.com/d/optout.



--
Ed St. Louis
Cell: 801-999-8844
Home: 801-964-1855
Reply all
Reply to author
Forward
0 new messages