gpt4 book ai didi

python - 运行得到错误认为python的命令

转载 作者:行者123 更新时间:2023-12-04 23:01:52 25 4
gpt4 key购买 nike

瓦苏普。

我有 shell 命令。

ffmpeg -list_devices true -f dshow -i dummy -hide_banner
当我运行该命令时,我得到输出数据(见下文)
[dshow @ 00000281450fbdc0] DirectShow video devices (some may be both video and audio devices)
[dshow @ 00000281450fbdc0] "HD WebCam"
[dshow @ 00000281450fbdc0] Alternative name "@device_pnp_\\?\usb#vid_0408&pid_a060&mi_00#6&391c16c1&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"
[dshow @ 00000281450fbdc0] DirectShow audio devices

[dshow @ 00000281450fbdc0] "Microphone (Realtek High Definition Audio)"
[dshow @ 00000281450fbdc0] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{4727F33A-DE04-4706-8312-03696FACC791}"
[dshow @ 00000281450fbdc0] "Stereo mix (Realtek High Definition Audio)"
[dshow @ 00000281450fbdc0] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{534A8FBC-6C02-4384-B51C-D0363BB7F8FD}"
[dshow @ 00000281450fbdc0] "Microphone (Avsoft Virtual Audio Device)"
[dshow @ 00000281450fbdc0] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{5CE20B48-361E-4B96-B113-B3E02BA448EC}"
dummy: Immediate exit requested
我必须获取所有音频设备的列表。
而且我不想解析那个字符串,我会很难的。
如何使用 ffmpeg-python 模块获取所有音频设备的列表?
感谢你。
更新 :
我决定解析那个字符串。但是当我输入:
command = subprocess.check_output('ffmpeg -list_devices true -f dshow -i dummy -hide_banner', shell=True)
我收到此错误:
subprocess.CalledProcessError: Command 'ffmpeg -list_devices true -f dshow -i dummy -hide_banner' returned non-zero exit status 1.
我如何调用该命令并将其结果放入我的变量“命令”中?

最佳答案

command = subprocess.run('ffmpeg -list_devices true -f dshow -i dummy -hide_banner', shell=True, stderr=subprocess.PIPE, text=True, encoding='utf-8')
print(command.stderr)

关于python - 运行得到错误认为python的命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64173352/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com