- Newest
- Most votes
- Most comments
The issue you're experiencing with your code is likely related to how Kinesis Video Streams (KVS) stores and retrieves video data. KVS stores video as a series of fragments, and when you're retrieving the data, you need to ensure you're getting all the fragments and properly reconstructing the video file.
Here are a few suggestions to improve your code and potentially resolve the issue:
-
Instead of using 'EARLIEST' as your StartSelector, consider using a specific timestamp or fragment number to ensure you're getting the exact 10-minute footage you want.
-
The 'iter_chunks()' method you're using might not be the best approach for reconstructing the video file. Instead, you should parse the MKV (Matroska) container format that KVS uses.
-
You may need to handle the continuation token to ensure you're getting all the fragments of your video.
-
Consider using the GetMedia API in a loop to retrieve all fragments, and then combine them properly.
Here's a rough outline of how you might modify your approach:
- Use GetDataEndpoint to get the endpoint for GET_MEDIA.
- Use GetMedia to start retrieving fragments.
- Parse the MKV container format to extract the video data.
- Continue calling GetMedia with the continuation token until you've retrieved all fragments.
- Properly combine the fragments to reconstruct the full video file.
Unfortunately, there isn't a simple, one-size-fits-all solution for this process, as it depends on the specifics of your video stream and how you want to handle the data. You may need to use a library that can handle MKV parsing and reconstruction, or implement the MKV parsing yourself.
For a more reliable implementation, you might want to consider using the AWS SDK for your preferred programming language, which often includes helper functions for dealing with KVS data. Additionally, you could look into using AWS services like Kinesis Video Streams Parser Library or exploring open-source projects on GitHub that specifically deal with KVS video reconstruction.
Remember that working with streaming video data can be complex, and you may need to handle various edge cases and error conditions to create a robust solution.
Sources
Capture & Record Video Streams - Amazon Kinesis Video Streams - AWS
Extract images from video streams - Amazon Kinesis Video Streams
Relevant content
- asked 9 months ago
- Accepted Answerasked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated a year ago