当前位置:网站首页>Push RTMP stream using ffmpeg
Push RTMP stream using ffmpeg
2022-06-23 02:05:00 【answer】
server setting
Turn off firewall or open port 1935,80 port
# Turn off firewall
systemctl stop firewalld.service
# Forbid ⽌firewall Boot up
systemctl disable firewalld.service
# View default anti ⽕ Wall state ( Show... When off notrunning, It will show running)
firewall-cmd --state
↵
install ffmpeg
1、 install yasm compiler
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
tar -xvf yasm-1.3.0.tar.gz
cd yasm-1.3.0/
./configure
make
make install
2、 install Ffmpeg
wget http://www.ffmpeg.org/releases/ffmpeg-3.4.tar.gz
tar -xvf ffmpeg-3.4.tar.gz
cd ffmpeg-3.4/
./configure --enable-shared --prefix=/usr/local/ffmpeg
make
make install
3. install yum
sudo yum install epel-release -y
sudo rpm –import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
4、 install FFmpeg and FFmpeg Development kit
sudo yum install ffmpeg ffmpeg-devel -y
5、 install libx264 Decoded packet
sudo yum install x264 x264-devel -y
6、 verification ffmpeg Is the installation successful
ffmpeg -version
install nginx
1、 Install the basic compiler ⼯ have
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel
2、 download rtmp modular
cd /usr/local/src # preservation ⽬ record
git clone https://github.com/arut/nginx-rtmp-module.git
3、 download nginx
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar zxvf nginx-1.18.0.tar.gz
4、 compile nginx
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/nginx-rtmp-module
make && make install
5、 Set startup script
vi /etc/init.d/nginx
Fill in ⼀ Below
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start() {
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload(){
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart(){
stop
start
}
configtest(){
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|
restart|configtest}"
RETVAL=1
esac
exit $RETVAL
Save after editing
# Change permissions
chmod 755 /etc/init.d/nginx
# Add to boot Item Configuration
chkconfig --add nginx
# Boot up
chkconfig nginx on
# Start command
service nginx start
#
service nginx stop
service nginx restart
6、 To configure nginx⽀ a rtmp and hls agreement
vim /usr/local/nginx/conf/nginx.conf
stay HTTP Label sibling add RTMP Configure the content
# RTMP To configure
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
}
}
}
5、 After modifying the configuration , Need to restart nginx The server
service nginx reload
ffmpeg Push flow ⾄Nginx
Ffmpeg Able to talk about data flow “ Push flow ” To the already built Nginx On the streaming server .
Nginx Has increased RTMP Agreed ⽀ a , So with the help of Ffmpeg After successful streaming , stay Nginx There are two kinds of video streams available on the server :RTMP flow .
We need to pay attention to , Whatever the flow , In the process of streaming, it is RTMP In the form of flow .
RTMP flow , Push flow ⾄live
ffmpeg -re -i {input-source} -vcodec libx264 -vprofile baseline -acodec aac -ar 44100 -strict -2 -ac 1 -f flv -s 1280x720 -q 10
rtmp://localhost:1935/live/test
perhaps
ffmpeg -i {input-source} -f flv -r 25 -s 1280*720 -an rtmp://localhost:1935/live/test
ffmpeg -i rtsp:// Camera login account : password @ camera ip:554 -f flv -r 25 -an rtmp://localhost:1935/hls/mystream
Streaming address
RTMP flow :
rtmp://localhost:1935/rtmplive/test
边栏推荐
- Uint8 serializing and deserializing pits using stringstream
- Dynamic address book in C language (add, delete, modify, check (duplicate), delete, sort and export)
- Operator part
- Exercise analysis summary
- Solve the problem that QQ flash photos cannot be saved
- 1. Mx6u bare metal program (1) - Lighting master
- Exercise analysis summary
- Vs Code inadvertently disable error waveform curve
- //1.15 putchar function
- 3. compilation and linking principle
猜你喜欢

Zabbix5 series - use temperature and humidity sensor to monitor the temperature and humidity of the machine room (XX)

There are animation characters interacting with each other when the mouse slides in the web page

JS advanced part

Detailed explanation of makefile usage

Dynamic address book in C language (add, delete, modify, check (duplicate), delete, sort and export)

Vs Code inadvertently disable error waveform curve

JS - single sign on

How to type Redux actions and Redux reducers in TypeScript?

An interesting example of relaxed memory models

JS rotation chart (Netease cloud rotation chart)
随机推荐
Branch and loop statements (including goto statements) -part1
Cut! 39 year old Ali P9 saved 150million
3. compilation and linking principle
Rebirth -- C language and the story I have to tell (text)
Bc116 xiaolele changed to digital
Module 8 job
Using WordPress to create a MySQL based education website (learning notes 2) (technical notes 1) xampp error1045 solution
How to download online printing on Web pages to local PDF format (manual personal test)
"Initial C language" (Part 2)
Detailed explanation of makefile usage
Mobile communication Overview - Architecture
On AI and its future trend | community essay solicitation
Cmake simple usage
Detailed explanation of clip attribute parameters
1. Mx6u bare metal program (1) - Lighting master
C language games: sanziqi (simple version) implementation explanation
Muduo simple usage
Quick sort method
//1.7 use of escape characters
pd. read_ CSV and np Differences between loadtext