mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 15:30:00 +01:00
Added Timeout to recorder in User Interface and Settings, and duration
query on Recorder.
This commit is contained in:
22
Recorder.cpp
22
Recorder.cpp
@@ -123,27 +123,27 @@ void PNGRecorder::addFrame(FrameBuffer *frame_buffer, float)
|
||||
}
|
||||
|
||||
const char* VideoRecorder::profile_name[VideoRecorder::DEFAULT] = {
|
||||
"H264 (Standard)",
|
||||
"H264 (Baseline)",
|
||||
"H264 (high)",
|
||||
"Apple ProRes (Standard)",
|
||||
"Apple ProRes (HQ 4444)",
|
||||
"WebM VP8 (Standard)",
|
||||
"WebM VP8 (2MB/s)",
|
||||
"Multiple JPEG"
|
||||
};
|
||||
const std::vector<std::string> VideoRecorder::profile_description {
|
||||
// Control x264 encoder quality :
|
||||
// pass=4
|
||||
// pass
|
||||
// quant (4) – Constant Quantizer
|
||||
// qual (5) – Constant Quality
|
||||
// quantizer=23
|
||||
// quantizer
|
||||
// The total range is from 0 to 51, where 0 is lossless, 18 can be considered ‘visually lossless’,
|
||||
// and 51 is terrible quality. A sane range is 18-26, and the default is 23.
|
||||
// speed-preset=3
|
||||
// speed-preset
|
||||
// veryfast (3)
|
||||
// faster (4)
|
||||
// fast (5)
|
||||
"x264enc pass=4 quantizer=23 speed-preset=3 ! video/x-h264, profile=baseline ! h264parse ! ",
|
||||
"x264enc pass=5 quantizer=18 speed-preset=4 ! video/x-h264, profile=high ! h264parse ! ",
|
||||
"x264enc pass=5 quantizer=23 speed-preset=3 threads=4 ! video/x-h264, profile=baseline ! h264parse ! ",
|
||||
"x264enc pass=4 quantizer=16 speed-preset=4 ! video/x-h264, profile=high ! h264parse ! ",
|
||||
// Apple ProRes encoding parameters
|
||||
// pass
|
||||
// cbr (0) – Constant Bitrate Encoding
|
||||
@@ -421,8 +421,6 @@ void VideoRecorder::addFrame (FrameBuffer *frame_buffer, float dt)
|
||||
}
|
||||
}
|
||||
|
||||
// if (timestamp_ > 10000000000)
|
||||
// stop();
|
||||
}
|
||||
|
||||
void VideoRecorder::stop ()
|
||||
@@ -443,6 +441,12 @@ std::string VideoRecorder::info()
|
||||
return "Saving file...";
|
||||
}
|
||||
|
||||
|
||||
double VideoRecorder::duration()
|
||||
{
|
||||
return gst_guint64_to_gdouble( GST_TIME_AS_MSECONDS(timestamp_) ) / 1000.0;
|
||||
}
|
||||
|
||||
// appsrc needs data and we should start sending
|
||||
void VideoRecorder::callback_need_data (GstAppSrc *, guint , gpointer p)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
virtual void addFrame(FrameBuffer *frame_buffer, float dt) = 0;
|
||||
virtual void stop() { }
|
||||
virtual std::string info() { return ""; }
|
||||
virtual double duration() { return 0.0; }
|
||||
|
||||
inline bool finished() const { return finished_; }
|
||||
|
||||
@@ -94,6 +95,8 @@ public:
|
||||
void stop() override;
|
||||
std::string info() override;
|
||||
|
||||
double duration() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ void Settings::Save()
|
||||
XMLElement *RecordNode = xmlDoc.NewElement( "Record" );
|
||||
RecordNode->SetAttribute("path", application.record.path.c_str());
|
||||
RecordNode->SetAttribute("profile", application.record.profile);
|
||||
RecordNode->SetAttribute("timeout", application.record.timeout);
|
||||
pRoot->InsertEndChild(RecordNode);
|
||||
|
||||
// Transition
|
||||
@@ -225,11 +226,11 @@ void Settings::Load()
|
||||
rendernode->QueryIntAttribute("res", &application.render.res);
|
||||
}
|
||||
|
||||
|
||||
// Render
|
||||
// Record
|
||||
XMLElement * recordnode = pRoot->FirstChildElement("Record");
|
||||
if (recordnode != nullptr) {
|
||||
recordnode->QueryIntAttribute("profile", &application.record.profile);
|
||||
recordnode->QueryFloatAttribute("timeout", &application.record.timeout);
|
||||
|
||||
const char *path_ = recordnode->Attribute("path");
|
||||
if (path_)
|
||||
|
||||
@@ -58,13 +58,17 @@ struct ViewConfig
|
||||
|
||||
};
|
||||
|
||||
#define RECORD_MAX_TIMEOUT 1800.f
|
||||
|
||||
struct RecordConfig
|
||||
{
|
||||
std::string path;
|
||||
int profile;
|
||||
float timeout;
|
||||
|
||||
RecordConfig() : path("") {
|
||||
profile = 0;
|
||||
timeout = RECORD_MAX_TIMEOUT;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -631,6 +631,12 @@ void UserInterface::Render()
|
||||
if (Settings::application.widget.stats)
|
||||
ImGuiToolkit::ShowStats(&Settings::application.widget.stats, &Settings::application.widget.stats_corner);
|
||||
|
||||
// TODO: better management of main_video_recorder
|
||||
if (main_video_recorder && main_video_recorder->duration() > Settings::application.record.timeout ){
|
||||
main_video_recorder->stop();
|
||||
main_video_recorder = nullptr;
|
||||
}
|
||||
|
||||
// all IMGUI Rendering
|
||||
ImGui::Render();
|
||||
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
|
||||
@@ -894,32 +900,30 @@ void UserInterface::RenderPreview()
|
||||
}
|
||||
if (ImGui::BeginMenu("Record"))
|
||||
{
|
||||
if ( ImGui::MenuItem( ICON_FA_CAMERA_RETRO " Capture frame") )
|
||||
if ( ImGui::MenuItem( ICON_FA_CAMERA_RETRO " Capture frame (PNG)") )
|
||||
Mixer::manager().session()->addRecorder(new PNGRecorder);
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Stop recording menu if recording exists
|
||||
// Stop recording menu if main recorder already exists
|
||||
if (main_video_recorder) {
|
||||
|
||||
if ( ImGui::MenuItem( ICON_FA_SQUARE " Stop Record", CTRL_MOD "R") ) {
|
||||
main_video_recorder->stop();
|
||||
main_video_recorder = nullptr;
|
||||
}
|
||||
}
|
||||
// start recording menu
|
||||
// start recording
|
||||
else {
|
||||
if ( ImGui::MenuItem( ICON_FA_CIRCLE " Record", CTRL_MOD "R") ) {
|
||||
main_video_recorder = new VideoRecorder;
|
||||
Mixer::manager().session()->addRecorder(main_video_recorder);
|
||||
}
|
||||
|
||||
// select profile
|
||||
ImGui::SetNextItemWidth(300);
|
||||
ImGui::Combo("##RecProfile", &Settings::application.record.profile, VideoRecorder::profile_name, IM_ARRAYSIZE(VideoRecorder::profile_name) );
|
||||
}
|
||||
|
||||
// Options menu
|
||||
ImGui::MenuItem("Destination", nullptr, false, false);
|
||||
ImGui::Separator();
|
||||
ImGui::MenuItem("Options", nullptr, false, false);
|
||||
{
|
||||
static char* name_path[4] = { nullptr };
|
||||
if ( name_path[0] == nullptr ) {
|
||||
@@ -934,14 +938,18 @@ void UserInterface::RenderPreview()
|
||||
sprintf( name_path[0], "%s", Settings::application.record.path.c_str());
|
||||
|
||||
int selected_path = 0;
|
||||
ImGui::SetNextItemWidth(300);
|
||||
ImGui::Combo("##RecDestination", &selected_path, name_path, 4);
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::Combo("Path", &selected_path, name_path, 4);
|
||||
if (selected_path > 2)
|
||||
std::thread (FolderDialogOpen, record_browser_path_, &record_path_selected, Settings::application.record.path).detach();
|
||||
else if (selected_path > 1)
|
||||
Settings::application.record.path = SystemToolkit::path_filename( Mixer::manager().session()->filename() );
|
||||
else if (selected_path > 0)
|
||||
Settings::application.record.path = SystemToolkit::home_path();
|
||||
|
||||
ImGui::SetNextItemWidth(IMGUI_RIGHT_ALIGN);
|
||||
ImGui::SliderFloat("Timeout", &Settings::application.record.timeout, 1.f, RECORD_MAX_TIMEOUT,
|
||||
Settings::application.record.timeout < (RECORD_MAX_TIMEOUT - 1.f) ? "%.0f s" : "None", 3.f);
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
|
||||
Reference in New Issue
Block a user