FFmpeg交叉编译方法
FFmpeg-X264交叉编译方法
FFmpeg交叉编译方法(生成FFplay)
一、确保nginx.conf文件配置好了
worker_processes 1;
events {
worker_connections 1024;
}
rtmp {
server {
listen 1935;
application camera {
live on;
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
add_header 'Access-Control-Allow-Origin' '*';
root html;
index index.html index.htm;
}
location /live {
flv_live on;
}
location /flv {
add_header 'Access-Control-Allow-Origin' '*';
flv_live on;
chunked_transfer_encoding on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
二、确保Nginx服务在运行状态
三、查看运行Nginx服务所在设备的IP地址
ifconfig
四、资源准备:本地视频文件、外部RTMP流地址
五、执行命令开始推流(假设设备IP地址:192.168.1.50)
1、推送本地视频流
ffmpeg -re -i input.mp4 -vcodec copy -f flv -y rtmp://192.168.1.50:1935/camera/test
2、循环推送本地视频流
ffmpeg -re -stream_loop -1 -i input.mp4 -vcodec copy -f flv -y rtmp://192.168.1.50:1935/camera/test
3、转发外源RTMP流
ffmpeg -re -i rtmp://192.168.1.150:1935/stream/test -vcodec copy -f flv -y c
RTMP流地址解析:
首先列出nginx.conf配置信息:
rtmp {
server {
listen 1935;
application camera {
live on;
}
}
}
上面用到的RTMP流地址:
rtmp://192.168.1.50:1935/camera/test
nginx服务器IP地址: 192.168.1.50
nginx-rtmp服务端口: 1935
rtmp-application名称: camera
自定义rtmp流名称: test
HTTP流地址解析:
首先列出nginx.conf配置信息:
server {
listen 8080;
server_name localhost;
HTTP拉流地址:
http://192.168.1.50:8080/flv?port=1935&app=camera&stream=test
nginx服务器IP地址: 192.168.1.50
nginx-http服务端口: 8080
nginx-rtmp服务端口: 1935
rtmp-application名称: camera
自定义rtmp流名称: test
到此,有客观应该会问:说好的http推流呢?
其实HTTP/FLV推流已由nginx服务处理推出。
查看软件:VLC 、PotPlayer等等
此处以VLC为例:
拉取RTMP视频流
拉取HTTP视频流
特别说明:
nginx服务http默认的端口号为80,此处我修改为8080,以防与系统其他程序的端口号相冲突。
当端口号为80时,HTTP拉流地址可以这样写:
http://192.168.1.50/flv?port=1935&app=camera&stream=test
http://192.168.1.50:80/flv?port=1935&app=camera&stream=test
而当端口号不是80时,HTTP拉流地址必须指定端口号,否则拉流失败