How can you write all of that and miss the fun?
apt-get install gnome-video-effects-frei0r #or whatever works for you
filter_idx=2
filters=(
"videobalance"
"quarktv"
"rippletv" #2
"streaktv"
"radioactv"
"vertigotv"
"frei0r-filter-twolay0r"
"frei0r-filter-distort0r"
"dicetv"
"edgetv"
"warptv"
"revtv"
"frei0r-filter-cartoon"
"shagadelictv")
gst-launch-1.0 autovideosrc device=$CAMERA ! videoconvert ! ${filters[$filter_idx]} ! videoconvert ! videobalance ! videoconvert ! v4l2sink device=$VID_LOOPBACK
edit:I've always needed an LD_PRELOAD to launch whatever, eg
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so /usr/bin/zoom
maybe someone will chime in because they know better than me about all the details here.