doucuo4413 2015-06-24 12:59
浏览 21
已采纳

avconv网络摄像头图像到标准输出在php中使用

I try to get a webcam image direct to my PHP script on a debian system. For this, I tried to open a file handling to /dev/video0, but that doesn't work. Using the software "streamer" I got an image to the disk, the webcam works on /dev/video0

I don't want to save the image to the disk first, because I need to refresh it in a short interval. My idea is to get an image direct to the standard output and use php passthru to pipe the output to the client browser:

$header("Content-type: image/jpeg");
passthru('avconv /dev/video0 someparamters for direct output');

I hoped that avconv has the option to push the image to the standard output, but I could not find any option like this. Is there a possibility to get the webcam image (via avconv or another tool) direct in php as an binary stream?

Thanks a lot! Sebastian

  • 写回答

2条回答 默认 最新

  • duanbei1598 2017-10-23 14:24
    关注

    This works without the need of a temporary file:

    <?php
    header("content-type: image/jpeg");
    echo passthru("avconv -f video4linux2 -i /dev/video0 -vframes 1 -s 1280x1024 pipe:.jpg 2>/dev/null");
    ?>
    

    (from https://gist.github.com/megasaturnv/a42ed77d3d08d0d3d91725dbe06a0efe)

    This also works in an img tag: https://gist.github.com/megasaturnv/6e5965732d4cff91f2e976e7a39efbaa

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 有人会搭建GPT-J-6B框架吗?有偿
  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名