Cannot encode audio to ogg vorbis...

1,264 views
Skip to first unread message

Marty

unread,
Dec 2, 2012, 5:41:03 PM12/2/12
to xuggle...@googlegroups.com
When I attempt to encode audio to an IMediaWriter using the ICodec.ID.CODEC_ID_VORBIS, I get the following error. This is (again) something I did with past versions of xuggler with no issues... The default is the expected IAudioSamples.Format.FMT_S16, but I have tried resampling to virtually every sample format in IAudioSamples.Format before encoding and I get the same result. What is going on here?

17:31:15.241 [Thread-11] ERROR org.ffmpeg - [libvorbis @ 0x7ffd38091420] Specified sample_fmt is not supported.
17:31:15.241 [Thread-11] WARN  com.xuggle.xuggler - Error: could not open codec (../../../../../../../csrc/com/xuggle/xuggler/StreamCoder.cpp:831)
java.lang.RuntimeException: could not open stream com.xuggle.xuggler.IStream@940144256[index:0;id:0;streamcoder:com.xuggle.xuggler.IStreamCoder@940140048[codec=com.xuggle.xuggler.ICodec@940143472[type=CODEC_TYPE_AUDIO;id=CODEC_ID_VORBIS;name=libvorbis;];time base=1/44100;frame rate=0/0;sample rate=44100;channels=2;];framerate:0/0;timebase:1/90000;direction:OUTBOUND;]: Operation not permitted
at com.xuggle.mediatool.MediaWriter.openStream(MediaWriter.java:1192)
at com.xuggle.mediatool.MediaWriter.getStream(MediaWriter.java:1052)
at com.xuggle.mediatool.MediaWriter.encodeAudio(MediaWriter.java:830)
at svgif_server.IFrameListener.onAudioSamples(IFrameListener.java:155)
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)

Marty

unread,
Dec 2, 2012, 11:52:05 PM12/2/12
to xuggle...@googlegroups.com
OK, I at least got the IMediaWriter to work with a little tweaking by doing the following upon creating it:

IAudioResampler oggResampler = IAudioResampler.make(2, audioCoder.getChannels(), audioCoder.getSampleRate(), IAudioSamples.Format.FMT_FLT, audioCoder.getSampleFormat());
IMediaWriter oggWriter = ToolFactory.makeWriter("out.ogg");
oggWriter.addAudioStream(0, 0, ICodec.ID.CODEC_ID_VORBIS, oggResampler.getOutputChannels(), oggResampler.getOutputRate());
oggWriter.getContainer().getStream(0).getStreamCoder().setSampleFormat(IAudioSamples.Format.FMT_FLT);

Strange that I have to manually set the sample format in the IContainer but at least that works. Then I read in a video with an IMediaReader and do the following in the listener:

public void onAudioSamples(IAudioSamplesEvent e) {
if (pVidParam.hasAudio) {
IAudioSamples inSamples = e.getAudioSamples();
long numSamples = inSamples.getNumSamples();
IAudioSamples outSamples = IAudioSamples.make(numSamples, resampler.getOutputChannels());
IAudioSamples outSamplesOGG = IAudioSamples.make(numSamples, resamplerOGG.getOutputChannels(), IAudioSamples.Format.FMT_FLT);
resampler.resample(outSamples, inSamples, numSamples);
resamplerOGG.resample(outSamplesOGG, inSamples, numSamples);
mp3Writer.encodeAudio(0, outSamples);
oggWriter.encodeAudio(0, outSamplesOGG);
}
}

The ogg file that is output though is still not correct. It seems like all of the audio data is there because it plays fine start to finish. However, any of the oggs I generate will cause vlc to choke somewhat, The time slider doesn't seem to be synced properly and the total time is incorrect. This seems to indicate that the header isn't being properly written. 

I have a feeling that tweaking some more things using the StreamCoder like I did above will solve the issue but the things I've changed so far have had no effect. Any advice here?

Thanks

Firas Abbasi

unread,
Dec 5, 2012, 10:41:18 AM12/5/12
to xuggle...@googlegroups.com
Try to configure Xuggler as described in link down may will helps you
http://www.benfarahmand.com/2012/11/tutorial-using-xuggler-in-processing.html

--
You received this message because you are subscribed to the Google Groups "xuggler-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/xuggler-users/-/vLYE1AeHVHEJ.

To post to this group, send email to xuggle...@googlegroups.com.
To unsubscribe from this group, send email to xuggler-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/xuggler-users?hl=en.

Stral Mob

unread,
Jul 31, 2013, 9:48:20 AM7/31/13
to xuggle...@googlegroups.com
Can you please give us working java file that converting to ogg file vorbis because we tried you above code but it is giving syntax error.

Thanks

Marty Sullivan

unread,
Aug 1, 2013, 11:25:42 AM8/1/13
to xuggle...@googlegroups.com
Honestly, I have left xuggler behind and I think others should too, at least until it is picked up again. What I do now is just use Java to construct an ffmpeg command and then have the system call it in a separate process. I use shared memory to hold any intermediate files. This honestly works better for me than xuggler ever did.


--
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.

Art Clarke

unread,
Aug 1, 2013, 3:20:32 PM8/1/13
to xuggler-users
As the guy who wrote most of the xuggler open sourced code:

1) if the ffmpeg command line fills your use case, always use it :) seriously -- it's the main thrust of the ffmpeg team's development. You really should only use Xuggle for the things that absolutely cannot be done by "ffmpeg -i ..."
2) and yes, there are some things that fit that use case.
3) I am NOT actively working on xuggle anymore. The API is too old to work with the new FFmpeg way of doing things, and the original licensing model (LGPL) left no way for the project to actually be self-sustaining in any way (as in no way to support developers financially, and no one else really contributed much code). That's actually fine -- and I welcome folks who want to fork xuggle. But if I return to the video space, it will be with an improved API build on the new FFmpeg way of doing things. And yes, that would include libswscale, libswrecale and libavfilter.
4) If you're interested in a new version along the lines of #3 above, drop me a line and let me know what your use-case for it might be, features you'd want, and any suggestions you have for how to sponsor active development.

- Art
--
http://www.xuggle.com/
xu‧ggle (zŭ' gl) v. To freely encode, decode, and experience audio and video.

Use Xuggle to get the power of FFmpeg in Java.

declan

unread,
Aug 6, 2013, 5:38:44 AM8/6/13
to xuggle...@googlegroups.com
Hi Art

 On point 4 below;

4) If you're interested in a new version along the lines of #3 above, drop me a line and let me know what your use-case for it might be, features you'd want, and any suggestions you have for how to sponsor active development.

.
Im interested in discussing this further with you. Can you drop me an email to let me know whats possible

Thanks
Declan 

William

unread,
Aug 6, 2013, 8:42:05 AM8/6/13
to xuggle...@googlegroups.com
I'd also be interested.  My use case is playback of files, cameras, and streams.

William
Reply all
Reply to author
Forward
0 new messages