Auto detect file type

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

Auto detect file type

Arthur
Hello,
I have a file with no extension, and I'd like to read it with sox, how
can I do to get the file type, or does sox have a feature to detect the
file type automatically ?
Thanks in advance for any help

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Jesse Ross-6
"soxi" can tell you information about the file, even without the extension.

The UNIX "file" command is pretty adept at figuring out sound files too.

best,
jesse


On Tue, Dec 3, 2013 at 2:48 PM, Arthur <[hidden email]> wrote:
Hello,
I have a file with no extension, and I'd like to read it with sox, how
can I do to get the file type, or does sox have a feature to detect the
file type automatically ?
Thanks in advance for any help

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Arthur
I tried with soxi, but it still doesn't work, with an mp3 ile, I get soxi FAIL formats: can't determine type of file `ringtone'

and is there any way to translate the output from file to something that sox understands ?

I'm using sox within a python script, maybe it would be a better idea to use the sox lib, but I think that even if it will be cleaner, I will have the same problem.

3 décembre 2013 21:22 "Jesse Ross" <[hidden email]> a écrit:

"soxi" can tell you information about the file, even without the extension.

The UNIX "file" command is pretty adept at figuring out sound files too.

best,
jesse


On Tue, Dec 3, 2013 at 2:48 PM, Arthur <[hidden email]> wrote:


Hello,
I have a file with no extension, and I'd like to read it with sox, how
can I do to get the file type, or does sox have a feature to detect the
file type automatically ?
Thanks in advance for any help

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

René Bastian
Le Tue, 03 Dec 2013 21:09:49 +0000,
[hidden email] a écrit :

> I tried with soxi, but it still doesn't work, with an mp3 ile, I get
> soxi FAIL formats: can't determine type of file `ringtone'

copy ringtone to ringtone.mp3, play it and listen ...
good luck

a file is an array of bytes; without header or other metadata
one cannot distinguish a sound file and another file.

>
> and is there any way to translate the output from file to something
> that sox understands ?
>
> I'm using sox within a python script, maybe it would be a better idea
> to use the sox lib, but I think that even if it will be cleaner, I
> will have the same problem.
>
> 3 décembre 2013 21:22 "Jesse Ross" <[hidden email]> a écrit:
> "soxi" can tell you information about the file, even without the
> extension.
>
> The UNIX "file" command is pretty adept at figuring out sound files
> too.
>
> best,
> jesse
>
>
> On Tue, Dec 3, 2013 at 2:48 PM, Arthur <[hidden email]> wrote:
>
>
> Hello,
> I have a file with no extension, and I'd like to read it with sox, how
> can I do to get the file type, or does sox have a feature to detect
> the file type automatically ?
> Thanks in advance for any help
>
> ------------------------------------------------------------------------------
> Sponsored by Intel(R) XDK
> Develop, test and display web and hybrid apps with a single code base.
> Download it for free now!
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> _______________________________________________
> Sox-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sox-users
>


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Arthur
It's not that simple, the file can be a user uploaded file or a webradio URL , and I don't know which file type a will have. Mplayer can do that, but it's a bit too heavy, and you can't apply effects to the file.



"René Bastian" <[hidden email]> a écrit :
Le Tue, 03 Dec 2013 21:09:49 +0000,
[hidden email] a écrit :

I tried with soxi, but it still doesn't work, with an mp3 ile, I get
soxi FAIL formats: can't determine type of file `ringtone'

copy ringtone to ringtone.mp3, play it and listen ...
good luck

a file is an array of bytes; without header or other metadata
one cannot distinguish a sound file and another file.

and is there any way to translate the output from file to something
that sox understands ?

I'm using sox within a python script, maybe it would be a better idea
to use the sox lib, but I think that even if it will be cleaner, I
will have the same problem.

3 décembre 2013 21:22 "Jesse Ross" <[hidden email]> a écrit:
"soxi" can tell you information about the file, even without the
extension.

The UNIX "file" command is pretty adept at figuring out sound files
too.

best,
jesse


On Tue, Dec 3, 2013 at 2:48 PM, Arthur <[hidden email]> wrote:


Hello,
I have a file with no extension, and I'd like to read it with sox, how
can I do to get the file type, or does sox have a feature to detect
the file type automatically ?
Thanks in advance for any help



Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk


Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users





Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk


Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users

--
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.
------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Jan Stary
In reply to this post by Arthur
On Dec 03 20:48:46, [hidden email] wrote:
> Hello,
> I have a file with no extension, and I'd like to read it with sox, how
> can I do to get the file type, or does sox have a feature to detect the
> file type automatically ?

