阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

Ubuntu 16.04下FFmpeg搭建简易监控环境

126次阅读
没有评论

共计 2612 个字符,预计需要花费 7 分钟才能阅读完成。

本文中的配置文件部分非本人原创,而是借鉴了他人配置文件后,修改的实际操作中使用的配置文件。本次实践对系统要求不严格,使用普通的 Ubuntu 版本即可,不需要 Server 版本,而且本人也只是在宿舍局域网中实现,有条件的朋友可以在公网中实现,成功的话可以与我分享一下,哈哈。

!本文中的命令都在终端下输入!
1. 安装软件,命令:
sudo apt-get install ffmpeg

2. 备份原始配置(防止配置文件修改错误,备份以防万一),命令:
sudo mv /etc/ffserver.conf /etc/ffserver.conf_backup

3. 编辑配置,把它改为下面的内容,命令:
sudo gedit /etc/ffserver.conf

配置文件:

Port 8090
# bind to all IPs aliased or not
BindAddress 0.0.0.0
# max number of simultaneous clients
MaxClients 100
# max bandwidth per-client (kb/s)
MaxBandwidth 16000
# Suppress that if you want to launch ffserver as a daemon.
#NoDaemon

<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 10M
</Feed>

# 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 30
# generally leave this is a large number
VideoBufferSize 160000
# another quality tweak
VideoBitRate 500
# quality ranges – 1-31 (1 = best, 31 = worst)
VideoQMin 1
VideoQMax 5
VideoSize 352×288
# this sets how many seconds in past to start
PreRoll 0
# wecams don’t have audio
Noaudio
</Stream>

# ASF output – for windows media player
<Stream test.asf>
# the source feed
Feed feed1.ffm
# the output stream format – ASF
Format asf
VideoCodec msmpeg4
# this must match the ffmpeg -r argument
VideoFrameRate 30
# generally leave this is a large number
VideoBufferSize 160000
# another quality tweak
VideoBitRate 500
# quality ranges – 1-31 (1 = best, 31 = worst)
VideoQMin 1
VideoQMax 5
VideoSize 352×288
# this sets how many seconds in past to start
PreRoll 0
# wecams don’t have audio
Noaudio
</Stream>

ps. 代码部分,大家也可以尝试修改,达到自己最满意的效果

4. 保存修改完代码配置文件后,运行,命令:ffserver

5. 再开一个终端操作,或者’ctrl+z’让 ffserver 在后台运行,命令:
ffmpeg -s 352×288 -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm

6. 同一局域网内的另一台电脑上, 用支持网络的播放器 (Windows Media Player) 打开:
mms://xx.xx.xx.xx:8090/test.asf
(xx.xx.xx.xx 为装有 ubuntu 的 ip 或域名)
这时候,在播放器上,就可以实时看到 ubuntu 摄像头所拍摄的画面了。

我在本次实践中,体会到了无论是对配置文件的修改,还是对 ffmpeg 的了解,功夫都还大大不够,
本文旨在分享基础方法,也欢迎大家来指正本文诸多不足的地方

! 问题注意!
有些朋友在操作时,发现自己电脑上不存在 /dev/video0 这个驱动文件
这里我推荐一个小办法,ubuntu 自带了一个 cheese(茄子大头贴),使用一下这个软件,等屏幕上显示出拍摄画面时,/dev/video0 就已经自动创建了

Linux 下编译 FFmpeg 之下载源文件并编译 http://www.linuxidc.com/Linux/2012-02/54565.htm

Linux 编译升级 FFmpeg 步骤 http://www.linuxidc.com/Linux/2013-08/88190.htm

在 Ubuntu 下安装 FFmpeg http://www.linuxidc.com/Linux/2012-12/75408.htm

Linux 下编译 FFmpeg 支持 x264, x265  http://www.linuxidc.com/Linux/2016-04/129858.htm

VS2013 编译 FFmpeg  http://www.linuxidc.com/Linux/2016-08/134102.htm

在 Mac OS X 环境中从源代码编译安装 FFmpeg  http://www.linuxidc.com/Linux/2015-12/126093.htm

Ubuntu 12.04 下编译 ffmpeg  http://www.linuxidc.com/Linux/2013-02/78857.htm

Ubuntu 14.04 下 PPA 安装 FFmpeg 2.2.2  http://www.linuxidc.com/Linux/2014-05/101322.htm

FFmpeg 常用基本命令  http://www.linuxidc.com/Linux/2016-10/136545.htm

FFmpeg 的详细介绍:请点这里
FFmpeg 的下载地址:请点这里

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-02/141091.htm

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计2612字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中