【问题标题】:Embed video from USB webcam into web page using ffserver and ffmpeg使用 ffserver 和 ffmpeg 将 USB 网络摄像头中的视频嵌入网页
【发布时间】:2015-05-29 11:14:41
【问题描述】:

我需要将图像从 USB 网络摄像头传输到嵌入式系统上的网页。使用的操作系统是Linux。

我成功安装了 ffserverffmpeg,以及 mplayer。 这是我的 /etc/ffserver.conf(它不是确定的,我只是在测试它):

# Port on which the server is listening. You must select a different
# port from your standard HTTP web server if it is running on the same
# computer.
Port 8090

# Address on which the server is bound. Only useful if you have
# several network interfaces.
BindAddress 0.0.0.0

# Number of simultaneous HTTP connections that can be handled. It has
# to be defined *before* the MaxClients parameter, since it defines the
# MaxClients maximum limit.
MaxHTTPConnections 2

# Number of simultaneous requests that can be handled. Since FFServer
# is very fast, it is more likely that you will want to leave this high
# and use MaxBandwidth, below.
MaxClients 2

# This the maximum amount of kbit/sec that you are prepared to
# consume when streaming to clients.
MaxBandwidth 1000

# Access log file (uses standard Apache log file format)
# '-' is the standard output.
CustomLog -

# Suppress that if you want to launch ffserver as a daemon.
NoDaemon

<Feed feed1.ffm>
    File /tmp/feed1.ffm #when remarked, no file is beeing created and the stream keeps working!!
    FileMaxSize 200K
       # Only allow connections from localhost to the feed.
       ACL allow 127.0.0.1
    # the output stream format - SWF = flash
    Format swf
    # this must match the ffmpeg -r argument
    VideoFrameRate 5
    # another quality tweak
    VideoBitRate 320
    # quality ranges - 1-31 (1 = best, 31 = worst)
    VideoQMin 1
    VideoQMax 3
    VideoSize 640x480
    # wecams don't have audio
    NoAudio
</Stream>

# FLV output - good for streaming
<Stream test.flv>
    # the source feed
    Feed feed1.ffm
    # the output stream format - FLV = FLash Video
    Format flv
    VideoCodec flv
    # this must match the ffmpeg -r argument
    VideoFrameRate 5
    # another quality tweak
    VideoBitRate 320
    # quality ranges - 1-31 (1 = best, 31 = worst)
    VideoQMin 1
    VideoQMax 3
    VideoSize 640x480
    # wecams don't have audio
    NoAudio
</Stream>

<Stream stat.html>
    Format status
</Stream>

<Redirect index.html>
    # credits!
    URL http://ffmpeg.sourceforge.net/
</Redirect>

我可以从 shell 执行:

# ffserver -f /etc/ffserver.conf

# ffmpeg -f video4linux2 -s 320x240 -r 5 -i /dev/video0 http://127.0.0.1:8090/test.flv

执行过程中没有报错。听起来不错,但可能根本不行。

然后,在网页中,我写了这个简单的代码:

<video controls>
   <source src="http://127.0.0.1:8090/test.flv">
</video>

我在堆栈溢出的另一个线程上读到(我丢失了链接),这段代码应该足够了。但它对我不起作用。

但是我可以看到文件 /tmp/feed1.ffm 已经创建,所以我想我可以使用这个流在我的网页上显示相机图像。我对吗 ?

最简单的解决方案是什么? 谢谢。

编辑

我允许连接到 ffserver 的配置文件:

<Feed feed1.ffm>
        File /tmp/feed1.ffm #when remarked, no file is beeing created and the stream keeps working!!
        FileMaxSize 200K
       ACL allow 127.0.0.1
       ACL allow localhost
       ACL allow 192.168.2.2 192.168.2.10   
</Feed>

但还是不行。

【问题讨论】:

  • 嗨,simo-zz。你的问题已经有一段时间了。你有没有让这个工作?如果是这样,我很想知道你是怎么做到的。谢谢!

标签: http video stream


【解决方案1】:
ffmpeg -f video4linux2 -s 320x240 -r 5 -i /dev/video0
http://127.0.0.1:8090/test.flv

the documentation 中所述,您应该流式传输到 feed1.ffm 文件,而不是 test.flv 文件。 ffmpeg -> ffserver 通信为ffm文件,ffserver -> webbrowser 通信为.flv文件。

【讨论】:

  • 好的,你是对的。但在浏览器中我收到错误GET http://127.0.0.1:8090/test.swf net::ERR_CONNECTION_REFUSED。我已经允许连接到 ffserver.conf 文件。
  • 流在您的 ffserver.conf 中具有扩展名 .flv,而不是 .swf。
【解决方案2】:

我认为 HTML 不喜欢管道或 .ffm 之类的伪文件 :)

也许您可以使用 HTML5 中的 &lt;embed&gt;标签。

<embed type="video/flv" src="http://127.0.0.1:8090/test.flv" width="320" height="240">

或者你想设置大小。

【讨论】:

    猜你喜欢
    • 2013-08-01
    • 2013-07-15
    • 1970-01-01
    • 2019-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多