mosaic alignment

About encoding, codec settings, muxers and filter usage
jesus_
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Feb 2008 16:28

mosaic alignment

Postby jesus_ » 14 Feb 2008 13:36

The mosaic generated by vlc 0.8.6d looks like this:

Image

but I would want it to look like this, with the video's centered in their container:

Image

This is the command I'm using:

Code: Select all

vlc -I telnet --ttl 12 --fake-aspect-ratio "16:9" --vlm-conf mosaic.conf --fake-file mosaic.jpg
with this conf:

Code: Select all

# reset VLM configuration del all # Background options new bg broadcast enabled setup bg input fake: setup bg output #transcode{acodec=mpga,ab=128,vcodec=mpgv,vb=4096,scale=1,sfilter=mosaic}:bridge-in:std{access=udp{ttl=5},mux=ts,dst=225.1.1.1:2000} # Mosaic options setup bg option mosaic-height=932 setup bg option mosaic-width=1526 setup bg option mosaic-xoffset=235 setup bg option mosaic-yoffset=103 setup bg option mosaic-position=1 setup bg option mosaic-rows=3 setup bg option mosaic-cols=4 setup bg option mosaic-order=een,two,[...] setup bg option mosaic-keep-picture new one broadcast enabled setup one input "udp://192.168.1.1@224.1.1.1:2000" setup one output #duplicate{dst=mosaic-bridge{id=one,width=360},select=video,dst=bridge-out{id=one}} new two broadcast enabled setup two input "udp://192.168.1.1@224.1.1.2:2000" setup two output #duplicate{dst=mosaic-bridge{id=two,width=360},select=video,dst=bridge-out{id=two}} [...] control bg play control one play control two play [...]
From the wiki:

Code: Select all

* mosaic-align <integer> : Alignment of the mosaic in the parent video. default value: 5
(http://wiki.videolan.org/Documentation:Modules/mosaic)

That's not the problem, it's aligned ok in the global video, it's the internal aligning I want to change.

Code: Select all

* mosaic-position <integer> : Positioning method of the mosaic elements. Use 0 to position the elements automatically on the grid, 1 to position the elements in fixed positions on the grid (see mosaic-order) and 2 to use grid independant offsets (see mosaic-offsets).. default value: 0
Is set to 1, since I want to decide in what order the images get on the grid.

I browsed through the source to find out where the positioning is taking place. I figured that somehow, the images were not aligned right inside their bounding box in the vertical direction. I found following code-snippet in mosaic.c:

Code: Select all

if( fmt_out.i_width > col_inner_width || p_sys->b_ar || p_sys->b_keep ) { /* we don't have to center the video since it takes the whole rectangle area or it's larger than the rectangle */ p_region->i_x = p_sys->i_xoffset + i_col * ( p_sys->i_width / p_sys->i_cols ) + ( i_col * p_sys->i_borderw ) / p_sys->i_cols; } else { /* center the video in the dedicated rectangle */ p_region->i_x = p_sys->i_xoffset + i_col * ( p_sys->i_width / p_sys->i_cols ) + ( i_col * p_sys->i_borderw ) / p_sys->i_cols + ( col_inner_width - fmt_out.i_width ) / 2; }
Sounds logic, if the image is wider than the containerm don't center. However, for the vertical alignment I found:

Code: Select all

if( fmt_out.i_height < row_inner_height || p_sys->b_ar || p_sys->b_keep ) { /* we don't have to center the video since it takes the whole rectangle area or it's taller than the rectangle */ p_region->i_y = p_sys->i_yoffset + i_row * ( p_sys->i_height / p_sys->i_rows ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows; } else { /* center the video in the dedicated rectangle */ p_region->i_y = p_sys->i_yoffset + i_row * ( p_sys->i_height / p_sys->i_rows ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows + ( row_inner_height - fmt_out.i_height ) / 2; }
First of all, the <, shouldn't that be >? The first block gets executed if the image is smaller than the container, while the comments show that it should be executed when it's larger. I tried to change it and compiled, but the behaviour did not change. p_sys->b_ar || p_sys->b_keep make sure that the images never get centered vertically if mosaic-keep-picture or mosaic-keep-aspect-ratio is enabled. Could someone explain why the image shouldn't be centered in that case? I'm missing the logic. I'm going to change the code and recompile so that the images are always centered, but I would like to understand why this is coded the way it is, there must be a reason. (God knows what will happen after my recompile :p)

Any hints an thoughts are appreciated.

jesus_
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Feb 2008 16:28

Re: mosaic alignment

Postby jesus_ » 14 Feb 2008 13:47

I changed the code into this:

Code: Select all

// if( fmt_out.i_height < row_inner_height // || p_sys->b_ar || p_sys->b_keep ) // { // /* we don't have to center the video since it takes the // whole rectangle area or it's taller than the rectangle */ // p_region->i_y = p_sys->i_yoffset // + i_row * ( p_sys->i_height / p_sys->i_rows ) // + ( i_row * p_sys->i_borderh ) / p_sys->i_rows; // } // else // { /* center the video in the dedicated rectangle */ p_region->i_y = p_sys->i_yoffset + i_row * ( p_sys->i_height / p_sys->i_rows ) + ( i_row * p_sys->i_borderh ) / p_sys->i_rows + ( row_inner_height - fmt_out.i_height ) / 2; // }
Very simple hack, but it does seem to do the trick. Everything still works, and my 16:9 images are aligned in the center vertically.

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: mosaic alignment

Postby Jean-Baptiste Kempf » 14 Feb 2008 19:10

I don't think this is the good way to do it.

Anyway, send PATCHES to vlc-devel@ mailing list
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

jesus_
Blank Cone
Blank Cone
Posts: 11
Joined: 12 Feb 2008 16:28

Re: mosaic alignment

Postby jesus_ » 14 Feb 2008 21:28

I agree :) That's why I won't submit a patch, it's a hack that does exactly what I want, but it's probably bugged for general purpose mosaic.


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 27 guests