#!/usr/bin/env nu # vim: filetype=nu : # Multimedia stream analyzer. export def main [ ...input_files: path ]: nothing -> table { $input_files | each { ^ffprobe -v quiet -print_format json -show_format -show_streams $in | from json } } # Retrieve all the streams from a list of ffprobe outputs export def streams []: table -> table { let streams = ($in | get streams); match ($streams | describe) { 'list>' => ($streams | flatten), _ => $streams } } # Retrieve all the video streams from a list of ffprobe outputs export def "streams video" []: table -> table { $in | streams | where codec_type == "video" } # Retrieve all the audio streams from a list of ffprobe outputs export def "streams audio" []: table -> table { $in | streams | where codec_type == "audio" } # Get the dimensions of a video stream export def "dimensions" []: table -> record { $in | select width height }