mirror of
https://github.com/sbrow/nu-ffmpeg.git
synced 2025-12-29 16:23:11 -05:00
feat: Initial commit.
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.direnv
|
||||
36
ffprobe
Executable file
36
ffprobe
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env nu
|
||||
# vim: filetype=nu :
|
||||
|
||||
# Multimedia stream analyzer.
|
||||
export def main [
|
||||
...input_files: path
|
||||
] {
|
||||
$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 [] {
|
||||
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" [] {
|
||||
$in | streams | where codec_type == "video"
|
||||
}
|
||||
|
||||
# Retrieve all the audio streams from a list of ffprobe outputs
|
||||
export def "streams audio" [] {
|
||||
$in | streams | where codec_type == "audio"
|
||||
}
|
||||
|
||||
# Get the dimensions of a video stream
|
||||
export def "dimensions" [] {
|
||||
$in | select width height
|
||||
}
|
||||
22
filters.nu
Executable file
22
filters.nu
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env -S nu --stdin
|
||||
|
||||
def "parse filter" [
|
||||
] {
|
||||
$in | parse --regex '^(?<name>[^=]+)=(?<params>.*)' | first |
|
||||
update params {|row| $row.params | parse --regex `(?<param>[^=]+)=(?<value>[^:]+):?` }
|
||||
}
|
||||
|
||||
def "filter to-string" [] {
|
||||
each { |filter| $'($filter.name)=($filter.params | format '{param}={value}')' } |
|
||||
str join ':'
|
||||
}
|
||||
|
||||
def "complex-filters to-string" [
|
||||
--pretty-print (-p)
|
||||
]: table<input: list<string>, filters: table<name: string, params: table<param: string, value: string>>, output: string> -> string {
|
||||
$in | update filters {
|
||||
|$row| $row.filters | flatten | filter to-string
|
||||
} | update input { |row|
|
||||
$row.input | str join ']['
|
||||
} | format '[{input}]{filters}[{output}]' | str join (";" + (if $pretty_print { "\n" } else { "" })) | str replace --all '[]' ''
|
||||
}
|
||||
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1704538339,
|
||||
"narHash": "sha256-1734d3mQuux9ySvwf6axRWZRBhtcZA9Q8eftD6EZg6U=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "46ae0210ce163b3cba6c7da08840c1d63de9c701",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
23
flake.nix
Normal file
23
flake.nix
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
description = "A very basic flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
in
|
||||
{
|
||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
ffmpeg
|
||||
|
||||
sbcl
|
||||
|
||||
nushellFull
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user