Vlc несколько rtsp одновременно
Recently had a task to open streams from 4 cameras over RSTP in a single windows using VLC. There is a bunch of howtos on net with relevant info and examples, but after trying many options non of them worked out of the box. Tweaking things here and there for a while I managed to come up with the working configuration, so I post it here for future reference and hopefully it will be helpful to anyone else.
My cameras stream dimensions is 1280×720 and as I want to fit 4 cameras on one screen, I will scale them in half to have screen size 1280×720 and each stream size 64×360.
First thing to do is to create some background image with exact size of the desired screen (1280×720 in my case) and save somewhere near (bg.jpg in my case).
Then we need to create a VLM config file (let it be cam.vlm.conf) to tell VLC about my streams and how to deal with them:
The input path to the camera streams as well as full path to the background image should be adjusted accordingly.
Somehow VLC doesn’t want to recognize mosaic-(height|width|order) parameters in the VLM file, so need to supply them inline as arguments when calling VLC. Now as we have VLM file ready, we can start the stream with the following command:
Adjust the path to the VLM file accordingly as well as mosaic order or whatever else you want. For me all of the above worked out perfectly well and I can see all my 4 cameras in single window.
Use the es module
Separate audio and video in two PS files:
Extract the audio track of the input stream to a TS file:
Stream in unicast the audio track on a port and the video track on another port (NOTE: This will not only work with VLC 0.8.6 or older - FIXME?): [Please check this]
- on the server side:
- on the client side:
- to receive the audio:
- to receive the video:
Stream in multicast the video and dump the audio in a file:
Note: You can also combine the es module with the other modules to set-up even more complex solution.
Step 1
Get VLC 2 or newer and install it on your computer.
Multiple streaming
Send a stream to a multicast IP address and a unicast IP address:
Display the stream and send it to two unicast IP addresses:
Send parts of a multiple program input stream:
This command sends the program of the input stream which id is 12345 to 239.255.12.42 and all video programs with id between 1234 and 2345 to 239.255.12.43.
Step 2
You now have to get a background for the mosaic.
An image is the easiest way to have a background that can be played as long as necessary. The image should be the same size as the video you want to create. Many image formats are supported (JPEG, PNG …).
It is also possible to use a video as a background for the mosaic, and superimpose other videos.
The frame rate of the background video or image will be the frame rate of the mosaic video. This is important since the default frame rate for image files is 10fps.
For videolan 1.x and earlier, use the fake: access method. The frames per second cannot be changed.
You should test it with VLC to see if it displays locally :
MMS / MMSH streaming to Windows Media Player
VLC media player can connect to this by using the following url: mmsh://server_ip_address:8080. Windows Media Player can connect to this by using the following url: mms://server_ip_address:8080.
Dual webcam with alphamask
You can then launch it with :
Keeping the stream open
The combination of :sout-keep and dst=gather:std mean that the stream is kept open and subsequent items are played through the same stream.
RTSP live streaming
Stream with RTSP and RTP:
- Run on the server:
- Run on the client(s):
More complex multi-transcoding example
Take a SDI input, and transcode it twice, once in HD, and one in SD and send both on udp.
Take a SDI input, and restreaming it once in raw and transcoding it for the second
- on the server, run:
- on the client(s), run:
Recording a live video stream:
Interfaces
Telnet interface
You can launch the telnet interface as a common interface using the command line:
The telnet interface can also be launched in the wxWindows interface:
The default port is 4212. The default password is "admin". These can be changed using --telnet-port and --telnet-password command line options. They can also be changed in the preferences panel when using the wxWindows interface in the Modules->interface->telnet section (check the Advanced options checkbox).
RTSP on-demand streaming
Step 3
You now need to configure VLC to get the 3 source streams and blend them on the background image.
Since VLC 2.0, the mosaic options must be passed in the command line, and not in the VLM file.
Alternatively, one can setup a mosaic directly from files using a VLM configuration file as the following :
To write the resulting stream to a file, the mosaic output line may also be replaced by :
Note that the source streams are network streams, which is likely to be the case if you're considering doing a mosaic.
Transcoding and multiple streaming
Transcode the input stream, display the transcoded stream and send it to a multicast IP address with the associated SAP announce and an unicast IP address:
Display the input stream, transcode it and send it to two unicast IP addresses:
Send the input stream to a multicast IP address and the transcoded stream to another multicast IP address with the associated SAP announces:
Configuration Files
A VLM configuration file is a list of command lines : one line corresponds to one command line.
To create a configuration file, just edit a text file and type a list of VLM commands. Beware of recursive calls: you can put a load (file) in a configuration file which can lead to recursive inclusion of the same file and result in VLC's crash.
You can automatically load a VLM configuration when launching VLC with the --vlm-conf command line option. The minimal command to make that work is:
Step 0
VLM Elements
Medias
A Media is composed with a list of inputs (the video and audio streams you want to stream), an output (how and where you want to stream them) and some options.
There are two types of medias:
- vod: A vod media is commonly used for Video on Demand. It will be launched only if a vod client asks for it.
- broadcast: A broadcast media is very close to a TV program or channel. It is launched, stopped or paused by the administrator and may be repeated several times. The client has no control over this media.
Schedules
A Schedule is a script with a date. When the schedule date is reached, the script is launched. There are several options available like a period or a number of repetitions.
6 thoughts on “VLC mosaic for multiple RSTP streams”
Hello.
Can you explain where to write the command “cvlc –vlm-conf /home/user/Desktop/cam.vlm.conf –mosaic-width 1280 –mosaic-order” 1,2,3,4 ” -mosaic-height 720 “?
You say “when you call VLC”.
Does this mean you have to add this command somewhere in the software shortcut?
Thank you.
– – – – –
Bonjour.
Pouvez-vous expliquer a quel endroit écrire la commande “cvlc –vlm-conf /home/user/Desktop/cam.vlm.conf –mosaic-width 1280 –mosaic-order “1,2,3,4” –mosaic-height 720″ ?
Vous dite “quand on appel VLC”.
Cela veux dire qu’il faut ajouter cette commande quelque part dans le raccourcis du logiciel?
Merci.I am not using shortcuts, but run direct commands in the shell. If you use shortcuts, then you probably need to edit them,
this is what I was looking for.
I need to mosaic for 16 inputs all are udp:// streams. All are on my local network so that I do not want to transcode in different codec.
Is that possible if I can see all of them in 16 windows without codec conversion. so video should not freeze
I haven’t touched this for ages, so not sure. Play around and see.
Is this for mac or windows? I need to set up something similar in mac and can’t figure it out.
ThanksThis was for Linux, not sure if will work same on Mac, but VLC is cross-platform, so I guess you can find a way.
If I had 1920×1080 cameras to work with, what would in the code provided above? Would the height and width of the streams need to be changed as well as the bg.jpg file?
Just play around with width/height and see how it changes for you.
Все равно не понятно, делаю все, как вы пишете, но плеер просто открывается, как обычно… подскажите, что значит слово “cvlc”? и правильно ли я делаю : я запускаю командную строку, указываю путь программы, и далее ввожу все эти параметры?
У меня всё это работало под линуксом, где была отдельная командна cvlc в добавок к обычной vlc.
Сдается мне у вас винда и там видимо всё подругому.Там говорится что вместо cvlc под виндой надо запускать vlc -I dummy –dummy-quiet
В общем, нужна софтина для просмотра видео сразу с нескольких IP-камер на одном экране.
Желательны:
1) реконнект при пропаже соединения с камерой,
2) кроссплатформенность,
3) бесплатность.Может, какой-нибудь VLC умеет в multiwindow playing? Как настроить тогда?
Ещё короче: ищу бесплатный аналог MacroScop
Тайловый wm+mplayer+скрипт на sh который запускает несколько копий mplayer, по одной на каждую камеру.
А вообще zoneminder, но оно web и требует отдельный сервер. и еще хранит видео в виде кучи jpg файлов, которые необходимо самому собирать через ffmpeg/mencoder, хотя может за 2 года что-то изменилось.
А как тогда переподключение раз в десять секунд при потере потока сделать?
mpv самостоятельно реконнектится, я с него сериалы смотрю. Есть ещё ключик --loop=inf, на случай если поток оборвётся.
mpv в мозаику не умеет, похоже
Имхо, этим должен заниматься оконный менеджер.
Можно как-то так:
mplayer tv:// -vo xv -tv driver=v4l:width=640:height=480:device=/dev/video9 -geometry 320x240+0+0 -noborder
при использовании vloopback, выведет картинку 320x240 в верхнем левом углу без оконного бордюра. Совершенно понятно, что следующую картинку следует показать, изменив лишь x-координату -geometry.
OldManClone ★★ ( 03.06.15 14:28:57 )
Последнее исправление: OldManClone 03.06.15 14:30:37 (всего исправлений: 1)Набросай себе табличную веб-страницу с флеш-плеером видеопотоков.
Ух. А флеш умеет в RTSP?
Первая ссылка в гугле выдала такое:
самое простое было бы встроить VLC, он жрёт вообще всё. Но Хром собрался выключить плагины, непонятно что с этим делать.
stevejobs ★★★★☆ ( 03.06.15 23:56:17 )
Последнее исправление: stevejobs 03.06.15 23:56:51 (всего исправлений: 1)это точно можно сделать средствами gstreamer, как именно - читай документацию, запускаешь из консоли gst-launcher и передаёшь в качестве параметра описание конвейера со всеми входящими потоками
Сегодня ночью выяснил что VLC не ресайзит потоки, поэтому нихрена не отображается. Попробую ещё с mpv и на худой конец с флешем.
Это еще очень сырой плеер.
Подскажите как настроить просмотр видео потока через vlc с помощью mosaic с нескольких ip камер одновременно. На роутере к которому подключены ip камеры, имеется статич. ip. Не получается настроить просмотр видео с камер. ОС ubuntu 16.04. С Уважением.
This is a small example about how to use VLC media player to create a mosaic. What we basically want is a video mosaic mixing 3 video channels (channels 1, 2 and 3) on a background image (background.jpg) and streaming the resulting video on the network. Note that we will also be streaming the 3 sound tracks from channels 1, 2 and 3 in the same MPEG-TS stream.
Starting with VLC 0.8.5-test2, the HTTP interface features a "Mosaic wizard". You might want to use it if you have no knowledge of VLC command line usage.
Other neat examples :
More complex transcoding example
Stream a SDI card to H.264 and AAC in TS on UDP
Multiple streams
Simple broadcasting
- if you are using direct show and are getting "control : unknown error" try "setup channel enabled"
Scheduled broadcasting
Command line syntax
Command lines
Media Properties
Note: Except the "append" property, all properties can be followed by another one.
- input (input_name): Add an input to the end of the media's input list.
- output (output_name): Define the media's output. The syntax is the same as the vlc ":sout=. " vlc option but you do not have to put the ":sout=. " string. See Documentation:Streaming HowTo/Advanced Streaming Using the Command Line for more information concerning stream outputs (sout). Note: You do not have to specify an output for vod elements.
- option (option_name)[=value] : Adds the (option_name) to the media option list. The syntax is equivalent to the ":(option)=. " option , but you do not have to put the ":" string. Options are global: they are applied to all inputs of the media.
- enabled|disabled: Enable or Disable the media. If a media is disabled, it cannot be streamed, paused, launched by a schedule, or played as VoD.
- loop|unloop (broadcast only): If a media with the "loop" option receives the "play" command, it will automatically restart to play the input list once the end of the input list is reached. Note: loop|unloop is only used for broadcast media types.
- mux (mux_name): This option should only be specified if you want the elementary streams to be sent encapsulated instead of raw. The (mux_name) should be specified as a four characters length identifier such as mp2t for MPEG TS or mp2p for MPEG PS. See Documentation:Streaming HowTo/Streaming, Muxers and Codecs. Note: The mux property is only used for vod media types.
Schedule Properties
- enabled|disabled: A disabled schedule will never be launched.
- append (command_until_rest_of_the_line): Add a command to the command line lit. The command line can be every command VLM can understand. Note: The rest of the line will be considered as part of the command line. You cannot put another option after the append one.
- date (year)/(month)/(day)-(hour):(minutes):(seconds)|now: Specify the first date the schedule should be launched. You can specify a date using the (year)/(month)/(day)-(hour):(minutes):(seconds) format (example: 2004/11/16-00:43:12) or using the now keyword. If now is used, the schedule will be launched as soon as possible (i.e. as soon as it is enabled) and the current date will be used as the first date of the schedule.
- period (years_aka_12_months)/(months_aka_30_days)/(days)-(hours):(minutes):(seconds): Specify the period of time a schedule must wait for launching itself another time. (Months are considered as 30 days, Years as 12 months) If a period is specified without a repeat property, the schedule will be launched endlessly.
- repeat (number_of_repetitions): Specify the number of times the schedule will be launched again. For example, if a schedule has repeat 11 it will be launched 12 times.
Control Commands
- play: Stat a broadcast media. The media begins to launch the first item of the input list, then launches the next one and so on. (like a play list)
- pause: Put the broadcast media in paused status.
- stop: Stop the broadcast media.
- seek (percentage): Seek in the current playing item of the input list.
Other examples
Video On Demand
Basic example
First launch the vlc
- 12 is the value of the TTL (Time To Live) of your IP packets (which means that the stream will be able to cross 11 routers).
- telnet launches the telnet interface of the vlc.
- videolan is the password to connect to the telnet interface.
- 0.0.0.0 is the host address.
- 554 is the port on which you stream.
Then you connect to the vlc telnet interface and create the vod object. You can connect to vlc telnet interface by use the terminal.
and create the vod object.
You can access to the stream with:
- server is the address of the streaming server (IP or DNS)
Advanced example
You can also specify options, a muxer, or an additional output chain that will be prepended to the RTP output used by VoD (e.g. to enable transcoding).
Note: make sure to enter the corresponding commands before the VoD media is enabled, or before you setup the input.
This page is part of official VLC media player Documentation (User Guide • Streaming HowTo • Hacker Guide • Modules)
Please read the Documentation Editing Guidelines before you edit the documentationPermission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Transcode a stream to Ogg Vorbis with 2 channels at 128kbps and 44100Hz and save it as foobar.ogg:
Transcode the input stream and send it to a multicast IP address with the associated SAP announce:
Display the input stream, transcode it and send it to a multicast IP address with the associated SAP announce:Transcode the input stream, display the transcoded stream and send it to a multicast IP address with the associated SAP announce:
To receive the input stream that is being multicasted above on a client:
Using VLC as a reflector
Taking a UDP input and resending it once raw via IPv6 multicast, and once in HLS
This page is part of official VLC media player Documentation (User Guide • Streaming HowTo • Hacker Guide • Modules)
Please read the Documentation Editing Guidelines before you edit the documentationPermission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
Step 4
And now, the right command to launch VLC :
Examples
This section provides several small vlm configuration files.
Читайте также: