我需要流图像从USB摄像头到我的嵌入式系统的网页。使用的操作系统是Linux。
我成功地安装了ffserver和ffmpeg,以及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>

但仍然不起作用。

最佳答案

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 communication是ffm文件,ffserver->webbrowser communication是.flv文件。

关于http - 使用ffserver和ffmpeg将USB网络摄像头的视频嵌入网页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30528137/

10-09 02:22