[RFE] Add borders on transcode

About encoding, codec settings, muxers and filter usage
urig
New Cone
New Cone
Posts: 9
Joined: 21 Aug 2004 19:12

[RFE] Add borders on transcode

Postby urig » 21 Aug 2004 19:46

Hi.

My problem is: I want to stream video to a PC that redirects the stream to a technotrend DVB card for output. These cards only accept video in certain resolutions, eg. 720x576 for PAL.
I've got it working with transcoding and UDP streaming, but only if the source video has a matching resolution.

In case of 4:3 movies, scaling to 720x576 works ok, but if the source video is in some widescreen format, theres no alternative to adding some black borders to the video.

Actually, I tried this:
vlc "foo.avi" --sout "#transcode{vcodec=mpgv,vb=4000,acodec=mpga,ab=192,croptop=-112,cropbottom=-112}: std{access=udp,mux=ts,url=foo:1234}"

(note the negative crop)
This actually works, but adds garbage around the video, and I wouldnt be surprised if it would crash sometimes too. ;)

The simplest enhancement would be adding paddtop,paddbottom,etc. options to add border pixels. Even better would be a way to padd/crop to a given resolution. And best-of-all would be a way to aspect-correct scale to a destination resolution plus padding the rest.

As ex. for the correct handling:
Assume source video is 640x352 (1:1.82). 720x576 output is assumed to be 4:3, so optimal output height would be 576*(4/3)*(1/1.82) = 422. That means we need to scale 640x352->720x422 and then add 77 pixels black brder on top and bottom. If vlc would do most of this calculation on its own, this would be perfect...

Any comments?

urig
New Cone
New Cone
Posts: 9
Joined: 21 Aug 2004 19:12

Postby urig » 04 Sep 2004 02:54

<push-up>

I've taken a look into the source codes. Inside modules/stream_out/transcode.c, the crop values get passed through to libavcodec, apparently unchecked:

Code: Select all

img_resample_full_init( id->f_dst.video.i_width, id->f_dst.video.i_height, id->ff_dec_c->width, id->ff_dec_c->height, p_stream->p_sys->i_crop_top, p_stream->p_sys->i_crop_bottom, p_stream->p_sys->i_crop_left, p_stream->p_sys->i_crop_right #if LIBAVCODEC_BUILD >= 4708 ,0, 0, 0, 0 ); #else ); #endif
The ,0,0,0,0 caught my attention: In ffmpeg's libavcodec/avcodec.h these parameters are called padtop, padbottom, padleft, padright. Seems just what we need.

My suggestion:
If i_crop_* is negative, catch it right before calling img_resample_full_init and transmit its negative value as pad. For libavcodec backwards compatibility, throw some error if version is too low. Something like this:

Code: Select all

int padbottom=0; if (i_crop_bottom<0) { padbottom=-i_crop_bottom; i_crop_bottom=0; } ... #if LIBAVCODEC_BUILD >= 4708 img_resample_full_init(....) /* full call */ #else if (padbottom>0||...) { throw_some_error(); } else { img_resample_full_init(....); /* no padding call */ } #endif
For a vlc developer, this should be a five-minute-hack. I could do it myself, but setting up a vlc compile environment would probably take me days, not minutes. ;)

Any further notes, or hints how to get this changed?

benex

same problem

Postby benex » 13 Oct 2004 02:52

I have the same problem...please help!:)

Guest

try ffmpeg 0.4.9

Postby Guest » 15 Oct 2004 00:56

until new version of vlc try to transcode file with ffmpeg 0.4.9, that have the padding option, and then stream the output to anything with vlc (or use ffserver)...

i think this help you.

benex

benex

oops

Postby benex » 15 Oct 2004 00:57

...and use "-re" option!


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 9 guests