问题描述
我正在制作一个python应用程序,该应用程序创建本地DVR的rtsp链接(基于通过输入提供的信息),它已完成90%,仅剩一步之遥。链接生成后,将打开VLC媒体播放器(这是我所走的距离)。然后在VLC媒体播放器中,将自动按CTRL + n,以便可以打开一个新窗口,其中将插入RTSP链接,以便DVR摄像机供稿将自动在VLC媒体播放器中播放。 我被卡在热键部分上...在VLC启动后将自动按CTRL + n。如果有人知道这件事,请帮助我。 我的密码:
#Import libaries
import os
import platform #To identify the OS
import subprocess #To start VLC
import keyboard #keyboard module (not working)
from pynput import keyboard #keyboard module (not working)
from subprocess import Popen,PIPE,STDOUT
from subprocess import DEVNULL # To keep the script running after subprocess is called
#DVR inputs
ip_adr = input("What is your DVR's ip address?: ")
port = input("What is your DVR's RTSP port? (it should be 554 or else): ")
username = input("What is your DVR's username? (The default is admin): ")
password = input("What is your DVR's password?: ")
linkurl = "rtsp://" + username +":" + password + "@" + ip_adr + ":" + port +"/Streaming/channels/1/"
#Identify OS
nameos = platform.system()
if nameos == "Linux": # For Linux
cmd='vlc';
print("Your DVR rtsp link is: " + linkurl)
Popen([cmd],stderr=subprocess.DEVNULL,stdin=PIPE,shell=True)
else: # For windows
cmd='vlc';
print("Your DVR rtsp link is: " + linkurl)
Popen([cmd],shell=True)
请勿使用终端或命令提示符运行它。使用VS Code终端(我建议从这里开始)或直接作为解释器运行它,并确保已安装VLC。
解决方法
好消息,VLC's command line args可以通过提供let input = [
{"__typename": "ProductsSold","createdAt": "2020-07-11T17:52:19.369Z","operationType": "Sell","productName": "Rover 4","quantity": 2,"storeId": "5f09f950f6b21a2b5c2d4c3c","totalPrice": 4400000,"unitPrice": 2200000},{"__typename": "ProductsSold","createdAt": "2020-07-11T20:55:23.637Z","quantity": 3,"totalPrice": 6600000,"createdAt": "2020-07-11T20:56:24.879Z","unitPrice": 2200000}
]
let result = [];
result = input.map((el) => {
return {title: el.createdAt,data: [{productName: el.productName,unitPrice: el.unitPrice,totalPrice: el.totalPrice}]};
})
console.log(result)
链接来直接启动网络流:
要接收RTSP流,请使用以下命令启动VLC:
rtsp://