简体   繁体   English

如何说服ffserver以高分辨率将本地源摄像头流保存到文件中并以较低分辨率流式传输?

[英]How can I convince ffserver to save a locally-sourced webcam stream to a file in high resolution AND stream it in lower resolution?

We have a remote Linux machine, accessible over VPN, which has a USB webcam. 我们有一台可通过VPN访问的远程Linux机器,它具有USB网络摄像头。 We want to use this for video conferencing, but we also want to store the stream for archiving. 我们希望将其用于视频会议,但我们也希望存储流以进行存档。

Since the streaming bandwidth is limited, it makes sense to capture the stream on the same machine as the webcam and rsync that across after-the-fact, rather than trying to capture the streamed content, which is necessarily going to be poor quality. 由于流式传输带宽有限,因此在与事后的网络摄像头和rsync相同的计算机上捕获流是有意义的,而不是尝试捕获流式内容,这必然会导致质量不佳。

We're trying to use ffmpeg and ffserver to achieve this, but with little success. 我们正在尝试使用ffmpeg和ffserver来实现这一目标,但收效甚微。 Most of the articles on the internet either deal with just streaming a webcam, or rebroadcasting a remote stream. 互联网上的大多数文章都只处理流式传输网络摄像头或重播远程流。 We found we had to recompile ffserver because of a missing "my_addr->sin_family = AF_INET;" 我们发现由于缺少“my_addr-> sin_family = AF_INET”,我们不得不重新编译ffserver。 in the version of ffserver.c we had been using, since fixed in git. 在ffserver.c的版本中我们一直在使用,因为在git中修复了。

Here's the ffserver.conf we're trying to use: 这是我们尝试使用的ffserver.conf:

Port 43688
BindAddress 127.0.0.1
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
NoDaemon
<Feed feed.ffm>
ReadOnlyFile /tmp/feed.ffm
FileMaxSize 20M
ACL allow 127.0.0.1
</Feed>
<Stream stream.mp4>
Feed feed.ffm
Format mp4
VideoSize qvga
VideoGopSize 12
VideoHighQuality
Video4MotionVector
VideoCodec libx264
VideoBitRate 100
VideoBufferSize 40
VideoFrameRate 5
VideoQMin 3
VideoQMax 31
AudioCodec libfaac
AudioBitRate 32
AudioChannels 2
AudioSampleRate 22050
ACL allow localhost
</Stream>

When we fire this up, we get the error: 当我们解雇时,我们得到错误:

Unable to create feed file '/tmp/feed.ffm' as it is marked readonly

Fair enough, but this is not what is implied in the docs. 很公平,但这不是文档中隐含的内容。 Changing the directive to: 将指令更改为:

File /tmp/feed.ffm

allows ffserver to fire up and appear to sit and wait for ffmpeg to connect to it. 允许ffserver启动并出现等待ffmpeg连接到它。 However, when we fire up ffmpeg with the command: 但是,当我们使用以下命令启动ffmpeg时:

ffmpeg -f alsa -i pulse -r 16000 -f video4linux2 -s qvga -i /dev/video0 -r 5 -f mp4 -vcodec libx264 -sameq -acodec libfaac -ab 32k http://127.0.0.1:43688/feed.ffm

then the webcam lights up and ffserver acknowledges the connection with the messages: 然后网络摄像头亮起,ffserver确认与消息的连接:

New connection: POST /feed.ffm
[POST] "/feed.ffm HTTP/1.1" 200 0

but after a few seconds we get the errors: 但几秒钟后我们得到错误:

[mp4 @ 0x264b160] muxer does not support non seekable output
Could not write header for output file #0 (incorrect codec parameters ?)

We've tried various other formats (mpeg, mpegts, avi) and codecs (mpeg1video, mpeg2video, mpeg4), all without success. 我们尝试了各种其他格式(mpeg,mpegts,avi)和编解码器(mpeg1video,mpeg2video,mpeg4),但都没有成功。

Moreover, we were under the impression that ffserver could reencode input format to a lower resolution for streaming, but if the stream resolution doesn't match the feed resolution, we get an error about the resolutions not matching. 此外,我们的印象是ffserver可以将输入格式重新编码为较低的分辨率以进行流式传输,但如果流分辨率与Feed分辨率不匹配,则会出现关于不匹配的分辨率的错误。

Has anyone ever managed to get this working correctly? 有没有人设法让这个正常工作? I've read about vlc being able to do something like this, but the vlc command lines are well nigh impenetrable. 我已经读过有关vlc能够做这样的事情,但vlc命令行几乎无法穿透。

Thanks! 谢谢!

Dominic 多米尼克

The problem is mp4. 问题是mp4。 There is no streaming in mp4, which is basically Moov-Atoms. mp4中没有流媒体,基本上是Moov-Atoms。 mp4 can wrap rtsp urls, but not around. mp4可以包装rtsp网址,但不能包围。 so switch to mpegts, or use rtsp with a sdp file for the connection details. 所以切换到mpegts,或者使用带有sdp文件的rtsp来获取连接细节。

To stream, I used the asf-format which worked well :) 为了流,我使用asf格式运行良好:)

Also I might add that the quality of the video probably will be pretty bad due to the 另外我可能会补充一点,视频的质量可能会非常糟糕

VideoBitRate 100

Which gives the server only 100 kbit/sec to serve the stream. 这使得服务器只能提供100 kbit / sec的流量。 When streaming in good quality I use 当我使用优质的流媒体时

VideoBitRate 1024

for a 640x480 Video. 对于640x480视频。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM