4

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?

stpiker
  • 383
  • 1
  • 3
  • 13
  • In playing around a bit with command line ffmpeg, it seems as if the issue is with the audio rate of the input videos being incompatible with the flv output (e.g., 48000 Hz). If I use the '-ar 44100' option for ffmpeg, the videos convert successfully. Now to translate that to Xuggle code... – stpiker Aug 04 '10 at 16:55

2 Answers2

5

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
  • 383
  • 1
  • 3
  • 13
1

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

xlnc
  • 11
  • 1
  • 1
    Your answer would be more useful if you describe the solution to the question rather than just including a link. – this.josh May 18 '11 at 17:27
  • @xlnc i also tried this, i was trying to convert to 3gp so there was a little difference in minor details but it started throwing a null pointer exception, which i solved by adding a null check in the onAddStream method. Now there is no error, but the program remains busy and a 65 Kb file is formed, which on playing says that the file has no playable streams. Please can u help me in any way here. – Khizar Sep 13 '11 at 06:37
  • The link you gave is not opening. – Pramod Aug 01 '19 at 06:24