实例八:摄像头与视频

-- 我是张三 发布于:2021年12月07日 浏览量:569  |


实时视频
https://github.com/waveform80/pistreaming

https://blog.csdn.net/maoxiang/article/details/17848497

视频摄像头

raspivid

  1. sudo apt-get update  

  2. sudo apt-get install vlc  

  3. 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

  1. [0xd604f0] packetizer_h264 demux packetizer debug: found NAL_PPS (pps_id=0 sps_id=0)  

  2. [0xce6458] main input debug: selecting program id=0  

  3. [0xd522f8] main decoder debug: looking for packetizer module: 21 candidates  

  4. [0xd522f8] main decoder debug: using packetizer module "packetizer_h264"  

  5. [0xd522f8] main decoder debug: TIMER module_need() : 0.912 ms - Total 0.912 ms / 1 intvls)  

  6. [0xce6458] main input error: Invalid PCR value in ES_OUT_SET_(GROUP_)PCR !  

  7. [0xce6458] main input debug: switching to sync mode  

  8. [0xce6458] main input debug: Buffering 0%  

  9. [0xd522f8] packetizer_h264 decoder debug: found NAL_SPS (sps_id=0)  

  10. [0xd522f8] packetizer_h264 decoder debug: found NAL_PPS (pps_id=0 sps_id=0)  

  11. [0xce6458] main input debug: Buffering 13%  

  12. [0xd5ac40] main stream output debug: adding a new sout input (sout_input:0xcee4d8)  

  13. [0xd5d270] main mux debug: adding a new input  

  14. [0xd5d270] mux_ts mux debug: adding input codec=h264 pid=68  

  15. [0xd5d270] mux_ts mux debug: new PCR PID is 68  

  16. [0xce6458] main input debug: Buffering 26%  

  17. [0xce6458] main input debug: Buffering 40%  

  18. [0xce6458] main input debug: Buffering 53%  

  19. [0xce6458] main input debug: Buffering 66%  

  20. [0xce6458] main input debug: Buffering 80%  

  21. [0xce6458] main input debug: Buffering 93%  

  22. [0xce6458] main input debug: Stream buffering done (320 ms in 22 ms)  

  23. [0xce6458] main input debug: Decoder buffering done in 0 ms  

  24. [0xd5d270] main mux warning: late buffer for mux input (30138)  

  25. [0xd5d270] mux_ts mux warning: packet with too strange dts (dts=5834500483,old=5837242731)  

  26. [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 |  使用帮助 |  关于我们 |  投诉建议

京ICP备13033209号-2