Could you explain a little more?
I don't understand about signal chain.
Thanks
I don't understand about signal chain.
Thanks
You'd need to buffer all the MP3 frames somehow (in memory or to a file), and then when a reposition occurs, move back to the frame that contains that time.I tried to do it with provider but it doesnt supports or contains setting position method. Is it necessary to buffer all frames or is it enough to buffer frames that just contains a specific time?
// Code invoking the provider and saving WMA
private static int JoinToWmaFile(string outputPathName, MediaType wmaMediaType, IEnumerable<MediaFoundationReader> waveReaders)
{
// ...
IWaveProvider joiningWaveProvider = new JoiningWaveProvider(waveReaders);
using (MediaFoundationEncoder wmaEncoder = new MediaFoundationEncoder(wmaMediaType))
{
wmaEncoder.Encode(outputPathName, joiningWaveProvider);
}
}
// The actual provider
public JoiningWaveProvider(IEnumerable<MediaFoundationReader> inputFileReaders)
{
// ...
private int _readIndex = 0;
// ...
public int Read(byte[] buffer, int offset, int count)
{
int startIndex = _readIndex;
int currentOffset = offset;
int totalRead = 0;
int remaining = count;
for (_readIndex = startIndex; _readIndex < _inputFileReaders.Count && remaining > 0; _readIndex++)
{
MediaFoundationReader currentReader = _inputFileReaders[_readIndex];
int readNow = currentReader.Read(buffer, currentOffset, remaining);
currentOffset += readNow;
totalRead += readNow;
remaining -= readNow;
}
return totalRead;
}
}
We put some Debug logs (not shown in code) and here are some info about the read invocations, although they're not very clear to us:Common format: 16 bit PCM: 44kHz 1 channels
Saving to WMA with explicit encoder
Read, offset: 0, count: 352800
- readIndex: 0, currentOffset: 0, remaining: 352800
- readIndex: 1, currentOffset: 117340, remaining: 235460
- readIndex: 2, currentOffset: 147132, remaining: 205668
- readIndex: 3, currentOffset: 172316, remaining: 180484
- readIndex: 4, currentOffset: 232060, remaining: 120740
- readIndex: 5, currentOffset: 261852, remaining: 90948
- totalRead: 352800
Read, offset: 0, count: 352800
- readIndex: 6, currentOffset: 0, remaining: 352800
- totalRead: 133468
Read, offset: 0, count: 352800
- totalRead: 0