docs: Added *more* examples to README.md.

This commit is contained in:
Spencer Brower
2024-03-03 00:48:03 -05:00
parent fe06cbea26
commit 674406054b
9 changed files with 121 additions and 5 deletions

View File

@@ -7,5 +7,9 @@ plugins:
ffprobe: ./get_ffprobe_commands_table ffprobe: ./get_ffprobe_commands_table
version: ./nu_version version: ./nu_version
ffprobe_example: ./examples/ffprobe.nu ffprobe_example: ./examples/ffprobe.nu
pluginTimeout: 10s ffprobe_multiple_files_example: ./examples/ffprobe-multiple-files.nu
ffprobe_streams_audio_example: ./examples/streams-audio.nu
ffprobe_streams_video_example: ./examples/streams-video.nu
ffprobe_dimensions_example: ./examples/dimensions.nu
#pluginTimeout: 10s

View File

@@ -2,12 +2,15 @@ SHELL:=/nix/store/zicq9x6aznw7x202564p8iy0rm04py6l-nushell-0.89.0/bin/nu
all: README.md all: README.md
README.md: examples/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 README.md: examples/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 examples/videos/sample-videos.com/video321/mkv/720/big_buck_bunny_720p_1mb.mkv
gomplate --config .gomplate.yml -V gomplate --config .gomplate.yml
examples/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4: examples/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4:
wget -x -P examples/videos https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 wget -x -P examples/videos https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4
examples/videos/sample-videos.com/video321/mkv/720/big_buck_bunny_720p_1mb.mkv:
wget -x -P examples/videos https://sample-videos.com/video321/mkv/720/big_buck_bunny_720p_1mb.mkv
clean: clean:
rm -f README.md rm -f README.md

View File

@@ -23,8 +23,56 @@ Utility commands for working with ffmpeg in nushell.
``` ```
- `ffprobe` multiple files at once - `ffprobe` multiple files at once
```nu
> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 https://sample-videos.com/video321/mkv/720/big_buck_bunny_720p_1mb.mkv
╭────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────╮
# │ streams │ ... │
├────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼─────┤
0 ╭───┬────────────┬───────────────────────────────────────────┬─────────┬────────────┬──────────────────┬────────────┬─────╮ ...
# │ codec_name │ codec_long_name │ profile │ codec_type │ codec_tag_string │ codec_tag │ ... │ │ │
├───┼────────────┼───────────────────────────────────────────┼─────────┼────────────┼──────────────────┼────────────┼─────┤
0 h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 Main video avc1 0x31637661 ...
1 aac AAC (Advanced Audio Coding) LC audio mp4a 0x6134706d ...
╰───┴────────────┴───────────────────────────────────────────┴─────────┴────────────┴──────────────────┴────────────┴─────╯
1 ╭───┬────────────┬─────────────────────────────┬────────────────┬────────────┬──────────────────┬───────────┬───────┬─────╮ ...
# │ codec_name │ codec_long_name │ profile │ codec_type │ codec_tag_string │ codec_tag │ width │ ... │ │ │
├───┼────────────┼─────────────────────────────┼────────────────┼────────────┼──────────────────┼───────────┼───────┼─────┤
0 mpeg4 MPEG-4 part 2 Simple Profile video [0][0][0][0] 0x0000 1280 ...
1 aac AAC (Advanced Audio Coding) LC audio [0][0][0][0] 0x0000 ...
╰───┴────────────┴─────────────────────────────┴────────────────┴────────────┴──────────────────┴───────────┴───────┴─────╯
╰────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────╯
```
- Use `streams`, `streams video`, and `streams audio` to filter `ffprobe` output - Use `streams`, `streams video`, and `streams audio` to filter `ffprobe` output
```nu
> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 | streams video
╭────┬─────────────┬────────────────────────────────────────────┬──────────┬─────────────┬───────────────────┬─────────────┬────────┬─────╮
# │ codec_name │ codec_long_name │ profile │ codec_type │ codec_tag_string │ codec_tag │ width │ ... │
├────┼─────────────┼────────────────────────────────────────────┼──────────┼─────────────┼───────────────────┼─────────────┼────────┼─────┤
0 h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 Main video avc1 0x31637661 1280 ...
╰────┴─────────────┴────────────────────────────────────────────┴──────────┴─────────────┴───────────────────┴─────────────┴────────┴─────╯
> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 | streams audio
╭────┬─────────────┬──────────────────────────────┬─────────┬────────────┬──────────────────┬────────────┬────────────┬─────────────┬─────╮
# │ codec_name │ codec_long_name │ profile │ codec_type │ codec_tag_string │ codec_tag │ sample_fmt │ sample_rate │ ... │
├────┼─────────────┼──────────────────────────────┼─────────┼────────────┼──────────────────┼────────────┼────────────┼─────────────┼─────┤
1 aac AAC (Advanced Audio Coding) LC audio mp4a 0x6134706d fltp 48000 ...
╰────┴─────────────┴──────────────────────────────┴─────────┴────────────┴──────────────────┴────────────┴────────────┴─────────────┴─────╯
```
- get the `dimensions` of a video stream as a record - get the `dimensions` of a video stream as a record
```nu
> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 | streams video | first | dimensions
╭────────┬──────╮
width 1280
height 720
╰────────┴──────╯
```
- Tab-completion for filter options. i.e. `fps --round<tab>` will yield `zero inf down up near` - Tab-completion for filter options. i.e. `fps --round<tab>` will yield `zero inf down up near`
- Apply and parse complex filters to a video (Work In Progress) - Apply and parse complex filters to a video (Work In Progress)

