我是 PyAV 的新手,需要一些帮助。
我需要使用 PyAV 解码来自 webscocket 的 H264 原始字节。我阅读了文档并尝试使用 CodecContext.parse 完成它,但失败如下:
import av
code_ctx = av.CodecContext.create("h264", "r")
code_ctx.pix_fmt = "yuv420p"
code_ctx.width = 1090
code_ctx.height = 1072
code_ctx.thread_type = "AUTO"
code_ctx.gop_size = 120
def test8(raw_bytes: bytes):
# packet = av.packet.Packet(fd1_bytes)
# print(type(packet))
packets = code_ctx.parse(raw_bytes)
## It should be decoded and results to a list a packets, but why it returns []
for i, packet in enumerate(packets):
print(type(packet))
frames = code_ctx.decode(packet)
for frame in frames:
print(type(frame), type(getattr(frame, "planes")))