作者:挽木城祠_ | 来源:互联网 | 2023-06-11 11:26
安装:condainstallav-cconda-forgeimportosimportsysimportcv2fromavimportopenvideoopen
安装:
conda install av -c conda-forge
import os
import sysimport cv2
from av import openvideo = open("d:/2.mp4")stream = next(s for s in video.streams if s.type == 'video')for packet in video.demux(stream):print(packet)for frame in packet.decode():# some other formats gray16be, bgr24, rgb24
img = frame.to_nd_array(format='bgr24')cv2.imshow("Test", img)if cv2.waitKey(1) == 27:break
cv2.destroyAllWindows()