标签:com http class div code c log size t tar sp
OS:ubuntu 12.04
ffmpeg:N-47141-g4063bb2
x264:0.133.2334
a3ac64b
目标:
使用ffserver建立流媒体服务器
使用ffmpeg对本地文件流化(x264编码器)
使用ffplay播放
1 |
Port 8090 #访问端口 |
2 |
RTSPPort 554 #rtsp端口 |
3 |
BindAddress 0.0.0.0 #服务器地址绑定 |
4 |
MaxHTTPConnections 2000 #允许的最大连接数 |
5 |
MaxClients 1000 #最大的客户数 |
6 |
MaxBandwidth 10000 |
7 |
CustomLog - |
8 |
9 |
<Feed feed1.ffm> |
10 |
File /tmp/feed1.ffm |
11 |
FileMaxSize 1G |
12 |
ACL allow 127.0.0.1 #只允许本地连接 |
13 |
</Feed> |
14 |
15 |
################ asf ################ |
16 |
17 |
<Stream test .asf> |
18 |
Feed feed1.ffm |
19 |
Format asf #流媒体格式 |
20 |
VideoCodec libx264 #编码格式 |
21 |
VideoFrameRate 25 #桢率 |
22 |
VideoSize 1024x768 #播放大小 |
23 |
VideoBitRate 2M #码率 |
24 |
VideoBufferSize 10000000 |
25 |
VideoGopSize 24 |
26 |
StartSendOnKey |
27 |
Preroll 5 |
28 |
#使用x264编码时必须有下面的4个参数 |
29 |
VideoQMin 3 |
30 |
VideoQMax 31 |
31 |
AVOptionVideo flags +global_header |
32 |
AVOptionAudio flags +global_header |
33 |
NOAudio |
34 |
</Stream> |
35 |
36 |
################ flv ################ |
37 |
38 |
<Stream test .flv> |
39 |
40 |
Feed feed1.ffm |
41 |
Format flv |
42 |
43 |
NoAudio |
44 |
#AudioBitRate 32 |
45 |
#AudioChannels 2 |
46 |
#AudioSampleRate 44100 |
47 |
#AVOptionAudio flags +global_header |
48 |
#AudioCodec libmp3lame |
49 |
50 |
#NoVideo |
51 |
VideoBitRate 1024 |
52 |
VideoFrameRate 40 |
53 |
VideoSize 1280x720 |
54 |
VideoBufferSize 1000000 |
55 |
VideoCodec libx264 |
56 |
57 |
VideoQMin 3 |
58 |
VideoQMax 31 |
59 |
60 |
VideoBitRateTolerance 100 |
61 |
VideoGopSize 12 |
62 |
StartSendOnKey |
63 |
64 |
AVOptionVideo qmin 3 |
65 |
AVOptionVideo qmax 31 |
66 |
#AVOptionVideo quality good |
67 |
#AVOptionVideo cpu-used 0 |
68 |
AVOptionVideo flags +global_header |
69 |
#AVOptionVideo keyint_min 25 |
70 |
#AVOptionVideo qcomp 0.6 |
71 |
AVOptionVideo qdiff 4 |
72 |
#AVOptionVideo me_range 16 |
73 |
#Preroll 15 |
74 |
</Stream> |
75 |
76 |
################ rtsp ################ |
77 |
78 |
<Stream live.h264> |
79 |
Format rtp |
80 |
Feed feed1.ffm |
81 |
VideoCodec libx264 |
82 |
#VideoFrameRate 7 |
83 |
VideoBitRate 300 |
84 |
#VideoSize 480x272 |
85 |
VideoSize 352x288 |
86 |
#AVPresetVideo default |
87 |
AVPresetVideo superfast |
88 |
AVOptionVideo flags +global_header |
89 |
90 |
PixelFormat yuv420p |
91 |
AVOptionVideo me_range 4 |
92 |
AVOptionVideo qdiff 4 |
93 |
AVOptionVideo qmin 2 |
94 |
AVOptionVideo qmax 51 |
95 |
96 |
#MulticastAddress 224.124.0.1 |
97 |
#MulticastPort 5000 |
98 |
#MulticastTTL 1 |
99 |
100 |
NoAudio |
101 |
#AudioCodec libfaac |
102 |
#AudioBitRate 32 |
103 |
#AudioChannels 2 |
104 |
#AudioSampleRate 22050 |
105 |
#AVOptionAudio flags +global_header |
106 |
</Stream> |
107 |
108 |
################ html ################ |
109 |
110 |
<Stream stat.html> |
111 |
Format status |
112 |
# Only allow local people to get the status |
113 |
ACL allow localhost |
114 |
ACL allow 192.168.0.0 192.168.255.255 |
115 |
#FaviconURL http://pond1.gladstonefamily.net:8080/favicon.ico |
116 |
</Stream> |
117 |
118 |
# Redirect index.html to the appropriate site |
119 |
<Redirect index.html> |
120 |
URL http://www.ffmpeg.org/ |
121 |
</Redirect> |
1 |
ffserver -d -f ./ffserver.conf |
1 |
./ffmpeg -i ./1.mov -vcodec libx264 -qmin 3 -qmax 31 -qdiff 4 -me_range 16 -keyint_min 25 -qcomp 0.6 -b 9000K http://localhost:8090/feed1.ffm |
1 |
./ffmpeg -f video4linux2 -i /dev/video0 http://localhost:8090/feed1.ffm |
在ffmserver.conf中打开声音:
1 |
#NoAudio |
2 |
AudioBitRate 128kb |
3 |
AudioChannels 2 |
4 |
AudioSampleRate 44100 |
5 |
AVOptionAudio flags +global_header |
在输入中加入声音捕获:
1 |
ffmpeg -f v4l2 -i /dev/video0 -f alsa -i hw:0,0 http://localhost:8090/feed_tv.ffm |
1 |
./ffplay mmsh://localhost:8090/ test .asf |
2 |
./ffplay http://localhost:8090/ test .flv |
3 |
./ffplay rtsp://localhost:554/live.h264 |
git: https://github.com/lnmcc/multi_stream_server.git
基于ffmpeg的流媒体服务器,布布扣,bubuko.com
标签:com http class div code c log size t tar sp
原文地址:http://www.cnblogs.com/lidabo/p/3701071.html