How do I decode g729
Created by: user3472g
IMPORTANT: Be sure to replace all template sections {{ like this }} or your issue may be discarded.
Overview
I am attempting to write a simple g729 decoder using PyAV. However, the audio being outputted is of extremely poor audio quality and does not match that of CLI ffmpeg.
Expected behavior
Output an audible audio file from g729 input.
Actual behavior
audio being outputted is of extremely poor audio quality and does not match that of CLI ffmpeg. I am unable to attach a sample g729 file here to this ticket. The request here is to review the provided sample code for sensibleness.
Traceback:
No exceptions.
Investigation
Sample code:
with open(path_to_g729_encoded_file, "rb") as f:
buf = f.read()
codec = av.CodecContext.create("g729", 'r')
codec.channels = 1
codec.bit_rate = 8000
codec.sample_rate = 8000
g729Packets = codec.parse(buf)
fout = open("audio.s16p", "wb")
for g729 in g729Packets:
for frame in codec.decode(g729):
for plane in frame.planes:
fout.write(bytes(plane))
fout.close()
Research
I have done the following:
- [* ] Checked the PyAV documentation
- [*] Searched on Google
- [*] Searched on Stack Overflow
- [*] Looked through old GitHub issues
- [*] Asked on PyAV Gitter
-
... and waited 72 hours for a response.