Page 1 of 1

Changing encoding params at runtime

Posted: 26 Oct 2009 12:01
by brizio
Hi all,
I'm using vlc 1.0.2 as live encoder (mpeg4)..Sometimes i need to change some params of encoding due changing in client side performance. Actually,i shut and then restart a new istance of vlc... there is any way to change this parameter (i mean bitrate of encoder,resolution...) "on the fly", without killing the running istance of vlc?

Thanks for your kind help

Re: Changing encoding params at runtime

Posted: 27 Oct 2009 21:34
by Rémi Denis-Courmont
Not implemented currently.

Re: Changing encoding params at runtime

Posted: 02 Nov 2009 20:28
by brizio
this for any parameter?key frame of ffmpeg included?
thanks!

Re: Changing encoding params at runtime

Posted: 02 Nov 2009 20:42
by Rémi Denis-Courmont
AFAIK, yes.

Re: Changing encoding params at runtime

Posted: 02 Nov 2009 22:08
by brizio
thanks for your kind replies...I need an advice, in your opinion, what could be a starting point to understand the code of vlc?Particularly where the trascode funcionalities are implemented? I don't know if i'm clear enough but if anyone has seen, studied or developed the source code of vlc could give hints or a starting point...
Thanks a lot!

Re: Changing encoding params at runtime

Posted: 02 Nov 2009 22:21
by Rémi Denis-Courmont
transcoding is done in modules/stream_out/transcode.c for what it's worth.

Re: Changing encoding params at runtime

Posted: 12 Nov 2009 16:52
by brizio
i've looked around the code, i would be able to change particulary the size of the gop, so i'm thinking about the use of ffmpeg encoder.. The functionalities of the ffmpeg encoder are implemented in codec/avcodec/encoder.c,correct me if i wrong.
The params that i'm interested in are
int i_key_int;
int i_b_frames;
and maybe also
int i_qmin;
int i_qmax;

Looking at the code, i've seen that these params are initialized in function OpenEncoder, now i'm lot sure about how vlc loads modules..i've looked around vlc wiki,docs and forum but i've not found something about it. This is a part of the code in OpenEncoder

config_ChainParse( p_enc, ENC_CFG_PREFIX, ppsz_enc_options, p_enc->p_cfg );

var_Get( p_enc, ENC_CFG_PREFIX "keyint", &val );
p_sys->i_key_int = val.i_int;

does config_ChainParse() get and parsify the command line parameters? var_Get takes the appropriate value for i_key_int?

Could anyone can tell me how a module is loaded in vlc startup sequence?Which part of code loads ffmpeg encoder module? If in this code i put a function that change at runtime the previous cited params, could be generate instability or bad side effects?

Thanks for help!

Re: Changing encoding params at runtime

Posted: 13 Nov 2009 18:07
by Rémi Denis-Courmont
The FFMPEG encoder module is loaded by the transcode module, which is loaded by the stream output core.

Re: Changing encoding params at runtime

Posted: 15 Nov 2009 16:31
by brizio
Ok, thanks for your reply..
I've tried to change the value of qmin and qmax in the body of thefunction EncodeVideo, i've change the data, just as a test, accoding to this

> qmax and qmin are the 'quality-ranges' in which you define to
> encode. Oposite from what most, atleast me, would expect is that
> higher the values the lower the quality.
> -qmin 50 an qmax 51 gives the lowest quality
> -qmin 0 -qmax 1 gives the highest quality

found here http://archives.free.net.ph/message/200 ... d6.en.html

int f; //as global variable
..
..
f=0; //this in OpenEncoder

static block_t *EncodeVideo( encoder_t *p_enc, picture_t *p_pict )
{
encoder_sys_t *p_sys = p_enc->p_sys;
AVFrame frame;
int i_out, i_plane;

if(!(i_framenum%500))
{
if(f)
{
p_enc->p_sys->i_qmin=0;
p_enc->p_sys->i_qmax=1;
f=0;
}
else
{
p_enc->p_sys->i_qmin=50;
p_enc->p_sys->i_qmax=51;
f=1;
}
}
..
..

this should change the quality of the video every 500 frames...I've compiled it and launched with command line


but at runtime the video quality remains the same... Do the values are stored in another structure which is not modificable in EncodeVideo function?
By using some dbg msg, i've seen that this function is called for each frame of the input (in my case, screen capture @25fps).. In your opinion there are any way to modify this quality parameters correctly?

Thanks a lot for your help,i'm a bit confused!

Re: Changing encoding params at runtime

Posted: 30 Nov 2009 11:54
by brizio
ok, if anyone are looking the same it seems that parameters, for ffmpeg encoder are in the structure

p_sys->p_context

I've another question,i'd like to create another thread which manage a socket. The socket should receives the parameters for the encoder from a client, i'm using vlc_thread_create to create the thread..could anyone know how to write the socket? I mean, are there any vlc's function which allow me to create and manage the socket?

Thanks a lot!