1369f5235d
Extract the tqdm-like stderr progress bar into a shared helper and reuse it across zed_svo_to_mp4, zed_svo_grid_to_mp4, and zed_svo_to_mcap. For zed_svo_to_mcap, single-source exports now report exact frame totals and bundled multi-camera exports report exact synced-group totals on TTY. When bundled mode runs without --end-frame, the tool performs a counting pass first so the progress total remains exact instead of estimated. Also document the bundled MCAP progress behavior in the README and record the current third_party dependency state in third_party/README. That note now makes it explicit that CLI11 and proxy are the active submodules, while tomlplusplus and mcap are vendored source drops, and adds a TODO to revisit converting mcap into a submodule later. Verified with the Debug build during implementation, including single-camera and bundled zed_svo_to_mcap runs that rendered clean progress output to a TTY.
105 lines
2.4 KiB
C++
105 lines
2.4 KiB
C++
#pragma once
|
|
|
|
#include "cvmmap_streamer/config/runtime_config.hpp"
|
|
|
|
#include <cstdint>
|
|
#include <expected>
|
|
#include <filesystem>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <string_view>
|
|
|
|
namespace cvmmap_streamer::zed_tools {
|
|
|
|
using cvmmap_streamer::CodecType;
|
|
using cvmmap_streamer::EncoderDeviceType;
|
|
|
|
inline constexpr std::uint32_t kDefaultGopSize = 30;
|
|
inline constexpr std::uint32_t kDefaultBFrames = 0;
|
|
inline constexpr int kDefaultQuality = 23;
|
|
inline constexpr std::uint64_t kNanosPerSecond = 1'000'000'000ull;
|
|
|
|
enum class PresetKind : std::uint8_t {
|
|
Fast,
|
|
Balanced,
|
|
Quality,
|
|
};
|
|
|
|
enum class TuneKind : std::uint8_t {
|
|
LowLatency,
|
|
Balanced,
|
|
};
|
|
|
|
struct EncodeTuning {
|
|
PresetKind preset{PresetKind::Fast};
|
|
TuneKind tune{TuneKind::LowLatency};
|
|
int quality{kDefaultQuality};
|
|
std::uint32_t gop{kDefaultGopSize};
|
|
std::uint32_t b_frames{kDefaultBFrames};
|
|
};
|
|
|
|
[[nodiscard]]
|
|
std::expected<CodecType, std::string> parse_codec(std::string_view raw);
|
|
|
|
[[nodiscard]]
|
|
std::expected<EncoderDeviceType, std::string> parse_encoder_device(std::string_view raw);
|
|
|
|
[[nodiscard]]
|
|
std::expected<PresetKind, std::string> parse_preset(std::string_view raw);
|
|
|
|
[[nodiscard]]
|
|
std::expected<TuneKind, std::string> parse_tune(std::string_view raw);
|
|
|
|
[[nodiscard]]
|
|
std::string_view codec_name(CodecType codec);
|
|
|
|
[[nodiscard]]
|
|
std::string_view preset_name(PresetKind preset);
|
|
|
|
[[nodiscard]]
|
|
std::string_view tune_name(TuneKind tune);
|
|
|
|
[[nodiscard]]
|
|
std::uint64_t frame_period_ns(float fps);
|
|
|
|
[[nodiscard]]
|
|
std::filesystem::path derive_output_path(const std::filesystem::path &input_path);
|
|
|
|
class Mp4Writer {
|
|
public:
|
|
Mp4Writer();
|
|
Mp4Writer(const Mp4Writer &) = delete;
|
|
Mp4Writer &operator=(const Mp4Writer &) = delete;
|
|
Mp4Writer(Mp4Writer &&) noexcept;
|
|
Mp4Writer &operator=(Mp4Writer &&) noexcept;
|
|
~Mp4Writer();
|
|
|
|
[[nodiscard]]
|
|
std::expected<void, std::string> open(
|
|
const std::filesystem::path &output_path,
|
|
CodecType codec,
|
|
EncoderDeviceType encoder_device,
|
|
std::uint32_t width,
|
|
std::uint32_t height,
|
|
float fps,
|
|
const EncodeTuning &tuning);
|
|
|
|
[[nodiscard]]
|
|
std::expected<void, std::string> write_bgr_frame(
|
|
const std::uint8_t *data,
|
|
std::size_t row_stride_bytes,
|
|
std::uint64_t relative_timestamp_ns);
|
|
|
|
[[nodiscard]]
|
|
std::expected<void, std::string> flush();
|
|
|
|
[[nodiscard]]
|
|
bool using_hardware() const;
|
|
|
|
private:
|
|
struct Impl;
|
|
std::unique_ptr<Impl> impl_{};
|
|
};
|
|
|
|
} // namespace cvmmap_streamer::zed_tools
|