Created
July 9, 2019 14:56
-
-
Save makoto1984/b98e2f4bd1a195d6025f87f55b4c30ef to your computer and use it in GitHub Desktop.
Streaming screen capture with camera at corner and playback with microphone input. Assuming first graphic card with kms support, camera available and pulseaudio.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#required for kmsgrab | |
setcap cap_sys_admin+ep /usr/bin/ffmpeg | |
#specify streamurl provided by streaming platform | |
#streamurl='rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx' | |
streamurl= | |
#specify loopback pulseaudio device | |
#loopback=alsa_output.pci-0000_00_1f.3.analog-stereo.monitor | |
loopback= | |
#specify microphone pulseaudio device | |
#microphone=alsa_input.pci-0000_00_1f.3.analog-stereo | |
microphone= | |
pactl load-module module-null-sink sink_name=mix | |
pactl load-module module-loopback source=$loopback sink=mix | |
pactl load-module module-loopback source=$microphone sink=mix | |
ffmpeg -thread_queue_size 512 -f kmsgrab -i - -thread_queue_size 512 -f v4l2 -i /dev/video0 -thread_queue_size 512 -f pulse -ac 2 -i mix.monitor -vaapi_device /dev/dri/renderD128 -filter_complex "[0:v]hwmap=derive_device=vaapi,hwdownload[screen];[screen][1:v]overlay=W-w:H-h,hwupload,scale_vaapi=w=1280:h=720:format=nv12" -c:v h264_vaapi -c:a libfdk_aac -profile:a aac_he_v2 -f flv $streamurl | |
pactl unload-module module-loopback | |
pactl unload-module module-null-sink |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment