Compare commits
2 Commits
issue4467
...
fix_audio_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f7869d130 | ||
|
|
0f28d39127 |
@@ -163,7 +163,7 @@ public final class AudioCapture {
|
||||
// - an estimation from the previous PTS and the packet size as a fallback.
|
||||
//
|
||||
// Therefore, the property that PTS are monotonically increasing is no guaranteed in corner cases, so enforce it.
|
||||
pts = previousPts + 1;
|
||||
pts = previousPts;
|
||||
}
|
||||
previousPts = pts;
|
||||
|
||||
|
||||
@@ -105,8 +105,17 @@ public final class AudioEncoder implements AsyncProcessor {
|
||||
private void outputThread(MediaCodec mediaCodec) throws IOException, InterruptedException {
|
||||
streamer.writeAudioHeader();
|
||||
|
||||
long lastPts = 0;
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
OutputTask task = outputTasks.take();
|
||||
|
||||
if (task.bufferInfo.presentationTimeUs < lastPts) {
|
||||
// Fix PTS if not monotonically increasing
|
||||
task.bufferInfo.presentationTimeUs = lastPts;
|
||||
} else {
|
||||
lastPts = task.bufferInfo.presentationTimeUs;
|
||||
}
|
||||
|
||||
ByteBuffer buffer = mediaCodec.getOutputBuffer(task.index);
|
||||
try {
|
||||
streamer.writePacket(buffer, task.bufferInfo);
|
||||
|
||||
Reference in New Issue
Block a user