命令行流网络摄像头,带有来自 Ubuntu 服务器的 WebM 格式的音频

发布于 2024-12-06 01:27:53 字数 894 浏览 1 评论 0原文

我正在尝试从连接到无头 Ubuntu 服务器(运行 Maverick 10.10)的网络摄像头传输视频和音频。我希望能够以 WebM 格式(VP8 视频 + OGG)进行流式传输。带宽有限,因此流必须低于 1Mbps。

我尝试过使用 FFmpeg。我可以通过以下方式从网络摄像头录制 WebM 视频:

ffmpeg -s 640x360 \
-f video4linux2 -i /dev/video0 -isync -vcodec libvpx -vb 768000 -r 10 -vsync 1 \
-f alsa -ac 1 -i hw:1,0 -acodec libvorbis -ab 32000 -ar 11025 \
-f webm /var/www/telemed/test.webm 

然而,尽管尝试了各种垂直同步和异步选项,我还是会出现不同步音频或 Benny Hill 风格的快进视频与匹配的快速音频的情况。我也无法让它实际与 ffserver 一起工作(通过用相关的提要文件名替换 test.webm 路径和文件名)。

目标是仅使用开源组件,在带宽紧张的情况下,获得可在现代浏览器中查看的实时音频+视频源。 (没有 MP3 格式的合法箔条)

因此我的问题是: 您将如何通过 Linux 从网络摄像头流式传输 webm 并使用同步音频?你用什么软件?

您是否成功通过 FFmpeg 从网络摄像头对 webm 进行编码并使用同步音频?如果是这样,您发出了什么命令?

是否值得坚持使用 FFmpeg + FFserver,或者还有其他更合适的命令行工具(例如 VLC,它似乎不太适合编码)?

可以从命令行配置类似 Gstreamer + Flumotion 的东西吗?如果是这样,我在哪里可以找到命令行文档,因为 Flumotion 文档对命令行细节的了解相当少?

提前致谢!

I am trying to stream video and audio from my webcam connected to my headless Ubuntu server (running Maverick 10.10). I want to be able to stream in WebM format (VP8 video + OGG). Bandwidth is limited, and so the stream must be below 1Mbps.

I have tried using FFmpeg. I am able to record WebM video from the webcam with the following:

ffmpeg -s 640x360 \
-f video4linux2 -i /dev/video0 -isync -vcodec libvpx -vb 768000 -r 10 -vsync 1 \
-f alsa -ac 1 -i hw:1,0 -acodec libvorbis -ab 32000 -ar 11025 \
-f webm /var/www/telemed/test.webm 

However despite experimenting with all manner of vsync and async options, I can either get out of sync audio, or Benny Hill style fast-forward video with matching fast audio. I have also been unable to get this actually working with ffserver (by replacing the test.webm path and filename with the relevant feed filename).

The objective is to get a live, audio + video feed which is viewable in a modern browser, in a tight bandwidth, using only open-source components. (None of that MP3 format legal chaff)

My questions are therefore:
How would you go about streaming webm from a webcam via Linux with in-sync audio? What software you use?

Have you succeeded in encoding webm from a webcam with in-sync audio via FFmpeg? If so, what command did you issue?

