Skip to content

Instantly share code, notes, and snippets.

@on-three
Last active October 11, 2022 14:09
Show Gist options
  • Save on-three/9e40cbf33765dbd3ffbb to your computer and use it in GitHub Desktop.
Save on-three/9e40cbf33765dbd3ffbb to your computer and use it in GitHub Desktop.
VLC capture window by xwindows id (window capture and streaming WITH audio)
1: Get the audio output device you'll record off:
pacmd list-sources | awk '/name:.+\.monitor/'
name: <alsa_output.pci-0000_01_00.1.hdmi-stereo.monitor>
name: <alsa_output.pci-0000_00_1b.0.analog-stereo.monitor>
2: Get the x windows id (linux) of the window you'll capture
xwininfo -name "Nestopia"
xwininfo: Window id: 0x3a00003 "Nestopia"
...
3: Fire up vlc with the right parameters:
vlc window://0x2a00003 :screen-fps=30 :input-slave=pulse://alsa_output.pci-0000_00_1b.0.analog-stereo.monitor --sout '#transcode{vcodec=h264,vb=800,scale=1,height=480,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{mux=ts,dst=:8090/game}'
@on-three
Copy link
Author

@echo off & cls
:: KNARZ
:: Description
:: Run the Batch with URL as Parameter
:: Exsample: THISBATCH.cmd http://www.anything.com/stream.m3u
:: Fixed Stream: replace "stream=%~1" with your URL "stream=http://..."
:: Batch closes after executing VLC.

set program=c:\progra~1\videolan\vlc\vlc.exe
set stream=%~1
set ratio=0

call :usage
choice /m "Select Ratio" /C 123456789
set select=%errorlevel%

if %select% equ 9 exit
if %select% equ 1 set ratio=2:1
if %select% equ 2 set ratio=3:2
if %select% equ 3 set ratio=4:3
if %select% equ 4 set ratio=5:4
if %select% equ 5 set ratio=16:9
if %select% equ 6 set ratio=16:10
if %select% equ 7 set ratio=21:9
if %select% equ 8 set ratio=21:10

start /b "VLC" "%program%" --aspect-ratio %ratio% "%stream%"
exit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment