live555 + ffmpeg进行录像

live555 + ffmpeg进行录像

安装live555

官方教程及下载地址:http://www.live555.com/liveMedia/#config-unix

下载live555-latest.tar.gz文件,并解压。

打开live目录,运行如下指令:

1
./genMakefiles <os-platform>

\<os-platform>为当前平台,如linux系统则输入

1
./genMakefiles linux

然后make即可(也可以make后进行make install将执行文件加入/usr/local/bin目录)

测试读取本地流文件

进入live目录下的mediaServer文件夹,将需要读取的留文件surfing.265放在该文件夹下,命令端输入

1
./live555MediaServer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[heroin@localhost mediaServer]$ ./live555MediaServer 
LIVE555 Media Server
version 0.90 (LIVE555 Streaming Media library version 2017.06.04).
Play streams from this server using the URL
rtsp://192.168.18.132:8554/<filename>
where <filename> is a file present in the current directory.
Each file's type is inferred from its name suffix:
".264" => a H.264 Video Elementary Stream file
".265" => a H.265 Video Elementary Stream file
".aac" => an AAC Audio (ADTS format) file
".ac3" => an AC-3 Audio file
".amr" => an AMR Audio file
".dv" => a DV Video file
".m4e" => a MPEG-4 Video Elementary Stream file
".mkv" => a Matroska audio+video+(optional)subtitles file
".mp3" => a MPEG-1 or 2 Audio file
".mpg" => a MPEG-1 or 2 Program Stream (audio+video) file
".ogg" or ".ogv" or ".opus" => an Ogg audio and/or video file
".ts" => a MPEG Transport Stream file
(a ".tsx" index file - if present - provides server 'trick play' support)
".vob" => a VOB (MPEG-2 video with AC-3 audio) file
".wav" => a WAV Audio file
".webm" => a WebM audio(Vorbis)+video(VP8) file
See http://www.live555.com/mediaServer/ for additional documentation.
(We use port 8000 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).)

根据输出rtsp://192.168.18.132:8554/<filename>,重新打开另一命令窗口做如下输入(保持当前窗口运行状态)

1
ffplay rtsp://192.168.18.132:8554/surfing.265

即可展示流文件中的视频。

录像

1
ffmpeg -loglevel debug -i "rtsp://172.16.1.100/1.sdp" -vcodec libx264 -subq 5 -g 250 -qmin 10 -qmax 51 -i_qfactor 0.71 out.mp4