We will need to download codecs, so we connect the debian-multimedia repository:
- mkdir ~ user / install
- cd ~ user / install
Add a line to /etc/apt/sources.list
- wget http: // www.debian-multimedia.org / pool / main / d / debian-multimedia-keyring / debian-multimedia-keyring_2008.10.16_all.deb
- dpkg -i . / debian-multimedia-keyring_2008.10.16_all.deb
We will need to install a lot of packages before we go directly to VLC. I tried to list everything here, but maybe something is not enough, in this case the missing ones will have to be delivered.
- deb http: // www.debian-multimedia.org stable main non-freel.deb
All the rest will be set from source to be able to enable or disable certain options. Let's start with the latest version of ffmpeg:
- apt-get update
- apt-get install yasm make subversion xcb libxcb1-dev libxcb-shm0-dev libxcb-keysyms0-dev \
- libavformatcvs51 libavcodeccvs51 libavcodeccvs51-dev libavformatcvs51-dev libavutilcvs49-dev \
- autoconf g ++ gcc liba52-0.7.4-dev libdvbpsi3-dev libdvbpsi3 libfaad-dev libfaac-dev libfribidi-dev \
- libavutilcvs49 libavahi-client3 libavahi-common-dev libpostproccvs51-dev libswscalecvs0-dev \
- libswscalecvs0 libxvidcore4-dev libxvidcore4 libx264-dev libx264-54 automake1.9 libgcrypt11-dev \
- liblame-dev liblua5.1- 0 -dev libmad0-dev libmpeg2- 4 -dev libogg-dev libvorbis-dev zlib1g-dev \
- libvcdinfo-dev libiso9660-dev libcddb2-dev libflac-dev libx264-dev x264
If you plan to work with the h264 codec, then you can configure ffmpeg with the options
- svn checkout svn : // svn.ffmpeg.org / ffmpeg / trunk ffmpeg
- cd ffmpeg
- . / configure
- make
- make install
- cd ..
./configure --enable-libx264 --enable-gpl
Next, we need the very necessary live555 streaming media library, it is through it that our VLC player will work with RTSP.Now go to the VLC player itself. Go to http://download.videolan.org/pub/videolan/vlc/latest/ and see which is the latest version, then download and unpack the source. In my case it looked like this:
- wget http: // www.live555.com / liveMedia / public / live555-latest.tar.gz
- tar zxvf. / live555-latest.tar.gz
- cd live
- . / genMakefiles linux
- make
- cd ..
The VLC configuration is the most creative part, we will try to make it so that we have what we need and nothing extra.
- wget http: // download.videolan.org / pub / videolan / vlc / latest / vlc-1.1.0.tar.bz2
- bzip2 -d vlc-1.1.0.tar.bz2
- tar xvf. / vlc-1.1.0.tar
- cd vlc-1.1.0
In the last line, we indicate the paths to the ffmpeg and live555 sources, with which we worked in the previous steps. If you plan to use the player as root, you need to add the
- . / configure --enable-release --enable-faad --disable-dbus --disable-hal \
- --disable-remoteosd --disable-qt4 --disable-skins2 --disable-activex \
- --disable-v4l2 --disable-libv4l2 --disable-x11 --disable-xvideo --disable-glx \
- --disable-opengl --disable-visual --disable-nls --disable-mozilla \
- --enable-realrtsp --enable-flac --disable-lua --prefix = / usr \
- --with-live555-tree = / home / user / install / live --with-ffmpeg-tree = / home / user / install / ffmpeg
--enable-run-as-root
key if the h264 codec is --enable-x264
. Next, compile and install the player. This procedure takes a long time. In my case there was always something missing to compile, I tried to enumerate all the necessary libraries, but in any case, everything can change from version to version, so watch for errors and deliver what it asks.Software installation is complete, all we have to do is launch the player with the necessary parameters. In general, the VLC player is unique in its flexibility. The player will work for us in two simultaneous streams: the first will receive video from the camera via RTSP multiplex it in MPEG TS and send it to localhost: 8001, the second will take the result from localhost: 8001, compress, encode, package into an FLV container and give it to HTTP on port 8080. We make 2 files to run these streams, respectively:
- make
- make install
Paste the lines in stream1.sh:
- mkdir ~ user / scripts
- touch ~ user / scripts / stream1.sh
- touch ~ user / scripts / stream2.sh
Here we have indicated to the player what to lose. The stream from the rtsp: //10.0.03: 554 / camera1.sdp camera was selected as the source, indicated the size of the buffer and immediately made the first stage our movie silent (
- #! / bin / sh
- vlc -vv rtsp: // 10.0.0.3: 554 / camera1.sdp - rtsp-caching = 100000 --no-sout-audio - sout \
- '#std {access = http, dst = 127.0.0.1: 8001, mux = ts}'
--no-sout-audio
). The result will be given to this stream at http://127.0.0.1:8001V stream2.sh insert the lines:The second stream takes http://127.0.0.1:8001, has its own cache, overwrites it (vb - bitrate, fps - FPS) and distributes it via HTTP on port 8080 as view01.flv file. If there are several interfaces on the server, then you can also specify in dst the specific ip address of the interface on which you need to distribute. In commercial operation, the streams must be run as a background and not tied to the console, in our example, we will launch them simply in two consoles. vlc should fill the buffer some time, and then pass in the regular mode. The duration of the filling depends on the size of the cache (
- #! / bin / sh
- vlc -vv http: // 127.0.0.1: 8001 --loop --http-caching = 10,000 --sout \
- '#transcode {vcodec = FLV1, vb = 512, fps = 15}: std {access = http {mime = video / x-flv}, dst =: 8080 / view01.flv, mux = ffmpeg {mux = flv}} '
--rtsp-caching
and --http-caching
respectively). We will need to create a page with the player. For simplicity, we will do it on the same server.
- apt-get install apache2
Next, download Flow Player. The developer’s site has a settings wizard. To use it, you need to register. The wizard is available at http://flowplayer.org/setup/index.html . Since we have a live stream and the camera displays the current time directly into the picture, the player should be minimalistic. Turning off everything except the “Fullscreen” button, downloading the player and unpacking the contents of the archive into the / var / www folder on our server. So that everything was perfect, I also renamed the swf and js files to player.swf and player.js, respectively. I would not write about this fact if I had not forgotten how they were called before. Therefore, in the text I will also use my new names. So, create an html page
- cd / var / www /
We save in it the following text:
- touch / var / www / index.html
Everything is ready, go to the browser on http://10.0.0.2/ and watch the broadcast.
- < html > < head >
- < meta http-equiv = "content-type" content = "text / html; charset = UTF-8" > < script type = "text / javascript" src = "/player.js" > < / script >
- < title > Camera View 1 < / title >
- < / head >
- < body >
- < h1 > Camera number 1 < / h1 >
- < a
- href = "http://stream.kubsu.ru:8080/view01.flv"
- style = "display: block; width: 520px; height: 330px; margin: 10px auto;"
- id = "player" >
- < / a >
- < script >
- flowplayer ("player", "/player.swf");
- < / script >
- < / body > < / html >
Source: https://habr.com/ru/post/98064/
All Articles