You can download the uploaded video as a MP4 video clip.
In this step, you will download the video in MP4 format from the management console or using AWS CLI.
First, let’s download the video at a specified time in MP4 format from the management console.
Video streams
in the left menu > Click on kvs-workshop-stream
in the list of streamsMedia playback
to expand it, then click on the Download clip
in the bottom rightDownload
Server timestamp
Start and end time
You can download the file kvs-workshop-stream.mp4
, and play it with an app such as QuickTime Player, you’ll see the video in the past minute.
You can also use the GetClip API using the AWS CLI to get the the MP4 file.
Execute the following command from the terminal on the PC for operation or Cloud9.
aws kinesisvideo get-data-endpoint --stream-name kvs-workshop-stream --api-name GET_CLIP
You will get the following result.
{
"DataEndpoint": "https://b-xxxxxxxx.kinesisvideo.region.amazonaws.com"
}
Store this value in an environment variable.
export KVS_DATA_ENDPOINT="The DataEndpoint value above"
Then execute the following command.
# for Linux only
ONE_MIN_AGO=$(date -d "1 minute ago" -u "+%FT%T+0000")
NOW=$(date -u "+%FT%T+0000")
# for macOS only
ONE_MIN_AGO=$(date -v -1M -u "+%FT%T+0000")
NOW=$(date -u "+%FT%T+0000")
# in case you don't have the "date" command
ONE_MIN_AGO="2020-01-02T03:04:05+0900"
NOW="2020-01-02T03:05:05+0900"
# common to all OSes
aws kinesis-video-archived-media get-clip --endpoint-url $KVS_DATA_ENDPOINT \
--stream-name kvs-workshop-stream \
--clip-fragment-selector "FragmentSelectorType=SERVER_TIMESTAMP,TimestampRange={StartTimestamp=$ONE_MIN_AGO,EndTimestamp=$NOW}" \
kvs-workshop-cli.mp4
The command generates a file kvs-workshop-cli.mp4
, so let’s play it as before.
That’s it for downloading video clips in MP4 format. The next step is to stream the video in HLS format.