Created
June 23, 2017 02:41
-
-
Save foxel/a434fb520a0b2a2aca966410cec13e5e to your computer and use it in GitHub Desktop.
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/bash | |
# Used to cast screen with camera feed ttached + recording this stream along with audio mixed from both mic and speakers. | |
# For hangouts one should share gst-launch window (the window itself can then be minimized) | |
# Tested on Ubuntu 16.04 | |
PIP_WIDTH=320 | |
PIP_HEIGHT=240 | |
SCREEN_WIDTH=1920 | |
SCREEN_HEIGHT=1200 | |
SCREEN_RIGHT=$((SCREEN_WIDTH-1)) | |
SCREEN_BOTTOM=$((SCREEN_HEIGHT-1)) | |
PIP_LEFT=$((SCREEN_WIDTH-PIP_WIDTH)) | |
PIP_TOP=$((SCREEN_HEIGHT-PIP_HEIGHT)) | |
FILE="screencast_$(date '+%Y%m%d_%H%M%S')" | |
# use `LC_ALL="EN_us" pactl list | grep -A2 'Source' | grep -P 'input|monitor'` to find out names for this section | |
MIC_DEVICE="alsa_input.usb-046d_0819_2455EEA0-02.analog-mono" | |
SPEAKER_DEVICE="alsa_output.pci-0000_01_00.1.hdmi-stereo.monitor" | |
gst-launch-1.0 -e \ | |
v4l2src \ | |
! "video/x-raw,framerate=25/1,width=${PIP_WIDTH},height=${PIP_HEIGHT}"\ | |
! queue \ | |
! vmix.sink_0 \ | |
ximagesrc use-damage=0 startx=0 endx=${SCREEN_RIGHT} endy=${SCREEN_BOTTOM} \ | |
! 'video/x-raw,framerate=25/1' \ | |
! queue \ | |
! vmix.sink_1 \ | |
videomixer name=vmix \ | |
sink_0::xpos=${PIP_LEFT} sink_0::ypos=${PIP_TOP} sink_0::zorder=1 \ | |
sink_1::xpos=0 sink_1::ypos=0 sink_1::zorder=0 \ | |
! tee name=t \ | |
! queue \ | |
! xvimagesink sync=false \ | |
t. ! queue \ | |
! x264enc speed-preset=ultrafast tune=zerolatency byte-stream=true threads=1 key-int-max=15 intra-refresh=true \ | |
! h264parse \ | |
! out.video_0 \ | |
pulsesrc device="${MIC_DEVICE}" \ | |
! queue \ | |
! amix. \ | |
pulsesrc device="${SPEAKER_DEVICE}" \ | |
! queue \ | |
! amix. \ | |
adder name=amix \ | |
! queue \ | |
! lamemp3enc encoding-engine-quality=fast target=bitrate bitrate=128 cbr=true mono=true \ | |
! out.audio_0 \ | |
avimux name=out ! filesink sync=false location="${FILE}.avi" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment