Skip to content

Commit 591e1bc

Browse files
author
luowei
committed
添加了视频转码相关配制...
1 parent dcc5992 commit 591e1bc

File tree

13 files changed

+135
-57
lines changed

13 files changed

+135
-57
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/html/media
44
/nginx_b
55
/ffplay
6+
/ffmpeg

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,26 @@ nginx-rtmp-sample
22
=================
33

44
在windows下编译的带rtmp的nginx的配置实例..
5+
6+
7+
###Transcoding streams
8+
9+
Encoding\ffmpeg -i rtmp://127.0.0.1/live1/1080 -vcodec flv -acodec copy -s 360x360 -f flv rtmp://127.0.0.1/live3/480
10+
pause
11+
12+
Encoding\ffmpeg -i rtmp://127.0.0.1/live1/1080 -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:fore-cfr=1:keyint=60 -b:v 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://127.0.0.1/live2/720
13+
pause
14+
15+
--------
16+
17+
18+
ffmpeg -i rtmp://127.0.0.1/big/1080 -vcodec libx264 -preset faster -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://127.0.0.1/small/720
19+
20+
ffmpeg -i rtmp://127.0.0.1/big/1080 -vcodec libx264 -preset veryfast -b:v 2000k -maxrate 2000k -bufsize 2000k -s 1280x720 -sws_flags lanczos -r 60 -acodec copy -f flv rtmp://127.0.0.1/small/720
21+
22+
ffmpeg -i rtmp://127.0.0.1/big/1080 -vcodec flv -acodec copy -s 64x64 -f flv rtmp://127.0.0.1/small/720
23+
24+
--------
25+
###Stream your X screen through RTMP
26+
27+
ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 -f flv rtmp://127.0.0.1/live1/screen

batch_file/screen2stream.bat

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
rem Stream your X screen through RTMP
2+
3+
rem ..\ffmpeg\ffmpeg -f x11grab -follow_mouse centered -r 25 -s cif -i :0.0 -f flv "rtmp://127.0.0.1/live1/1080"
4+
5+
6+
rem ..\ffmpeg\ffmpeg -f x11grab -s 1600¡Á1200 -r 20 -i :0.0 -f alsa -ac 2 -i hw:0,0 -vb 20 -vcodec libx264 -threads 0 -acodec libmp3lame -ab 128k -ar 22050 -f flv ¡°rtmp://127.0.0.1/live1/1080¡±
7+
8+
rem ..\ffmpeg\ffmpeg -y -loglevel warning -f dshow -i video="screen-capture-recorder" -vf crop=690:388:136:0 -r 30 -s 962x388 -threads 2 -vcodec libx264 -vpre baseline -vpre my_ffpreset -f flv rtmp://127.0.0.1/live1/1080
9+
10+
rem ..\ffmpeg\ffmpeg -f dshow -i video="Virtual-Camera" -vcodec libx264 -tune zerolatency -b 900k -f mpegts rtmp://127.0.0.1/live1/1080
11+
12+
rem ..\ffmpeg\ffmpeg -f dshow -i video="screen-capture-recorder":audio="Stereo Mix (IDT High Definition" -vcodec libx264 -preset ultrafast -tune zerolatency -r 10 -async 1 -acodec libmp3lame -ab 24k -ar 22050 -bsf:v h264_mp4toannexb -maxrate 750k -bufsize 3000k -f mpegts rtmp://127.0.0.1/live1/1080
13+
14+
rem ..\ffmpeg\ffmpeg -f x11grab -s 1920x1200 -r 15 -i :0.0 -c:v libx264 -preset fast -pix_fmt yuv420p -s 1280x800 -threads 0 -f flv "rtmp://127.0.0.1/live1/1080"
15+
16+
rem the following command will generate a signal, and will stream it to the port 1234 on localhost:
17+
rem ..\ffmpeg\ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtmp://127.0.0.1/live1/1080
18+
19+
rem To play the stream with ffplay (which has some caveats, see above), run the command:
20+
rem ..\ffmpeg\ffplay rtmp://127.0.0.1/live1/1080
21+
22+
pause

