RockefellerArchiveCenter / scripts

Useful scripts
MIT License
16 stars 5 forks source link

Use ffprobe instead of ffmpeg to get duration #30

Closed ghost closed 6 years ago

ghost commented 6 years ago

Regarding scripts/extractClipGetInfo/ and other scripts. The stderr output from ffmpeg is not meant to be machine parsed. Instead, you can use ffprobe to get a standard, simpler, and machine parseable output. Since it will provide just the duration (in seconds) you can also avoid the additional grep, cut, sed, and awk processes. Example:

ffprobe -loglevel error -show_entries format=duration -of csv=p=0 input

See the ffprobe documentation and FFmpeg Wiki: FFprobe Tips for more info.

bonniegee commented 6 years ago

Thank you! This would also fix #27

ghost commented 6 years ago

That was quick. However, you're requesting the stream duration instead of the format duration which can result in an output of N/A for some inputs such as Matroska (MKV). If that's a potential issue you can use the command in my first comment, or the "Format (container) duration" example in the FFwiki to get the format duration.