I am making a python application that creates a rtsp link of a local DVR (based on the information that it's given through input), It's 90% complete and there's just one more step left. After the link generation, VLC media player will be opened (which is how far i have got).Then in VLC media player, CTRL+ n will be automatically pressed so that a new window can open, in which the RTSP link will be inserted so that the DVR camera feed will automatically play in VLC media player. I am stuck on the hotkey part...In which CTRL+ n will be automatically pressed after VLC has started. If someone knows about it then please help me. MY CODE:
#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], stderr=subprocess.DEVNULL, stdin=PIPE, shell=True)
Don't run it using the terminal or command prompt. Run it using VS Code terminal (i recommend from here) or directly as interpreter and make sure to have VLC installed.
Good news, VLC's command line args can start a network stream directly by supplying an rtsp://
link:
To receive a RTSP stream, start VLC with:
% vlc rtsp://www.example.org/your_stream