diff --git a/src/gstreamer/gstkvssink.cpp b/src/gstreamer/gstkvssink.cpp index a6af58cf..42506719 100644 --- a/src/gstreamer/gstkvssink.cpp +++ b/src/gstreamer/gstkvssink.cpp @@ -401,7 +401,7 @@ void create_kinesis_video_stream(GstKvsSink *kvssink) { // (i.e. starting from 0) if (kvssink->streaming_type == STREAMING_TYPE_OFFLINE && kvssink->file_start_time != 0) { kvssink->absolute_fragment_times = TRUE; - data->pts_base = (uint64_t) duration_cast(milliseconds(kvssink->file_start_time)).count(); + data->pts_base = (uint64_t) duration_cast(seconds(kvssink->file_start_time)).count(); } switch (data->media_type) { @@ -651,8 +651,8 @@ gst_kvs_sink_class_init(GstKvsSinkClass *klass) { g_object_class_install_property (gobject_class, PROP_FILE_START_TIME, g_param_spec_uint64 ("file-start-time", "File Start Time", - "Epoch time that the file starts in kinesis video stream. By default, current time is used. Unit: Milliseconds", - 0, G_MAXUINT64, 0, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); + "Epoch time that the file starts in kinesis video stream. By default, current time is used. Unit: Seconds", + 0, G_MAXULONG, 0, (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS))); g_object_class_install_property (gobject_class, PROP_DISABLE_BUFFER_CLIPPING, g_param_spec_boolean ("disable-buffer-clipping", "Disable Buffer Clipping", @@ -743,7 +743,7 @@ gst_kvs_sink_init(GstKvsSink *kvssink) { kvssink->service_connection_timeout = DEFAULT_SERVICE_CONNECTION_TIMEOUT_SEC; kvssink->service_completion_timeout = DEFAULT_SERVICE_COMPLETION_TIMEOUT_SEC; kvssink->credential_file_path = g_strdup (DEFAULT_CREDENTIAL_FILE_PATH); - kvssink->file_start_time = (uint64_t) chrono::duration_cast( + kvssink->file_start_time = (uint64_t) chrono::duration_cast( systemCurrentTime().time_since_epoch()).count(); kvssink->track_info_type = MKV_TRACK_INFO_TYPE_VIDEO; kvssink->audio_codec_id = g_strdup (DEFAULT_AUDIO_CODEC_ID_AAC); @@ -757,7 +757,7 @@ gst_kvs_sink_init(GstKvsSink *kvssink) { GST_OBJECT_FLAG_SET (kvssink, GST_ELEMENT_FLAG_SINK); LOGGER_TAG("com.amazonaws.kinesis.video.gstkvs"); - LOG_CONFIGURE_STDOUT("DEBUG") + LOG_CONFIGURE_STDOUT("DEBUG"); } static void @@ -1295,8 +1295,13 @@ gst_kvs_sink_handle_buffer (GstCollectPads * pads, // timestamp. Therefore in here we add the file_start_time to frame pts to create absolute timestamp. // If user did not specify file_start_time, file_start_time will be 0 and has no effect. if (IS_OFFLINE_STREAMING_MODE(kvssink->streaming_type)) { - buf->dts = 0; // if offline mode, i.e. streaming a file, the dts from gstreamer is undefined. - buf->pts += data->pts_base; + if(!data->use_original_pts) { + buf->dts = 0; // if offline mode, i.e. streaming a file, the dts from gstreamer is undefined. + buf->pts += data->pts_base; + } + else { + buf->pts = buf->dts; + } } else if (!GST_BUFFER_DTS_IS_VALID(buf)) { buf->dts = data->last_dts + DEFAULT_FRAME_DURATION_MS * HUNDREDS_OF_NANOS_IN_A_MILLISECOND * DEFAULT_TIME_UNIT_IN_NANOS; } @@ -1334,6 +1339,12 @@ gst_kvs_sink_handle_buffer (GstCollectPads * pads, data->producer_start_time = (uint64_t) chrono::duration_cast( systemCurrentTime().time_since_epoch()).count(); } + if(!data->use_original_pts) { + buf->pts += data->producer_start_time - data->first_pts; + } + else { + buf->pts = buf->dts; + } } put_frame(kvssink->data, info.data, info.size, @@ -1630,4 +1641,4 @@ GST_PLUGIN_DEFINE ( "Proprietary", "GStreamer", "http://gstreamer.net/" -) +) \ No newline at end of file