-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffprobe
executable file
·36 lines (30 loc) · 1.1 KB
/
ffprobe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/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" []: table<streams: table, format: record> -> record<width: int, height: int> {
$in | select width height
}