ffmpeg - downmix and merge audio tracks

ffmpeg -i $SRC -ss 4:00 -filter_complex '[0:a:1]pan=2c|c0=c0|c1=c0[l];[0:a:0][l]amerge=inputs=2[a]' -map '0:v:0' -map '[a]' -c:v copy -c:a libvorbis -q:a 10 -ac 2 $DEST

This is what I do for preparing 5 minute ShadowPlay clips for playback in conventional applications.
We start with two audio tracks: first is stereo (game audio), second is stereo (mic) but the right channel is unused.


Select input and set start time to 4 minutes.
-i $SRC -ss 4:00


From input 0 (file at $SRC), get the second audio track (mic), and use pan to set both channels to the left channel signal. Save as 'l'.
Merge the first and 'l' audio tracks into 'a'.
Select first video from first input, and select our synthesized audio track 'a'.
-map '0:v:0' -map '[a]'
Copy the video (do not re-encode), encode the audio with libvorbis (quality 10) with 2 channels.
-c:v copy -c:a libvorbis -q:a 10 -ac 2

iptables - IP forwarding/NAT

iptables -t nat -A PREROUTING --dport $LPORT -j DNAT --to-destination $TARGET_HOST:$RPORT
iptables -t nat -A POSTROUTING -j MASQUERADE
This will perform forwarding for requests that originate external from the host. The rule written here will forward requests sent to
. For this to work, the appropriate kernel modules need to be loaded, and IP forwarding needs to be enabled.
modprobe ip_tables
modprobe iptable_nat
sysctl net.ipv4.ip_forward=1 # for systemd


In the NAT table (for packets that create connections), append a rule to the PREROUTING chain.
For requests to port
, rewrite the destination field as
. We do this in PREROUTING so that other filters can see the intended destination.
--dport $LPORT -j DNAT --to-destination $TARGET_HOST:$RPORT
Rewrite the source field as the packet is being transmitted to the target host. This can be done explicitly with
if the IP address of the forwarding host is static. For packets returning from the target host, MASQ will look up which client is requesting them and send them back.

tor - list IPv4 exit relays

nc -U $SOCKET << EOF | grep -E "^s.*Exit" -B1 | awk '/^r/ { print $7 }'
authenticate "$PASSWORD"
getinfo ns/all
Run tor with
        ControlSocket $SOCKET