batch_file/transcodin2x480.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
..\ffmpeg\ffmpeg -i rtmp://127.0.0.1/live1/1080 -vcodec flv -acodec copy -s 360x360 -f flv rtmp://127.0.0.1/live3/480
2+
pause

batch_file/transcodin2x720.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
rem ..\ffmpeg\ffmpeg -i rtmp://127.0.0.1/live1/1080 -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://127.0.0.1/live2/720
2+
3+
..\ffmpeg\ffmpeg -i rtmp://127.0.0.1/live1/1080 -vcodec libx264 -preset veryfast -b:v 2000k -maxrate 2000k -bufsize 2000k -s 1280x720 -sws_flags lanczos -r 60 -acodec copy -f flv rtmp://127.0.0.1/live2/720
4+
5+
pause

batch_file/video2steam.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
..\ffmpeg\ffmpeg -re -i "html\media\a.mov" -c:v copy -c:a copy -f flv rtmp://127.0.0.1/live1/1080
2+
rem ..\ffmpeg\ffplay rtmp://127.0.0.1/live1/1080
3+
4+
pause

conf/conf.d/rtmp5.conf

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#����������Լ���IPΪ��192.168.31.230���Է���IPΪ:192.168.31.232��
2+
3+
rtmp{
4+
server{
5+
listen 1935;
6+
chunk_size 8192;
7+
8+
application live1 {
9+
allow publish all;
10+
deny publish all;
11+
allow play all;
12+
deny play all;
13+
live on;
14+
15+
#exec ffmpeg -re -i rtmp://127.0.0.1:1935/live1/1080 -vcodec flv -acodec copy -s 32x32 -f flv rtmp://127.0.0.1:1935/live2/720;
16+
}
17+
application live2 {
18+
allow publish all;
19+
deny publish all;
20+
allow play all;
21+
deny play all;
22+
live on;
23+
}
24+
application live3 {
25+
allow publish all;
26+
deny publish all;
27+
allow play all;
28+
deny play all;
29+
live on;
30+
}
31+
32+
}
33+
}

conf/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ rtmp_auto_push on;
1515
include conf.d/http3.conf;
1616

1717
#rtmp config
18-
include conf.d/rtmp4.conf;
18+
include conf.d/rtmp5.conf;
1919

2020
#mail config
2121
#include conf.d/mail.conf

ffmpeg.7z

12.4 MB
Binary file not shown.

html/transcoding.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Transcoding Stream !</title>
5+
<style>
6+
7+
<!--
8+
div{float:left}
9+
.div-inline{ display:inline}
10+
div{ display:inline}
11+
-->
12+
13+
</style>
14+
</head>
15+
<body>
16+
<h1>Transcoding Stream !</h1>
17+
<script type="text/javascript" src="/jwplayer/jwplayer.js"></script>
18+
<script type="text/javascript">jwplayer.key="Y3ov5YsCxOP6Q4wTSY9lpbUZExQl8SNrNOYggw==";</script>
19+
20+
<div style="width:1120px;height:320px;overflow:auto;display:inline">
21+
<div style="width:360px;height:400px;margin:10px;float:left" id="myElement">Loading the player...</div>
22+
<div style="width:360px;height:400px;margin:10px;float:left" id="myElement2">Loading the player...</div>
23+
<div style="width:360px;height:400px;margin:10px;float:left" id="myElement3">Loading the player...</div>
24+
</div>
25+
<script type="text/javascript">
26+
jwplayer("myElement").setup({
27+
file:"rtmp://127.0.0.1/live1/flv:1080",
28+
height:240,
29+
width:360
30+
});
31+
jwplayer("myElement2").setup({
32+
file:"rtmp://127.0.0.1/live2/flv:720",
33+
height:240,
34+
width:360
35+
});
36+
jwplayer("myElement3").setup({
37+
file:"rtmp://127.0.0.1/live3/flv:480",
38+
height:240,
39+
width:360
40+
});
41+
</script>
42+
43+
</body>
44+
</html>

0 commit comments

Comments
 (0)