mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
BugFix Add keyframes every second of output recording
Also compilation warning fix for GValue init.
This commit is contained in:
@@ -272,7 +272,7 @@ FrameGrabber::FrameGrabber(): finished_(false), initialized_(false), active_(fal
|
||||
endofstream_(false), accept_buffer_(false), buffering_full_(false), pause_(false),
|
||||
pipeline_(nullptr), src_(nullptr), caps_(nullptr), timer_(nullptr), timer_firstframe_(0),
|
||||
timer_pauseframe_(0), timestamp_(0), duration_(0), pause_duration_(0), frame_count_(0),
|
||||
buffering_size_(MIN_BUFFER_SIZE), buffering_count_(0), timestamp_on_clock_(true)
|
||||
keyframe_count_(0), buffering_size_(MIN_BUFFER_SIZE), buffering_count_(0), timestamp_on_clock_(true)
|
||||
{
|
||||
// unique id
|
||||
id_ = BaseToolkit::uniqueId();
|
||||
@@ -513,6 +513,18 @@ void FrameGrabber::addFrame (GstBuffer *buffer, GstCaps *caps)
|
||||
// push frame
|
||||
gst_app_src_push_buffer (src_, buffer);
|
||||
// NB: buffer will be unrefed by the appsrc
|
||||
|
||||
// add a key frame every second (if keyframecount is valid)
|
||||
if (keyframe_count_ > 1 && frame_count_ % keyframe_count_ < 1) {
|
||||
GstEvent *event
|
||||
= gst_video_event_new_downstream_force_key_unit(timestamp_,
|
||||
GST_CLOCK_TIME_NONE,
|
||||
GST_CLOCK_TIME_NONE,
|
||||
FALSE,
|
||||
frame_count_ / keyframe_count_);
|
||||
gst_element_send_event(GST_ELEMENT(src_), event);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ protected:
|
||||
GstClockTime pause_duration_;
|
||||
GstClockTime frame_duration_;
|
||||
guint64 frame_count_;
|
||||
guint64 keyframe_count_;
|
||||
guint64 buffering_size_;
|
||||
guint64 buffering_count_;
|
||||
bool timestamp_on_clock_;
|
||||
|
||||
@@ -124,7 +124,7 @@ std::string Loopback::init(GstCaps *caps)
|
||||
|
||||
// specify streaming framerate in the given caps
|
||||
GstCaps *tmp = gst_caps_copy( caps );
|
||||
GValue v = { 0, };
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, GST_TYPE_FRACTION);
|
||||
gst_value_set_fraction (&v, LOOPBACK_FPS, 1); // fixed FPS
|
||||
gst_caps_set_value(tmp, "framerate", &v);
|
||||
|
||||
@@ -334,7 +334,8 @@ std::string VideoRecorder::init(GstCaps *caps)
|
||||
// apply settings
|
||||
buffering_size_ = MAX( MIN_BUFFER_SIZE, buffering_preset_value[Settings::application.record.buffering_mode]);
|
||||
frame_duration_ = gst_util_uint64_scale_int (1, GST_SECOND, framerate_preset_value[Settings::application.record.framerate_mode]);
|
||||
timestamp_on_clock_ = Settings::application.record.priority_mode < 1;
|
||||
timestamp_on_clock_ = Settings::application.record.priority_mode < 1;
|
||||
keyframe_count_ = framerate_preset_value[Settings::application.record.framerate_mode];
|
||||
|
||||
// create a gstreamer pipeline
|
||||
std::string description = "appsrc name=src ! videoconvert ! queue ! ";
|
||||
@@ -440,7 +441,7 @@ std::string VideoRecorder::init(GstCaps *caps)
|
||||
|
||||
// specify recorder framerate in the given caps
|
||||
GstCaps *tmp = gst_caps_copy( caps );
|
||||
GValue v = { 0, };
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, GST_TYPE_FRACTION);
|
||||
gst_value_set_fraction (&v, framerate_preset_value[Settings::application.record.framerate_mode], 1);
|
||||
gst_caps_set_value(tmp, "framerate", &v);
|
||||
|
||||
@@ -131,7 +131,7 @@ std::string ShmdataBroadcast::init(GstCaps *caps)
|
||||
|
||||
// specify streaming framerate in the given caps
|
||||
GstCaps *tmp = gst_caps_copy( caps );
|
||||
GValue v = { 0, };
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, GST_TYPE_FRACTION);
|
||||
gst_value_set_fraction (&v, SHMDATA_FPS, 1); // fixed 30 FPS
|
||||
gst_caps_set_value(tmp, "framerate", &v);
|
||||
|
||||
@@ -449,7 +449,7 @@ std::string VideoStreamer::init(GstCaps *caps)
|
||||
|
||||
// specify streaming framerate in the given caps
|
||||
GstCaps *tmp = gst_caps_copy( caps );
|
||||
GValue v = { 0, };
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, GST_TYPE_FRACTION);
|
||||
gst_value_set_fraction (&v, STREAMING_FPS, 1); // fixed 30 FPS
|
||||
gst_caps_set_value(tmp, "framerate", &v);
|
||||
|
||||
@@ -156,7 +156,7 @@ std::string VideoBroadcast::init(GstCaps *caps)
|
||||
|
||||
// specify streaming framerate in the given caps
|
||||
GstCaps *tmp = gst_caps_copy( caps );
|
||||
GValue v = { 0, };
|
||||
GValue v = G_VALUE_INIT;
|
||||
g_value_init (&v, GST_TYPE_FRACTION);
|
||||
gst_value_set_fraction (&v, BROADCAST_FPS, 1); // fixed 30 FPS
|
||||
gst_caps_set_value(tmp, "framerate", &v);
|
||||
|
||||
Reference in New Issue
Block a user