mirror of
https://github.com/sbrow/nu-ffmpeg.git
synced 2025-12-29 16:23:11 -05:00
docs: Updated README.md.
This commit is contained in:
26
README.md
26
README.md
@@ -1,4 +1,26 @@
|
|||||||
#
|
# nu-ffmpeg
|
||||||
|
|
||||||
|
Utility commands for working with ffmpeg in nushell.
|
||||||
|
|
||||||
|
## Capabilities
|
||||||
|
|
||||||
|
- Return tables from `ffprobe`
|
||||||
|
- `ffprobe` multiple files at once
|
||||||
|
- Use `streams`, `streams video`, and `streams audio` to filter `ffprobe` output
|
||||||
|
- get the `dimensions` of a video stream as a record
|
||||||
|
- Apply and parse complex filters to a video (Work In Progress)
|
||||||
|
|
||||||
|
## Setup
|
||||||
|
|
||||||
|
The `ffmpeg` and `ffprobe` commands are required to be installed and available
|
||||||
|
in your path; they are not installed for you.
|
||||||
|
|
||||||
|
Currently nushell versions 0.87.0 - 0.88.1 are supported.
|
||||||
|
|
||||||
|
After that, clone this repository and add the following code to your scripts,
|
||||||
|
or to your `config.nu` file:
|
||||||
|
|
||||||
```nu
|
```nu
|
||||||
use ./ffprobe
|
use <path-to-repository>/ffprobe
|
||||||
|
use <path-to-repository>/filters *
|
||||||
|
```
|
||||||
|
|||||||
10
ffprobe
10
ffprobe
@@ -4,14 +4,14 @@
|
|||||||
# Multimedia stream analyzer.
|
# Multimedia stream analyzer.
|
||||||
export def main [
|
export def main [
|
||||||
...input_files: path
|
...input_files: path
|
||||||
] {
|
]: nothing -> table {
|
||||||
$input_files | each {
|
$input_files | each {
|
||||||
^ffprobe -v quiet -print_format json -show_format -show_streams $in | from json
|
^ffprobe -v quiet -print_format json -show_format -show_streams $in | from json
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve all the streams from a list of ffprobe outputs
|
# Retrieve all the streams from a list of ffprobe outputs
|
||||||
export def streams [] {
|
export def streams []: table<streams: table, format: record> -> table {
|
||||||
let streams = ($in | get streams);
|
let streams = ($in | get streams);
|
||||||
|
|
||||||
match ($streams | describe) {
|
match ($streams | describe) {
|
||||||
@@ -21,16 +21,16 @@ export def streams [] {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve all the video streams from a list of ffprobe outputs
|
# Retrieve all the video streams from a list of ffprobe outputs
|
||||||
export def "streams video" [] {
|
export def "streams video" []: table<streams: table, format: record> -> table {
|
||||||
$in | streams | where codec_type == "video"
|
$in | streams | where codec_type == "video"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve all the audio streams from a list of ffprobe outputs
|
# Retrieve all the audio streams from a list of ffprobe outputs
|
||||||
export def "streams audio" [] {
|
export def "streams audio" []: table<streams: table, format: record> -> table {
|
||||||
$in | streams | where codec_type == "audio"
|
$in | streams | where codec_type == "audio"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the dimensions of a video stream
|
# Get the dimensions of a video stream
|
||||||
export def "dimensions" [] {
|
export def "dimensions" []: table<streams: table, format: record> -> record<width: int, height: int> {
|
||||||
$in | select width height
|
$in | select width height
|
||||||
}
|
}
|
||||||
|
|||||||
14
filters.nu
14
filters.nu
@@ -1,22 +1,22 @@
|
|||||||
#!/usr/bin/env -S nu --stdin
|
#!/usr/bin/env -S nu --stdin
|
||||||
|
|
||||||
def "parse filter" [
|
export def "parse filter" [
|
||||||
] {
|
] {
|
||||||
$in | parse --regex '^(?<name>[^=]+)=(?<params>.*)' | first |
|
$in | parse --regex '^(?<name>[^=]+)=(?<params>.*)' | first |
|
||||||
update params {|row| $row.params | parse --regex `(?<param>[^=]+)=(?<value>[^:]+):?` }
|
update params { parse --regex `(?<param>[^=]+)=(?<value>[^:]+):?` }
|
||||||
}
|
}
|
||||||
|
|
||||||
def "filter to-string" [] {
|
export def "filter to-string" [] {
|
||||||
each { |filter| $'($filter.name)=($filter.params | format '{param}={value}')' } |
|
each { |filter| $'($filter.name)=($filter.params | format '{param}={value}')' } |
|
||||||
str join ':'
|
str join ':'
|
||||||
}
|
}
|
||||||
|
|
||||||
def "complex-filters to-string" [
|
export def "complex-filters to-string" [
|
||||||
--pretty-print (-p)
|
--pretty-print (-p)
|
||||||
]: table<input: list<string>, filters: table<name: string, params: table<param: string, value: string>>, output: string> -> string {
|
]: table<input: list<string>, filters: table<name: string, params: table<param: string, value: string>>, output: string> -> string {
|
||||||
$in | update filters {
|
$in | update filters {
|
||||||
|$row| $row.filters | flatten | filter to-string
|
flatten | filter to-string
|
||||||
} | update input { |row|
|
} | update input {
|
||||||
$row.input | str join ']['
|
str join ']['
|
||||||
} | format '[{input}]{filters}[{output}]' | str join (";" + (if $pretty_print { "\n" } else { "" })) | str replace --all '[]' ''
|
} | format '[{input}]{filters}[{output}]' | str join (";" + (if $pretty_print { "\n" } else { "" })) | str replace --all '[]' ''
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user