Skip to content

Instantly share code, notes, and snippets.

@vtajzich
Last active May 21, 2019 07:45
Show Gist options
  • Save vtajzich/7577876 to your computer and use it in GitHub Desktop.
Save vtajzich/7577876 to your computer and use it in GitHub Desktop.
Install & compile script fro ffmpeg on raspberry pi
#!/bin/bash
function install_build_tools {
sudo apt-get install git
sudo apt-get install libasound2-dev
sudo apt-get install build-essential
sudo apt-get install make
sudo apt-get install autoconf
sudo apt-get install libtool
sudo apt-get install nginx
}
function build_yasm {
echo "Building yasm..."
# an assembler used by x264 and ffmpeg
cd /usr/src
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install
}
function build_h264 {
# h.264 video encoder
echo "Building h264"
cd /usr/src
git clone git://git.videolan.org/x264
cd x264
./configure --disable-asm --enable-shared
make
make install
}
function build_lame {
# mp3 audio encoder
echo "Building lame"
cd /usr/src
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.tar.gz
tar xzvf lame-3.99.tar.gz
cd lame-3.99
./configure
make
make install
}
function build_faac {
# aac encoder
echo "Building faac"
cd /usr/src
curl -#LO http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
tar xzvf faac-1.28.tar.gz
cd faac-1.28
./configure
make
make install
}
function build_ffmpeg {
echo "Building ffmpeg"
cd /usr/src/
git clone git://source.ffmpeg.org/ffmpeg.git
cd ffmpeg
./configure --enable-shared --enable-gpl --prefix=/usr --enable-nonfree --enable-libmp3lame --enable-libfaac --enable-libx264 --enable-version3 --disable-mmx
make
make install
}
function configure_ldconfig {
echo "Building ldconfig"
echo "/usr/local/lib" > /etc/ld.so.conf.d/libx264.conf
ldconfig
}
function build_psips {
git clone git://github.com/AndyA/psips.git
cd psips
./setup.sh && ./configure && make && make install
}
install_build_tools
build_yasm
build_h264
build_lame
build_faac
build_ffmpeg
configure_ldconfig
build_psips
#!/bin/bash
base="/usr/share/nginx/www"
set -x
rm -rf live live.h264 "$base/live"
mkdir -p live
ln -s "$PWD/live" "$base/live"
# fifos seem to work more reliably than pipes - and the fact that the
# fifo can be named helps ffmpeg guess the format correctly.
mkfifo live.h264
raspivid -w 1280 -h 720 -fps 25 -hf -t 86400000 -b 1800000 -o - | psips > live.h264 &
# Letting the buffer fill a little seems to help ffmpeg to id the stream
sleep 2
# Need ffmpeg around 1.0.5 or later. The stock Debian ffmpeg won't work.
# I'm not aware of options apart from building it from source. I have
# Raspbian packags built from Debian Multimedia sources. Available on
# request but I don't want to post them publicly because I haven't cross
# compiled all of Debian Multimedia and conflicts can occur.
ffmpeg -y \
-i live.h264 \
-f s16le -i /dev/zero -r:a 48000 -ac 2 \
-c:v copy \
-c:a libfaac -b:a 128k \
-map 0:0 -map 1:0 \
-f segment \
-segment_time 8 \
-segment_format mpegts \
-segment_list "$base/live.m3u8" \
-segment_list_size 720 \
-segment_list_flags live \
-segment_list_type m3u8 \
"live/%08d.ts" < /dev/null
@thierryR51
Copy link

make[2]: Leaving directory '/usr/src/faac-1.28/common/mp4v2'
Makefile:216: recipe for target 'install-recursive' failed
make[1]: *** [install-recursive] Error 1
make[1]: Leaving directory '/usr/src/faac-1.28/common'
Makefile:253: recipe for target 'install-recursive' failed
make: *** [install-recursive] Error 1

And after

e-version3 --disable-mmx
Unknown option "--enable-libfaac".
See ./configure --help for available options.
root@raspberrycamera:/usr/src/ffmpeg# make
Makefile:2: ffbuild/config.mak: Aucun fichier ou dossier de ce type
Makefile:66: /tools/Makefile: Aucun fichier ou dossier de ce type
Makefile:67: /ffbuild/common.mak: Aucun fichier ou dossier de ce type
Makefile:119: /libavutil/Makefile: Aucun fichier ou dossier de ce type
Makefile:119: /ffbuild/library.mak: Aucun fichier ou dossier de ce type
Makefile:121: /doc/Makefile: Aucun fichier ou dossier de ce type
Makefile:209: /tests/Makefile: Aucun fichier ou dossier de ce type
make: *** No rule to make target '/tests/Makefile'. Arrêt.
root@raspberrycamera:/usr/src/ffmpeg# make install
Makefile:2: ffbuild/config.mak: Aucun fichier ou dossier de ce type
Makefile:66: /tools/Makefile: Aucun fichier ou dossier de ce type
Makefile:67: /ffbuild/common.mak: Aucun fichier ou dossier de ce type
Makefile:119: /libavutil/Makefile: Aucun fichier ou dossier de ce type
Makefile:119: /ffbuild/library.mak: Aucun fichier ou dossier de ce type
Makefile:121: /doc/Makefile: Aucun fichier ou dossier de ce type
Makefile:209: /tests/Makefile: Aucun fichier ou dossier de ce type
make: *** No rule to make target '/tests/Makefile'. Arrêt.

@Uttarwarsanket33
Copy link

./build.sh: 10: ./build.sh: Syntax error: "}" unexpected

I am getting this error!

@labs-stellios
Copy link

@thierryR51 it looks like the --enable-libfaac option is no longer available after checking ./configure --help of the ffmpeg repo.

@labs-stellios
Copy link

@Uttarwarsanket33, I just reworked this script here. Hopefully that works for you.

@FernandaOchoa
Copy link

hi @labs-tellios where I can find it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment