Created
June 30, 2019 20:32
-
-
Save RyAndrew/fe986b93e6e5ebf6c9c067ef320db60f to your computer and use it in GitHub Desktop.
letsrobot / runmyrobot / custom ffmpeg dynoverlay build script
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
#!/bin/bash | |
# Clear screen | |
printf "\ec" | |
echo -en "\ec" | |
echo | |
echo -e "\e[31m**************************************************" | |
echo -e "\e[31m* \e[39mYou are now about to install everything needed \e[31m*" | |
echo -e "\e[31m* \e[39mto get your robot connected to letsrobot.tv \e[31m*" | |
echo -e "\e[31m* \e[39mBefore we can start, you need to get a robot, \e[31m*" | |
echo -e "\e[31m* \e[39mand camera ID. You can get that by pressing \e[31m*" | |
echo -e "\e[31m* \e[39mthe \"connect your robot\" button \e[31m*" | |
echo -e "\e[31m**************************************************" | |
echo | |
cd ~ &&\ | |
if [ ! -f ~/start_robot ] | |
then | |
echo -e "\e[33mPlease enter your Robot ID:\e[39m " | |
read input_robot | |
re='^[0-9]+$' | |
if ! [[ $input_robot =~ $re ]] ; then | |
echo "Error: Robot ID is not a number" >&2; exit 1 | |
fi | |
echo | |
echo -e "\e[33mPlease enter your Camera ID:\e[39m " | |
read input_camera | |
echo | |
echo | |
if ! [[ $input_camera =~ $re ]] ; then | |
echo "Error: Camera ID is not a number" >&2; exit 1 | |
fi | |
fi | |
echo -e "\e[33mThank you, sit back and relax, we'll see you on letsrobot.tv\e[39m" | |
echo | |
sleep 3s | |
# Write the start_robot file with the ID for robot and camera in | |
if [ ! -f ~/start_robot ] | |
then | |
echo '#!/bin/bash' >> ~/start_robot | |
echo '# suggested use for this:' >> ~/start_robot | |
echo '# (1) Put in the ids for your robot, YOURROBOTID and YOURCAMERAID' >> ~/start_robot | |
echo '# (2) use sudo to create a crontab entry: @reboot /bin/bash /home/pi/start_robot' >> ~/start_robot | |
echo 'cd /home/pi/runmyrobot' >> ~/start_robot | |
echo "nohup scripts/repeat_start python controller.py ${input_robot} &> /dev/null &" >> ~/start_robot | |
echo "nohup scripts/repeat_start python send_video.py ${input_camera} 0 &> /dev/null &" >> ~/start_robot | |
fi | |
# Make sure the system is up-to-date | |
echo | |
echo -e "\e[33mBringing system up to date\e[39m " | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
sudo apt-get -y dist-upgrade | |
# Make sure we are still up-to-date if dist got upgraded | |
sudo apt-get -y update | |
sudo apt-get -y upgrade | |
sudo apt-get -y update | |
# Start installing everything needed | |
echo | |
echo -e "\e[33mInstalling all the things needed to run the robot\e[39m " | |
sudo apt-get -y install python-serial python-dev libgnutls28-dev espeak python-smbus python-pip git | |
sudo pip install -U socketIO-client && | |
sudo pip install -U configparser | |
echo | |
echo -e "\e[33mGit clone: Adafruit Motor HAT\e[39m " | |
cd ~ &&\ | |
git clone https://github.com/adafruit/Adafruit-Motor-HAT-Python-Library.git &&\ | |
cd Adafruit-Motor-HAT-Python-Library &&\ | |
sudo apt-get -y install python-dev &&\ | |
sudo python setup.py install &&\ | |
echo | |
echo -e "\e[33mGetting alsa\e[39m " | |
cd ~ &&\ | |
wget ftp://ftp.alsa-project.org/pub/lib/alsa-lib-1.0.25.tar.bz2 &&\ | |
tar xjf alsa-lib-1.0.25.tar.bz2 &&\ | |
cd alsa-lib-1.0.25 &&\ | |
./configure --host=arm-unknown-linux-gnueabi &&\ | |
make -j4 &&\ | |
sudo make install &&\ | |
echo | |
echo "Compile and install prerequisite for FFmpeg: x264" | |
cd ~ &&\ | |
if [ -d "x264" ]; then | |
sudo rm -r x264 | |
fi | |
# Move back to a version before the api change, needed to work with the ffmpeg version with overlay | |
git clone "git://git.videolan.org/x264" | |
cd x264 | |
git checkout "09705c0b68232a05da8cc672c7c6092071eb4a21" | |
./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl | |
make -j4 | |
sudo make install | |
echo | |
echo -e "\e[33mGit clone: FFMpeg with dynoverlay by roboempress\e[39m " | |
cd ~ &&\ | |
if [ -d "FFmpeg" ]; then | |
sudo rm -r FFmpeg | |
fi | |
git clone -b dynoverlay --single-branch https://github.com/r3n33/FFmpeg.git &&\ | |
cd FFmpeg &&\ | |
echo -e "\e[33mCleaning FFMpeg\e[39m " | |
./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree --enable-gnutls --extra-libs=-ldl --enable-zlib &&\ | |
make clean | |
echo -e "\e[33mBuilding FFMpeg\e[39m " | |
make -j4 &&\ | |
sudo make install | |
echo | |
echo -e "\e[33mGit clone: RunMyRobot\e[39m " | |
cd ~ &&\ | |
git clone https://github.com/runmyrobot/runmyrobot &&\ | |
echo | |
echo -e "\e[33mTTS: Installing boto3 for AWS Polly\e[39m " | |
cd ~ &&\ | |
sudo pip install -U boto3 &&\ | |
echo | |
echo -e "\e[33mInstalling mpg123 for use with AWS Polly\e[39m " | |
cd ~ &&\ | |
sudo apt-get -y install mpg123 | |
echo | |
echo -e "\e[33mPIP: Installing ina219 for python\e[39m " | |
cd ~ &&\ | |
sudo pip install -U pi-ina219 | |
# Add start_robot script to crontab, it might throw an error, but it works anyways | |
echo | |
echo -e "\e[33mAdding to crontab\e[39m " | |
crontab -l | { cat; echo "@reboot /bin/bash /home/pi/start_robot"; } | crontab - | |
echo | |
echo | |
echo -e "\e[33mInstall has completed, please run start_robot, or reboot your robot to bring it online.\e[39m" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment