1. 如何搭建一个属于自己的直播平台 参考 http://www.open-open.com/lib/view/open1473231814360.html
nginx.conf 配置如下,
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
chunk_size 4000;
# HLS
application hls {
live on;
hls on;
hls_path /tmp/hls;
}
# MPEG-DASH is similar to HLS
application dash {
live on;
dash on;
dash_path /tmp/dash;
}
}
}
# HTTP can be used for accessing RTMP stats
http {
server {
listen 8080;
#location / {
# index index.html;
# root /usr/local/nginx/html;
#}
# This URL provides RTMP statistics in XML
#location /stat {
#rtmp_stat all;
# Use this stylesheet to view XML as web page
# in browser
#rtmp_stat_stylesheet stat.xsl;
#}
#location /stat.xsl {
# XML stylesheet to view RTMP stats.
# Copy stat.xsl wherever you want
# and put the full directory path here
#root /path/to/stat.xsl/;
#}
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
location /dash {
# Serve DASH fragments
root /tmp;
add_header Cache-Control no-cache;
}
}
}
player.html里面,改为 newplayer({"stream_url": "hls/life.m3u8","poster":"hls/poster.jpg"}); 这样就可以直播 hls里面的m3u8文件了,http://localhost:8080/player.html
运行时出现"the maximum number of files supported by select() is 64", 问题解决参考http://powertech.iteye.com/blog/2126745
这表示FD_SETSIZE的值比nginx配置文件中worker_connections指令所指定的值,加了--with-cc-opt=”-D FD_SETSIZE=4096”后就不会碰到这问题
3. ffmpeg build
build过程参考http://blog.youkuaiyun.com/zmlcool/article/details/8141097
a. Builing ffmpeg with libx264 enabled on cygwin, 参考http://stackoverflow.com/questions/4779040/builing-ffmpeg-with-libx264-enabled-on-cygwin
加上 --extra-ldflags="-L /usr/local/lib", 在运行configure的时候。
./configure --extra-ldflags="-L /usr/local/lib" --enable-libx264 --enable-libmp3lame --enable-libfaac --enable-gpl --enable-nonfree
b. build mp3lame
configure: error: cannot guess build type; you must specify one
解决办法:http://stackoverflow.com/questions/4810996/how-to-resolve-configure-guessing-build-type-failure
search for /usr/share/automake*/config.guess
check the latest version of automake
$ which automake
$ automake --version
find the appropriate automake folder in /usr/share/automake.1.11.1/config.guess
replace config.guess from your build tree with /usr/share/automake.1.11.1/config.guess
(The same may/is usually needed for config.sub.)