Created
June 13, 2019 21:02
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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