[FFmpeg-devel] [PATCH] List supported video size and rate abbreviations

Stefano Sabatini stefano.sabatini-lala
Fri Jun 1 18:13:28 CEST 2007


On date Friday 2007-06-01 16:55:47 +0200, Benoit Fouet encoded:
[snip]
> what i mean is that you should not reindent the part:
> 
>     if (parse_frame_rate(&frame_rate, &frame_rate_base, arg) < 0) {
>         fprintf(stderr, "Incorrect frame rate\n");
>         exit(1);
> 
> but do it in a second patch, after the first one is applied

Got it, you meant I don't have to reindent the pre-existent code,
either in the case it will result badly indented after the patch
application. Is this correct?
 
> > Index: libavformat/avformat.h
> > ===================================================================
> > --- libavformat/avformat.h	(revision 9165)
> > +++ libavformat/avformat.h	(working copy)
> > @@ -883,6 +883,51 @@
> >  
> >  int match_ext(const char *filename, const char *extensions);
> >  
> > +
> > +/**
> > + * Number of supported video size and rate abbreviations supported.
> > + */
> > +extern int const video_size_rate_abv_nb;
> > +
> > +/**
> > + * Prints in buf the string corresponding to the video size
> > + * abbreviation with number video_size_abv.  FFmpeg supports
> > + * video_size_rate_abv_nb different video size abbreviations, so the
> > + * argument may vary between 0 and video_size_rate_abv_nb -1. If
> > + * video_size_abv is negative it will print a header, if
> > + * video_size_abv is greater or equal to video_size_rate_abv_nb it
> > + * will do nothing and return -1.
> > + *
> > + * @return 0 if video_size_abv is negative or it corresponds to a valid
> > + * video size abbreviation, -1 otherwise.
> > + * @param buf the buffer where to write the string
> > + * @param buf_size the size of buf
> > + * @param video_size_abv the number of the video size abbreviation
> > + * whose information you want to get, or a negative number to print a
> > + * header
> >   
> 
> well, this is still redundant information
[snip]
> same here

OK, removed the sentences:

"If video_{rate,size}_abv is negative it will print a header, if
video_{rate,size}_abv is greater or equal to video_size_rate_abv_nb it
will do nothing and return -1."
 
[snip] 
> > +int avcodec_video_rate_abv_string (char *buf, int buf_size, int video_rate_abv)
> > +{
> > +    AbvEntry info= frame_abvs[video_rate_abv];
> > +
> > +    /* print header */
> > +    if (video_rate_abv < 0) {
> > +        snprintf (buf, buf_size,
> > +                  "name      "  " frame_rate" " frame_rate_base"
> > +            );
> > +    } else if (video_rate_abv < video_size_rate_abv_nb && info.frame_rate != 0) {
> >   
> 
> "!= 0" is unneeded

Look at this command:

sds at santefisi:~/opt/univ/tesi/tests$ ffmpeg -i movie.avi -r qcif -s qcif -y movie.3gp
                                                         ^^^^^^^
FFmpeg version SVN-r9143, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/home/sds --mandir=/home/sds/share/man --enable-gpl --enable-swscaler --enable-pp
  libavutil version: 49.4.0
  libavcodec version: 51.40.4
  libavformat version: 51.12.1
  built on May 29 2007 12:36:12, gcc: 4.1.2 20061028 (prerelease) (Debian 4.1.1-19)
Input #0, avi, from 'movie.avi':
  Duration: 00:07:48.0, start: 0.000000, bitrate: 602 kb/s
  Stream #0.0: Video: mpeg2video, yuv420p, 720x576, 7456 kb/s, 25.00 fps(r)  Stream #0.1: Audio: mp2, 48000 Hz, stereo, 384 kb/s
Output #0, 3gp, to 'movie.3gp':
  Stream #0.0: Video: h263, yuv420p, 176x144, q=2-31, 200 kb/s,   nan fps(c)
  Stream #0.1: Audio: 0x0000, 48000 Hz, stereo, 64 kb/s
Stream mapping:
  Stream #0.0 -> #0.0
  Stream #0.1 -> #0.1
[h263 @ 0x84ab468]framerate not set
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

Ffmpeg sets the output video framerate to 0/0, then the encoder will
complain and exit, I wanted to avoid to let the user specify a
meaningless video rate abbreviation, so I skipped in the listing the
meaningless values (corresponding to 0/0 rate values).

But maybe it's also a bug in parse_frame_rate (libavformat/utils.c) since
it seems to me this function should avoid to set a framerate
corresponding to a meanigless video rate abbreviation (such as "qcif"),
possibly exiting before to pass the 0/0 value to the encoder.

Cheers
-- 
Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: list-video-size-rate-abvs-02.patch
Type: text/x-diff
Size: 7447 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070601/df24c3f5/attachment.patch>



More information about the ffmpeg-devel mailing list