<div dir="ltr">Hello,<div><br></div><div style>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?</div>
<div style><br></div><div style><br></div><div>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."</div>
<div><br></div><div>Question: Is this the right approach and how do I then specify where the decoding is supposed to stop?</div><div><div><br></div><div><br></div></div><div style>I will describe the steps I've tried so far (maybe not the best approach):</div>
<div style><br></div><div style>I have tried modifying the opusfile-1.0.2/examples/seeking_example.c as a base, replacing<br></div><div style><br></div><div style>
<p class=""> pcm_offset=(ogg_int64_t)(rand()/(double)RAND_MAX*pcm_length);</p>
<p class="">with</p><p class=""> pcm_offset=(<span class="">ogg_int64_t</span>)((<span class="">double</span>)pcm_length/<span class="">2.0</span>);</p><p class="" style>presumably to start the decoding at the middle of the file by:</p>
<p class="" style> ret=<span class="">op_pcm_seek</span>(of,pcm_offset);</p>
<p class="" style>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.</p><p class="" style>
Thanks,<br>Matt</p>
</div></div>