如何搭建一个属于自己的直播平台 编译问题总结

本文介绍如何使用Nginx和FFmpeg搭建个人直播平台,包括Nginx配置文件详解及常见问题解决方案,如worker_connections设置、libx264编译等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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


2. nginx build on cygwin
运行时出现"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.)


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值