简体   繁体   中英

How can I get the name of the webcams present on the computer in python?

I have a problem. I would need to use ffmpeg with subprocess in python for video capture.

For this I need to identify the name of the cameras present in the computer in order to be able to pass this parameter to the ffmpeg process.

So far I have used the WMI module, but it only works on windows and is not very easy to use.

Is there any easier way to extract the names of the webcams on your computer and save them to an array? Maybe also using the ffmpeg list-devices and filtering the results? Can you help me?

I would not like to use the WMI module anymore, as I would like a universal solution for windows or linux, perhaps using subprocess and the ffmpeg list_devices command. Thank you

Windows

In Windows use dshow :

ffmpeg -list_devices true -f dshow -i dummy

Linux

In Linux use v4l2-ctl :

v4l2-ctl --list-devices

Then connect using the FFmpeg video4linux2/v4l2 demuxer .

Also see

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