Raspberry pi Install H.264,ffmpeg

本版討論物聯網 IoT Platform 技術與應用
回覆文章
inho
文章: 55
註冊時間: 2017-12-08, 23:00

Raspberry pi Install H.264,ffmpeg

文章 inho » 2018-02-06, 07:30

參考網站:
https://www.hackster.io/whitebank/rasbp ... web-389c34
http://blog.michaelchi.net/2016/06/iotr ... rvice.html

一、安裝 H.264 相關 Library
$ cd /usr/src
$ sudo git clone git://git.videolan.org/x264
$ cd x264
$ sudo ./configure --host=arm-unknown-linux-gnueabi --enable-static --disable-opencl
$ sudo make -j4
$ sudo make install

安裝完成可在 /usr/local/bin 目錄底下,新增加一個 x264執行檔

二、安裝 FFmpeg
$ cd /usr/src
$ sudo git clone git://source.ffmpeg.org/ffmpeg.git
$ cd ffmpeg/
$ sudo ./configure --arch=armel --target-os=linux --enable-gpl --enable-libx264 --enable-nonfree
$ sudo make -j4 (如果是 RPi 3 Model B+ (4-Cores), RP2 使用 $ make,這個步驟要花很長的時間)
$ sudo make install

安裝完成可在 /usr/local/bin 目錄底下,新增加一個 ffmpeg、ffprobe、ffplay 執行檔。

三、3. Config something:
$ gedit /etc/ffserver.conf
// Input following settings:
=====================================
Port 8090
# bind to all IPs aliased or not
BindAddress 0.0.0.0
# max number of simultaneous clients
MaxClients 10
# max bandwidth per-client (kb/s)
MaxBandwidth 1000
# Suppress that if you want to launch ffserver as a daemon.
NoDaemon

<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 10M
</Feed>

<Stream test.mjpg>
Feed feed1.ffm
Format mpjpeg
VideoFrameRate 4
VideoSize 600x480
VideoBitRate 80
# VideoQMin 1
# VideoQMax 100
VideoIntraOnly
NoAudio
Strict -1
</Stream>
==========================================
Make execute file for easy command: (製作指令執行檔案)
$ vi /usr/sbin/webcam.sh
========== 輸入以下內容 ========================
ffserver -f /etc/ffserver.conf & ffmpeg -v verbose -r 5 -s 600x480 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm
=====================================================
變更 webcam.sh 的 file mode, so it can execute, then run it:
$ chmod +x /usr/sbin/webcam.sh
$ /usr/sbin/webcam.sh
After the above command, streaming will be started to local web.
=========================================================================
Check the installed ffmpeg information :
$ ffmpeg

回覆文章