直播源制作

210 阅读1分钟

Nginx+FFMPEG

  1. 安装Nginx
    Mac安装:命令行  brew install nginx-full --with-rtmp-module
    启动服务:start nginx
    验证:localhost:8080

  2. 安装ffmpeg
    Mac安装:brew install ffmpeg
    验证:ffmpeg

  3. 配置Nginx
    nginx.conf: 
    #rtmp{ # server{ # listen 1935; # chunk_size 4000; # #RTMP 直播流配置 # application rtmplive{ # live on; # max_connections 1024; # } # #HLS 直播流配置 # application hls{ # live on; # hls on; # hls_path D:\video # hls_fragment 5s; # } # } #}

    server{location /hls{ # types{ # application/vnd.apple.mpegurl m3u8; # video/mp2t ts; # } # root D:\video; # add_header Cache-Control no-cache; # }}

  4. 准备视频
    rtmp:ffmpeg -re -i 视频.MP4 -vcodec libx264 -acodec acc -f flv rtmp://localhost:1935/trmplive/rtmp
    hls:ffmpeg -re -i 视频.MP4 -vcodec libx264 -acodec acc -f flv rtmp://localhost:1935/hls/stream
    在vlc视频播放器里面选择network open 输入:rtmp://localhost:1935/trmplive/rtmp访问
    hls播放:Safari里面访问rtmp://localhost:1935/hls/stream

  5. 利用ffmpeg推流