[FFmpeg-devel] [PATCH] Make the ffmpeg "Overwrite ? [y/N]" question works with more than one file to overwrite
Stefano Sabatini
stefano.sabatini-lala
Sat Mar 14 01:14:13 CET 2009
On date Wednesday 2009-03-11 01:42:10 +0100, Michael Niedermayer encoded:
> On Tue, Mar 10, 2009 at 09:36:00PM +0100, Stefano Sabatini wrote:
> > Hi all,
> >
> > I recently stepped into this:
> > stefano at geppetto ~/s/ffmpeg> ffmpeg -i in123.mpeg out0.avi out1.ogg -y -map 0:2 -map 0:1
> > [...]
> > Input #0, mpeg, from 'in123.mpeg':
> > Duration: 00:03:40.05, start: 0.500000, bitrate: 81 kb/s
> > Stream #0.0[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16, 64 kb/s
> > Stream #0.1[0x1c1]: Audio: mp2, 48000 Hz, stereo, s16, 64 kb/s
> > Stream #0.2[0x1c2]: Audio: mp2, 48000 Hz, stereo, s16, 64 kb/s
> > File 'out0.avi' already exists. Overwrite ? [y/N] y
> > File 'out1.ogg' already exists. Overwrite ? [y/N]
> > Not overwriting - exiting
> >
> > After the first question is replied, the stdin buffer still contains
> > the '\n' buffered, then ffmpeg read from it with getchar(), get a
> > '\n', which is different from 'Y' and abort immediately.
> >
> > Patch fixes it.
> >
> > Regards.
> > --
> > FFmpeg = Fast and Faboulous Most Picky Energized Gorilla
>
> > Index: ffmpeg.c
> > ===================================================================
> > --- ffmpeg.c (revision 17926)
> > +++ ffmpeg.c (working copy)
> > @@ -3362,12 +3362,13 @@
> > filename[1] == ':' ||
> > av_strstart(filename, "file:", NULL))) {
> > if (url_exist(filename)) {
> > - int c;
> > + char c, line[256];
> >
> > if (!using_stdin) {
> > fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
> > fflush(stderr);
> > - c = getchar();
> > + fgets(line, sizeof(line), stdin);
> > + sscanf(line, "%c", &c);
>
> what weird mess is this ?
> getchar();getchar()
underkill, what if the user prints more than one character?
> or
> fscanf()
fgets() should be equivalent and simpler in this case, check the patch below.
Regards.
--
FFmpeg = Freak Faithless Merciless Pure Ecstatic Gospel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-multiple-overwrite-question.patch
Type: text/x-diff
Size: 847 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090314/2e6725fa/attachment.patch>
More information about the ffmpeg-devel
mailing list