diff --git a/README.md b/README.md index 32156f2..899eaa3 100644 --- a/README.md +++ b/README.md @@ -182,3 +182,38 @@ use /filters * ### Examples +```nu +# Re-encode the video to 30fps +( + fmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'] [] + | fps 30 + | ffmpeg run +) + +Would run: +╭───┬────────────────────────────────────────────────────────────────────────╮ +│ 0 │ ffmpeg │ +│ 1 │ -i │ +│ 2 │ https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 │ +│ 3 │ -filter_complex │ +│ 4 │ fps=fps=30 │ +╰───┴────────────────────────────────────────────────────────────────────────╯ +``` + +```nu +# Re-encode the video to 30fps, specifying input and output streams +( + fmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'] [] + | filterchain -i ['0'] -o ['video'] { fps 30 } + | ffmpeg run +) + +Would run: +╭───┬────────────────────────────────────────────────────────────────────────╮ +│ 0 │ ffmpeg │ +│ 1 │ -i │ +│ 2 │ https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4 │ +│ 3 │ -filter_complex │ +│ 4 │ [0]fps=fps=30[video] │ +╰───┴────────────────────────────────────────────────────────────────────────╯ +``` diff --git a/README.md.tmpl b/README.md.tmpl index 0c61e01..f7c2d74 100644 --- a/README.md.tmpl +++ b/README.md.tmpl @@ -69,3 +69,10 @@ use /filters * ### Examples +```nu +{{ example "convert-to-30-fps" -}} +``` + +```nu +{{ example "convert-to-30-fps-with-filterchain" -}} +``` diff --git a/examples/convert-to-30-fps-with-filterchain.nu b/examples/convert-to-30-fps-with-filterchain.nu new file mode 100755 index 0000000..387e205 --- /dev/null +++ b/examples/convert-to-30-fps-with-filterchain.nu @@ -0,0 +1,25 @@ +#!/usr/bin/env -S nu -n + +use ../ffmpeg.nu; +use ../ffmpeg.nu [filterchain]; +use ../filters.nu *; + +# Re-encode the video to 30fps +def main []: nothing -> any { + print '# Re-encode the video to 30fps, specifying input and output streams' + print '(' + print ' fmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'] []' + print " | filterchain -i ['0'] -o ['video'] { fps 30 }" + print ' | ffmpeg run' + print ')' + print '' + print 'Would run:' + + ( + ffmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'] [] + | filterchain -i ['0'] -o ['video'] { fps 30 } + | ffmpeg cmd to-args + | ['ffmpeg' ...$in] + ) +} + diff --git a/examples/convert-to-30-fps.nu b/examples/convert-to-30-fps.nu new file mode 100755 index 0000000..7bb8aa1 --- /dev/null +++ b/examples/convert-to-30-fps.nu @@ -0,0 +1,24 @@ +#!/usr/bin/env -S nu -n + +use ../ffmpeg.nu; +use ../filters.nu *; + +# Re-encode the video to 30fps +def main []: nothing -> any { + print '# Re-encode the video to 30fps' + print '(' + print ' fmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'] []' + print ' | fps 30' + print ' | ffmpeg run' + print ')' + print '' + print 'Would run:' + + ( + ffmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4'] [] + | fps 30 + | ffmpeg cmd to-args + | ['ffmpeg' ...$in] + ) +} +