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

From VideoLAN Wiki
Jump to navigation Jump to search
(Mosaic method update)
Line 19: Line 19:
 
===Step 1===
 
===Step 1===
  
Get VLC 0.8.2-test1 or newer and install it on your computer. (you need an ffmpeg version older than 28/04/2005. Compatibility with newer versions will be fixed)
+
Get [[VLC]] 0.8.4-test1 or newer and install it on your computer.
  
 
===Step 2===
 
===Step 2===
  
You now have to get a background image. This image needs to be in the uyvy format. The conversion of any format to uyvy can be acheived using the programs given by the imagemagick package in debian linux.
+
You now have to get a background image. Many image formats are supported (JPEG, PNG ...).
 
 
Take any image (image.ext) and convert it to the uyvy format. The source and destination image sizes are necessary.
 
<pre>
 
convert -size 360x288 image.ext -resize 360x288 image.uyvy
 
</pre>
 
 
 
You can then test the resulting image :
 
<pre>
 
display -size 360x288 image.uyvy
 
</pre>
 
  
 
You can also test it with VLC to see if it displays locally :
 
You can also test it with VLC to see if it displays locally :
 
<pre>
 
<pre>
./vlc --sout-switcher-files=videolan.uyvy --sout-switcher-sizes=360x288 --sout-switcher-command=1 --ttl 12 --sout "#switcher:display" fake:
+
./vlc --fake-file background.png --fake-aspect-ratio "4:3" fake:
 
</pre>
 
</pre>
  
Line 61: Line 51:
 
new background broadcast enabled
 
new background broadcast enabled
 
setup background input fake:
 
setup background input fake:
setup background output #switcher{files=/home/via/videolan/background_image.uyvy,sizes=360x288,command=1}: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"}
  
 
control background play
 
control background play
Line 77: Line 67:
 
<pre>
 
<pre>
 
./vlc --color -I telnet --vlm-conf ../mosaic.vlm.conf --ttl 12 \
 
./vlc --color -I telnet --vlm-conf ../mosaic.vlm.conf --ttl 12 \
 +
--fake-file background.png --fake-aspect-ratio "4:3" \
 
  --mosaic-width 360 --mosaic-height 288 --udp-caching 800 \
 
  --mosaic-width 360 --mosaic-height 288 --udp-caching 800 \
 
  --mosaic-keep-picture --mosaic-rows 2 --mosaic-cols 2 \
 
  --mosaic-keep-picture --mosaic-rows 2 --mosaic-cols 2 \
Line 175: Line 166:
 
           bridge_out to obtain the stream IDs bridge_in
 
           bridge_out to obtain the stream IDs bridge_in
 
           will register.
 
           will register.
 +
</pre>
 +
 +
===Fake input module===
 +
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>
 
</pre>

Revision as of 16:50, 19 October 2005

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.

mosaic1.png

Other neat examples :

12 video mosaic

20 video mosaic

20 video mosaic

Step 0

Read the VLC streaming howto (chapters 3 and 5 concerning command line and vlm usage in VLC) : http://videolan.org/doc/

Step 1

Get VLC 0.8.4-test1 or newer and install it on your computer.

Step 2

You now have to get a background image. Many image formats are supported (JPEG, PNG ...).

You can also test it with VLC to see if it displays locally :

./vlc --fake-file background.png --fake-aspect-ratio "4:3" fake:

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 fake:
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

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.vlm.conf --ttl 12 \
 --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

Small Diagram That Might Help

Small Diagram That Might Help

Appendix

Mosaic video sub filter

The full set of mosaic commands is :

 Mosaic video sub filter
      --mosaic-alpha <integer>   Alpha blending
          Alpha blending (0 -> 255). Default is 255
      --mosaic-height <integer>  Height in pixels
          Height in pixels
      --mosaic-width <integer>   Width in pixels
          Width in pixels
      --mosaic-align {0 (Center), 1 (Left), 2 (Right), 4 (Top), 8 (Bottom), 5 (Top-Left), 6 (Top-Right), 9 (Bottom-Left), 10 (Bottom-Right)}
                                 Mosaic alignment
          Mosaic alignment
      --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.

Mosaic bridge stream output

The full set of mosaic bridge stream output commands is :

 Mosaic bridge stream output
      --sout-mosaic-bridge-id <string>
                                 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.

Bridge stream output

The full set of bridge stream output commands is :

 Bridge stream output
      --sout-bridge-out-id <integer>
                                 ID
          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.

Fake input module

The full set of the fake input options is :

 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.