Difference between revisions of "VLC HowTo/Make a mosaic"

From VideoLAN Wiki
Jump to navigation Jump to search
 
(36 intermediate revisions by 15 users not shown)
Line 1: Line 1:
 +
{{See also|Documentation:Modules/mosaic}}
 +
{{howto|set up a mosaic of a few videos or stream like a TV portal}}
 +
 
==VLC mosaic howto==
 
==VLC mosaic howto==
  
This is a small example about how to use VLC 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_image.uyvy) 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.
+
This is a small example about how to use {{VLC}} 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.png) 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.
+
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.
  
http://people.via.ecp.fr/~dionoea/videolan/mosaic1.png
+
https://web.archive.org/web/20070303011022/https://people.via.ecp.fr/~dionoea/videolan/mosaic1.png
  
 
Other neat examples :
 
Other neat examples :
 +
* [https://web.archive.org/web/20081011005351/https://people.via.ecp.fr/~dionoea/videolan/mosaic2.jpg 12 video mosaic]
 +
* [https://web.archive.org/web/20070404201658/https://people.via.ecp.fr/~dionoea/videolan/mos1.png 20 video mosaic]
 +
* [https://web.archive.org/web/20081011005318/https://people.via.ecp.fr/~dionoea/videolan/mos2.png 20 video mosaic]
  
[http://people.via.ecp.fr/~dionoea/videolan/mosaic2.jpg 12 video mosaic]
+
===Step 0===
  
[http://people.via.ecp.fr/~dionoea/videolan/mos1.png 20 video mosaic]
+
Read the [https://web.archive.org/web/20091228140745/https://www.videolan.org/doc/streaming-howto/en/streaming-howto-en.html VLC streaming howto]<sup class="plainlinks">[https://web.archive.org/web/20100106011007/https://www.videolan.org/doc/streaming-howto/fr/streaming-howto-fr.html &#x5B;fr&#x5D;]</sup> ([https://web.archive.org/web/20091227093342/https://www.videolan.org/doc/streaming-howto/en/ch03.html chapters 3]<sup class="plainlinks">[https://web.archive.org/web/20100117041601/https://www.videolan.org/doc/streaming-howto/fr/ch03.html &#x5B;fr&#x5D;]</sup> and [https://web.archive.org/web/20091230100742/https://www.videolan.org/doc/streaming-howto/en/ch05.html 5]<sup class="plainlinks">[https://web.archive.org/web/20100112081440/https://www.videolan.org/doc/streaming-howto/fr/ch05.html &#x5B;fr&#x5D;]</sup> concerning command line and VLM usage in VLC) : [https://web.archive.org/web/20091227093342/https://www.videolan.org/doc/ www.videolan.org/doc]
  
[http://people.via.ecp.fr/~dionoea/videolan/mos2.png 20 video mosaic]
+
===Step 1===
  
===Step 0===
+
[https://www.videolan.org/vlc/#download Get VLC] 2 or newer and [[Documentation:Installing VLC|install it]] on your computer.
 +
 
 +
===Step 2===
  
Read the VLC streaming howto (chapters 3 and 5 concerning command line and vlm usage in VLC) : http://videolan.org/doc/
+
You now have to get a background for the mosaic.
  
===Step 1===
+
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]] &hellip;).
  
Get [[VLC]] 0.8.4-test1 or newer and install it on your computer.
+
It is also possible to use a video as a background for the mosaic, and [[wiktionary:superimpose|superimpose]] other videos.
  
===Step 2===
+
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.
  
You now have to get a background image. Many image formats are supported (JPEG, PNG ...).
+
For videolan 1.x and earlier, use the {{docmod|fake}}: access method. The frames per second cannot be changed.
  
You can also test it with VLC to see if it displays locally :
+
You should test it with VLC to see if it displays locally :
<pre>
+
./vlc file:///full/path/to/background.png --image-duration=-1 --image-fps=10
./vlc --fake-file background.png --fake-aspect-ratio "4:3" fake:
 
</pre>
 
  
 
===Step 3===
 
===Step 3===
Line 36: Line 42:
 
You now need to configure VLC to get the 3 source streams and blend them on the background image.
 
You now need to configure VLC to get the 3 source streams and blend them on the background image.
  
The vlm configuration file looks like :
+
The [[VLM#vlm.conf|VLM configuration file]] looks like :
  
 
<pre>
 
<pre>
Line 52: Line 58:
  
 
new background broadcast enabled
 
new background broadcast enabled
setup background input fake:
+
setup background input /full/path/to/background.png
 
setup background output #transcode{sfilter=mosaic,vcodec=mp2v,vb=10000,scale=1}:bridge-in{delay=400,id-offset=100}:standard{access=udp,mux=ts,url=239.255.12.42,sap,name="mosaic"}
 
setup background output #transcode{sfilter=mosaic,vcodec=mp2v,vb=10000,scale=1}:bridge-in{delay=400,id-offset=100}:standard{access=udp,mux=ts,url=239.255.12.42,sap,name="mosaic"}
  
Line 61: Line 67:
 
</pre>
 
</pre>
  
Note that the source streams are network streams, which is likely to be the case if you're considering doing a mosaic.
+
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 :
 +
 
 +
<pre>
 +
new channel1 broadcast enabled                                                     
 +
setup channel1 input file:///path/to/movie.mp4
 +
setup channel1 output #duplicate{dst=mosaic-bridge{id=1,height=366}}
 +
                                           
 +
new channel2 broadcast enabled                                                     
 +
setup channel2 input file:///path/to/movie.mp4
 +
setup channel2 output #duplicate{dst=mosaic-bridge{id=2,height=366}}
  
===Step 4===
+
new channel3 broadcast enabled                                                     
 +
setup channel3 input file:///path/to/movie.mp4
 +
setup channel3 output #duplicate{dst=mosaic-bridge{id=3,height=366}}
  
And now, the right command to launch vlc :
+
new channel4 broadcast enabled                                                     
 +
setup channel4 input file:///path/to/movie.mp4
 +
setup channel4 output #duplicate{dst=mosaic-bridge{id=4,height=366}}
 +
                               
 +
new mosaic broadcast enabled
 +
setup mosaic input file:///path/to/background1600.png
 +
setup mosaic output #transcode{sfilter=mosaic,vcodec=mp4v,VB=20000,acodec=none,fps=15,scale=1}:display
  
 +
control mosaic play
 +
control channel1 play
 +
control channel2 play
 +
control channel3 play
 +
control channel4 play
 +
</pre>
 +
 +
To [[Documentation:Modules/standard|write the resulting stream to a file]], the mosaic output line may also be replaced by :
 
<pre>
 
<pre>
./vlc --color -I telnet --vlm-conf ../mosaic.vlm.conf --ttl 12 \
+
setup mosaic output #transcode{sfilter=mosaic,vcodec=mp4v,VB=20000,acodec=none,fps=15,scale=1}:standard{access=file,mux=ogg,dst="output_file.ogg"}
--fake-file background.png --fake-aspect-ratio "4:3" \
 
--mosaic-width 360 --mosaic-height 288 --udp-caching 800 \
 
--mosaic-keep-picture --mosaic-rows 2 --mosaic-cols 2 \
 
--mosaic-position 1 --mosaic-order 1,2,3
 
 
</pre>
 
</pre>
  
===Small Diagram That Might Help===
+
Note that the source streams are network streams, which is likely to be the case if you're considering doing a mosaic.
[http://people.via.ecp.fr/~dionoea/videolan/mosaic-diagram.png Small Diagram That Might Help]
+
 
 +
===Step 4===
 +
 
 +
And now, the right command to launch VLC :
 +
./vlc --color -I telnet --vlm-conf --mosaic-width=360 --mosaic-height=288 --mosaic-keep-picture --mosaic-rows=2 --mosaic-cols=2 --mosaic-position=1 --mosaic-order=1,2,3,4 ../mosaic.vlm.conf --ttl 12 --udp-caching 800
  
==Appendix==
+
== Other examples ==
  
===Mosaic video sub filter===
+
=== Dual webcam with alphamask ===
The full set of mosaic commands is :
+
{{See also|Documentation:Modules/alphamask}}
 +
https://web.archive.org/web/20110421103501/https://people.videolan.org/~dionoea/mosaic/dual-webcam.png
  
 
<pre>
 
<pre>
Mosaic video sub filter
+
new isight broadcast
      --mosaic-alpha <integer>  Alpha blending
+
setup isight input v4l2:///dev/video0:width=320:height=240:audio-method=0
          Alpha blending (0 -> 255). Default is 255
+
setup isight option v4l2-brightness=90
      --mosaic-height <integer>  Height in pixels
+
setup isight output #mosaic-bridge{chroma=YUVA,vfilter=alphamask{mask=../mask.png},width=320,height=240}
          Height in pixels
+
setup isight enabled
      --mosaic-width <integer>  Width in pixels
+
 
          Width in pixels
+
new logitech broadcast
      --mosaic-align {0 (Center), 1 (Left), 2 (Right), 4 (Top), 8 (Bottom), 5 (Top-Left), 6 (Top-Right), 9 (Bottom-Left), 10 (Bottom-Right)}
+
setup logitech input v4l2:///dev/video1:width=640:height=480:audio-method=0
                                Mosaic alignment
+
setup logitech output #transcode{vcodec=mp4v,vb=1024,sfilter="mosaic:marq{marquee='VLC dual webcam setup',position=8}"}:bridge-in:display
          Mosaic alignment
+
setup logitech enabled
      --mosaic-xoffset <integer> Top left corner x coordinate
 
          Top left corner x coordinate
 
      --mosaic-yoffset <integer> Top left corner y coordinate
 
          Top left corner y coordinate
 
      --mosaic-vborder <integer> Vertical border width in pixels
 
          Vertical border width in pixels
 
      --mosaic-hborder <integer> Horizontal border width in pixels
 
          Horizontal border width in pixels
 
      --mosaic-position {0 (auto), 1 (fixed)}
 
                                Positioning method
 
          Positioning method. auto : automatically
 
          choose the best number of rows and columns.
 
          fixed : use the user-defined number of rows
 
          and columns.
 
      --mosaic-rows <integer>    Number of rows
 
          Number of rows
 
      --mosaic-cols <integer>    Number of columns
 
          Number of columns
 
      --mosaic-keep-aspect-ratio, --no-mosaic-keep-aspect-ratio
 
                                Keep aspect ratio when resizing (default
 
                                disabled)
 
          Keep aspect ratio when resizing (default
 
          disabled)
 
      --mosaic-keep-picture, --no-mosaic-keep-picture
 
                                Keep original size (default disabled)
 
          Keep original size (default disabled)
 
      --mosaic-order <string>    Order as a comma separated list of
 
                                picture-id(s)
 
          Order as a comma separated list of
 
          picture-id(s)
 
      --mosaic-delay <integer>  Delay
 
          Pictures coming from the picture video
 
          outputs will be delayed accordingly (in
 
          milliseconds). For high values you will need
 
          to raise file-caching and others.
 
</pre>
 
  
===Mosaic bridge stream output===
+
new audio broadcast enabled
The full set of mosaic bridge stream output commands is :
+
setup audio input v4l:///dev/dsp1
 +
setup audio output #transcode{acodec=mp4a,ab=128}:bridge-out
  
<pre>
+
control isight play
Mosaic bridge stream output
+
#control audio play
      --sout-mosaic-bridge-id <string>
+
control logitech play
                                ID
 
          Specify an identifier string for this
 
          subpicture
 
      --sout-mosaic-bridge-width <integer>
 
                                Video width
 
          Allows you to specify the output video width.
 
      --sout-mosaic-bridge-height <integer>
 
                                Video height
 
          Allows you to specify the output video height.
 
 
</pre>
 
</pre>
  
===Bridge stream output===
+
You can then launch it with :
The full set of bridge stream output commands is :
+
vlc --vlm-conf ../dual-webcam.conf --no-media-library --plugin-path modules -v --no-video-title --mosaic-keep-picture
 +
 
 +
The mask.png file is used to set transparency values on the isight camera (uses the png alpha plane). An example file to use [https://web.archive.org/web/20110824043406/https://people.videolan.org/~dionoea/mosaic/mosaic_transparency_mask.txt is available] at people.videolan.org/~dionoea/mosaic.
  
<pre>
+
==See also==
Bridge stream output
+
* [https://web.archive.org/web/20070303010905if_/http://people.via.ecp.fr:80/~dionoea/videolan/mosaic-diagram.png Diagram that might help]
      --sout-bridge-out-id <integer>
+
* [https://web.archive.org/web/20121015070412/https://people.videolan.org/~dionoea/mosaic/ VLC mosaic-related resources]
                                ID
+
* [[MosaicExampleSetup | Example set-up of conference web-streaming with two grabber cards]]
          Specify an identifier integer for this
 
          elementary stream
 
      --sout-bridge-in-delay <integer>
 
                                Delay
 
          Pictures coming from the picture video
 
          outputs will be delayed accordingly (in
 
          milliseconds, >= 100 ms). For high values you
 
          will need to raise file-caching and others.
 
      --sout-bridge-in-id-offset <integer>
 
                                ID Offset
 
          Offset to add to the stream IDs specified in
 
          bridge_out to obtain the stream IDs bridge_in
 
          will register.
 
</pre>
 
  
===Fake input module===
+
{{Mosaic framework}}
The full set of the fake input options is :
 
<pre>
 
Fake video decoder
 
      --fake-file <string>      Image file
 
          Path of the image file when using the fake
 
          input.
 
      --fake-width <integer>    Video width
 
          Allows you to specify the output video width.
 
      --fake-height <integer>    Video height
 
          Allows you to specify the output video height.
 
      --fake-keep-ar, --no-fake-keep-ar
 
                                Keep aspect ratio (default disabled)
 
          If selected, width and height will be
 
          considered as maximum values. (default
 
          disabled)
 
      --fake-aspect-ratio <string>
 
                                Background aspect ratio
 
          Aspect ratio of the image file (4:3, 16:9).
 
          Default is square pixels.
 
      --fake-deinterlace, --no-fake-deinterlace
 
                                Deinterlace video (default disabled)
 
          Allows you to deinterlace the image after
 
          loading. (default disabled)
 
      --fake-deinterlace-module {deinterlace,ffmpeg-deinterlace}
 
                                Deinterlace module
 
          Specifies the deinterlace module to use.
 
</pre>
 

Latest revision as of 07:50, 31 May 2019

This page describes how to set up a mosaic of a few videos or stream like a TV portal. Other "how to" pages

VLC mosaic howto

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.png) 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.

mosaic1.png

Other neat examples :

Step 0

Read the VLC streaming howto[fr] (chapters 3[fr] and 5[fr] concerning command line and VLM usage in VLC) : www.videolan.org/doc

Step 1

Get VLC 2 or newer and install it on your computer.

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 :

./vlc file:///full/path/to/background.png --image-duration=-1 --image-fps=10

Step 3

You now need to configure VLC to get the 3 source streams and blend them on the background image.

The VLM configuration file looks like :

new channel1 broadcast enabled                                                       
setup channel1 input udp://@239.255.2.60:1234                                        
setup channel1 output #duplicate{dst=mosaic-bridge{id=1,height=144,width=180},select=video,dst=bridge-out{id=1},select=audio}                                                         
                                                                                
new channel2 broadcast enabled
setup channel2 input udp://@239.255.10.200:1234
setup channel2 output #duplicate{dst=mosaic-bridge{id=2,height=144,width=180},select=video,dst=bridge-out{id=2},select=audio}                                                         

new channel3 broadcast enabled
setup channel3 input udp://@239.255.6.9:1234
setup channel3 output #duplicate{dst=mosaic-bridge{id=3,height=144,width=180},select=video,dst=bridge-out{id=3},select=audio}                                                         

new background broadcast enabled
setup background input /full/path/to/background.png
setup background output #transcode{sfilter=mosaic,vcodec=mp2v,vb=10000,scale=1}:bridge-in{delay=400,id-offset=100}:standard{access=udp,mux=ts,url=239.255.12.42,sap,name="mosaic"}

control background play
control channel1 play
control channel2 play
control channel3 play

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 :

new channel1 broadcast enabled                                                       
setup channel1 input file:///path/to/movie.mp4
setup channel1 output #duplicate{dst=mosaic-bridge{id=1,height=366}} 
                                            
new channel2 broadcast enabled                                                       
setup channel2 input file:///path/to/movie.mp4
setup channel2 output #duplicate{dst=mosaic-bridge{id=2,height=366}}

new channel3 broadcast enabled                                                       
setup channel3 input file:///path/to/movie.mp4
setup channel3 output #duplicate{dst=mosaic-bridge{id=3,height=366}}

new channel4 broadcast enabled                                                       
setup channel4 input file:///path/to/movie.mp4
setup channel4 output #duplicate{dst=mosaic-bridge{id=4,height=366}}
                                 
new mosaic broadcast enabled
setup mosaic input file:///path/to/background1600.png
setup mosaic output #transcode{sfilter=mosaic,vcodec=mp4v,VB=20000,acodec=none,fps=15,scale=1}:display

control mosaic play
control channel1 play
control channel2 play
control channel3 play
control channel4 play

To write the resulting stream to a file, the mosaic output line may also be replaced by :

setup mosaic output #transcode{sfilter=mosaic,vcodec=mp4v,VB=20000,acodec=none,fps=15,scale=1}:standard{access=file,mux=ogg,dst="output_file.ogg"}

Note that the source streams are network streams, which is likely to be the case if you're considering doing a mosaic.

Step 4

And now, the right command to launch VLC :

./vlc --color -I telnet --vlm-conf --mosaic-width=360 --mosaic-height=288 --mosaic-keep-picture --mosaic-rows=2 --mosaic-cols=2 --mosaic-position=1 --mosaic-order=1,2,3,4 ../mosaic.vlm.conf --ttl 12 --udp-caching 800

Other examples

Dual webcam with alphamask

dual-webcam.png

new isight broadcast
setup isight input v4l2:///dev/video0:width=320:height=240:audio-method=0
setup isight option v4l2-brightness=90
setup isight output #mosaic-bridge{chroma=YUVA,vfilter=alphamask{mask=../mask.png},width=320,height=240}
setup isight enabled

new logitech broadcast
setup logitech input v4l2:///dev/video1:width=640:height=480:audio-method=0
setup logitech output #transcode{vcodec=mp4v,vb=1024,sfilter="mosaic:marq{marquee='VLC dual webcam setup',position=8}"}:bridge-in:display
setup logitech enabled

new audio broadcast enabled
setup audio input v4l:///dev/dsp1
setup audio output #transcode{acodec=mp4a,ab=128}:bridge-out

control isight play
#control audio play
control logitech play

You can then launch it with :

vlc --vlm-conf ../dual-webcam.conf --no-media-library --plugin-path modules -v --no-video-title --mosaic-keep-picture

The mask.png file is used to set transparency values on the isight camera (uses the png alpha plane). An example file to use is available at people.videolan.org/~dionoea/mosaic.

See also


Mosaic framework (How-To)
Modules: mosaic (mosaic-bridgebridge-inbridge-out) • alphamaskbluescreen