-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Started on movie producing
- Loading branch information
Showing
46 changed files
with
3,989 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,9 @@ | |
[submodule "n2k/canboat"] | ||
path = n2k/canboat | ||
url = [email protected]:sergei/canboat.git | ||
[submodule "cxxopts"] | ||
path = cxxopts | ||
url = https://github.com/jarro2783/cxxopts.git | ||
[submodule "gopro/gpmf-parser"] | ||
path = gopro/gpmf-parser | ||
url = https://github.com/gopro/gpmf-parser.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// Created by Sergei on 8/16/23. | ||
// | ||
|
||
#ifndef SAILVUE_INSTRDATAREADER_H | ||
#define SAILVUE_INSTRDATAREADER_H | ||
|
||
|
||
#include <ctime> | ||
#include <list> | ||
#include "navcomputer/InstrumentInput.h" | ||
|
||
class InstrDataReader { | ||
public: | ||
virtual void read(uint64_t ulStartUtcMs, uint64_t ulEndUtcMs, std::list<InstrumentInput> &listInputs) = 0; | ||
}; | ||
|
||
|
||
#endif //SAILVUE_INSTRDATAREADER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
129029,ZG100 Antenna-100022#, GNSS Position Data | ||
129025,ZG100 Antenna-100022#, Position, Rapid Update | ||
129026,ZG100 Antenna-100022#, COG & SOG, Rapid Update | ||
127250,Precision-9 Compass-120196210, Vessel Heading | ||
128259,H5000 CPU-007060#, Speed | ||
130306,H5000 CPU-007060#, Wind Data | ||
127245,RF25 _Rudder feedback-038249#, Rudder | ||
127257,Precision-9 Compass-120196210, Attitude |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "FFMpeg.h" | ||
#include <iostream> | ||
#include <sstream> | ||
#include <filesystem> | ||
|
||
std::string FFMpeg::s_ffmpeg = "/dev/null"; | ||
std::string FFMpeg::s_ffprobe = "/dev/null"; | ||
|
||
bool FFMpeg::setBinDir(const std::string &binDir) { | ||
std::filesystem::path ffmpegPath(binDir); | ||
std::filesystem::path absoluteFfmpegPath = std::filesystem::absolute(binDir); | ||
|
||
|
||
// Check if the directory exist | ||
if (!std::filesystem::exists(absoluteFfmpegPath)) { | ||
std::cerr << "FFMpeg::setBinDir: " << absoluteFfmpegPath << " does not exist" << std::endl; | ||
return false; | ||
} | ||
|
||
// Check if ffmpeg and ffprobe files exist | ||
s_ffmpeg = absoluteFfmpegPath / "ffmpeg"; | ||
s_ffprobe = absoluteFfmpegPath / "ffprobe"; | ||
|
||
if (!std::filesystem::is_regular_file(s_ffmpeg )) { | ||
std::cerr << "FFMpeg::setBinDir: " << s_ffmpeg << " does not exist" << std::endl; | ||
return false; | ||
} | ||
|
||
if (!std::filesystem::is_regular_file(s_ffprobe )) { | ||
std::cerr << "FFMpeg::setBinDir: " << s_ffprobe << " does not exist" << std::endl; | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
std::tuple<int, int> FFMpeg::getVideoResolution(const std::string &mp4name) { | ||
// Build the ffprobe command | ||
std::string cmd = s_ffprobe | ||
+ " -v error -select_streams v:0 -show_entries stream=width,height,fps -of csv=p=0 " | ||
+ "\"" + mp4name + "\""; | ||
|
||
// Execute it | ||
CommandResult res = Command::exec(cmd); | ||
if ( res.exitstatus == 0){ | ||
std::istringstream iss(res.output); | ||
std::string width; | ||
std::string height; | ||
std::getline(iss, width, ','); | ||
std::getline(iss, height, ','); | ||
return {stoi(width), stoi(height)}; | ||
} | ||
return {-1, -1}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
#ifndef SAILVUE_FFMPEG_H | ||
#define SAILVUE_FFMPEG_H | ||
|
||
#include <string> | ||
#include <array> | ||
#include <ostream> | ||
#include <string> | ||
#include <cstdio> | ||
|
||
struct CommandResult { | ||
std::string output; | ||
int exitstatus; | ||
friend std::ostream &operator<<(std::ostream &os, const CommandResult &result) { | ||
os << "command exitstatus: " << result.exitstatus << " output: " << result.output; | ||
return os; | ||
} | ||
bool operator==(const CommandResult &rhs) const { | ||
return output == rhs.output && | ||
exitstatus == rhs.exitstatus; | ||
} | ||
bool operator!=(const CommandResult &rhs) const { | ||
return !(rhs == *this); | ||
} | ||
}; | ||
|
||
class Command { | ||
public: | ||
/** | ||
* Execute system command and get STDOUT result. | ||
* Regular system() only gives back exit status, this gives back output as well. | ||
* @param command system command to execute | ||
* @return commandResult containing STDOUT (not stderr) output & exitstatus | ||
* of command. Empty if command failed (or has no output). If you want stderr, | ||
* use shell redirection (2&>1). | ||
*/ | ||
static CommandResult exec(const std::string &command) { | ||
int exitcode = 0; | ||
std::array<char, 8192> buffer{}; | ||
std::string result; | ||
#ifdef _WIN32 | ||
#define popen _popen | ||
#define pclose _pclose | ||
#define WEXITSTATUS | ||
#endif | ||
FILE *pipe = popen(command.c_str(), "r"); | ||
if (pipe == nullptr) { | ||
throw std::runtime_error("popen() failed!"); | ||
} | ||
try { | ||
std::size_t bytesread; | ||
while ((bytesread = std::fread(buffer.data(), sizeof(buffer.at(0)), sizeof(buffer), pipe)) != 0) { | ||
result += std::string(buffer.data(), bytesread); | ||
} | ||
} catch (...) { | ||
pclose(pipe); | ||
throw; | ||
} | ||
// Workaround "error: cannot take the address of an rvalue of type 'int'" on MacOS | ||
// see e.g. https://github.com/BestImageViewer/geeqie/commit/75c7df8b96592e10f7936dc1a28983be4089578c | ||
int res = pclose(pipe); | ||
exitcode = WEXITSTATUS(res); | ||
return CommandResult{result, exitcode}; | ||
} | ||
|
||
}; | ||
|
||
class FFMpeg { | ||
public: | ||
static bool setBinDir(const std::string &binDir); | ||
static std::tuple<int , int > getVideoResolution(const std::string &mp4name); | ||
|
||
private: | ||
static std::string s_ffmpeg; | ||
static std::string s_ffprobe; | ||
}; | ||
|
||
|
||
#endif //SAILVUE_FFMPEG_H |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.