mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-07-05 11:00:54 +00:00
Fixed voice message encoding issue that resulted in malformed ogg files causing playback errors on ffmpeg v4
This commit is contained in:
parent
ee3142966e
commit
f3901f6dc4
@ -178,7 +178,7 @@ static const int encoderPacketSizeInBytes = TGBridgeAudioEncoderSampleRate / 100
|
||||
if (_assetReader.status == AVAssetReaderStatusCompleted)
|
||||
{
|
||||
NSLog(@"finished");
|
||||
if (_oggWriter != nil && [_oggWriter writeFrame:NULL frameByteCount:0])
|
||||
if (_oggWriter != nil)
|
||||
{
|
||||
dataItemResult = _tempFileItem;
|
||||
durationResult = [_oggWriter encodedDuration];
|
||||
|
@ -557,7 +557,7 @@ final class ManagedAudioRecorderContext {
|
||||
self.currentPeak = max(Int64(sample), self.currentPeak)
|
||||
self.currentPeakCount += 1
|
||||
if self.currentPeakCount == self.peakCompressionFactor {
|
||||
var compressedPeak = self.currentPeak//Int16(Float(self.currentPeak) / Float(self.peakCompressionFactor))
|
||||
var compressedPeak = self.currentPeak
|
||||
withUnsafeBytes(of: &compressedPeak, { buffer in
|
||||
self.compressedWaveformSamples.append(buffer.bindMemory(to: UInt8.self))
|
||||
})
|
||||
@ -592,7 +592,6 @@ final class ManagedAudioRecorderContext {
|
||||
}
|
||||
|
||||
func takeData() -> RecordedAudioData? {
|
||||
if self.oggWriter.writeFrame(nil, frameByteCount: 0) {
|
||||
var scaledSamplesMemory = malloc(100 * 2)!
|
||||
var scaledSamples: UnsafeMutablePointer<Int16> = scaledSamplesMemory.assumingMemoryBound(to: Int16.self)
|
||||
defer {
|
||||
@ -640,9 +639,6 @@ final class ManagedAudioRecorderContext {
|
||||
}
|
||||
|
||||
return RecordedAudioData(compressedData: self.dataItem.data(), duration: self.oggWriter.encodedDuration(), waveform: waveform)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user