Files
nu-ffmpeg/ffprobe

37 lines
1.1 KiB
Nu
Executable File

#!/usr/bin/env nu
# vim: filetype=nu :
# Run ffprobe on a list of files and return the output as a table.
export def main [
...input_files: string
]: 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<streams: table, format: record> -> table {
let streams = ($in | get streams);
match ($streams | describe) {
'list<list<any>>' => ($streams | flatten),
_ => $streams
}
}
# Retrieve all the video streams from a list of ffprobe outputs
export def "streams video" []: table<streams: table, format: record> -> table {
$in | streams | where codec_type == "video"
}
# Retrieve all the audio streams from a list of ffprobe outputs
export def "streams audio" []: table<streams: table, format: record> -> table {
$in | streams | where codec_type == "audio"
}
# Get the dimensions of a video stream
export def "dimensions" []: record<width: int, height: int> -> record<width: int, height: int> {
$in | select width height
}