ffmpeg推流 av_dict_set 参数设置解析(降低延时、处理花屏、改善画面质量)(实时更新)
obs+nginx+ffmpeg搭建流媒体服务器(一)推流和拉流
使用FFmpeg工具进行推流、拉流、截图、变速、转换,及常见问题处理
-r rate set frame rate (Hz value, fraction or abbreviation)
可以用来测试的公网rtmp流,不需要搭建服务器可以直接播放
ffplay rtmp://mobliestream.c3tv.com:554/live/goodtv.sdp
苹果提供的测试源(点播):
ffplay http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/gear2/prog_index.m3u8
ffmpeg -list_devices true -f dshow -i dummy
ffmpeg -rtbufsize "1G" -r 30 -f vfwcap -i 0 -vcodec h264 -muxdelay 1 -preset ultrafast -tune zerolatency -f flv -g 5 -b:v 1000000 rtmp://127.0.0.1/live/test
ffplay rtmp://localhost:1935/live/test
worker_processes 1; #Nginx进程数,建议设置为等于CPU总核数
events {
worker_connections 1024; #工作模式与连接数上限
}
rtmp_auto_push on;
#RTMP服务
rtmp{
server{
listen 1935; #服务端口
chunk_size 4096; #数据传输块的大小
application vod{
play ./vod; #视频文件存放位置
}
application live{
live on; #开启直播
hls on; #开启hls直播。这个参数把直播服务器改造成实时回放服务器
#wait_key on; #对视频切片进行保护,这样就不会产生马赛克了
hls_path ./m3u8File; #切片视频文件存放位置(HLS,m3u8文件存放位置)
hls_fragment 2s; #每个视频切片的时长
hls_playlist_length 16s;
recorder myRecord{
record all manual;
record_suffix _.flv;
record_path ./rec; #指定录制的flv文件存放目录
}
#hls_continuous on; #连续模式
#hls_cleanup on; #对多余的切片进行删除
#hls_nested on; #嵌套模式
}
}
}
#HTTP服务
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
location /live_hls{
types{
#m3u8 type设置
application/vnd.apple.mpegurl m3u8;
#ts分片文件设置
video/mp2t ts;
}
#指向访问m3u8文件目录
alias ./m3u8File;
add_header Cache-Control no-cache; #禁止缓存
}
location /control{
rtmp_control all;
}
location /stat{
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl{
root ./nginx-rtmp-module-master;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}