Skip to content

Instantly share code, notes, and snippets.

@LeifAndersen
Created December 28, 2018 21:15
Show Gist options
  • Select an option

  • Save LeifAndersen/15738330d117344e2cde8992a9cc7deb to your computer and use it in GitHub Desktop.

Select an option

Save LeifAndersen/15738330d117344e2cde8992a9cc7deb to your computer and use it in GitHub Desktop.
trap "echo q > ctr0; echo q > ctr1; sleep 1; killall -INT ffplay; killall -INT ffmpeg" EXIT
mkfifo prv0 prv1
mkfifo ctr0 ctr1
n0=recordings/$(date +"%m%d%y+%H%M")_r0.mp4
n1=recordings/$(date +"%m%d%y+%H%M")_r1.mp4
n2=recordings/$(date +"%m%d%y+%H%M")_a0.mp4
ffplay -i - < prv0 &
cat ctr0 | ffmpeg -y -i /dev/video0 -thread_queue_size 512 -i /dev/video1 \
-filter_complex "[0]split[s0][s1]" \
-map "[s0]" -f mp4 -vcodec libx264 -preset superfast $n0 \
-map "1" -f mp4 -vcodec libx264 -preset superfast $n1 \
-map "[s1]" -pix_fmt yuv422p -f yuv4mpegpipe pipe:3 3>prv0 &
cat ctr1 | ffmpeg -y -f alsa -i hw:0 \
-f alsa -i hw:1 -f alsa -i hw:2 \
-map 0 -map 1 -map 2 $n2 &
wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment