Andrey Baryshnikov
Andrey Baryshnikov

Reputation: 801

ffprobe - getting file info from pipe

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?

Upvotes: 13

Views: 13054

Answers (3)

Paulo Fidalgo
Paulo Fidalgo

Reputation: 22296

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 following 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.

Upvotes: 3

Yu Jiaao
Yu Jiaao

Reputation: 4714

And you can pipeline it from remote site by curl

curl  --silent --header "Range: bytes=0-51200" https://example.com/your.mp4 | ffprobe -v quiet -show_format -of flat=s=_ -show_entries stream=height,width,nb_frames,duration,codec_name -

Upvotes: 0

Keith Ma
Keith Ma

Reputation: 344

Just a quick note to say that piping input to ffprobe seems to work just fine. Use a hyphen in place of the input file and you are off to the races. Here is an example with a random video file on my system:

cat 01.mp4 | ffprobe -show_format -pretty -loglevel quiet -

Returns:

[FORMAT]
filename=pipe:
nb_streams=2
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=N/A
duration=0:02:56.400000
size=N/A
bit_rate=N/A
probe_score=100
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2mp41
TAG:creation_time=1970-01-01T00:00:00.000000Z
TAG:title=yy.mp4
TAG:encoder=Lavf52.78.3
[/FORMAT]

Upvotes: 5

Related Questions