[Ffmpeg-devel] getopt() on FreeBSD

Marcus Engene ffmpeg
Tue Oct 25 19:59:22 CEST 2005


Hi!

I wrote vhook/watermark.c and today I got a mail from someone who didn't 
get it to work properly. He's on a FreeBSD system and I only have access 
to some Linux flavours and Windows.

Watermark complains that no filename is given. We added a

// Struct is mallocz:ed so noo need to reset.
// new code:
for (c=0; c<argc; c++) {
    fprintf(stderr,"arg %d is [%s]\n", c, argv[c]);
}

and indeed all arguments are there:

...
arg 0 is [/usr/local/lib/vhook/watermark.so]
arg 1 is [-f]
arg 2 is [/hdd1/ffmpeg_watermark.gif]
...

However adding this:

fprintf(stderr, "Filename [%s] [%s]", optarg, ci->filename);

right before break; in the switch-case 'f'  inside the getopt()-while 
gave no result!?

    while ((c = getopt(argc, argv, "f:")) > 0) {
        switch (c) {
            case 'f':
                strncpy(ci->filename, optarg, 1999);
                ci->filename[1999] = 0;
 ->             fprintf(stderr, "Filename [%s] [%s]", optarg, ci->filename);
                break;
            default:
                av_log(NULL, AV_LOG_DEBUG, "Unrecognized argument '%s'\n", argv[optind]);
                fprintf(stderr,"Unrecognized argument\n");
                return -1;
        }
    }
    
    //
    if (0 == ci->filename[0]) {
        fprintf(stderr,"No filename!\n");
        return -1;
    }



I have no access to a FreeBSD system, but does the getopt() behaviour 
really differ from Linux?

(Also added debug output in ffmpeg.c:add_frame_hooker())

db122# ffmpeg -v 2 -i /hdd1/anything_goes+0_1.vob -s 640x480 -vhook
'/usr/local/lib/vhook/watermark.so -f /hd1/ffmpeg_watermark.gif' out.mov
ffmpeg version CVS, build 3277056, Copyright (c) 2000-2004 Fabrice Bellard
  configuration:  --enable-memalign-hack --enable-gpl
--extra-cflags=-I/usr/local/include --extra-libs=-L/usr/local/lib
--enable-mp3lame --enable-faad --enable-faadbin --enable-faac --enable-xvid
--enable-a52 --enable-dts --enable-pp --enable-shared
  built on Oct 25 2005 13:52:54, gcc: 3.4.2 [FreeBSD] 20040728
Input #0, mpeg, from '/hdd1/anything_goes+0_1.vob':
  Duration: 00:24:44.4, start: 127.641967, bitrate: 5658 kb/s
  Stream #0.0[0xa0], 1/90000: Audio: pcm_s16be, 48000 Hz, stereo, 1536 kb/s
  Stream #0.1[0x1e0], 1/90000, 29.97 fps: Video: mpeg2video, yuv420p,
720x480, 1001/30000, 8000 kb/s
add_frame_hooker() Adding string [/usr/local/lib/vhook/watermark.so -f
/hdd1/ffmpeg_watermark.gif]
add_frame_hooker() Added [/usr/local/lib/vhook/watermark.so]
add_frame_hooker() Added [-f]
add_frame_hooker() Added [/hdd1/ffmpeg_watermark.gif] last
arg 0 is [/usr/local/lib/vhook/watermark.so]
arg 1 is [-f]
arg 2 is [/hdd1/ffmpeg_watermark.gif]
No filename!
Failed to Configure /usr/local/lib/vhook/watermark.so
Failed to add video hook function: /usr/local/lib/vhook/watermark.so -f
/hdd1/ffmpeg_watermark.gif
db122#

Does anyone have an idea about this?

Mvh Marcus





More information about the ffmpeg-devel mailing list