http - 使用 ffserver 和 ffmpeg 将来自 USB 网络摄像头的视频嵌入到网页中

标签 http video stream

我需要将图像从 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>

但是还是不行。

最佳答案

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文件。

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

相关文章:

Java 将数据从服务器发送回客户端

swift - 如何在 Swift 中调用 HTTP Get 并保存到变量中?

javascript - 使用Javascript将页面从子域链接到具有相同结构子文件夹的另一个子域

php - 通过 Chemistry in PHP 从 Alfresco 下载文件

c# - Windows Media Player 嵌入 C# 视频速度变化

iphone - 是否可以在 iPhone 上播放视频并显示与其同步的字幕?

html - 禁用 html5 视频自动播放

linux - 一段时间后 HTTP Live Stream 停止播放

c++ - 流到字节数组

ffmpeg - 使用 ffmpeg 合并片段会导致音频出现小裂缝