aws-samples / aws-samples/amazon-kinesis-video-streams-consumer-library-for-python

Saving fragment_bytes to disk as .mkv produces unsupported file

Open
#2 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
35
Forks
28
PR merge metrics
No merged PRs in 30d

Description

Hello,

This is an amazing post and I've been searching for something like this to leverage. I've implemented only certain components of the solution that I require within a lambda function, specifically in the **KvsConsumerLibrary** to "Iterate through reading and parsing streaming body response of KVS GET Media API call to MKV fragments".

I take the MKV fragments and save to disk as accomplished in **save_fragment_as_local_mkv** function of your **KvsFragementProcessor**.

However, when I download the temp.mkv file that was created and try to open it in Windows Media Player, I get an unsupported or corrupt error.

Additionally, I try to process the temp.mkv file using moviepy.editor and get the errors below. Your code comments suggest that "fragment_bytes as it arrives in is already a well formatted MKV fragment so can just write the bytes straight to disk and it will be a playable MKV file". This does not seem to be the case? Any suggestions or ideas that I might be doing incorrectly? The fragments appear to have the correct Metadata shown below, but is not a playable MKV file. Your feedback is appreciated! Thanks in advance!

[matroska,webm @ 0x64dd740] Found unknown-length element with ID 0x18538067 at pos. 0x8a54 for which no syntax for parsing is available.
[aac @ 0x64e06c0] channel element 0.0 is not allocated
Last message repeated 15 times
[matroska,webm @ 0x64dd740] decoding for stream 0 failed
[matroska,webm @ 0x64dd740] Could not find codec parameters for stream 0 (Audio: aac (LC), stereo, fltp): unspecified sample rate
Consider increasing the value for the 'analyzeduration' and 'probesize' options
Input #0, matroska,webm, from 'temp.mkv':
Metadata:
title : Kinesis Video SDK
encoder : Kinesis Video SDK 1.1.0 JNI 2.0
AWS_KINESISVIDEO_FRAGMENT_NUMBER: 91343852333181457156434608515546941761758546382
AWS_KINESISVIDEO_SERVER_TIMESTAMP: 1672248217.655
AWS_KINESISVIDEO_PRODUCER_TIMESTAMP: 1672248218.560
Duration: N/A, start: 1672248218.560000, bitrate: N/A
Stream #0:0(eng): Audio: aac (LC), stereo, fltp (default)
Metadata:
title : AUDIO_FROM_CUSTOMER
At least one output file must be specified
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 59, in lambda_handler
    audioclip = AudioFileClip("temp.mkv")

Contributor guide

Open the contributing guide

Research direction

Start with KvsConsumerLibrary and KvsFragementProcessor.save_fragment_as_local_mkv, then trace how fragment_bytes is produced and written. Reproduce the temp.mkv workflow with the reported media-player or MoviePy errors. Done means identifying whether the saved bytes are expected to be playable and documenting or correcting the behavior accordingly.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud, data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.