Teach Ubuntu how to build an RTSP video push service hand by hand

Live555 compilation and installation start

compile

wget http://www.live555.com/liveMedia/public/live555-latest.tar.gz tar xzf live555-latest.tar.gz cd live ./genMakefiles This parameter is made from the config.< suffix > in the current directory

Boot: CD MediaServer &&./live555MediaServer to print this out and install successfully.

[root@localhost MediaServer]#./ Live555MediaServer Live555 MediaServer version 0.89 (Live555 Streaming Media Library) Version 2016.06.26). Play streams from this server using the URL RTSP ://192.168.0.111/<filename> # <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 80 for optional RTSP-over-HTTP tunneling, or for HTTP live streaming (for indexed Transport Stream files only).)

Fill the video

Just put the video in the same path as live555mediaServer. Note that Live555 does not support MP4 format, you need to convert MP4 to MKV

ffmpeg -i xxx.mp4 xxx.mkv

At this time, use the playback software to play the address:

VLC RTSP: / / 192.168.0.111 / XXX. MKV or ffplay RTSP: / / 192.168.0.111 / XXX. MKV

Splash problem 01 buffer size

The first few seconds of the video may have a splash problem. I checked it on the Internet. The reason is that the buffer size is not enough. The buffer size needs to be modified

The video stream after Live555 push appears flower screen, check the source DynamicrtSPServer.cpp file, the source is as follows:  sms->addSubsession(MPEG4VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource)); } else if (strcmp(extension, ".264") == 0) { // Assumed to be a H.264 Video Elementary Stream file: NEW_SMS("H.264 Video"); OutPacketBuffer::maxSize = 100000; // allow for some possibly large H.264 frames sms->addSubsession(H264VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource)); } else if (strcmp(extension, ".265") == 0) { // Assumed to be a H.265 Video Elementary Stream file: NEW_SMS("H.265 Video"); OutPacketBuffer::maxSize = 100000; // allow for some possibly large H.265 frames sms->addSubsession(H265VideoFileServerMediaSubsession::createNew(env, fileName, reuseSource)); } else if (strcmp(extension, ".mp3") == 0) { // Assumed to be a MPEG-1 or 2 Audio file: NEW_SMS("MPEG-1 or 2 Audio")

The maximum buffer of 100000 bytes (100K) for H264 and H265 output packages is shown in red above. This is too small for HD video and must be changed to a larger buffer. Now change to 800000, for 1080P video playing with VLC, it will no longer appear splashed screen. -e ‘OutPacketBuffer:: MaxSize = ‘. If you need to modify the buff file, the problem may exist, but the video stag problem will be solved.

Floral screen problem 02 video format

I once tried to replace MKV with H264 format, but found that Live555 could not recognize the H264 format. I accidentally scanned the command prompt part, and found that the H264 format supported by Live555 needs to be extended to 264, changed the extension of H264 to 264, and found that the problem was solved. (But the solution wasn’t perfect). Video processing:

ffmpeg -i xxx.mp4 xxx.h264
mv xxx.h264 xxx.264

Copy the video to the same path as live555mediaServer, connect the RTSP address after startup, and find that the problem is solved. Small videos are generally OK (less than 10M), while large videos will have problems (more than 200M). When VLC is connected to the RTSP of large videos, there will still be a splash screen problem.

OpenCV Connect RTSP: OK FFPlay Connect RTSP: OK VLC Connect RTSP: Flower Screen

It is speculated that VLC is not compatible with some code stream data, or there is a problem with the video source. In short, two of the three playback tools are no problem, so you can think RTSP is OK.

Unable to push to the external network (Tencent cloud)

Using Tencent cloud host to build RTSP server, we found that the generated pull address IP is not the external network IP, but the IP beginning with 172. First: How does live555 get IP? Found in the live555 source groupsock/GroupsockHelper CPP live555 is port 15947 by connecting the machine to determine its own IP. Eth0 IP addr show eth0 IP addr show eth0

Why? Because Tencent cloud made a ghost, see the reference “Tencent cloud public network IP can not be accessed (public network IP can not be bound – listening) solution” to monitor 172 address, from the external network access must not be accessed, resulting in the external network can not pull the flow.

What should I do? If you let it monitor 0.0.0.0, how do you let it monitor 0?

Can be seen from the other posts, groupsock/GroupsockHelper. The function of the CPP ipv4AddressBits ourIPAddress (UsageEnvironment & env), the return value is the IP. Change its return value to 0.

After the modification, you need to recompile the source code.

Reference: live555 learnt 2 (get the local IP address method 1) : https://blog.csdn.net/wesleyl… Tencent cloud public IP cannot access (public IP cannot bind – listening) solution: https://blog.csdn.net/chenggo…

Error: The input frame data was too large for our buffer size

Modify 01: vim live/liveMedia MultiFramedRTPSource. CPP line76: increaseReceiveBufferTo (env, RTPgs – > socketNum (), 2000 * 1024); Modify 02: vim live/liveMedia StreamParser. CPP line26: BANK_SIZE 600000. Modify 03: vim live/liveMedia MediaSink. CPP line113: unsigned OutPacketBuffer: : maxSize = 600000; Modify 04: vim live/mediaServer DynamicRTSPServer. The modified CPP line 141146202208: OutPacketBuffer: : maxSize = 600000; Modification of 06: vim live/testProgs playCommon. CPP line116: unsigned fileSinkBufferSize = 600000; recompile

Live555: The input frame data was too large for our buffer size https://caibiao-lee.blog.csdn… Live555:MultiFramedRTPSink::afterGettingFrame1(): The input frame data was too large for our buffer:https://blog.csdn.net/xiongli…

reference

Do with VLC streaming media server: https://blog.csdn.net/redstar… Win: using the live555 structures, the simplest RTSP streaming media service: https://blog.csdn.net/huweiji… Use the live555 under Linux builds RTSP server:https://www.cnblogs.com/dpf-1… nginx+rtmp:https://hub.docker.com/r/data… nginx+rtsp:https://hub.docker.com/r/srnb… Ffmpeg + ffserver structures, RTSP server: https://blog.csdn.net/FPGATOM… Live555 push 1080 p flower screen: https://blog.csdn.net/youyicc… Live555 streaming media development of open source project – size changes on the server side frame rate and code rate size: https://www.cnblogs.com/pengk…