使用ffplay播放rtmp直播live视频php
转载请注明原文:http://blog.sina.com.cn/s/blog_5fde6089010198a9.html 做者:shuiyourenhtml
最简单效率的方法是:git
一、下载并安装homebrew;github
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"ruby
brew doctor (检测是否安装成功)curl
二、执行如下命令:ide
brew install openssl (经过查看Makefile可知,rtmpdump须要openssl支持)测试
brew rtmpdump (通过测试,必需要有librtmp,自带的rtmp只能支持播放非直播的rtmp,而添加librtmp以后是能够播放直播的视频)字体
sudo chmod a+w /usr/local/Cellar/rtmpdump/2.3/include/librtmp/rtmp.h(须要修改权限,具体哪一个没具体研究,都改了吧)ui
sudo chmod a+w /usr/local/include/librtmp
brew install rtmpdump(若发现未能link成功,则brew link rtmpdump ;若是之前安装过则要进行删除操做:sudo rm -f $(brew link --overwrite --dry-run rtmpdump | grep "^[^W]");)
三、进行ffmpeg的安装(查看ffplay须要SDL-devel 的支持,参考出处忘了,由于文章是隔天写的,抱歉。sudo rpm -i SDL-devel-1.2.15-1.x86_64.rpm.txt,地址:http://www.libsdl.org/release/SDL-devel-1.2.15-1.x86_64.rpm;固然,前提是你mac上安装了rpm,rpm下载地址:http://rpm5.org/files/rpm/rpm-5.1/BINARY/RPM5-20080414.dmg,注:我当时好像使用的是SDL源码安装,故未用到rpm,sdl源码地址:http://www.libsdl.org/release/SDL-1.2.15.tar.gz):
进入ffmpeg文件夹,进行以下操做:
./configure --disable-yasm --enable-librtmp --enable-decoder=h264
make
sudo make install
四、好了,能够进行rtmp直播了:
ffplay -i "rtmp://192.168.1.13/room1/room1 live=1"
如下灰色字体文字实现方法还没有实现(多是参数缘故),待研究:
咱们在使用ffmpeg支持rtmp时,常遇到如下几个问题:
一、ERROR: librtmp not found
二、ld: library not found for -lrtmp (请见步骤三、4)
三、pkg-config: command not found
四、Perhaps you should add the directory containing ‘librtmp.pc’ (注:须要有 /usr/local/lib/pkgconfig/librtmp.pc)
我使用的可行解决方案步骤:
一、首先下载解压ffmpeg;
二、下载librtmp:http://rtmpdump.mplayerhq.hu/ (参考:http://bbs.chinavideo.org/viewthread.php?tid=8002)
三、cd至rtmpdump目录,将文件/rtmpdump-2.3/librtmp/makefile中的-soname 改成 -dylib_install_name;(这里可能会涉及到权限问题,此时能够切换为root进行操做,参考:http://blog.yikuyiku.com/?p=3150,另外可能须要安装pkg-config,参考:http://hi.baidu.com/newdreamllc/item/3be0780d186f0e7abfe97ea4,由于库是经过pkg-config寻找的,下载地址http://code.google.com/p/rudix/downloads/detail?name=pkg-config-0.25-1.dmg&can=2&q=label:Rudix-2011。还有一种不经过pkg-config的方法我没试过:http://d2100.com/questions/53589或http://blog.csdn.net/glcdw/article/details/7558303)
四、make && make install;