Saturday, 15 January 2011

converter - Xugller illegalArgumentExeception -



converter - Xugller illegalArgumentExeception -

i'm seek convert film (.mp4) in sound (.mp3) xuggler. utilize porcessing on os x.

imediareader reader = toolfactory.makereader("/users/nouv/desktop/video1.mp4"); imediawriter author = toolfactory.makewriter("/users/nouv/desktop/audiooutput.mp3", reader); int samplerate = 22050; int channels = 1; writer.addaudiostream(0, 0, icodec.id.codec_id_mp3, channels, samplerate); reader.addlistener(writer); seek { while (reader.readpacket() == null) ; } {}

i have error : illegalargumentexception : stream[0] not video

exception in thread "animation thread" java.lang.illegalargumentexception: stream[0] not video @ com.xuggle.mediatool.mediawriter.encodevideo(mediawriter.java:754) @ com.xuggle.mediatool.mediawriter.encodevideo(mediawriter.java:783) @ com.xuggle.mediatool.mediawriter.onvideopicture(mediawriter.java:1434) @ com.xuggle.mediatool.amediatoolmixin.onvideopicture(amediatoolmixin.java:166) @ com.xuggle.mediatool.mediareader.dispatchvideopicture(mediareader.java:610) @ com.xuggle.mediatool.mediareader.decodevideo(mediareader.java:519) @ com.xuggle.mediatool.mediareader.readpacket(mediareader.java:475) @ xuggle.setup(xuggle.java:135) @ processing.core.papplet.handledraw(papplet.java:2117) @ processing.core.pgraphicsjava2d.requestdraw(pgraphicsjava2d.java:193) @ processing.core.papplet.run(papplet.java:2020) @ java.lang.thread.run(thread.java:680)

i tried .mp4 , .mov , .flv film , have same error.

icontainer container = icontainer.make();

int result = container.open(inputfilename, icontainer.type.read, null); // check if operation successful if (result<0) throw new runtimeexception("failed open media file"); int numstreams = container.getnumstreams(); int audiostreamid = -1; icontainer author = icontainer.make(); writer.open(outputfilename, icontainer.type.write, icontainerformat.make()); (int i=0; i<numstreams; i++) { istream stream = container.getstream(i); istreamcoder coder = stream.getstreamcoder(); istreamcoder audiocoder = istreamcoder.make(istreamcoder.direction.encoding, coder); if( coder.getcodectype() == icodec.type.codec_type_audio){ coder.open(imetadata.make(), imetadata.make()); audiostreamid = i; icodec inputcodec = icodec.finddecodingcodec(icodec.id.codec_id_mp3); if (inputcodec == null) throw new illegalargumentexception("could not find input codec id"); if (audiostreamid == -1) throw new runtimeexception("could not find sound stream in container: "+inputfilename); writer.addnewstream(audiocoder); if(writer.writeheader() == 0) { ipacket packet = ipacket.make(); while(container.readnextpacket(packet) >= 0){ if(packet.getstreamindex() == audiostreamid) { if(coder.isopen()){ writer.writepacket(packet); } else {throw new runtimeexception("could not open coder"); } } } }else {throw new runtimeexception("header not written author container.");} } coder.close(); audiocoder.close(); } writer.writetrailer(); writer.close();

hope helps... :)

converter processing illegalargumentexception xuggler

No comments:

Post a Comment