[FFmpeg-devel] [PATCH] Use file protocol to deal with bogus protocol strings

Stefano Sabatini stefano.sabatini-lala
Fri Sep 28 12:04:06 CEST 2007

On date Friday 2007-09-28 10:48:26 +0200, Reimar D?ffinger encoded:
> Hello,
> On Thu, Sep 27, 2007 at 11:13:32PM +0200, Luca Barbato wrote:
> > Stefano Sabatini wrote:
> > > Another (maybe cleaner) solution would be to request the user to
> > > specify the protocol string for ambiguos files such as foo:movie.mpeg,
> > > which should then be specified as file:foo:movie.mpeg. Anyway in this
> > > case ffmpeg should say something if it can't recognize the protocol
> > > (for example: unrecognized protocol: foo), rather than simply negate
> > > the existence of the file.
> > 
> > what about enforcing the "://" separator?
> I must somehow have missed the whole issue... Why wouldn't someone who
> want to use such filenames specify them as
> file://file...
> for relative and
> file:///path...
> for absolute path like it is done almost everywhere else?
> Or is that not supported by ffmpeg yet?


no, actually in libavutil/file.c there is:

static int file_open(URLContext *h, const char *filename, int flags)
    int access;
    int fd;

    av_strstart(filename, "file:", &filename);

so file://foo.avi

doesn't make ffmpeg use the file protocol, while

does it.

With the attached patch I'm changing this behaviour, favouring the
file://foo.avi approach.

Note that in this way a file such as:

is still interpreted using the file protocol (while foo://movie.avi fails).

And for the most pathological cases such as that suggested by Aurelian:

$ mkdir -p http://samples.mplayerhq.hu/V-codecs/IV50
$ cp foo.avi http://samples.mplayerhq.hu/V-codecs/IV50/girl_01.avi
$ file http://samples.mplayerhq.hu/V-codecs/IV50/girl_01.avi
http://samples.mplayerhq.hu/V-codecs/IV50/girl_01.avi: RIFF (little-endian)
data, AVI, 320 x 240, 25.00 fps, video: DivX 5, audio: MPEG-1 Layer 3
(stereo, 48000 Hz)
$ ffmpeg -i http://samples.mplayerhq.hu/V-codecs/IV50/girl_01.avi
FFmpeg version SVN-r10579, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  libavutil version: 49.5.0
  libavcodec version: 51.44.0
  libavformat version: 51.14.0
  built on Sep 25 2007 22:51:10, gcc: 4.2.1 (Debian 4.2.1-5)
Input #0, avi, from 'http://samples.mplayerhq.hu/V-codecs/IV50/girl_01.avi':
  Duration: 00:00:26.0, start: 0.000000, bitrate: 418 kb/s
  Stream #0.0: Video: IV50 / 0x30355649, 256x256, 30.00 fps(r)

you can still do:
$ ffmpeg -i file://http://samples.mplayerhq.hu/V-codecs/IV50/girl_01.avi

Stefano Sabatini
Linux user number 337176 (see http://counter.li.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: interpret-as-file-bogus-protocols-strings-01.patch
Type: text/x-diff
Size: 3205 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070928/eaf78384/attachment.patch>

More information about the ffmpeg-devel mailing list