Is it worth persevering with FFmpeg + FFserver, or are there other more suitable command-line tools around (e.g. VLC which doesn't seem too well built for encoding)?

Is something like Gstreamer + flumotion configurable from the command line? If so, where do I find command line documentation because flumotion doc is rather light on command line details?

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

貪欢 2024-12-13 01:27:53

您应该考虑尝试一下flumotion。您可以使用 Flumotion-admin 轻松设置从网络摄像头捕获的 WebM 管道,并让它在后台运行。

You should consider giving flumotion a try. You can easily set up a webm pipeline capturing from a webcam with flumotion-admin and let it run in the background.

永言不败 2024-12-13 01:27:53

我最近设置了这个,但有点痛苦。这是我必须做的:

首先,从源代码构建 ffmpeg 以包含 libvpx 驱动程序(即使您使用包含该驱动程序的版本,您也需要最新的版本(截至本月)来流式传输 webm,因为它们只是添加了功能包括全局标头)。我在 Ubuntu 服务器和桌面上执行此操作,本指南向我展示了如何操作 - 说明其他操作系统可以在此处找到

一旦您获得了适当版本的 ffmpeg/ffserver,您就可以将它们设置为流式传输,在我的例子中,这是按如下方式完成的。

在视频捕获设备上:

ffmpeg -f video4linux2 -standard ntsc -i /dev/video0 http://<server_ip>:8090/0.ffm
  • “-f video4linux2 -standard ntsc -i /dev/video0”部分可能会根据您的输入源而变化(我的是视频捕获卡)。

相关 ffserver.conf 摘录:

Port 8090
#BindAddress <server_ip>
MaxHTTPConnections 2000
MAXClients 100
MaxBandwidth 1000000
CustomLog /var/log/ffserver
NoDaemon

<Feed 0.ffm>
File /tmp/0.ffm
FileMaxSize 5M
ACL allow <feeder_ip>
</Feed>
<Feed 0_webm.ffm>
File /tmp/0_webm.ffm
FileMaxSize 5M
ACL allow localhost
</Feed>

<Stream 0.mpg>
Feed 0.ffm
Format mpeg1video
NoAudio
VideoFrameRate 25
VideoBitRate 256
VideoSize cif
VideoBufferSize 40
VideoGopSize 12
</Stream>
<Stream 0.webm>
Feed 0_webm.ffm
Format webm
NoAudio
VideoCodec libvpx
VideoSize 320x240
VideoFrameRate 24
AVOptionVideo flags +global_header
AVOptionVideo cpu-used 0
AVOptionVideo qmin 1
AVOptionVideo qmax 31
AVOptionVideo quality good
PreRoll 0
StartSendOnKey
VideoBitRate 500K
</Stream>

<Stream index.html>
Format status
ACL allow <client_low_ip> <client_high_ip>
</Stream>
  • 请注意,这是为 feeder_ip 处的服务器配置的,以执行上述 ffmpeg 命令,以及为 server_ip 处的服务器配置的,以便服务器通过 client_high_ip 到 client_low_ip,同时处理 server_ip 上的 mpeg 到 webm 会话(下文继续)。

此 ffmpeg 命令在之前称为 server_ip 的机器上执行(它处理实际的 mpeg --> webm 转换,并将其反馈到不同源上的 ffserver):

ffmpeg -i http://<server_ip>:8090/0.mpg -vcodec libvpx http://localhost:8090/0_webm.ffm

一旦这些都启动(首先是 ffserver,然后是 feeder_ip ffmpeg 进程,然后是 server_ip ffmpeg 进程)您应该能够通过 http://:8090/0.webm 访问实时流并检查状态http://:8090/

希望这有帮助。

I set this up recently, but it's kind of a pain. Here's what I had to do:

First, build ffmpeg from source to include the libvpx drivers (even if your using a version that has it, you need the newest ones (as of this month) to stream webm because they just did add the functionality to include global headers). I did this on an Ubuntu server and desktop, and this guide showed me how - instructions for other OSes can be found here.

Once you've gotten the appropriate version of ffmpeg/ffserver you can set them up for streaming, in my case this was done as follows.

On the video capture device:

ffmpeg -f video4linux2 -standard ntsc -i /dev/video0 http://<server_ip>:8090/0.ffm
  • The "-f video4linux2 -standard ntsc -i /dev/video0" portion of that may change depending on your input source (mine is for a video capture card).

Relevant ffserver.conf excerpt:

Port 8090
#BindAddress <server_ip>
MaxHTTPConnections 2000
MAXClients 100
MaxBandwidth 1000000
CustomLog /var/log/ffserver
NoDaemon

<Feed 0.ffm>
File /tmp/0.ffm
FileMaxSize 5M
ACL allow <feeder_ip>
</Feed>
<Feed 0_webm.ffm>
File /tmp/0_webm.ffm
FileMaxSize 5M
ACL allow localhost
</Feed>

<Stream 0.mpg>
Feed 0.ffm
Format mpeg1video
NoAudio
VideoFrameRate 25
VideoBitRate 256
VideoSize cif
VideoBufferSize 40
VideoGopSize 12
</Stream>
<Stream 0.webm>
Feed 0_webm.ffm
Format webm
NoAudio
VideoCodec libvpx
VideoSize 320x240
VideoFrameRate 24
AVOptionVideo flags +global_header
AVOptionVideo cpu-used 0
AVOptionVideo qmin 1
AVOptionVideo qmax 31
AVOptionVideo quality good
PreRoll 0
StartSendOnKey
VideoBitRate 500K
</Stream>

<Stream index.html>
Format status
ACL allow <client_low_ip> <client_high_ip>
</Stream>
  • Note this is configured for a server at feeder_ip to execute the aforementioned ffmpeg command, and for the server at server_ip so server to client_low_ip through client_high_ip while handling the mpeg to webm conversation on server_ip (continued below).

This ffmpeg command is executed on the machine previously referred to as server_ip (it handles the actual mpeg --> webm conversion and feeds it back into the ffserver on a different feed):

ffmpeg -i http://<server_ip>:8090/0.mpg -vcodec libvpx http://localhost:8090/0_webm.ffm

Once these have all been started up (first the ffserver, then the feeder_ip ffmpeg process then then the server_ip ffmpeg process) you should be able to access the live stream at http://:8090/0.webm and check the status at http://:8090/

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文