简体   繁体   中英

How to play it on fullscreen python cv2

How do I play the video.mp4 in fullscreen instead of playing it in a window and is there any way to play video with audio without playing the audio separately?

import cv2
from playsound import playsound
from threading import Thread
   
def func1():
    cap = cv2.VideoCapture("video.mp4")
    ret, frame = cap.read()
    while(1):
        ret, frame = cap.read()
        cv2.imshow('frame',frame)
        if cv2.waitKey(33) & 0xFF == ord('q') or ret==False :
            cap.release()
            cv2.destroyAllWindows()
            break
        cv2.imshow('frame',frame)

def func2():
    playsound('6989946141014084358.mp3')

if __name__ == '__main__':
    Thread(target = func1).start()
    Thread(target = func2).start()

You should be able to setup the window ahead of time (eg before your blocking while loop):

cv2.namedWindow('frame',cv2.WINDOW_NORMAL)
cv2.setWindowProperty('frame',cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM