views:

183

answers:

2

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?

+1  A: 

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.

stpiker
A: 

regarding this "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."

I really love to see how you have done it for I wasted 2 hours and I couldn't not make it work.

is there any chance that you can post the code regarding

IAudioResampler & onAudioSamples()

this is the second day I'm reading about xuggle and I really need help.

Thanks

webBuilder