mirror of
https://github.com/Palakis/obs-websocket.git
synced 2024-08-30 18:12:16 +00:00
Utils: Attempt fix output timecode string
This commit is contained in:
parent
7081824bbe
commit
7f7651b405
@ -1,7 +1,4 @@
|
||||
#include <inttypes.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
#include <obs-frontend-api.h>
|
||||
#include <util/util_uint64.h>
|
||||
|
||||
@ -11,17 +8,6 @@
|
||||
|
||||
#define CASE(x) case x: return #x;
|
||||
|
||||
template<typename ... Args>
|
||||
std::string string_format( const std::string& format, Args ... args )
|
||||
{
|
||||
int size_s = std::snprintf( nullptr, 0, format.c_str(), args ... ) + 1;
|
||||
if( size_s <= 0 ){ throw std::runtime_error( "Error during formatting." ); }
|
||||
auto size = static_cast<size_t>( size_s );
|
||||
auto buf = std::make_unique<char[]>( size );
|
||||
std::snprintf( buf.get(), size, format.c_str(), args ... );
|
||||
return std::string( buf.get(), buf.get() + size - 1 ); // We don't want the '\0' inside
|
||||
}
|
||||
|
||||
std::vector<std::string> ConvertStringArray(char **array)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
@ -132,7 +118,7 @@ std::string Utils::Obs::StringHelper::GetOutputTimecodeString(obs_output_t *outp
|
||||
uint64_t frameTimeNs = video_output_get_frame_time(video);
|
||||
int totalFrames = obs_output_get_total_frames(output);
|
||||
|
||||
uint64_t ms = (((uint64_t)totalFrames) * frameTimeNs) / 1000000ULL;
|
||||
uint64_t ms = util_mul_div64(totalFrames, frameTimeNs, 1000000ULL);
|
||||
uint64_t secs = ms / 1000ULL;
|
||||
uint64_t minutes = secs / 60ULL;
|
||||
|
||||
@ -141,7 +127,8 @@ std::string Utils::Obs::StringHelper::GetOutputTimecodeString(obs_output_t *outp
|
||||
uint64_t secsPart = secs % 60ULL;
|
||||
uint64_t msPart = ms % 1000ULL;
|
||||
|
||||
return string_format("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%03" PRIu64, hoursPart, minutesPart, secsPart, msPart);
|
||||
QString formatted = QString::asprintf("%02" PRIu64 ":%02" PRIu64 ":%02" PRIu64 ".%03" PRIu64, hoursPart, minutesPart, secsPart, msPart);
|
||||
return formatted.toStdString();
|
||||
}
|
||||
|
||||
uint64_t Utils::Obs::NumberHelper::GetOutputDuration(obs_output_t *output)
|
||||
@ -154,7 +141,6 @@ uint64_t Utils::Obs::NumberHelper::GetOutputDuration(obs_output_t *output)
|
||||
int totalFrames = obs_output_get_total_frames(output);
|
||||
|
||||
return util_mul_div64(totalFrames, frameTimeNs, 1000000ULL);
|
||||
//return (((uint64_t)totalFrames) * frameTimeNs) / ;
|
||||
}
|
||||
|
||||
std::vector<std::string> Utils::Obs::ListHelper::GetSceneCollectionList()
|
||||
|
Loading…
Reference in New Issue
Block a user