audio icon indicating copy to clipboard operation
audio copied to clipboard

StreamReader seek frame number

Open lminer opened this issue 2 years ago • 1 comments

🚀 The feature

It would be nice if seek could go to a specific frame rather than the timestamp.

Motivation, pitch

I'm taking strided chunks from an audio file. I need the frame numbers to be exact rather than rounded from frame//sample_rate.

Alternatives

No response

Additional context

No response

lminer avatar Jul 24 '23 12:07 lminer

Hi - This is something I thought of couple of times, but it is more complicated than how it seems on the surface.

  1. The input to StreamReader can be audio and video formats that can have multiple streams with different sampling rates. A single frame number is not enough to fully determine the position.
  2. Audio streams are processed packe-by-packet, and each packet can contain arbitrary number of samples. Seeking is implemented on packet-level and it does not involve samples. So as to do exact sample-level seeking, we need to add a state to StreamReader which tracks the stream ID and target sample number.

mthrok avatar Jul 24 '23 17:07 mthrok