python ffmpeg读取摄像头,如何在Windows中使用ffmpeg抓取笔记本电脑摄像头视频

在Linux上成功使用ffmpeg捕获内置摄像头视频的Python程序无法在Windows上直接运行,因为不能使用"/dev/video0"。文章讨论了如何在Windows上找到摄像头设备名并用ffmpeg进行录制。通过列出DirectShow视频设备并提取设备名,作者找到了解决方法。
摘要由CSDN通过智能技术生成

I have a small python program that works very well to capture short videos from webcams in linux (at least for laptops that have built-in webcams) using a sub-process with ffmpeg.

Now i'm trying to write the same program to capture webcams in windows, and i know i can't use the generic "/dev/video0" that works pretty well in linux, but i thought something like naming it "Integrated Camera" should be enough, but it fails.

Here's my linux code (that works):

import sys

from subprocess import call

from datetime import datetime

def record_webcam(seconds):

cam = '/dev/video0'

timestamp = datetime.now().strftime('%Y%m%d-%H%M%S')

filename = timestamp + 'something.mkv' #generated with more complexity in the actual code, but that isn't important

ffmpeg_cmd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值