Quantcast

[Libav-user] Faulty handling of file: protocol on Windows

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Libav-user] Faulty handling of file: protocol on Windows

Hendrik Schreiber
Hi,

I have searched the archive and the bug database, but haven't found any references to this... If this is an old hat, please ignore.


as far as I remember, in the dev documentation it is mentioned that one can open resources either via a filename, a URL or some other form of custom AVIOContext.

But in its current form FFmpeg does not seem to support well formed Windows file URLs.

On Windows, the scheme part (file:) is always followed by a bunch of slashes, usually three (file:///), before the drive designator.
A correct local file URL is e.g.:

file:///C:/somePath/someFile.mp3

A more complete explanation can be found at http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx

Contrary to this, in libavformat/file.c (static int file_open(URLContext *h, const char *filename, int flags), line 112) FFmpeg simply cuts off "file:" in line 119 and thinks it is done.

Unfortunately,

open("///C:/somePath/someFile.mp3", access, 0666); // line 135

leads to EINVAL/Invalid Argument. This function is called via avio_open2, which is called by avformat_open_input.


Is this a known issue? Or should I file a bug report?

Cheers,

-hendrik
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Carl Eugen Hoyos
Hendrik Schreiber <hs@...> writes:

> On Windows, the scheme part (file:) is always followed
> by a bunch of slashes, usually three (file:///),

three sounds like a very unlikely number to me.

Carl Eugen

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Hendrik Schreiber
On Jun 18, 2013, at 11:16 AM, Carl Eugen Hoyos wrote:

> Hendrik Schreiber <hs@...> writes:
>
>> On Windows, the scheme part (file:) is always followed
>> by a bunch of slashes, usually three (file:///),
>
> three sounds like a very unlikely number to me.

Yes, it sounds odd, but please read http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx

That said - Java only uses one slash for these kinds of URLs on Windows... and I guess, misbehaves.

-hendrik
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Hendrik Schreiber
On Jun 18, 2013, at 11:47 AM, Hendrik Schreiber wrote:

> On Jun 18, 2013, at 11:16 AM, Carl Eugen Hoyos wrote:
>
>> Hendrik Schreiber <hs@...> writes:
>>
>>> On Windows, the scheme part (file:) is always followed
>>> by a bunch of slashes, usually three (file:///),
>>
>> three sounds like a very unlikely number to me.
>
> Yes, it sounds odd, but please read http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx

Anyhow - the only Windows file URL FFmpeg accepts is something like:

file:C:/somePath/someFile.mp3

And that is definitely not a valid URL by any standard I am aware of.

-hendrik
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Hendrik Leppkes
On Tue, Jun 18, 2013 at 1:22 PM, Hendrik Schreiber <[hidden email]> wrote:

> On Jun 18, 2013, at 11:47 AM, Hendrik Schreiber wrote:
>
>> On Jun 18, 2013, at 11:16 AM, Carl Eugen Hoyos wrote:
>>
>>> Hendrik Schreiber <hs@...> writes:
>>>
>>>> On Windows, the scheme part (file:) is always followed
>>>> by a bunch of slashes, usually three (file:///),
>>>
>>> three sounds like a very unlikely number to me.
>>
>> Yes, it sounds odd, but please read http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
>
> Anyhow - the only Windows file URL FFmpeg accepts is something like:
>
> file:C:/somePath/someFile.mp3
>
> And that is definitely not a valid URL by any standard I am aware of.
>

While it may be bugged, why even use a file: URL and not just a plain
path to the file, and avoid this whole mess?
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Jamal Waseem (RBEI/EAP3)
Feeding a file is fine to ffmpeg but what if I want to feed a payload to ffmpeg??
How can I give this payload which is stored in char array to ffmpeg for decoding?
This char array contains H.264 data.

Your help will be highly appreciated.


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Hendrik Leppkes
Sent: Tuesday, June 18, 2013 4:56 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.
Subject: Re: [Libav-user] Faulty handling of file: protocol on Windows

On Tue, Jun 18, 2013 at 1:22 PM, Hendrik Schreiber <[hidden email]> wrote:

> On Jun 18, 2013, at 11:47 AM, Hendrik Schreiber wrote:
>
>> On Jun 18, 2013, at 11:16 AM, Carl Eugen Hoyos wrote:
>>
>>> Hendrik Schreiber <hs@...> writes:
>>>
>>>> On Windows, the scheme part (file:) is always followed
>>>> by a bunch of slashes, usually three (file:///),
>>>
>>> three sounds like a very unlikely number to me.
>>
>> Yes, it sounds odd, but please read http://blogs.msdn.com/b/ie/archive/2006/12/06/file-uris-in-windows.aspx
>
> Anyhow - the only Windows file URL FFmpeg accepts is something like:
>
> file:C:/somePath/someFile.mp3
>
> And that is definitely not a valid URL by any standard I am aware of.
>

While it may be bugged, why even use a file: URL and not just a plain
path to the file, and avoid this whole mess?
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Hendrik Schreiber
In reply to this post by Hendrik Leppkes
On Jun 18, 2013, at 1:25 PM, Hendrik Leppkes wrote:

>
> While it may be bugged, why even use a file: URL and not just a plain
> path to the file, and avoid this whole mess?

Certainly you can work around the whole issue and I did.
So this is nothing urgent.

But.

To me it makes a whole lot of sense to pretty much always use URLs. That saves me the trouble to distinguish between local files and other resources, like e.g. a file hosted on a web server. URLs/URIs are simply a great abstractions, making your code simpler.

But only, if they work.

And in the case of FFmpeg, the file:-scheme, and Windows, the documentation says, feel free to use URLs, but the implementation isn't able to handle them. I think, it would be nice to resolve this discrepancy.

I spent the better part of a day figuring out, why FFmpeg does not understand correct URLs. I would like to spare others this frustrating experience.

-hendrik
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Nicolas George-2
In reply to this post by Carl Eugen Hoyos
Le decadi 30 prairial, an CCXXI, Carl Eugen Hoyos a écrit :
> three sounds like a very unlikely number to me.

The standard syntax is proto://host/full/path; if host is empty with the
file: protocol, that gives file:///full/path, that is correct.

Regards,

--
  Nicolas George

_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user

signature.asc (205 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Hendrik Schreiber
In reply to this post by Jamal Waseem (RBEI/EAP3)
On Jun 18, 2013, at 1:28 PM, Jamal Waseem (RBEI/EAP3) wrote:

> Feeding a file is fine to ffmpeg but what if I want to feed a payload to ffmpeg??
> How can I give this payload which is stored in char array to ffmpeg for decoding?

I'm not sure highjacking a thread is looked upon kindly here. Neither is topposting.
But in any case:

AVIOContext *io;
AVFormatContext *format_context;

format_context = avformat_alloc_context();
io = avio_alloc_context(buffer, buffer_size, 0, your_custom_pointer, read_callback, write_callback, seek_callback);
format_context->pb = io;

Then proceed with avformat_open_input(..) as you normally would. As filename/URL simply use something like "MyCustomIO".

read_callback, write_callback, and seek_callback are function pointers defined in http://www.ffmpeg.org/doxygen/trunk/structAVIOContext.html

If you choose not to implement the seek_callback (perhaps because you are streaming), make sure to call

io->seekable = 0;

Otherwise funny things happen (it would be nice, if avio_alloc_context did that automatically, when seek_callback is NULL).
http://stackoverflow.com/questions/13634539/how-can-libavformat-be-used-without-using-other-libav-libraries/13642438#13642438 may also be useful to you.

Good luck.


-hendrik
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Jamal Waseem (RBEI/EAP3)
Thanks a lot hendrik.
I will try this and will let you know the results.

Thanks again :)



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Hendrik Schreiber
Sent: Wednesday, June 19, 2013 1:07 PM
To: This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.
Subject: Re: [Libav-user] Faulty handling of file: protocol on Windows

On Jun 18, 2013, at 1:28 PM, Jamal Waseem (RBEI/EAP3) wrote:

> Feeding a file is fine to ffmpeg but what if I want to feed a payload to ffmpeg??
> How can I give this payload which is stored in char array to ffmpeg for decoding?

I'm not sure highjacking a thread is looked upon kindly here. Neither is topposting.
But in any case:

AVIOContext *io;
AVFormatContext *format_context;

format_context = avformat_alloc_context();
io = avio_alloc_context(buffer, buffer_size, 0, your_custom_pointer, read_callback, write_callback, seek_callback);
format_context->pb = io;

Then proceed with avformat_open_input(..) as you normally would. As filename/URL simply use something like "MyCustomIO".

read_callback, write_callback, and seek_callback are function pointers defined in http://www.ffmpeg.org/doxygen/trunk/structAVIOContext.html

If you choose not to implement the seek_callback (perhaps because you are streaming), make sure to call

io->seekable = 0;

Otherwise funny things happen (it would be nice, if avio_alloc_context did that automatically, when seek_callback is NULL).
http://stackoverflow.com/questions/13634539/how-can-libavformat-be-used-without-using-other-libav-libraries/13642438#13642438 may also be useful to you.

Good luck.


-hendrik
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Faulty handling of file: protocol on Windows

Hendrik Schreiber
In reply to this post by Nicolas George-2
On Jun 18, 2013, at 7:37 PM, Nicolas George wrote:

> Le decadi 30 prairial, an CCXXI, Carl Eugen Hoyos a écrit :
>> three sounds like a very unlikely number to me.
>
> The standard syntax is proto://host/full/path; if host is empty with the
> file: protocol, that gives file:///full/path, that is correct.

I filed a bug report: https://ffmpeg.org/trac/ffmpeg/ticket/2702

Cheers,

-hendrik
_______________________________________________
Libav-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/libav-user
Loading...