Body: <p>I'm curious, is it possible to do frame-perfect audio cutting using ffmpeg's complex filter graphs + frame filtering <code>aselect</code> functionality?</p>
  <p>I've tried a bunch of other approaches (using <code>-segment_times</code> and <code>-ss</code>/<code>-t</code>) - they worked but were only <code>~0.02sec</code> accurate, just for reference:</p>
  <ul>
  <li><code>ffmpeg -f lavfi -i &quot;sine=frequency=1000:duration=5&quot; -ar 48000 test.wav</code></li>
  <li><code>ffmpeg -y -i test.wav -f segment -segment_times &quot;1.55,2.00&quot; -segment_list_type csv -segment_list output.csv test%04d.opus</code></li>
  <li><code>ffmpeg -y -i test.wav -ss 0.00 -t 1.55 test0000.opus -ss 2.00 -t 1.00 test0001.opus</code></li>
  </ul>
  <p>My filter-based attempts:</p>
  <ul>
  <li><code>ffmpeg -y -i test.wav -ar 48000 -af &quot;aselect=between(samples_n\,100\,16100)&quot; test0000.opus</code> as an example but this produces a 5-second long <code>test0000.opus</code> instead of a 0.25-second one</li>
  <li><code>ffmpeg -y -i test.wav -ar 48000 -af &quot;aselect=between(t\,0.0\,1.55)&quot; test0000.opus</code> kind of works, but still gives a 1.57-second audio instead of 1.55-second one.</li>
  </ul>
  <p>Can this be done in principle using frame filtering? Am I missing something in these commands above? If the filter-based approach is not more accurate, I will fall back to my initial attempts.</p>
  <p>Thanks!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-27T18:40:03.903Z
Comments.Text: Same issue as https://video.stackexchange.com/q/26451/
Comments.UserDisplayName: Gyan
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-09-28T15:13:40.477Z
Comments.Text: I think the linked issue is about generation of files of specific duration while here I'm inquiring about cutting from an input PCM with sample-perfect provided boundaries (I realize that some padding may appear during encoding to opus, but I care that input cutpoints are as sample-precise as possible)
Comments.UserDisplayName: Vadim Kantorov
Tags: <ffmpeg><audio>
Title: Frame-perfect audio cutting using ffmpeg filter graphs and frame filtering
UserDisplayName: Vadim Kantorov
ThreadText: # Frame-perfect audio cutting using ffmpeg filter graphs and frame filtering
  
  (Asked by: username_0 on 2023-09-27)
  
  I'm curious, is it possible to do frame-perfect audio cutting using ffmpeg's complex filter graphs + frame filtering `aselect` functionality?
  
  I've tried a bunch of other approaches (using `-segment_times` and `-ss`/`-t`) - they worked but were only `~0.02sec` accurate, just for reference:
  
  * `ffmpeg -f lavfi -i "sine=frequency=1000:duration=5" -ar 48000 test.wav`
  * `ffmpeg -y -i test.wav -f segment -segment_times "1.55,2.00" -segment_list_type csv -segment_list output.csv test%04d.opus`
  * `ffmpeg -y -i test.wav -ss 0.00 -t 1.55 test0000.opus -ss 2.00 -t 1.00 test0001.opus`
  
  My filter-based attempts:
  
  * `ffmpeg -y -i test.wav -ar 48000 -af "aselect=between(samples_n\,100\,16100)" test0000.opus` as an example but this produces a 5-second long `test0000.opus` instead of a 0.25-second one
  * `ffmpeg -y -i test.wav -ar 48000 -af "aselect=between(t\,0.0\,1.55)" test0000.opus` kind of works, but still gives a 1.57-second audio instead of 1.55-second one.
  
  Can this be done in principle using frame filtering? Am I missing something in these commands above? If the filter-based approach is not more accurate, I will fall back to my initial attempts.
  
  Thanks!
  
  **Tags:** ffmpeg, audio
  
  > **Comments:**
  > **username_1**: Same issue as https://video.stackexchange.com/q/26451/  
  > **username_0**: I think the linked issue is about generation of files of specific duration while here I'm inquiring about cutting from an input PCM with sample-perfect provided boundaries (I realize that some padding may appear during encoding to opus, but I care that input cutpoints are as sample-precise as possible)  
  
  ---
  
  ## 0 answers
  
  