使用 Raspberry Pi 上的 ffserver 从摄像机流式传输视频?

使用 Raspberry Pi 上的 ffserver 从摄像机流式传输视频?

我正在尝试使用 ffserver 从相机模块传输视频。想法是让raspivid输出 h264,然后让 ffmpeg/ffserver 传输它而无需重新编码。

我的服务器配置是

HTTPPort 8090
HTTPBindAddress 0.0.0.0
MaxHTTPConnections 8
MaxClients 4
MaxBandwidth 1000
CustomLog -
#NoDaemon

<Feed feed1.ffm>
    File /tmp/feed1.ffm
    FileMaxSize 5M
    ACL allow 127.0.0.1
</Feed>

<Stream live.flv>
    Feed feed1.ffm
    NoAudio
</Stream>

##################################################################
# Special streams
##################################################################
<Stream stat.html>
    Format status
    # Only allow local people to get the status
    ACL allow localhost
    ACL allow 192.168.0.0 192.168.255.255
</Stream>

# Redirect index.html to the appropriate site
<Redirect index.html>
    URL http://www.ffmpeg.org/
</Redirect>
##################################################################

我跑

ffserver -f server.conf &

进而

raspivid -t 0 -w 640 -h 480 -b 1024000 -fps 5 -ih -n -o - | \
  ffmpeg -i - -c:v copy -r 5 -an -f flv -override_ffserver \
  http://localhost:8090/feed1.ffm

然而 ffmpeg 抱怨

[flv @ 0x215e520] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
Thu Mar  3 02:58:36 2016 127.0.0.1 - - [POST] "/feed1.ffm HTTP/1.1" 200 276
av_interleaved_write_frame(): Connection reset by peer
[flv @ 0x215e520] Failed to update header with correct duration.
[flv @ 0x215e520] Failed to update header with correct filesize.
Error writing trailer of http://localhost:8090/feed1.ffm: Connection reset by peer

然后退出。

我该如何解决?

顺便说一句,我测试了raspivid一下ffmpeg

raspivid -t 0 -w 640 -h 480 -o - | ffmpeg -i - -c:v copy test.mkv

并且工作正常。

答案1

当 ffmpeg 的输出正在流式传输到 ffserver 时,设置输出格式将导致此错误。

您已在 ffserver 配置文件中指定了输出格式,因此请-f flv从 ffmpeg 命令中删除:

raspivid -t 0 -w 640 -h 480 -b 1024000 -fps 5 -ih -n -o - | \
ffmpeg -i - -c:v copy -r 5 -an -override_ffserver \
http://localhost:8090/feed1.ffm

相关内容