[opus] opus file trimming/clipping

Matt Ruck ultymatt at gmail.com
Wed May 8 17:12:53 PDT 2013


I am new to opus and C, so please forgive my basic question. I am trying to
trim a file to remove an extract at a specified starting and ending time --
an example would be to save an excerpt from a song as a ringtone. What is
the best way to accomplish this?

I have been trying to use op_pcm_seek, and the documentation for
op_pcm_seek says "Seek to the specified PCM offset, such that decoding will
begin at exactly the requested position."

Question: Is this the right approach and how do I then specify where the
decoding is supposed to stop?

I will describe the steps I've tried so far (maybe not the best approach):

I have tried modifying the opusfile-1.0.2/examples/seeking_example.c as a
base, replacing




presumably to start the decoding at the middle of the file by:


However, when I save the file using the
write_samples(buffer,nsamples,nchannels) function, the file is unreadable,
and the resulting file is less than half the size of the original file.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.xiph.org/pipermail/opus/attachments/20130508/ac753dcf/attachment.htm 

More information about the opus mailing list