Testimonial: filtering to glance at ffprobe - how this repo saves me time #1
Replies: 2 comments 1 reply
|
Wow, never in a million years did I expect such a positive response! Thank you. While nushell is my favorite language, they do update it frequently, which breaks old stuff, and I never updated this repo because I didn't think anyone would use it 😆 My apologies for never including any ffmpeg examples in the repo, I should work on that. Basically any work with ffmpeg starts with I'll try and update the library for the latest nushell version and then add some examples, but here's a few in case you're in a hurry: use ffmpeg.nu;
use filters.nu *;
# Re-encode the video to 30fps
(
ffmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4']
| fps 30
| ffmpeg run
)use ffmpeg.nu;
use filters.nu *;
# Re-encode the video to 30fps, specifying inputs and outputs
# Equivalent to the previous example
(
ffmpeg cmd ['https://sample-videos.com/video321/mp4/720/big_buck_bunny_720p_1mb.mp4']
| filterchain ['0'] { fps 30 } ['video']
| command to-args
| ^ffmpeg ...$in
) |
|
Everything on master should work with nushell 0.108.0 now. If you open a PR and link me a video that contains subtitles, I'd love to include your |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I don't have a blog, but this is what I'd write if I did.
Disclaimer
I'm very new to nushell and quite new to nix: I'm sure there are better ways to do everything I do. Feedback is always welcome.
Motivation - A Backstory No One Cares About
I'm looking for the same info 99% of the time I use ffprobe. I've run ffprobe for years, visually parsing out the information I cared about until I discovered nushell and this repo. I tried various tools and frontends in the past but I'd always hit limitations and end up doing it by hand, eye, and occasionally grep. It doesn't seem like much but it always took me a while, and there were little "gotcha's" that added extra effort and time: like how ffprobe and ffmpeg index streams differently by default (making me count streams and sanity-check
mapparameters etc). Doing it this way has probably burned hours of my life by this point.nu-ffmpegis a game-changer. It gave me structured ffprobe output I could easily use nushell to filter my way to the data I care about, and format it however I wanted.Subtitles and Nu-er Shell
Adding
steams subtitle. nu-ffmpeg provides helpers to retrieve structured data for audio and video streams but seemed to lack one for subtitles which was a common use-case for me, so I added it master...alaestor:nu-ffmpeg:master (I'd make a PR for this but I'm too dumb and disinterested to write tests/docs)A newer shell. I'm using nushell 0.108 (current version in nixpkgs/unstable at time of writing) which nu-ffmpeg doesn't support. It seems there have been some changes to nushell which makes the setup and usage slightly different. I don't know what those changes are and I couldn't quite figure out how to adapt the instructions, so I just kinda made it up.
First I locally packaged (my tweaked fork of) nu-ffmpeg, which I added to an overlay in my flake.
nu-ffmpeg.nix
Then I put
use ${pkgs.nu-ffmpeg}/ffprobein my home-manager'sprograms.nushell.extraConfig(I haven't tried to get the ffmpeg side of nu-ffmpeg to work, which is a bit sad given the project's name... But it was beyond my scope as I'm only interested in making the ffprobe side of my life easier.)
Big win. Instead of trying to remember the various ffprobe arguments and visually parse things (or trying to grep...), now I could just run
ffprobe file.mkv | ffprobe streams audioand use nushell to find whatever it was I wanted to see. Whyffprobe streams audioand not juststreams audio? I don't know... I think it had something to do with newer nushell versions. But it works.Custom Commands - Getting What I Want at a Glance
Having structured data that I could query and navigate through is great, but it opened the door to further time-savings. Next, I wanted short commands to get at the info I need most often: so I added some custom commands to
programs.nushell.extraConfigcommands
The result is as seen in the picture at the top.
Text output of "ffp file.mkv"
The only hiccup to this (aside from not being composable) is that the
videorecord is a bit larger than the typical terminal window, making nushell truncate the output to [table ...]s on smaller displays. This is mostly owing to the inclusion offield_orderandPARwhich aren't often used by most people who are dealing with modern formats.But now, finally: three letters and a filepath gives me all the info I need from ffprobe on a daily basis, and in a very compact and structured format.
A big <3 to sbrow/nu-ffmpeg for making life easier
All reactions