View File

@@ -17,8 +17,23 @@ Utility commands for working with ffmpeg in nushell.
``` ```
- `ffprobe` multiple files at once - `ffprobe` multiple files at once
```nu
{{ ffprobe_multiple_files_example }}
```
- Use `streams`, `streams video`, and `streams audio` to filter `ffprobe` output - Use `streams`, `streams video`, and `streams audio` to filter `ffprobe` output
```nu
{{ ffprobe_streams_video_example }}
{{ ffprobe_streams_audio_example }}
```
- get the `dimensions` of a video stream as a record - get the `dimensions` of a video stream as a record
```nu
{{ ffprobe_dimensions_example }}
```
- Tab-completion for filter options. i.e. `fps --round<tab>` will yield `zero inf down up near` - Tab-completion for filter options. i.e. `fps --round<tab>` will yield `zero inf down up near`
- Apply and parse complex filters to a video (Work In Progress) - Apply and parse complex filters to a video (Work In Progress)

10
examples/dimensions.nu Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env nu
use ../ffprobe ["main" "dimensions" "streams video"];
# Extract the dimensions of a video stream
def main [] {
echo "> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 | streams video | first | dimensions"
ffprobe $'($env.FILE_PWD)/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'
| streams video | first | dimensions
}

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env nu
use ../ffprobe;
# Use ffprobe on mutliple files at once
def main [] {
echo "> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 https://sample-videos.com/video321/mkv/720/big_buck_bunny_720p_1mb.mkv"
(
ffprobe
$'($env.FILE_PWD)/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'
$'($env.FILE_PWD)/videos/sample-videos.com/video321/mkv/720/big_buck_bunny_720p_1mb.mkv'
)
}

View File

@@ -2,5 +2,8 @@
use ../ffprobe; use ../ffprobe;
echo "> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4" # Return a table from ffprobe
ffprobe $'($env.FILE_PWD)/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4' def main [] {
echo "> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4"
ffprobe $'($env.FILE_PWD)/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'
}

10
examples/streams-audio.nu Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env nu
use ../ffprobe ["main" "streams audio"];
# Extract the audio streams from a video
def main [] {
echo "> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 | streams audio"
ffprobe $'($env.FILE_PWD)/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'
| streams audio
}

10
examples/streams-video.nu Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env nu
use ../ffprobe ["main" "streams video"];
# Extract the video streams from a video
def main [] {
echo "> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 | streams video"
ffprobe $'($env.FILE_PWD)/videos/sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'
| streams video
}