[FFmpeg-devel] fix for issue 1676 - file.c doesn't understand file URLs

Tomas Härdin tomas.hardin
Fri Feb 5 11:38:32 CET 2010

On Fri, 2010-02-05 at 10:57 +0100, Michael Niedermayer wrote:
> On Mon, Jan 11, 2010 at 12:44:10PM +0200, aviad rozenhek wrote:
> > as in $subj
> > the purpose of this patch is to allow files to also be accessed via
> > well-formed URLs such as file:///c:/temp/myfile.avi
> where does this 3rd / come from?
> also like reimar already asked on roundup, is there some
> standard/ RFC/ whatever that contains this 3rd /
> ?

I can  shed some light on this. I read up on this a while back and found
the RFC in which the URI syntax is defined. In fact, the RFC is here:

The short answer is that you shouldn't use any extra slashes at all.
That example URI is NOT well-formed.

On *NIX systems you'd say "file:/foo/bar". While "file:///foo/bar" might
seem valid if you stretch the RFC a bit, the regex defined in the RFC
does not match that. In other words, a zero-length auth (between the
second and third slash) is invalid, but most parsers accept that anyway.
An auth on the local file system doesn't do you much good anyway, unless
you su to that user in your program using that info, thus giving you
access ("file://alice:password/home/alice/secret/bob.avi").

On Windows however things are a bit trickier. The correct syntax is
"file:c:/foo/bar" since it's an absolute URI. The problem is that some
parts and versions of Windows fails to parse this. If instead you say
"file://c:/foo/bar" you have just defined an absolute URI to the "foo"
drive with an auth of "c:" (usename = "c", password = ""). This is why
you need zero or three slashes, depending on which part of the Windows
system you're talking to. In other words, you might need need to use
three slashes as a hack to get around certain problems on that platform.

On Cygwin this gets even worse. I'm currently using a hack that detects
whether a given URI has to be rewritten from "file:c:/foo/bar" (with
zero, two or three slashes) to "file:/cygdrive/c/foo/bar".

I hope that made sense :)


More information about the ffmpeg-devel mailing list