Skip to content

Commit

Permalink
Add support for milliseconds in the file upload sample (#947)
Browse files Browse the repository at this point in the history
* Minor syntax fix

.. is required for fetching files from parent dir ... without .. it throws error

* Fix typo in readme

* add free missing (#746)

Co-authored-by: David D <david.desbiens@tentaq.com>

* Update readme (#744)

* Fix typo in readme

* Update Readme

Debug section: add solution to cmake error "could not find JNI"

Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com>

* Add instruction to set offline mode (#741)

Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com>

* Update README and travis.yml to acknowledge develop (#739)

Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com>

* Gstreamer RTSP Docs Update (#712)

Hoping this help others avoid hours of frustration.

As noted in the helpful but well hidden issue comment #193 (comment), the Gstreamer examples for RTSP do not run at all.  I'm no Gstreamer expert but using `h264parse` works perfectly, while `video/x-h264, format=avc,alignment=au` just causes the pipeline to hang.

* free missing property (#767)

Co-authored-by: David D <david.desbiens@tentaq.com>

* Update gstkvssink.cpp

* Added millisecond support to kvs_gstreamer_file_upload_sample + gstkvssink

---------

Co-authored-by: Ketul shah <ketulshah1993@gmail.com>
Co-authored-by: waikup83 <waikup@hotmail.com>
Co-authored-by: David D <david.desbiens@tentaq.com>
Co-authored-by: Hassan Sahibzada <hsahibza@amazon.com>
Co-authored-by: Divya Sampath Kumar <disa6302@colorado.edu>
Co-authored-by: jdelapla <delaplan@amazon.com>
Co-authored-by: Anton Vattay <3martini@gmail.com>
Co-authored-by: bkneff <bkneff@amazon.com>
  • Loading branch information
9 people committed Feb 9, 2023
1 parent ad2fd16 commit a1d05af
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 18 deletions.
5 changes: 2 additions & 3 deletions docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ Device found:

###### Running the `gst-launch-1.0` command to start streaming from a RTSP camera source.
```
$ gst-launch-1.0 -v rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! h264parse ! kvssink stream-name=YourStreamName storage-size=128
$ gst-launch-1.0 -v rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! h264parse ! kvssink stream-name=YourStreamName storage-size=128
```

**Note:** If you are using **IoT credentials** then you can pass them as parameters to the gst-launch-1.0 command
```
$ gst-launch-1.0 -v rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au !
h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
$ gst-launch-1.0 -v rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
```
You can find the RTSP URL from your IP camera manual or manufacturers product page. For more information on how to set up IoT/role policies and role-aliases, please refer to [iot-based-credential-provider](auth.md#iot-based-credential-provider) and https://docs.aws.amazon.com/kinesisvideostreams/latest/dg/how-iot.html.

Expand Down
5 changes: 2 additions & 3 deletions docs/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ Device found:
###### Running the `gst-launch-1.0` command to start streaming from RTSP camera source.

```
$ gst-launch-1.0 rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! h264parse ! kvssink stream-name=YourStreamName storage-size=128 access-key="YourAccessKey" secret-key="YourSecretKey"
$ gst-launch-1.0 rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! h264parse ! kvssink stream-name=YourStreamName storage-size=128 access-key="YourAccessKey" secret-key="YourSecretKey"
```

**Note:** If you are using **IoT credentials** then you can pass them as parameters to the gst-launch-1.0 command

```
$ gst-launch-1.0 rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au !
h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
$ gst-launch-1.0 rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
```
You can find the RTSP URL from your IP camera manual or manufacturers product page.

Expand Down
7 changes: 3 additions & 4 deletions docs/raspberry-pi.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,12 @@ Device found:

###### Running the `gst-launch-1.0` command to start streaming from a RTSP camera source.
```
$ gst-launch-1.0 -v rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! h264parse ! kvssink stream-name=YourStreamName storage-size=128
$ gst-launch-1.0 -v rtspsrc location=rtsp://YourCameraRtspUrl short-header=TRUE ! rtph264depay ! h264parse ! kvssink stream-name=YourStreamName storage-size=128
```

**Note:** If you are using **IoT credentials** then you can pass them as parameters to the gst-launch-1.0 command
```
$ gst-launch-1.0 -v rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au !
h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
$ gst-launch-1.0 -v rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
```
You can find the RTSP URL from your IP camera manual or manufacturers product page.

Expand Down Expand Up @@ -163,7 +162,7 @@ gst-launch-1.0 -v filesrc location="YourAudioVideo.mkv" ! matroskademux name=dem
###### Running the `gst-launch-1.0` command to upload MP4 file that contains both *audio and video*:

```
gst-launch-1.0 -v filesrc location="YourAudioVideo.mp4" ! qtdemux name=demux ! queue ! h264parse ! video/x-h264,stream-format=avc,alignment=au ! kvssink name=sink stream-name="audio-video-file" access-key="YourAccessKeyId" secret-key="YourSecretAccessKey" streaming-type=offline demux. ! queue ! aacparse ! sink.
gst-launch-1.0 -v filesrc location="YourAudioVideo.mp4" ! qtdemux name=demux ! queue ! h264parse ! video/x-h264,stream-format=avc,alignment=au ! kvssink name=sink stream-name="audio-video-file" access-key="YourAccessKeyId" secret-key="YourSecretAccessKey" streaming-type=offline demux. ! queue ! aacparse ! sink.
```

###### Running the `gst-launch-1.0` command to upload MPEG2TS file that contains both *audio and video*:
Expand Down
4 changes: 2 additions & 2 deletions docs/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ gst-launch-1.0 ksvideosrc do-timestamp=TRUE ! video/x-raw,width=640,height=480,f
**Note:** If you are using IoT credentials then you can pass them as parameters to the gst-launch-1.0 command

```
gst-launch-1.0 rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! video/x-h264, format=avc,alignment=au ! h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
gst-launch-1.0 rtspsrc location="rtsp://YourCameraRtspUrl" short-header=TRUE ! rtph264depay ! h264parse ! kvssink stream-name="iot-stream" iot-certificate="iot-certificate,endpoint=endpoint,cert-path=/path/to/certificate,key-path=/path/to/private/key,ca-path=/path/to/ca-cert,role-aliases=role-aliases"
```

2.2 Use `gst-launch-1.0` to send audio and raw video to Kinesis Video Streams
Expand All @@ -98,7 +98,7 @@ gst-launch-1.0 -v filesrc location="YourAudioVideo.mkv" ! matroskademux name=dem
###### Running the `gst-launch-1.0` command to upload MP4 file that contains both *audio and video*.

```
gst-launch-1.0 -v filesrc location="YourAudioVideo.mp4" ! qtdemux name=demux ! queue ! h264parse ! video/x-h264,stream-format=avc,alignment=au ! kvssink name=sink stream-name="audio-video-file" access-key="YourAccessKeyId" secret-key="YourSecretAccessKey" streaming-type=offline demux. ! queue ! aacparse ! sink.
gst-launch-1.0 -v filesrc location="YourAudioVideo.mp4" ! qtdemux name=demux ! queue ! h264parse ! video/x-h264,stream-format=avc,alignment=au ! kvssink name=sink stream-name="audio-video-file" access-key="YourAccessKeyId" secret-key="YourSecretAccessKey" streaming-type=offline demux. ! queue ! aacparse ! sink.
```

###### Running the `gst-launch-1.0` command to upload MPEG2TS file that contains both *audio and video*.
Expand Down
4 changes: 2 additions & 2 deletions samples/kvs_gstreamer_file_uploader_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int gstreamer_init(int argc, char* argv[], CustomData *data) {
return 0;
}

string build_kvssink_str(string stream_name, unsigned long file_start_time) {
string build_kvssink_str(string stream_name, unsigned long long file_start_time) {
const char** property;
stringstream ss;
const char *key_raw, *value;
Expand Down Expand Up @@ -259,7 +259,7 @@ int main(int argc, char* argv[]) {
}
fclose(file);

unsigned long file_start_time = strtoul(argv[3], &ptr, 10);
unsigned long long file_start_time = strtoull(argv[3], &ptr, 10);
if (*ptr != '\0') {
LOG_ERROR("File start time is not a valid number");
return 1;
Expand Down
8 changes: 4 additions & 4 deletions src/gstreamer/gstkvssink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,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<nanoseconds>(seconds(kvssink->file_start_time)).count();
data->pts_base = (uint64_t) duration_cast<nanoseconds>(milliseconds(kvssink->file_start_time)).count();
}

switch (data->media_type) {
Expand Down Expand Up @@ -568,8 +568,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: Seconds",
0, G_MAXULONG, 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: Milliseconds",
0, G_MAXUINT64, 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",
Expand Down Expand Up @@ -631,7 +631,7 @@ gst_kvs_sink_init(GstKvsSink *kvssink) {
kvssink->log_config_path = g_strdup (DEFAULT_LOG_FILE_PATH);
kvssink->storage_size = DEFAULT_STORAGE_SIZE_MB;
kvssink->credential_file_path = g_strdup (DEFAULT_CREDENTIAL_FILE_PATH);
kvssink->file_start_time = (uint64_t) chrono::duration_cast<seconds>(
kvssink->file_start_time = (uint64_t) chrono::duration_cast<milliseconds>(
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);
Expand Down

0 comments on commit a1d05af

Please sign in to comment.