audio
audio copied to clipboard
StreamReader seek frame number
🚀 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
Hi - This is something I thought of couple of times, but it is more complicated than how it seems on the surface.
- The input to
StreamReadercan 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. - 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.