ffprobe - getting file info from pipe

Andrey Baryshnikov picture Andrey Baryshnikov · Dec 7, 2012 · Viewed 7.2k times · Source

I've got an oog file (it was mixed by sox from two audiostreams recorded by pbx Asterisk) and I'm trying to get file information with ffprobe. When I use something like

cat %filename%.ogg | ffprobe -i - 

I get invalid file info (Duration : N/A, wrong bitrate and etc.) When I try

ffprobe -i %filename%

Everything works fine and I get file info. What could be wrong? File content?

Answer

Paulo Fidalgo picture Paulo Fidalgo · May 29, 2013

As of version 1.0.7 of ffprobe you can even get the output in a JSON formatted output:

ffprobe -v quiet -print_format json -show_format Ramp\ -\ Apathy.mp3

Which produces the follwing output:

{
    "format": {
        "filename": "Ramp - Apathy.mp3",
        "nb_streams": 2,
        "format_name": "mp3",
        "format_long_name": "MP2/3 (MPEG audio layer 2/3)",
        "start_time": "0.000000",
        "duration": "203.638856",
        "size": "4072777",
        "bit_rate": "159999",
        "tags": {
            "title": "Apathy",
            "artist": "Ramp",
            "album": "Evolution Devolution Revolution",
            "date": "1999",
            "genre": "Metal"
        }
    }
}

I think you can get the probe using cat, do you have any requirement to cat the file contents? If not just use ffprobe without cat.