1.丢掉你的电视机
2.打开你的电脑
3.安装好你的python软件和pycharm软件
4.记住好一下的rtmp流地址
CCTV-1综合:rtmp://58.200.131.2:1935/livetv/cctv1CCTV-2财经:rtmp://58.200.131.2:1935/livetv/cctv2CCTV-3综艺:rtmp://58.200.131.2:1935/livetv/cctv3CCTV-4中文国际:rtmp://58.200.131.2:1935/livetv/cctv4CCTV-5体育:rtmp://58.200.131.2:1935/livetv/cctv5CCTV-6电影:rtmp://58.200.131.2:1935/livetv/cctv6CCTV-7军事农业:rtmp://58.200.131.2:1935/livetv/cctv7CCTV-8电视剧:rtmp://58.200.131.2:1935/livetv/cctv8CCTV-9记录:rtmp://58.200.131.2:1935/livetv/cctv9CCTV-10科教:rtmp://58.200.131.2:1935/livetv/cctv10
5.下载好你的opencv库
使用命令 pip install opencv-python
6.使用cv2读取所有的视频流
7.完整代码呈现
import cv2def main():a=int(input("输入:"))if a==1:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv1")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==2:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv2")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==3:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv3")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==4:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv4")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==5:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv5")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==6:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv6")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==7:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv7")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==8:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv8")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==9:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv9")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if a==10:cap=cv2.VideoCapture("rtmp://58.200.131.2:1935/livetv/cctv10")while (cap.isOpened()):ret,frame=cap.read()cv2.imshow("11",frame)if cv2.waitKey(40) & 0xFF == ord('q'):cv2.destroyAllWindows()main()if cv2.waitKey(40) & 0xFF == ord('s'):cv2.waitKey(0)if __name__ == '__main__':main()
8.展现一手运行后图片
9.感谢观看,手动一键三连,谢谢兄弟们