我想使用av.open()(PyAV包)读取Python中的BytesIO对象,但是失败了。我使用一个普通的x.mp4文件和一个BytesIO对象进行比较。对于普通的x.mp4,av.open函数返回正确的容器,并且容器可以被解码成帧列表。
container = av.open('x.mp4')
print(container.streams.video) # <av.VideoStream #0 h264, yuv420p 1280x720 at 0x7eff2ac89168>
for frame in container.decode(video=0):
frame.to_image().save('frame-{}.jpg'.format(frame.index)) # which can output the jpg list
对于BytesIO对象,
some_bytesio_object = io.BytesIO(some_byte_file) # the x.mp4 has the same content as the some_byte_file
container = av.open(some_bytesio_object)
print(container.streams.video) # <av.VideoStream #? h264, yuv420p 1280x720 at 0x7eff2ac89168>, ? means the result can be random, like 0, 1054153136, -649221856.
for frame in container.decode(video=0):
frame.to_image().save('frame-{}.jpg'.format(frame.index)) # which can not output the jpg list
1条答案
按热度按时间kknvjkwl1#