Tutorial :Deciphering Xuggle/ffmpeg errors (newbie)



Question:

I've recently started working with Xuggle to convert video files of various formats into corresponding FLVs (to be played on our site via jwplayer). The code I'm using is trivially simple; essentially what they show for the basic video conversion tutorial:

IMediaReader reader = ToolFactory.makeReader(file.getPath());  reader.addListener(ToolFactory.makeWriter(tempFileName, reader));    while (reader.readPacket() == null)  ;  

This works well for about 50% of the videos I've attempted. However, I get the following error for some videos (all .MP4s I've come across, as well as some .MOVs)

Caused by: java.lang.RuntimeException: Error Operation not permitted, failed to write header to container com.xuggle.xuggler.IContainer@-635072136[url:/tmp/1280786368521.flv;type:WRITE;format:com.xuggle.xuggler.IContainerFormat@-631842520[oname:flv;olongname:FLV format;omimetype:video/x-flv;oextensions:flv;];] while establishing stream com.xuggle.xuggler.IStream@-615272544[index:1;id:2;streamcoder:com.xuggle.xuggler.IStreamCoder@-677475184[codec=com.xuggle.xuggler.ICodec@-635131032[type=CODEC_TYPE_AUDIO;id=CODEC_ID_MP3;name=libmp3lame;];time base=1/48000;frame rate=0/0;sample rate=48000;channels=2;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]          at com.xuggle.mediatool.MediaWriter.getStream(MediaWriter.java:1065)          at com.xuggle.mediatool.MediaWriter.encodeAudio(MediaWriter.java:837)          at com.xuggle.mediatool.MediaWriter.onAudioSamples(MediaWriter.java:1448)          at com.xuggle.mediatool.AMediaToolMixin.onAudioSamples(AMediaToolMixin.java:89)          at com.xuggle.mediatool.MediaReader.dispatchAudioSamples(MediaReader.java:628)          at com.xuggle.mediatool.MediaReader.decodeAudio(MediaReader.java:555)          at com.xuggle.mediatool.MediaReader.readPacket(MediaReader.java:469)          ... 10 more  

I'm having a hard time determining if the root cause for the error is related to the Xuggle/ffmpeg/lame/etc. installation, or whether there's an issue with my code.

I figure the first step is deciphering the error log and using that info to try to convert the video using native ffmpeg calls. If that works, I assume it's reasonable to believe that those components are installed correctly?

So for a log message like:

Error Operation not permitted, failed to write header to container com.xuggle.xuggler.IContainer@-635072136  [url:/tmp/1280786368521.flv;type:WRITE;format:com.xuggle.xuggler.IContainerFormat@-631842520[oname:flv;olongname:FLV format;omimetype:video/x-flv;oextensions:flv;];]     while establishing stream com.xuggle.xuggler.IStream@-615272544  [index:1;id:2;streamcoder:com.xuggle.xuggler.IStreamCoder@-677475184[codec=com.xuggle.xuggler.ICodec@-635131032[type=CODEC_TYPE_AUDIO;id=CODEC_ID_MP3;name=libmp3lame;];time base=1/48000;frame rate=0/0;sample rate=48000;channels=2;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]  

how would I translate that to a ffmpeg command?

any other debugging tips for this Xuggle newbie?


Solution:1

Problem solved. It was due to FLV only supporting audio streams with sample rates of 44.1, 22.05 & 11.025 kHz. Used Xuggle's IAudioResampler class from within a custom MediaTool listener listening to onAudioSamples() to resample the audio to a supported rate.


Solution:2

I also recently ran across this same issue. Spent couple of days on this till I found the answer here.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »