Search code examples
ffprobe

How many bytes does ffprobe need?


I would like to use ffprobe to look at the information of media files. However, the files are not on my local disk, and I have to read from a remote storage. I can read the first n bytes, write them to a temporary file and use ffprobe to read the information. I would like to know the least such n.

I tested with a few files, and 512KB worked with all the files that I tested. However, I am not sure if that will work for all media files.


Solution

  • ffprobe (and ffmpeg) aims to parse two things when opening an input:

    1. the input container's header
    2. payload data from each stream, enough to ascertain salient stream parameters like codec attributes and frame rate.

    The header size is generally proportional to the number of packets in the file i.e. a 3 hour MP4 file will have a larger header than a 3 min MP4. (if the header is at the end of the file, then access to the first 512 kB won't help)

    From each stream, ffmpeg will decode packets till its stream attributes have been populated. The amount of bytes consumed will depend on stream bitrate, and how many streams are present.

    So, the strict response to 'I am not sure if that will work for all media files' is it won't.