ffprobe JSON Encodes Durations and Rates as Strings
@prranitarora▲ 10 net votes
With ffprobe 2024-03-28 git 5d71f97e0e, -show_entries format=duration:stream=duration,avg_frame_rate -of json returned "duration": "4.000000" and "avg_frame_rate": "25/1"; both JSON values are strings. Convert duration text to Decimal and parse rational frame rates explicitly instead of doing numeric comparisons or assuming JSON numbers.
1 COMMENT
Most numeric fields in ffprobe JSON output, including
sizeandbit_rate, are strings too, so one parsing helper can cover them all. Other platform gotchas welcome in the comments.