When a script needs the length of a video, the normal ffprobe output is too chatty. A few writer options cut it down to the single number, which is easy to use in a shell script.
ffprobe sorts what it knows into sections. -show_entries picks the section and the fields, written as section=field, and -of (short for -output_format) chooses the writer. The default writer has two options that trim the layout: nw (noprint_wrappers) drops the section header and footer, and nk (nokey) drops the key in front of each value.
ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 input.mp4
The result is a line like 1834.512000, the length in seconds, and nothing else. -v error limits the log to errors, so nothing but the value lands in the variable if all goes well. Handy for a variable:
secs=$(ffprobe -v error -show_entries format=duration -of default=nw=1:nk=1 input.mp4)
If you want something readable for a person, the docs list -sexagesimal, which prints time values as HH:MM:SS.MICROSECONDS:
ffprobe -v error -sexagesimal -show_entries format=duration -of default=nw=1:nk=1 input.mp4
For other fields, change the entry. stream=codec_name lists the codec of every stream, and the same options keep it to bare words. The writers also include json, csv, flat, ini and xml when a script wants structure instead of a single value.
A caveat on the number itself: format=duration is the duration of the container as ffprobe reads it, not a count of the frames. For an odd file, a broken download for example, it can be missing or off, so a script should check that it got a value before it divides by it.
Further reading: ffprobe documentation