VLC HowTo/Make a mosaic
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.
Step 1
Get VLC 0.8.2-test1 or newer and install it on your computer.
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.
Take any image (image.ext) and convert it to the uyvy format. The source and destination image sizes are necessary.
convert -size 360x288 image.ext -resize 360x288 image.uyvy
You can then test the resulting image :
display -size 360x288 image.uyvy
You can also test it with VLC to see if it displays locally :
./vlc --sout-switcher-files=videolan.uyvy --sout-switcher-sizes=360x288 --sout-switcher-command=1 --ttl 12 --sout "#switcher:display" 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 #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"} 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 \ --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
Appendix
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.
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.
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.