实时视频
https://github.com/waveform80/pistreaming
https://blog.csdn.net/maoxiang/article/details/17848497
视频摄像头
raspivid
sudo apt-get update
sudo apt-get install vlc
sudo raspivid -o - -t 0 -w 640 -h 360 -fps 25|cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8090}' :demux=h264
在电脑端,无论是Windows,Linux还是OSX,或者安卓机器,只要能安装VLC,现在就可以打开VLC,然后打开媒体-》网络串流-》输入http://PI的IP地址:8090查看实时不卡的网络监控了。
第一行是更新软件数据库
第二行是安装vlc
第三行是使用PI官方的raspivid捕获视频工具把视频流输出到vlc,通过vlc转码成h264网络视频流通过http协议以ts的形式封装,然后输出到8090端口,用这个当监控只要网络稳定绝对不卡。
看到以下内容就说明开始正常输出内容了。然后在其它VLC客户端打开网络串流就行了。
[html] view plain copy
[0xd604f0] packetizer_h264 demux packetizer debug: found NAL_PPS (pps_id=0 sps_id=0)
[0xce6458] main input debug: selecting program id=0
[0xd522f8] main decoder debug: looking for packetizer module: 21 candidates
[0xd522f8] main decoder debug: using packetizer module "packetizer_h264"
[0xd522f8] main decoder debug: TIMER module_need() : 0.912 ms - Total 0.912 ms / 1 intvls)
[0xce6458] main input error: Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !
[0xce6458] main input debug: switching to sync mode
[0xce6458] main input debug: Buffering 0%
[0xd522f8] packetizer_h264 decoder debug: found NAL_SPS (sps_id=0)
[0xd522f8] packetizer_h264 decoder debug: found NAL_PPS (pps_id=0 sps_id=0)
[0xce6458] main input debug: Buffering 13%
[0xd5ac40] main stream output debug: adding a new sout input (sout_input:0xcee4d8)
[0xd5d270] main mux debug: adding a new input
[0xd5d270] mux_ts mux debug: adding input codec=h264 pid=68
[0xd5d270] mux_ts mux debug: new PCR PID is 68
[0xce6458] main input debug: Buffering 26%
[0xce6458] main input debug: Buffering 40%
[0xce6458] main input debug: Buffering 53%
[0xce6458] main input debug: Buffering 66%
[0xce6458] main input debug: Buffering 80%
[0xce6458] main input debug: Buffering 93%
[0xce6458] main input debug: Stream buffering done (320 ms in 22 ms)
[0xce6458] main input debug: Decoder buffering done in 0 ms
[0xd5d270] main mux warning: late buffer for mux input (30138)
[0xd5d270] mux_ts mux warning: packet with too strange dts (dts=5834500483,old=5837242731)
[0xd5d270] mux_ts mux warning: packet with too strange dts (dts=5834706185,old=5834740483)
http://shumeipai.nxez.com/2017/05/14/raspberry-pi-mjpg-streamer-installation.html
N 基于mjpg-streamer的视频传输方案
pi@raspberrypi:~ $ sudo modprobe bcm2835-v4l2
pi@raspberrypi:~ $ ls
2018-06-03-142724_1360x768_scrot.png Documents lrkey.asc Music oldconffiles P-05:31:2018-15:21:50.pnm Pictures python_games Templates t.txt
Desktop Downloads mjpg-streamer mykeychain.h264 P-05:31:2018-15:21:21.pnm P-05:31:2018-15:22:41.pnm Public SG90 test Videos
pi@raspberrypi:~ $ cd mjpg-streamer/
pi@raspberrypi:~/mjpg-streamer $ ls
mjpg-streamer-experimental README.md
pi@raspberrypi:~/mjpg-streamer $ cd mjpg-streamer-experimental/
pi@raspberrypi:~/mjpg-streamer/mjpg-streamer-experimental $ ls
_build Dockerfile input_http.so LICENSE mjpg_streamer mjpg_streamer@.service output_rtsp.so postinstall.sh start.sh utils.h
cmake docker-start.sh input_raspicam.so makedeb.sh mjpg_streamer.c output_file.so output_udp.so README.md TODO www
CMakeLists.txt input_file.so input_uvc.so Makefile mjpg_streamer.h output_http.so plugins scripts utils.c
pi@raspberrypi:~/mjpg-streamer/mjpg-streamer-experimental $ ./mjpg_streamer -i "./input_uvc.so -d /dev/video0 -n -y -f 25 -r 640x480" -o "./output_http.so -n -w /usr/local/www"
MJPG Streamer Version: git rev: 821c330ea6bbb5fbed98d48e00aac156e923161b
i: Using V4L2 device.: /dev/video0
i: Desired Resolution: 640 x 480
i: Frames Per Second.: 25
i: Format............: YUYV
i: JPEG Quality......: 80
i: TV-Norm...........: DEFAULT
o: www-folder-path......: /usr/local/www/
o: HTTP TCP port........: 8080
o: HTTP Listen Address..: (null)
o: username:password....: disabled
o: commands.............: disabled
^X^Z
[1]+ Stopped ./mjpg_streamer -i "./input_uvc.so -d /dev/video0 -n -y -f 25 -r 640x480" -o "./output_http.so -n -w /usr/local/www"
参数
参数:输入UVC,网页输出,图片输出(更详细的设置,建议去看源码)
mjpg_streamer -i "input_uvc.so -f 10 -r 320*240 -y" -o "output_http.so -c "ruoyun:liufeng" -w www -p 8888" -o "output_file.so -d 1000 -f /mnt "
-i 输入
"input_uvc.so -f 10 -r 320*240 -y"
input_uvc.so:UVC输入组件
-f 10 :表示10帧
-r 320*240 :分辨率
-y :YUV格式输入(有卡顿),不加表示MJPG输入(需要摄像头支持)
-o输出
"output_http.so -c "ruoyun:liufeng" -w www -p 8888"
output_http.so :网页输出组件
-c "ruoyun:liufeng" :用户名:ruoyun 密码:liufeng
-w www : 网页输出
-p 8888 :端口 8888
"output_file.so -d 1000 -f /mnt "
output_file.so :图片输出组件
-d 1000 : 时间1S
-f /mnt :输出图片放在哪,我是开机直接把/mnu挂载到本地文件夹了
源码:
https://github.com/jacksonliam/mjpg-streamer
-----------------
Copyright © 2015 - 2016 DISPACE.NET | 使用帮助 | 关于我们 | 投诉建议