gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:28:59 27 4
gpt4 key购买 nike

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

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com