[FFmpeg-devel] [PATCH] examples/decoding_encoding: store temporary files in current dir
Stefano Sabatini
stefasab at gmail.com
Mon Aug 27 10:12:03 CEST 2012
On date Saturday 2012-08-25 17:33:17 +0200, Clément Bœsch encoded:
> On Fri, Aug 24, 2012 at 05:01:16PM +0200, Stefano Sabatini wrote:
> > On date Friday 2012-08-24 16:31:43 +0200, Michael Niedermayer encoded:
> > > On Fri, Aug 24, 2012 at 12:22:53PM +0200, Stefano Sabatini wrote:
> > > > On date Friday 2012-08-24 03:35:15 +0200, Michael Niedermayer encoded:
> > > > > On Thu, Aug 23, 2012 at 08:18:17PM +0200, Stefano Sabatini wrote:
> > > > > > Do not clutter the temporary directory with files, also "/tmp" is not
> > > > > > always available, e.g. in Windows.
> > > > >
> > > >
> > > > > the current directory is maybe not better, it might be read only
> > > > > for example ...
> > > >
> > > > On the other hand if not readable, then the program won't be compilable.
> > >
> > > compilation and execution could happen at different times, with
> > > different current directories or by different users.
> > >
> > > >
> > > > > and /tmp gets cleaned, the current directory likely wont
> > > >
> > > > But will fail on Windows and other OSes with no "/tmp", also the user
> > > > won't have to wonder where the output files are (having them in the
> > > > current dir looks to have a so much better "least surprise factor").
> > > >
> > >
> > > > I could add a rule for removing test output files when doing make
> > > > clean.
> > >
> > > thats surely a good idea ...
> >
> > Updated.
> > --
> > FFmpeg = Faithless and Frenzy Mastodontic Portentous EnGraver
>
> > From 6e1a64b2df67750717d3425e5354ce4f8dec242c Mon Sep 17 00:00:00 2001
> > From: Stefano Sabatini <stefasab at gmail.com>
> > Date: Thu, 23 Aug 2012 20:17:25 +0200
> > Subject: [PATCH] examples/decoding_encoding: store temporary files in current
> > dir
> >
> > Do not clutter the temporary directory with files, also "/tmp" is not
> > always available, e.g. in Windows.
> >
> > Also add the clean-test Makefile rule, which will clean the generated
> > files.
> > ---
> > doc/examples/Makefile | 7 +++++--
> > doc/examples/decoding_encoding.c | 14 +++++++-------
> > 2 files changed, 12 insertions(+), 9 deletions(-)
> >
> > diff --git a/doc/examples/Makefile b/doc/examples/Makefile
> > index 37bfb44..0fa5179 100644
> > --- a/doc/examples/Makefile
> > +++ b/doc/examples/Makefile
> > @@ -24,9 +24,12 @@ OBJS=$(addsuffix .o,$(EXAMPLES))
> > decoding_encoding: LDLIBS += -lm
> > muxing: LDLIBS += -lm
> >
> > -.phony: all clean
> > +.phony: all clean-test clean
> >
> > all: $(OBJS) $(EXAMPLES)
> >
> > -clean:
> > +clean-test:
> > + rm -rf test*.pgm test.h264 test.mp2 test.sw test.mpg
> > +
>
> -r looks unnecessary
>
> Note: I think you can safely use $(RM) here
Applied in a second commit.
> > +clean: clean-test
> > rm -rf $(EXAMPLES) $(OBJS)
> > diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
> > index 96b1a4b..046c7da 100644
> > --- a/doc/examples/decoding_encoding.c
> > +++ b/doc/examples/decoding_encoding.c
> > @@ -606,18 +606,18 @@ int main(int argc, char **argv)
> > avcodec_register_all();
> >
> > if (argc <= 1) {
> > - audio_encode_example("/tmp/test.mp2");
> > - audio_decode_example("/tmp/test.sw", "/tmp/test.mp2");
> > + audio_encode_example("test.mp2");
> > + audio_decode_example("test.sw", "test.mp2");
> >
> > - video_encode_example("/tmp/test.h264", AV_CODEC_ID_H264);
> > - video_encode_example("/tmp/test.mpg", AV_CODEC_ID_MPEG1VIDEO);
> > - filename = "/tmp/test.mpg";
> > + video_encode_example("test.h264", AV_CODEC_ID_H264);
> > + video_encode_example("test.mpg", AV_CODEC_ID_MPEG1VIDEO);
> > + filename = "test.mpg";
> > } else {
> > filename = argv[1];
> > }
> >
> > - // audio_decode_example("/tmp/test.sw", filename);
> > - video_decode_example("/tmp/test%d.pgm", filename);
> > + // audio_decode_example("test.sw", filename);
> > + video_decode_example("test%02d.pgm", filename);
> >
>
> Should be OK.
>
> Note: "test" is fine but maybe "encdec-example.<ext>" would be more
> appropriate (this code is not a test but an example).
Unrelated change, PAWE.
Patch applied.
--
FFmpeg = Faithful & Fostering Mortal Purposeless Encoding/decoding Guru
More information about the ffmpeg-devel
mailing list