Previously I had a .bat
script that triggers an STB blaster script, kills any open sessions of VLC
, then starts a new one to encode capture card raw video output into a transport stream. This stream is the used as the input to a PVR program I am using.
The batch script looked like this:
"G:\Visual Studio 2017\C++ Projects\SkyQChannelChanger\Release\SkyQChannelChanger.exe" %1
taskkill /f /im vlc.exe /t
"G:\VLC\vlc" --ffmpeg-hw --avcodec-hw=any dshow:// :dshow-vdev="Video (00 Pro Capture HDMI 4K+)" :dshow-adev="Audio (2- 00 Pro Capture HDMI 4K+)" :dshow-threads=8 :dshow-aspect-ratio=16\:9 :dshow-size="3840x2160" :dshow-pixel_format=yuv444p16le :dshow-tune=film :dshow-preset=lossless :dshow-profile=main10 show-vcodec=x265 :dshow-fps=50 :dshow-crf=0 :dshow-acodec=mp4a :dshow-stereo-mode=5 :dshow-force-surround-sound=0 :dshow-ab=128 :dshow-samplerate=44100 :no-dshow-config :live-caching=300 --sout "#transcode{venc=ffmpeg,vcodec=mp2v,threads=8,aspect=16:9,width=3840,height=2160,fps=50,acodec=a52,ab=1500,channels=2,samplerate=48000,soverlay}:standard{access=file,dst=-,mux=ts}"
However, I want to move the VLC
call to a Python
file that the .bat
script calls. This means the new batch script looks like this:
@echo off
"G:\Visual Studio 2017\C++ Projects\SkyQChannelChanger\Release\SkyQChannelChanger.exe" %1
taskkill /f /im vlc.exe /t
"G:\HTPC Scripts\NPVR Command Line\Command Line.py"
And the Python script being called looks like this:
import os
import sys
import subprocess
os.chdir('G:\\VLC\\')
startupinfo = None
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
process = subprocess.Popen([
'vlc',
'--ffmpeg-hw',
'--avcodec-hw=any',
'dshow:// :dshow-vdev="Video (00 Pro Capture HDMI 4K+)" :dshow-adev="Audio (2- 00 Pro Capture HDMI 4K+)"',
':dshow-threads=8',
':dshow-aspect-ratio=16\:9',
':dshow-size="3840x2160"',
':dshow-pixel_format=yuv444p16le',
':dshow-tune=film',
':dshow-preset=lossless',
':dshow-profile=main10',
'show-vcodec=x265',
':dshow-fps=50',
':dshow-crf=0',
':dshow-acodec=mp4a',
':dshow-stereo-mode=5',
':dshow-force-surround-sound=0',
':dshow-ab=128',
':dshow-samplerate=44100',
':no-dshow-config',
':live-caching=300',
'--sout',
'"#transcode{venc=ffmpeg,vcodec=mp2v,threads=8,aspect=16:9,width=3840,height=2160,fps=50,acodec=a52,ab=1500,channels=2,samplerate=48000,soverlay}:standard{access=file,dst=-,mux=ts}"',
], stdout=subprocess.PIPE, startupinfo=startupinfo)
Both the batch script and the Python
script appear to work so far as the batch script calls the Python
script successfully and the Python
script in turn opens VLC
successfully.
However, the issue, which I really don't understand is that Python
doesn't appear to be passing the encoded video to the shell if that makes sense?
My PVR software now cannot detect the stream. So my question is, how can I amend the subprocess
part of my code so that it fully replicates calling the VLC
commands directly from the command line? I have tried using shell=True
, but this has no effect...
Any ideas?
Thanks