Where does the file come from?
Do you have no idea what it can possibly contain?
What does file(1) say about the file?


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Arthur Toussaint
In reply to this post by Arthur
Sorry, I have borken my other email address, i'm answering with this one ...
The file is a file chose by the user, it can be of any codec, mp3, wav,
or any other. It can also be a web ressource, and for example with
http://sc3.spacialnet.com:31560 you don't have the extension, so sox
doesn't recognize it.
VLC, mplayer or ffmpeg autodetect the format, and i'm wondering if there
is any way to do so with sox.

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Jan Stary
On Dec 08 12:14:28, [hidden email] wrote:
> Sorry, I have borken my other email address, i'm answering with this one ...
> The file is a file chose by the user, it can be of any codec, mp3, wav,
> or any other. It can also be a web ressource, and for example with
> http://sc3.spacialnet.com:31560 you don't have the extension, so sox
> doesn't recognize it.
> VLC, mplayer or ffmpeg autodetect the format, and i'm wondering if there
> is any way to do so with sox.

No, SoX does not detect the format without the proper name.

$ play http://sc3.spacialnet.com:31560       
play FAIL formats: no handler for file extension `com:31560'
ftp: Writing -: Broken pipe

However, it plays just fine if you tell SoX
what format it actually is.

 $ play -t mp3 http://sc3.spacialnet.com:31560

 <a href="http://sc3.spacialnet.com:31560:">http://sc3.spacialnet.com:31560:

   Encoding: MPEG audio    
   Channels: 2 @ 16-bit  
   Samplerate: 44100Hz      
   Replaygain: off        
   Duration: unknown      

   In:0.00% 00:00:00.84 [00:00:00.00] Out:32.8k [======|=====!] Hd:0.0 Clip:0  

So you situation is, the user can provide _any_ kind of data
under _any_ kind of name, and you never know?


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Arthur Toussaint
Yes, that's the problem, I don't know what kind of file the user will
give, and the URL of the remote ressource often contains no information
in the filename...

With a local file, I could check the file type with the file command,
but I don't know how to do so with a remote stream ...



Le 08/12/13 13:55, Jan Stary a écrit :

> On Dec 08 12:14:28, [hidden email] wrote:
>> Sorry, I have borken my other email address, i'm answering with this one ...
>> The file is a file chose by the user, it can be of any codec, mp3, wav,
>> or any other. It can also be a web ressource, and for example with
>> http://sc3.spacialnet.com:31560 you don't have the extension, so sox
>> doesn't recognize it.
>> VLC, mplayer or ffmpeg autodetect the format, and i'm wondering if there
>> is any way to do so with sox.
> No, SoX does not detect the format without the proper name.
>
> $ play http://sc3.spacialnet.com:31560       
> play FAIL formats: no handler for file extension `com:31560'
> ftp: Writing -: Broken pipe
>
> However, it plays just fine if you tell SoX
> what format it actually is.
>
>  $ play -t mp3 http://sc3.spacialnet.com:31560
>
>  <a href="http://sc3.spacialnet.com:31560:">http://sc3.spacialnet.com:31560:
>
>    Encoding: MPEG audio    
>    Channels: 2 @ 16-bit  
>    Samplerate: 44100Hz      
>    Replaygain: off        
>    Duration: unknown      
>
>    In:0.00% 00:00:00.84 [00:00:00.00] Out:32.8k [======|=====!] Hd:0.0 Clip:0  
>
> So you situation is, the user can provide _any_ kind of data
> under _any_ kind of name, and you never know?
>
>
> ------------------------------------------------------------------------------
> Sponsored by Intel(R) XDK
> Develop, test and display web and hybrid apps with a single code base.
> Download it for free now!
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> _______________________________________________
> Sox-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sox-users


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Jan Stary
On Dec 08 14:36:34, [hidden email] wrote:
> Yes, that's the problem, I don't know what kind of file the user will
> give, and the URL of the remote ressource often contains no information
> in the filename...
>
> With a local file, I could check the file type with the file command,
> but I don't know how to do so with a remote stream ...

You can download a bit of the data and run `fle' on that.

 $ ftp -o - http://sc3.spacialnet.com:31560 | head | file -
 $ Trying 208.80.53.106...
 $ Requesting http://sc3.spacialnet.com:31560
 $ /dev/stdin: data
 $ ftp: Writing -: Broken pipe

However, an mp3 stream, for example, is just 'data'.


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: Auto detect file type

Arthur Toussaint
Otherwise, it seems that there is a Content-Type header that gives the
mime type of the file, maybe I'll try with curl -v | head.
Le 08/12/13 14:52, Jan Stary a écrit :

> On Dec 08 14:36:34, [hidden email] wrote:
>> Yes, that's the problem, I don't know what kind of file the user will
>> give, and the URL of the remote ressource often contains no information
>> in the filename...
>>
>> With a local file, I could check the file type with the file command,
>> but I don't know how to do so with a remote stream ...
> You can download a bit of the data and run `fle' on that.
>
>  $ ftp -o - http://sc3.spacialnet.com:31560 | head | file -
>  $ Trying 208.80.53.106...
>  $ Requesting http://sc3.spacialnet.com:31560
>  $ /dev/stdin: data
>  $ ftp: Writing -: Broken pipe
>
> However, an mp3 stream, for example, is just 'data'.
>
>
> ------------------------------------------------------------------------------
> Sponsored by Intel(R) XDK
> Develop, test and display web and hybrid apps with a single code base.
> Download it for free now!
> http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
> _______________________________________________
> Sox-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/sox-users


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users