Skip to content

Instantly share code, notes, and snippets.

@n3storm
Forked from Brick85/somagic_rec_and_play.sh
Created January 6, 2016 14:44
Show Gist options
  • Save n3storm/d7aa0f9166f55b9d070d to your computer and use it in GitHub Desktop.
Save n3storm/d7aa0f9166f55b9d070d to your computer and use it in GitHub Desktop.
somagic record and play
#!/bin/sh
PIPE=/tmp/somagic-pipe
OUTFILEDIR=~/dirs/Videos/
LOGDIR=~/.somagic-log/
NOW=`date +"%m_%d_%Y_%H_%M_%S"`
OUTFILE=${OUTFILEDIR}fpv_video_${NOW}.mp4
mkdir $LOGDIR
FFMPEG_LOG=${LOGDIR}ffmpeg.log
SOMAGIC_LOG=${LOGDIR}somagic.log
MPLAYER_LOG=${LOGDIR}mplayer.log
rm $PIPE >/dev/null 2>&1
rm $OUTFILE >/dev/null 2>&1
rm $FFMPEG_LOG
rm $SOMAGIC_LOG
rm $MPLAYER_LOG
mkfifo $PIPE >/dev/null 2>&1
ffmpeg -loglevel panic -f rawvideo -pixel_format uyvy422 -video_size 720x576 -framerate 25 -i $PIPE -vcodec libx264 -preset ultrafast $OUTFILE > $FFMPEG_LOG 2>&1 &
somagic-capture 2> $SOMAGIC_LOG | tee $PIPE | \
mplayer -nosound -vo xv -vf yadif,screenshot -demuxer rawvideo -rawvideo pal:format=uyvy:fps=25 -vf crop=720:430:0:65 -monitoraspect 16:9 -aspect 4:3 -fs - 2> $MPLAYER_LOG
rm $PIPE >/dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment