Hello, 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 pcm_offset=(ogg_int64_t)(rand()/(double)RAND_MAX*pcm_length); with pcm_offset=(ogg_int64_t)((double)pcm_length/2.0); presumably to start the decoding at the middle of the file by: ret=op_pcm_seek(of,pcm_offset); 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. Thanks, Matt -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/opus/attachments/20130508/ac753dcf/attachment.htm
Matt Ruck wrote:> 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?Are you trying to produce a WAV file with the decoded output of just a segment of the input file, or are you trying to produce a new .opus file without re-encoding that segment?
I think producing a new .opus file would be ideal to maintain the benefits of using the opus codec for transmission over the Internet, and I have had success encoding to and decoding from .opus to .wav using opus-tools. Thanks, Matt On Wed, May 8, 2013 at 8:41 PM, Timothy B. Terriberry <tterribe at xiph.org>wrote:> Matt Ruck wrote: > > 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? > > Are you trying to produce a WAV file with the decoded output of just a > segment of the input file, or are you trying to produce a new .opus file > without re-encoding that segment? > > _______________________________________________ > opus mailing list > opus at xiph.org > http://lists.xiph.org/mailman/listinfo/opus >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/opus/attachments/20130508/e30ae885/attachment.htm