[Ffmpeg-devel] Wrap --- again..

Michel Bardiaux mbardiaux
Tue Jan 9 17:42:36 CET 2007


Ignazio Castrogiovanni wrote:
> I've followed your suggestion to use dlopen - dlsym - dlclose to call many
> times the main of ffmpeg.
> Now I can make my own wrapper library that has different functions all
> calling the main of ffmpeg with different parameters. Now I'm getting crazy
> around a problem that I can't understand.
> I have renamed the main of ffmpeg.c to boss(int argc, char **argv) and I
> call it from another function (for example get_video_segment()).
> Why if I call the function boss and I pass it the right parameters it works
> and if I pass the same parameters to the function called by dlsym I get
> Must supply at least one output file.
> Here there is my code:
> 
> void get_video_segment(int n, int m)
> {
> int (*principale)(int argc, char **argv); void* lib_handle;
> lib_handle = dlopen("libffmpeg.so",RTLD_LAZY);*if*(!lib_handle)
> {
> fprintf(stderr,"Coudn't open library libffmpeg.so because os %s", 
> dlerror());
> exit(1);
> }**
> *(void **)(&principale) = dlsym (lib_handle,"boss");
> int hl = m-n;char beg[10];char howlong[10];
> sprintf(beg,"%d",n);
> sprintf(howlong,"%d",hl);

The declaration of pamateri seems to have been lost.

> parametri[0]="Yasw";
> parametri[1]="-ss";
> parametri[2]=beg;
> parametri[3]="-t";
> parametri[4]=howlong;
> parametri[5]="-an";
> parametri[6]="-y";
> parametri[7]="-i";
> parametri[8]=filein;
> parametri[9]=fileout;
> 
> 
> nParametri = 10;

Should be 9, I think, the progname being present but not counted.

> *//boss(nParametri,parametri);*

Why *that* works I dont know.

> int ab = (*principale)(nParametri,parametri);
> 
> dlclose(lib_handle);
> }
> 
> It seems that i forget to pass the last parameter... but the same 
> parameters
> are totally working if I uncomment boss(nParametri,parametri);, and comment
> the rest.
> 
> Here there is the complete output:
> 
> Seems stream 0 codec frame rate differs from container frame rate:
> 23.98(65535/2733) ->
> 23.98 (24000/1001)
> Input #0, avi, from '/users/castrogiovanni/salt/salt.avi':
>  Duration: 00:42:39.6, start: 0.000000, bitrate: 1192 kb/s
>  Stream #0.0: Video: mpeg4, yuv420p, 624x352, 23.98 fps(r)
>  Stream #0.1: Audio: mp3, 48000 Hz, stereo, 160 kb/s
> Must supply at least one output file
> Premi Invio per continuare!
> 


-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/




More information about the ffmpeg-devel mailing list