diff --git a/README.md b/README.md index 5edd41e..7cfece7 100644 --- a/README.md +++ b/README.md @@ -3,76 +3,12 @@ Utility commands for working with ffmpeg in nushell. -## Capabilities +## Capabilities ([see examples](#examples)) - Return tables from `ffprobe` - -```nu -> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 -╭────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────╮ -│ # │ 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 │ ... │ │ │ -│ │ ╰───┴────────────┴───────────────────────────────────────────┴─────────┴────────────┴──────────────────┴────────────┴─────╯ │ │ -╰────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────╯ - -``` - - `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 - -```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 - -```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` will yield `zero inf down up near` - Apply and parse complex filters to a video (Work In Progress) @@ -107,14 +43,82 @@ use /filters * ## FFMpeg -## Supported Filters +### Supported Filters -| name | usage | -| ------- | -------------------------------------------------------------------------------------------------- | -| crop | Crop the input video to given dimensions. | -| fps | Convert the video to specified constant frame rate by duplicating or dropping frames as necessary. | -| loop | loop video frames | -| overlay | Overlay one video on top of another. | -| split | | -| vflip | Flip the input video vertically. | +| name | usage | +| ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| crop | Crop the input video to given dimensions. | +| format | Convert the input video to one of the specified pixel formats. Libavfilter will try to pick one that is suitable as input to the next filter. | +| fps | Convert the video to specified constant frame rate by duplicating or dropping frames as necessary. | +| loop | loop video frames | +| overlay | Overlay one video on top of another. | +| settb | Set the timebase to use for the output frames timestamps. It is mainly useful for testing timebase configuration. | +| split | | +| vflip | Flip the input video vertically. | +| xfade | Apply cross fade from one input video stream to another input video stream. The cross fade is applied for specified duration. +Both inputs must be constant frame-rate and have the same resolution, pixel format, frame rate and timebase. | + +## Examples + +```nu +# Return a table from ffprobe +> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 +╭────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬─────╮ +│ # │ 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 │ ... │ │ │ +│ │ ╰───┴────────────┴───────────────────────────────────────────┴─────────┴────────────┴──────────────────┴────────────┴─────╯ │ │ +╰────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────╯ +``` + +```nu +# Use ffprobe on mutliple files at once +> 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 │ ❎ │ ... │ │ │ +│ │ ╰───┴────────────┴─────────────────────────────┴────────────────┴────────────┴──────────────────┴───────────┴───────┴─────╯ │ │ +╰────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴─────╯ +``` + +```nu +# Extract the video streams from a video +> 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 │ ... │ +╰────┴─────────────┴────────────────────────────────────────────┴──────────┴─────────────┴───────────────────┴─────────────┴────────┴─────╯ +# Extract the audio streams from a video +> 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 │ ... │ +╰────┴─────────────┴──────────────────────────────┴─────────┴────────────┴──────────────────┴────────────┴────────────┴─────────────┴─────╯ +``` + +```nu +# Extract the dimensions of a video stream +> ffprobe https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 | streams video | first | dimensions +╭────────┬──────╮ +│ width │ 1280 │ +│ height │ 720 │ +╰────────┴──────╯ +``` diff --git a/README.md.tmpl b/README.md.tmpl index f7c96de..e13994c 100644 --- a/README.md.tmpl +++ b/README.md.tmpl @@ -8,32 +8,12 @@ vim: filetype=markdown : Utility commands for working with ffmpeg in nushell. -## Capabilities +## Capabilities ([see examples](#examples)) - Return tables from `ffprobe` - -```nu -{{ ffprobe_example }} -``` - - `ffprobe` multiple files at once - -```nu -{{ ffprobe_multiple_files_example }} -``` - - 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 - -```nu -{{ ffprobe_dimensions_example }} -``` - Tab-completion for filter options. i.e. `fps --round` will yield `zero inf down up near` - Apply and parse complex filters to a video (Work In Progress) @@ -60,6 +40,25 @@ use /filters * ## FFMpeg -## Supported Filters +### Supported Filters {{ filters }} + +## Examples + +```nu +{{ ffprobe_example -}} +``` + +```nu +{{ ffprobe_multiple_files_example -}} +``` + +```nu +{{ ffprobe_streams_video_example -}} +{{ ffprobe_streams_audio_example -}} +``` + +```nu +{{ ffprobe_dimensions_example -}} +``` diff --git a/examples/dimensions.nu b/examples/dimensions.nu index ff1d4e8..a98c578 100755 --- a/examples/dimensions.nu +++ b/examples/dimensions.nu @@ -2,8 +2,8 @@ use ../ffprobe ["main" "dimensions" "streams video"]; -# Extract the dimensions of a video stream def main [] { + echo "# Extract the dimensions of a video stream" 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 diff --git a/examples/ffprobe-multiple-files.nu b/examples/ffprobe-multiple-files.nu index f728d14..9288444 100755 --- a/examples/ffprobe-multiple-files.nu +++ b/examples/ffprobe-multiple-files.nu @@ -2,8 +2,8 @@ use ../ffprobe; -# Use ffprobe on mutliple files at once def main [] { + echo "# Use ffprobe on mutliple files at once" 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 diff --git a/examples/ffprobe.nu b/examples/ffprobe.nu index a15f771..f497ec1 100755 --- a/examples/ffprobe.nu +++ b/examples/ffprobe.nu @@ -2,8 +2,8 @@ use ../ffprobe; -# Return a table from ffprobe def main [] { + echo "# Return a table from ffprobe" 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' } diff --git a/examples/streams-audio.nu b/examples/streams-audio.nu index 10f4c3a..2e2aaaa 100755 --- a/examples/streams-audio.nu +++ b/examples/streams-audio.nu @@ -2,8 +2,8 @@ use ../ffprobe ["main" "streams audio"]; -# Extract the audio streams from a video def main [] { + echo "# Extract the audio streams from a video" 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 diff --git a/examples/streams-video.nu b/examples/streams-video.nu index 1662e0e..cdaa3a7 100755 --- a/examples/streams-video.nu +++ b/examples/streams-video.nu @@ -2,8 +2,8 @@ use ../ffprobe ["main" "streams video"]; -# Extract the video streams from a video def main [] { + echo "# Extract the video streams from a video" 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