1

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.

W. Zhu
  • 755
  • 6
  • 16

1 Answers1

1

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.

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • Does it mean that we cannot be sure how many bytes are enough but ffprobe knows and stops when it has read enough (so that if reading via http, it may close the connection before downloading all content)? – W. Zhu Jan 16 '22 at 14:26
  • Yes, for probing purposes it will read just enough for evaluation OR till it hits analyzeduration or probesize limit. – Gyan Jan 16 '22 at 17:41