[FFmpeg-devel] Fix for drawtext under FreeBSD

Eduardo M. Bragatto eduardo
Wed Jan 2 02:42:43 CET 2008


I've sent this message a while ago and had no feedback so far..

Do I need to create a patch form the latest snapshot in order to have my 
change being applied to the next release?

That's a very serious problem for those running drawtext vhook under 
FreeBSD (it simply does not work at all!!!). The fix couldn't be more 
simple, other vhook modules work the same way as I'm suggesting here, 
it's just drawtext module that has a problem with the portability to 
other OSes where getopt() does not behaviour the same way as under 
Linux. (I do like British english, behaviour is not misspelled).

If you guys don't care about portability to other OSes than Linux, let 
me know so I can contact the FreeBSD development list and having them 
patching the source under the ports system.

Regards,
Eduardo M. Bragatto.

Eduardo M. Bragatto wrote:
> Hi there --
> 
> 
> I'm not a developer but I just came across an problem using drawtext 
> vhook under FreeBSD that I managed to fix. Basically drawtext was 
> complaining that I was not passing the parameters -t and -f, although I was.
> 
> The vhook module has the following lines to parse it's command line 
> parameters:
> 
>      optind = 0;
>      while ((c = getopt(argc, argv, "f:t:T:x:y:s:c:C:bo")) > 0) {
> 
> On FreeBSD, getopt() will return -1 when the first non-argument  is 
> found. So, if optind is set to ZERO, the first string it will check will 
> be the module's filename, which of course is not considered an argument 
> (as it doesn't have "-" on the beginning). So, regardless of the 
> parameters I was passing, it was always failing. See getopt() manpage 
> for FreeBSD[1].
> 
> On Linux, getopt() permutes the contents of argv during scan to make 
> sure all non-argument strings are at the end, so having optind set to 
> ZERO doesn't really make any difference as the module's filename would 
> be shifted to the end and the parameters would be properly parsed. See 
> getopt() manpage for Linux[2].
> 
> The solution is simply change:
> 
> optind = 1;
> 
> That way, both Linux and FreeBSD will skip the vhook's filename and will 
> check only the parameters as we want.
> 
> By the way, the vhook watermark.c uses this same approach I'm suggesting 
> here (setting optind=1).
> 
> I have tested the module with this little modification both on Linux and 
> FreeBSD and it now works.
> 
> Best regards,
> Eduardo M. Bragatto.
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel





More information about the ffmpeg-devel mailing list