improve webrtc audio quality
This commit is contained in:
parent
b9d77f9fb5
commit
a3a86bf299
|
@ -43,7 +43,7 @@
|
|||
<h2>Media</h2>
|
||||
|
||||
<audio id="audio" autoplay="true"></audio>
|
||||
<video id="video" autoplay="true" playsinline="true"></video>
|
||||
<video id="video" style="width:600px;" autoplay="true" playsinline="true"></video>
|
||||
</div>
|
||||
|
||||
<script src="client.js"></script>
|
||||
|
|
16
webrtc.py
16
webrtc.py
|
@ -46,18 +46,22 @@ class PlayerStreamTrack(MediaStreamTrack):
|
|||
|
||||
if self.kind == 'video':
|
||||
if hasattr(self, "_timestamp"):
|
||||
self._timestamp += int(VIDEO_PTIME * VIDEO_CLOCK_RATE)
|
||||
wait = self._start + (self._timestamp / VIDEO_CLOCK_RATE) - time.time()
|
||||
await asyncio.sleep(wait)
|
||||
self._timestamp = (time.time()-self._start) * VIDEO_CLOCK_RATE
|
||||
# self._timestamp += int(VIDEO_PTIME * VIDEO_CLOCK_RATE)
|
||||
# wait = self._start + (self._timestamp / VIDEO_CLOCK_RATE) - time.time()
|
||||
# if wait>0:
|
||||
# await asyncio.sleep(wait)
|
||||
else:
|
||||
self._start = time.time()
|
||||
self._timestamp = 0
|
||||
return self._timestamp, VIDEO_TIME_BASE
|
||||
else: #audio
|
||||
if hasattr(self, "_timestamp"):
|
||||
self._timestamp += int(AUDIO_PTIME * SAMPLE_RATE)
|
||||
wait = self._start + (self._timestamp / SAMPLE_RATE) - time.time()
|
||||
await asyncio.sleep(wait)
|
||||
self._timestamp = (time.time()-self._start) * SAMPLE_RATE
|
||||
# self._timestamp += int(AUDIO_PTIME * SAMPLE_RATE)
|
||||
# wait = self._start + (self._timestamp / SAMPLE_RATE) - time.time()
|
||||
# if wait>0:
|
||||
# await asyncio.sleep(wait)
|
||||
else:
|
||||
self._start = time.time()
|
||||
self._timestamp = 0
|
||||
|
|
Loading…
Reference in New Issue