CLI GIF/video rendering uses the editor's FFmpeg setting unless --ffmpeg is given
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
abb9f965d6
commit
f4fd255a02
2 files changed
+15
-3
No files matched your search
@@ -63,4 +63,4 @@ anm2ed info file.anm2 # animations, items, sprit
|
|||||||
anm2ed frame file.anm2 --out frame.png --time 4 # one frame
|
anm2ed frame file.anm2 --out frame.png --time 4 # one frame
|
||||||
anm2ed render file.anm2 --out sheet.png --scale 3 # every frame in a grid (--type pngs|gif|webm|mp4|ogv)
|
anm2ed render file.anm2 --out sheet.png --scale 3 # every frame in a grid (--type pngs|gif|webm|mp4|ogv)
|
||||||
```
|
```
|
||||||
Common options: `--animation NAME|INDEX`, `--scale`, `--fps`, `--start`/`--end`, `--background RRGGBB`. `anm2ed render` alone lists them all.
|
Common options: `--animation NAME|INDEX`, `--scale`, `--fps`, `--start`/`--end`, `--background RRGGBB`, `--ffmpeg PATH` (defaults to the editor's FFmpeg setting). `anm2ed render` alone lists them all.
|
||||||
+14
-2
@@ -15,6 +15,8 @@
|
|||||||
#include "model/xml.hpp"
|
#include "model/xml.hpp"
|
||||||
#include "path.hpp"
|
#include "path.hpp"
|
||||||
#include "render.hpp"
|
#include "render.hpp"
|
||||||
|
#include "sdl.hpp"
|
||||||
|
#include "settings.hpp"
|
||||||
#include "working_directory.hpp"
|
#include "working_directory.hpp"
|
||||||
|
|
||||||
using namespace anm2ed::util;
|
using namespace anm2ed::util;
|
||||||
@@ -29,7 +31,7 @@ commands:
|
|||||||
render the animation as --type:
|
render the animation as --type:
|
||||||
sheet all frames in a grid PNG (default; --rows, --columns)
|
sheet all frames in a grid PNG (default; --rows, --columns)
|
||||||
pngs one PNG per frame in the --out folder (--format, default "{}.png")
|
pngs one PNG per frame in the --out folder (--format, default "{}.png")
|
||||||
gif, webm, mp4, ogv through FFmpeg (--ffmpeg, default "ffmpeg")
|
gif, webm, mp4, ogv through FFmpeg (--ffmpeg, default: the editor's setting)
|
||||||
|
|
||||||
options:
|
options:
|
||||||
--animation NAME|INDEX which animation (default: the default animation)
|
--animation NAME|INDEX which animation (default: the default animation)
|
||||||
@@ -102,6 +104,16 @@ options:
|
|||||||
(float)(value & 0xFF) / CHANNEL_MAX, 1.0f};
|
(float)(value & 0xFF) / CHANNEL_MAX, 1.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --ffmpeg, or else the FFmpeg the editor's Render Animation uses (or "ffmpeg" on the PATH).
|
||||||
|
std::filesystem::path ffmpeg_path_get(const Arguments& arguments)
|
||||||
|
{
|
||||||
|
if (auto ffmpeg = arguments.get("ffmpeg")) return path::from_utf8(*ffmpeg);
|
||||||
|
auto settingsPath = sdl::preferences_directory_get() / "settings.ini";
|
||||||
|
auto settingsFfmpeg =
|
||||||
|
path::is_exist(settingsPath) ? Settings(settingsPath).renderFFmpegPath : std::filesystem::path{};
|
||||||
|
return settingsFfmpeg.empty() ? std::filesystem::path("ffmpeg") : settingsFfmpeg;
|
||||||
|
}
|
||||||
|
|
||||||
// By index or name; the default animation otherwise.
|
// By index or name; the default animation otherwise.
|
||||||
std::pair<int, const model::Animation*> animation_get(const model::Model& model, const Arguments& arguments)
|
std::pair<int, const model::Animation*> animation_get(const model::Model& model, const Arguments& arguments)
|
||||||
{
|
{
|
||||||
@@ -241,7 +253,7 @@ options:
|
|||||||
render::RecorderOptions options{.type = type,
|
render::RecorderOptions options{.type = type,
|
||||||
.path = outPath,
|
.path = outPath,
|
||||||
.format = path::from_utf8(arguments.get("format").value_or("{}.png")),
|
.format = path::from_utf8(arguments.get("format").value_or("{}.png")),
|
||||||
.ffmpegPath = path::from_utf8(arguments.get("ffmpeg").value_or("ffmpeg")),
|
.ffmpegPath = ffmpeg_path_get(arguments),
|
||||||
.start = arguments.number_get("start", 0),
|
.start = arguments.number_get("start", 0),
|
||||||
.end = arguments.number_get("end", animation->frameNum - 1),
|
.end = arguments.number_get("end", animation->frameNum - 1),
|
||||||
.animationFps = fps,
|
.animationFps = fps,
|
||||||
|
|||||||
Reference in new issue
Block a user