Created
March 8, 2014 06:34
-
-
Save tobert/9426323 to your computer and use it in GitHub Desktop.
four streams, one mpegts
This file contains 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 | |
# pulsesrc ⇨ audioconvert ⇨ lamemp3enc | |
# ⇩ | |
# queue | |
# ⇩ | |
# queue ⇨ x264enc ⇨ queue ⇨ mpegtsmux ⇨ filesink | |
# ⇧ | |
# ⇧ queue ⇦ jpegdec ⇦ jpegparse ⇦ v4l2src | |
# ⇧ ⇙ | |
# videomixer ⇦ queue ⇦ jpegdec ⇦ jpegparse ⇦ v4l2src | |
# ⇖ | |
# queue ⇦ videoconvert ⇦ Terminal | |
set -e | |
queue_bytes=$((2**24)) # 16mb queues between threads | |
timestamp=$(date -Im) | |
# write the final video to this file | |
outfile="$HOME/Video/gst-video0-${timestamp}.mpts" | |
# both cameras will capture in MJPG mode even though the C920 has support for H.264/1080p | |
# since it looks like either h264 is lagging or USB is. In any case running the same mode | |
# on both matches things up nicely | |
camera_resolution="width=1280, height=720" | |
camera0="/dev/video0" # Logitech C920 | |
camera1="/dev/video1" # Microsoft Lifecam | |
# pactl list short | |
microphone="alsa_input.usb-BLUE_MICROPHONE_Blue_Snowball_201202-00-Snowball.analog-stereo" | |
# use xwininfo to get the window ID and update this | |
# I manually size the terminal window to 2560x1440 before running this script. | |
term_xid=0x4e0001d | |
set -x | |
gst-launch-1.0 --eos-on-shutdown -vvv \ | |
mpegtsmux name=mux ! \ | |
filesink location=$outfile \ | |
videomixer name=mix sink_1::xpos=1280 sink_2::ypos=720 ! \ | |
video/x-raw, width=2560, height=1440 ! \ | |
queue max-size-bytes=$queue_bytes ! \ | |
x264enc ! \ | |
queue max-size-bytes=$queue_bytes ! \ | |
mux. \ | |
v4l2src device=$camera0 do-timestamp=true ! \ | |
image/jpeg, $camera_resolution ! \ | |
jpegparse ! jpegdec ! \ | |
queue max-size-bytes=$queue_bytes ! \ | |
mix. \ | |
v4l2src device=$camera1 do-timestamp=true ! \ | |
image/jpeg, $camera_resolution ! \ | |
jpegparse ! jpegdec ! \ | |
queue max-size-bytes=$queue_bytes ! \ | |
mix. \ | |
ximagesrc xid=$term_xid ! \ | |
timeoverlay ! \ | |
videoconvert ! \ | |
queue max-size-bytes=$queue_bytes ! \ | |
mix. \ | |
pulsesrc device=$microphone name=microphone ! \ | |
audioconvert ! \ | |
lamemp3enc target=bitrate bitrate=64 cbr=true ! \ | |
queue max-size-bytes=$queue_bytes ! \ | |
mux. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment