diff --git a/applications/reconstruct/src/main.cpp b/applications/reconstruct/src/main.cpp index b3a4538dfe2c4e5b281c465ef966ce68d9670739..8059e5b2712a70379a89183250ab8cbc0758873a 100644 --- a/applications/reconstruct/src/main.cpp +++ b/applications/reconstruct/src/main.cpp @@ -16,6 +16,7 @@ #include <ftl/rgbd/group.hpp> #include <ftl/threads.hpp> #include <ftl/codecs/writer.hpp> +#include <ftl/codecs/reader.hpp> #include "ilw/ilw.hpp" #include <ftl/render/splat_render.hpp> @@ -102,6 +103,36 @@ static void run(ftl::Configurable *root) { net->start(); net->waitConnections(); + + // Check paths for an FTL file to load... + auto paths = (*root->get<nlohmann::json>("paths")); + for (auto &x : paths.items()) { + std::string path = x.value().get<std::string>(); + auto eix = path.find_last_of('.'); + auto ext = path.substr(eix+1); + + // Command line path is ftl file + if (ext == "ftl") { + // Create temp reader to count number of sources found in file + std::ifstream file; + file.open(path); + ftl::codecs::Reader reader(file); + reader.begin(); + + int max_stream = 0; + reader.read(reader.getStartTime()+100, [&max_stream](const ftl::codecs::StreamPacket &spkt, const ftl::codecs::Packet &pkt) { + max_stream = max(max_stream, spkt.streamID); + }); + reader.end(); + + LOG(INFO) << "Found " << (max_stream+1) << " sources in " << path; + + // For each stream found, add a source object + for (int i=0; i<max_stream; ++i) { + root->getConfig()["sources"].push_back(nlohmann::json{{"uri",std::string("file://") + path + std::string("#") + std::to_string(i)}}); + } + } + } // Create a vector of all input RGB-Depth sources auto sources = ftl::createArray<Source>(root, "sources", net); diff --git a/components/codecs/src/encoder.cpp b/components/codecs/src/encoder.cpp index fdacc89596668937f8f465995f52f0955bbded01..834c003b706be7208b627e3ea03d7b5efbb7245e 100644 --- a/components/codecs/src/encoder.cpp +++ b/components/codecs/src/encoder.cpp @@ -73,6 +73,6 @@ bool Encoder::encode(const cv::Mat &in, preset_t preset, const auto &settings = ftl::codecs::getPreset(preset); const definition_t definition = (in.type() == CV_32F) ? settings.depth_res : settings.colour_res; const bitrate_t bitrate = (in.type() == CV_32F) ? settings.depth_qual : settings.colour_qual; - LOG(INFO) << "Encode definition: " << (int)definition; + return encode(in, definition, bitrate, cb); }