Skip to content

Instantly share code, notes, and snippets.

@baskeboler
Created June 13, 2019 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baskeboler/407c37c2361800568ae176feef0fbad5 to your computer and use it in GitHub Desktop.
Save baskeboler/407c37c2361800568ae176feef0fbad5 to your computer and use it in GitHub Desktop.
record webcam lip-syncing an mp3 played with cvlc and then mux the recorded audio with the selected audio stream
#!/usr/bin/env fish
set AUDIO $argv[1]
echo input: $AUDIO
rm /tmp/salida.mpg
set BIRTH_T (date +%s%N)
cvlc $AUDIO &
set START_T (date +%s%N)
set DIFF_T (math $START_T - $BIRTH_T)
echo $DIFF_T > DIFF
# I am assuming the webcam is at /dev/video0
ffmpeg -f v4l2 -framerate 25 -s 640x480 -i /dev/video0 /tmp/salida.mpg
ffmpeg -y -i /tmp/salida.mpg -ss 0:0:1 -i $AUDIO -shortest -f mp4 -pass 1 -passlogfile /tmp/passlogfile -vcodec mpeg4 -r 25 -b:v 512K -s 640x480 -an /dev/null
ffmpeg -y -i /tmp/salida.mpg -ss 0:0:1 -i $AUDIO -shortest -f mp4 -pass 2 -passlogfile /tmp/passlogfile -vcodec mpeg4 -r 25 -b:v 512K -s 640x480 -acodec libmp3lame -ar 44100 -b:a 96K salida.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment