[FFmpeg-devel] first experience with ffmpeg

D. Hugh Redelmeier hugh
Fri Feb 15 16:27:28 CET 2008

| From: Stefano Sabatini <stefano.sabatini-lala at poste.it>

Thanks for your reply.

| On date Friday 2008-02-15 02:09:19 -0500, D. Hugh Redelmeier encoded:

| > ===> the ffmpeg program should diagnose malformed arguments to -v.

| This happens everytime we use atoi() in ffmpeg.c. When the string is
| unparsable as a string ffmpeg uses the value 0 without to warn the
| user a blink.
| What about the attached patch (I think there could be some trouble
| from the conversion from long int to int)?
| Suggested log: replace atoi() in ffmpeg.c with the parse_int_or_die()
| function.

I think that this is a very good start.

Have you tested it?  Your function parse_int_or_die seems to have a
bug.  The result of strtol ought to be stored in i but it is instead

The function knows that an integer numeral is desired, but it does not
know what the numeral is for.  So it's diagnostic cannot explain the
context to the user.  I recommend a const char * argument just to
provide this context.

  fprintf(stderr, "expected integer for %s but found: %s\n", ctxt, instr);

I would recommend checking for overflow/underflow tool.  This may mean
that you need a separate function for parsing unsigned values.

Here's a modified version of your function.  Untested:

#include <errno.h>

static long int parse_int_or_die(const char* intstr, const char *ctxt)
    long int i;
    char *tail;

    errno = 0;
    i = strtol(intstr, &tail, 10);
    if (*tail != '\0') {
        fprintf(stderr, "Expected integer for %s but found \"%s\"\n", ctxt, instr);
    } else if (errno == ERANGE) {
        fprintf(stderr, "Integer for %s is too big: %s\n", ctxt, intstr);
    return i;

| >     $ ffmpeg -v 9 -ss 00:23:44 -t 00:09:15 -i 2008.02.11-19.28.wma don.mp3
| >     FFmpeg version SVN-r8876, Copyright (c) 2000-2007 Fabrice Bellard, et al.
|                      ^^^^^^^^^
| >       configuration: --prefix=/usr --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic --enable-libmp3lame --enable-libogg --enable-libtheora --enable-libvorbis --enable-libfaad --enable-libfaac --enable-libgsm --enable-xvid --enable-x264 --enable-liba52 --enable-liba52bin --enable-libdts --enable-pp --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-opts --disable-strip
| >       libavutil version: 49.4.0
| >       libavcodec version: 51.40.4
| >       libavformat version: 51.12.1
| >       built on May  3 2007 12:41:19, gcc: 4.1.2 20070424 (Red Hat 4.1.2-11)

| Really ancient version acccording to the ffmpeg standards. Retry with
| the newest and greatest, maybe that has been fixed.

OK, I will try.  This is the version that is in the Livna repository
for Fedora 7.

It isn't clear what packages will be or need to be replaced.  At least
ffmpeg and ffmpeg-libs.  I wonder if this will break the installed

More information about the ffmpeg-devel mailing list