diff --git a/projects/FBX/ReadFBX.cpp b/projects/FBX/ReadFBX.cpp index e672ae585f..32e41c2d8b 100644 --- a/projects/FBX/ReadFBX.cpp +++ b/projects/FBX/ReadFBX.cpp @@ -1398,6 +1398,6 @@ ZENDEFNODE(ReadSTL, { {"prim"}, }, {}, - {"BaseIO"}, + {"primitive"}, }); } diff --git a/zeno/src/nodes/prim/SimpleGeometry.cpp b/zeno/src/nodes/prim/SimpleGeometry.cpp index 5a0cb4ac5e..3bcfe5b2f5 100644 --- a/zeno/src/nodes/prim/SimpleGeometry.cpp +++ b/zeno/src/nodes/prim/SimpleGeometry.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #define ROTATE_COMPUTE \ auto gp = glm::vec3(p[0], p[1], p[2]); \ @@ -1455,5 +1456,49 @@ ZENDEFNODE(RemoveFolder, { {}, {"create"}, }); + +struct FFMPEGImagesToVideo : zeno::INode { + virtual void apply() override { + namespace fs = std::filesystem; + auto fps = get_input2("fps"); + auto imageFolderPath = get_input2("imageFolderPath"); + auto bitrate = get_input2("bitrate"); + auto outPath = get_input2("outPath"); + + bool ok = fs::exists(imageFolderPath) && fs::is_directory(imageFolderPath); + if (!ok) { + throw zeno::makeError("imageFolderPath not exists or not is_directory"); + } + std::vector filenames; + std::string extension; + for (const auto& entry : fs::directory_iterator(imageFolderPath)) { + if (fs::is_regular_file(entry.status())) { + filenames.emplace_back(entry.path().filename()); + extension = entry.path().filename().extension().string(); + } + } + std::sort(filenames.begin(), filenames.end()); + for (auto i = 0; i < filenames.size(); i++) { + auto old_name = zeno::format("{}/{}", imageFolderPath, filenames[i].string()); + auto new_name = zeno::format("{}/{:07d}{}", imageFolderPath, i, extension); + fs::rename(old_name, new_name); + } + + auto cmd = zeno::format("ffmpeg -y -r {} -i {}/%07d{} -b:v {}k -c:v mpeg4 {}", fps, imageFolderPath, extension, bitrate, outPath); + std::system(cmd.c_str()); + } +}; + +ZENDEFNODE(FFMPEGImagesToVideo, { + { + {"int", "fps", "25"}, + {"directory", "imageFolderPath", "imageFolderPath"}, + {"int", "bitrate", "200000"}, + {"writepath", "outPath", "outPath"}, + }, + {}, + {}, + {"Miscellaneous"}, +}); } }