@@ -401,7 +401,7 @@ void create_kinesis_video_stream(GstKvsSink *kvssink) {
401401 // (i.e. starting from 0)
402402 if (kvssink->streaming_type == STREAMING_TYPE_OFFLINE && kvssink->file_start_time != 0 ) {
403403 kvssink->absolute_fragment_times = TRUE ;
404- data->pts_base = (uint64_t ) duration_cast<nanoseconds>(milliseconds (kvssink->file_start_time )).count ();
404+ data->pts_base = (uint64_t ) duration_cast<nanoseconds>(seconds (kvssink->file_start_time )).count ();
405405 }
406406
407407 switch (data->media_type ) {
@@ -651,8 +651,8 @@ gst_kvs_sink_class_init(GstKvsSinkClass *klass) {
651651
652652 g_object_class_install_property (gobject_class, PROP_FILE_START_TIME,
653653 g_param_spec_uint64 (" file-start-time" , " File Start Time" ,
654- " Epoch time that the file starts in kinesis video stream. By default, current time is used. Unit: Milliseconds " ,
655- 0 , G_MAXUINT64 , 0 , (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
654+ " Epoch time that the file starts in kinesis video stream. By default, current time is used. Unit: Seconds " ,
655+ 0 , G_MAXULONG , 0 , (GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
656656
657657 g_object_class_install_property (gobject_class, PROP_DISABLE_BUFFER_CLIPPING,
658658 g_param_spec_boolean (" disable-buffer-clipping" , " Disable Buffer Clipping" ,
@@ -743,7 +743,7 @@ gst_kvs_sink_init(GstKvsSink *kvssink) {
743743 kvssink->service_connection_timeout = DEFAULT_SERVICE_CONNECTION_TIMEOUT_SEC;
744744 kvssink->service_completion_timeout = DEFAULT_SERVICE_COMPLETION_TIMEOUT_SEC;
745745 kvssink->credential_file_path = g_strdup (DEFAULT_CREDENTIAL_FILE_PATH);
746- kvssink->file_start_time = (uint64_t ) chrono::duration_cast<milliseconds >(
746+ kvssink->file_start_time = (uint64_t ) chrono::duration_cast<seconds >(
747747 systemCurrentTime ().time_since_epoch ()).count ();
748748 kvssink->track_info_type = MKV_TRACK_INFO_TYPE_VIDEO;
749749 kvssink->audio_codec_id = g_strdup (DEFAULT_AUDIO_CODEC_ID_AAC);
@@ -757,7 +757,7 @@ gst_kvs_sink_init(GstKvsSink *kvssink) {
757757 GST_OBJECT_FLAG_SET (kvssink, GST_ELEMENT_FLAG_SINK);
758758
759759 LOGGER_TAG (" com.amazonaws.kinesis.video.gstkvs" );
760- LOG_CONFIGURE_STDOUT (" DEBUG" )
760+ LOG_CONFIGURE_STDOUT (" DEBUG" );
761761}
762762
763763static void
@@ -1295,8 +1295,13 @@ gst_kvs_sink_handle_buffer (GstCollectPads * pads,
12951295 // timestamp. Therefore in here we add the file_start_time to frame pts to create absolute timestamp.
12961296 // If user did not specify file_start_time, file_start_time will be 0 and has no effect.
12971297 if (IS_OFFLINE_STREAMING_MODE (kvssink->streaming_type )) {
1298- buf->dts = 0 ; // if offline mode, i.e. streaming a file, the dts from gstreamer is undefined.
1299- buf->pts += data->pts_base ;
1298+ if (!data->use_original_pts ) {
1299+ buf->dts = 0 ; // if offline mode, i.e. streaming a file, the dts from gstreamer is undefined.
1300+ buf->pts += data->pts_base ;
1301+ }
1302+ else {
1303+ buf->pts = buf->dts ;
1304+ }
13001305 } else if (!GST_BUFFER_DTS_IS_VALID (buf)) {
13011306 buf->dts = data->last_dts + DEFAULT_FRAME_DURATION_MS * HUNDREDS_OF_NANOS_IN_A_MILLISECOND * DEFAULT_TIME_UNIT_IN_NANOS;
13021307 }
@@ -1334,6 +1339,12 @@ gst_kvs_sink_handle_buffer (GstCollectPads * pads,
13341339 data->producer_start_time = (uint64_t ) chrono::duration_cast<nanoseconds>(
13351340 systemCurrentTime ().time_since_epoch ()).count ();
13361341 }
1342+ if (!data->use_original_pts ) {
1343+ buf->pts += data->producer_start_time - data->first_pts ;
1344+ }
1345+ else {
1346+ buf->pts = buf->dts ;
1347+ }
13371348 }
13381349
13391350 put_frame (kvssink->data , info.data , info.size ,
@@ -1630,4 +1641,4 @@ GST_PLUGIN_DEFINE (
16301641 " Proprietary" ,
16311642 " GStreamer" ,
16321643 " http://gstreamer.net/"
1633- )
1644+ )
0 commit comments