ab-av1
ab-av1 copied to clipboard
Add Output File Path Formatting Option
If you want to specify the output file path with the --output
option, you must first know an appropriate extension for it, and this isn't trivial to figure out.
In the code, extension determination depends on an ffprobe run and some logic:
https://github.com/alexheretic/ab-av1/blob/1082edf609303a97f9df5f92cb81293ac70abcdf/src/command/encode.rs#L151-L159
where is_image
comes from ffprobe.
Maybe there's a solution with output formatting? This would let ab-av1 do the heavy lifting on media type determination while allowing the user control over output path directory, name, etc.
For example, here's how it may be documented:
--output-format <FORMAT>
Write output to the path at <FORMAT>, interpolating any braced
specifiers according to the following list:
{name} The file name of the input path.
E.g. dir/vid.mkv --> vid.mkv
{stem} The file stem of the input path.
E.g. dir/vid.mkv --> vid
{ext} An appropriate extension (without the leading dot) for
the output, chosen by ab-av1. If <FORMAT> does not end
with this specifier, ffmpeg may fail to produce output
because the corresponding media container may not
support the encoded stream.
A literal `{` or `}` may be escaped as `{{` or `}}` respectively.
Additionally, unknown specifiers will cause an error.
This option is exclusive with `--output`.
Examples:
ab-av1 --input "dir/vid.avi" --output-format "other/{stem}-encode.{ext}"
# writes to "other/vid-encode.mkv"
Hopefully, we could create a syntax that is more or less a drop-in for Rust's format!
.
What do you think?
I would vote for a simple default. ffmpeg would eat a (real) .avi when it was just renamed to .mp4 or .mkv, so why would media detection be important? Also .mkv as default (target-)container eats everything. If an end device can't read .mkv then I doubt it could play av1 smooth. ;) In the end changing the container after encoding from .mkv away (if really needed) is a smaller problem than dealing before with a ton of different formats and containers.
My suggestion would be if ab-av1 auto-encode -i supervideo.mp4
Create subfolders with timestamp of start, this is unique, prevents overwriting, prepared for batch usage and robust against errors.
/.YYMMDDHHMMSS-TEMP-supervideomp4-ab-av1-$random12digit/
/YYMMDDHHMMSS-OUTPUT-supervideomp4-ab-av1-$random12digit/YYMMDDHHMMSS-supervideo.mkv