bugfix
This commit is contained in:
parent
4eec80b588
commit
f4822d38b9
@ -6,6 +6,7 @@ from av import AudioFrame
|
|||||||
|
|
||||||
from aiortc import VideoStreamTrack, AudioStreamTrack
|
from aiortc import VideoStreamTrack, AudioStreamTrack
|
||||||
|
|
||||||
|
# 计算每个样本的字节数,对于's16'是2字节,'s32'是4字节等
|
||||||
def bytes_to_audio_frame(bytes_data, format='s16', layout='mono', sample_rate=16000):
|
def bytes_to_audio_frame(bytes_data, format='s16', layout='mono', sample_rate=16000):
|
||||||
"""
|
"""
|
||||||
从字节数据构造av.AudioFrame对象。
|
从字节数据构造av.AudioFrame对象。
|
||||||
@ -18,7 +19,7 @@ def bytes_to_audio_frame(bytes_data, format='s16', layout='mono', sample_rate=16
|
|||||||
"""
|
"""
|
||||||
# 根据给定的参数创建AudioFrame
|
# 根据给定的参数创建AudioFrame
|
||||||
frame = AudioFrame(format=format, layout=layout,
|
frame = AudioFrame(format=format, layout=layout,
|
||||||
samples=len(bytes_data) // AudioFrame.format_size(format),
|
samples=len(bytes_data) // 2,
|
||||||
rate=sample_rate)
|
rate=sample_rate)
|
||||||
|
|
||||||
# 将字节数据复制到AudioFrame中
|
# 将字节数据复制到AudioFrame中
|
||||||
|
Loading…
Reference in New Issue
Block a user