├── install_ffmpeg.sh └── README.md /install_ffmpeg.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | sudo apt-get update 4 | sudo apt-get upgrade 5 | sudo sh -c 'echo "deb http://www.deb-multimedia.org jessie main non-free" >> /etc/apt/sources.list.d/deb-multimedia.list' 6 | sudo sh -c 'echo "deb-src http://www.deb-multimedia.org jessie main non-free" >> /etc/apt/sources.list.d/deb-multimedia.list' 7 | sudo apt-get update 8 | sudo apt-get install deb-multimedia-keyring --yes 9 | sudo apt-get update 10 | sudo apt-get remove ffmpeg 11 | sudo apt-get install build-essential libmp3lame-dev libvorbis-dev libtheora-dev libspeex-dev yasm pkg-config libfaac-dev libopenjpeg-dev libx264-dev --yes 12 | cd /usr/src/ 13 | sudo apt-get install git --yes 14 | sudo git clone git://git.videolan.org/x264 15 | cd x264/ 16 | sudo ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl 17 | sudo make 18 | sudo make install 19 | cd /usr/src 20 | sudo git clone https://github.com/FFmpeg/FFmpeg.git 21 | cd FFmpeg/ 22 | sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree 23 | sudo make -j4 24 | sudo make install 25 | ffmpeg -encoders # test it works 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Static builds (update 2017/08/23) 2 | 3 | **--- Downloading and compiling the source code takes a lot of time. ---** 4 | 5 | **You can save time** by using the static builds maintained by John Van Sickle and can be found here: [https://www.johnvansickle.com/ffmpeg/](https://www.johnvansickle.com/ffmpeg/). Just make sure that you download the appropriate binary depending on the processor architecture you use. 6 | 7 | # FFmpeg on Raspberry Pi 3 with h264 support (2017/01/23) 8 | 9 | Steps below are a combination of these 2 sources: 10 | - [https://www.assetbank.co.uk/support/documentation/install/ffmpeg-debian-squeeze/ffmpeg-debian-jessie/](https://www.assetbank.co.uk/support/documentation/install/ffmpeg-debian-squeeze/ffmpeg-debian-jessie/) 11 | - [http://www.jeffreythompson.org/blog/2014/11/13/installing-ffmpeg-for-raspberry-pi/](http://www.jeffreythompson.org/blog/2014/11/13/installing-ffmpeg-for-raspberry-pi/) 12 | 13 | Raspberry Pi 3 Model B with [Raspbian Jessie Lite 2017-01-11](http://vx2-downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2017-01-10/2017-01-11-raspbian-jessie-lite.zip) 14 | 15 | ```bash 16 | sudo apt-get update 17 | sudo apt-get upgrade 18 | sudo sh -c 'echo "deb http://www.deb-multimedia.org jessie main non-free" >> /etc/apt/sources.list.d/deb-multimedia.list' 19 | sudo sh -c 'echo "deb-src http://www.deb-multimedia.org jessie main non-free" >> /etc/apt/sources.list.d/deb-multimedia.list' 20 | sudo apt-get update 21 | sudo apt-get install deb-multimedia-keyring 22 | sudo apt-get update 23 | sudo apt-get remove ffmpeg 24 | sudo apt-get install build-essential libmp3lame-dev libvorbis-dev libtheora-dev libspeex-dev yasm pkg-config libfaac-dev libopenjpeg-dev libx264-dev 25 | cd /usr/src/ 26 | sudo apt-get install git 27 | sudo git clone git://git.videolan.org/x264 28 | cd x264/ 29 | sudo ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl 30 | sudo make 31 | sudo make install 32 | cd /usr/src 33 | sudo git clone https://github.com/FFmpeg/FFmpeg.git 34 | cd FFmpeg/ 35 | sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree 36 | sudo make -j4 37 | sudo make install 38 | ffmpeg -encoders # test it works 39 | ``` 40 | 41 | # Install and test ffmpeg on Raspberry Pi 3 (with Docker) 42 | 43 | Docker containers were used, so ffmpeg was not installed directly on the RPi. The docker image has been pushed to [https://hub.docker.com/r/tgogos/ffmpeg/](https://hub.docker.com/r/tgogos/ffmpeg/), you can save time by pulling it and then start testing... If you'd like to reproduce the whole process take a look at the section below "Download ffmpeg source code / compile" 44 | 45 | 46 | ## Test environment 47 | - Raspberry Pi 3 48 | - Host OS: Raspbian Jessie Lite image (downloaded [2016-09-23-raspbian-jessie-lite.zip](http://director.downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2016-09-28/2016-09-23-raspbian-jessie-lite.zip) from the official site) 49 | - Docker image to start with (FROM): `resin/rpi-raspbian:jessie-20160831` 50 | - Video file: Big Buck Bunny by Blender Foundation [https://www.youtube.com/watch?v=YE7VzlLtp-4](https://www.youtube.com/watch?v=YE7VzlLtp-4) 51 | 52 | ## Download ffmpeg source code / compile 53 | `* Beware that this compilation procedure takes a few hours to finish` 54 | 55 | 56 | ```bash 57 | apt-get update 58 | apt-get upgrade 59 | apt-get install git 60 | git clone git://source.ffmpeg.org/ffmpeg.git 61 | cd ffmpeg 62 | apt-get install build-essential 63 | apt-get install pkg-config 64 | ./configure 65 | make 66 | make install 67 | ``` 68 | 69 | 70 | ## 1. Test with Docker & without OVS 71 | ```bash 72 | 73 | +------------------------+ +------------------------+ 74 | | Raspberry Pi | | Demo PC | 75 | | | | | 76 | | +------------------+ | | | 77 | | | Docker Container | | | | 78 | | +------------------+ | | | 79 | | | | | | 80 | +------------------------+ +------------------------+ 81 | | | 82 | +------------------->-------------------+ 83 | 84 | 85 | # STEP 1 - Raspberry Pi (eth0: 10.143.0.246): 86 | # big_buck_bunny.mp4 is not provided within the docker image 87 | # if it is available on the docker host (RPi), use `docker cp...` to copy it inside the image 88 | ffmpeg -re -i big_buck_bunny.mp4 -vcodec mpeg4 -an -b 1024k -s 640x480 -f mpegts udp:10.143.0.245:9999?pkt_size=1316 89 | 90 | # STEP 2 - Demo pc (eth0: 10.143.0.245): 91 | ffplay udp://10.143.0.246:9999 92 | ``` 93 | 94 | 95 | ## 2. Test with Docker & OVS 96 | Open vSwitch must be installed on the docker host which is the Raspberry Pi, not on any other docker container. Network configuration comes from this source: [https://developer.ibm.com/recipes/tutorials/using-ovs-bridge-for-docker-networking/](https://developer.ibm.com/recipes/tutorials/using-ovs-bridge-for-docker-networking/) 97 | ```bash 98 | 99 | +------------------------+ +------------------------+ 100 | | Raspberry Pi | | Demo PC | 101 | | | | | 102 | | +------------------+ | | | 103 | | | Docker Container | | | | 104 | | +------------------+ | | | 105 | | | | | | 106 | | +------------------+ | | | 107 | | | Open vSwitch | | | | 108 | | +------------------+ | | | 109 | | | | | | 110 | +------------------------+ +------------------------+ 111 | | | 112 | +------------------->-------------------+ 113 | 114 | 115 | # first add and configure the bridge 116 | sudo ovs-vsctl add-br ovs-br1 117 | sudo ifconfig ovs-br1 192.168.0.1 netmask 255.255.255.0 up 118 | export pubintf=eth0 119 | export priintf=ovs-br1 120 | sudo iptables -t nat -A POSTROUTING -o $pubintf -j MASQUERADE 121 | sudo iptables -A FORWARD -i $priintf -j ACCEPT 122 | sudo iptables -A FORWARD -i $priintf -o $pubintf -m state --state RELATED,ESTABLISHED -j ACCEPT 123 | 124 | # then, run a container without network 125 | docker run --net=none --name=ffmpeg_nonet_privileged --privileged -itd tgogos/ffmpeg:latest 126 | docker exec ffmpeg_nonet_privileged ifconfig # this should print out only 'lo' 127 | 128 | # add a NIc 129 | sudo ovs-docker add-port ovs-br1 eth0 ffmpeg_nonet_privileged --ipaddress=192.168.0.2/24 --gateway=192.168.0.1 130 | docker exec ffmpeg_nonet_privileged ifconfig # this should print out 'lo' and 'eth0' 131 | 132 | # test (RPi: 10.143.0.246, Demo pc: 10.143.0.245) 133 | # big_buck_bunny.mp4 is not provided within the docker image 134 | # if it is available on the docker host (RPi), use `docker cp...` to copy it inside the image 135 | docker attach ffmpeg_nonet_privileged 136 | ffmpeg -re -i big_buck_bunny.mp4 -vcodec mpeg4 -an -b 1024k -s 640x480 -f mpegts udp:10.143.0.245:9999?pkt_size=1316 137 | ffplay udp://10.143.0.246:9999 # for the Demo pc 138 | 139 | 140 | 141 | # commands you might need later... 142 | sudo iptables --flush 143 | sudo ovs-vsctl del-br name_of_bridge 144 | ``` 145 | 146 | 147 | 148 | ## 3. Test with Docker (as transcoder) 149 | ```bash 150 | 151 | +------------------------+ +------------------------+ 152 | | Raspberry Pi | | Demo PC | 153 | | | | | 154 | | +------------------+ | | | 155 | | | Docker Container | | | | 156 | | +------------------+ | | | 157 | | | | | | 158 | +------------------------+ +------------------------+ 159 | | | 160 | +--------------(1)--<-------------------+ 161 | | | 162 | +--------------(2)-->-------------------+ 163 | 164 | # 1 - Demo PC sends a video 165 | # 2 - Docker container with ffmpeg transcodes it and sends it back 166 | 167 | 168 | # STEP 1 - Demo pc (eth0: 10.143.0.245): 169 | # start sending the video file at udp port 9999... 170 | ffmpeg -re -i big_buck_bunny.mp4 -vcodec mpeg4 -an -b 1024k -s 640x480 -f mpegts udp://10.143.0.246:9999?pkt_size=1316 171 | 172 | 173 | # STEP 2 - Raspberry Pi (eth0: 10.143.0.246): 174 | # run a container and expose udp port 9999 175 | docker run -itd --name=ffmpegTranscoder -p 9999:9999/udp tgogos/ffmpeg 176 | docker attach ffmpegTranscoder 177 | # send back through udp port 9998 178 | ffmpeg -re -i udp:10.143.0.245:9999 -vcodec mpeg4 -b:v 2048 -f mpegts udp:10.143.0.245:9998?pkt_size=1316 179 | 180 | 181 | # STEP 3 - Demo pc (eth0: 10.143.0.245): 182 | ffplay udp://10.143.0.246:9998 183 | ``` 184 | --------------------------------------------------------------------------------