awslabs / amazon-kinesis-video-streams-producer-sdk-cpp

Amazon Kinesis Video Streams Producer SDK for C++ is for developers to install and customize for their connected camera and other devices to securely stream video, audio, and time-encoded data to Kinesis Video Streams.
Apache License 2.0
376 stars 337 forks source link

Failed to allocate memory #1185

Open maximelebastard opened 3 months ago

maximelebastard commented 3 months ago

I'm trying to stream from a Raspberry PI Model 2 (I know, the tutorial recommands a Model 3, but both have 1GB of RAM), but I'm facing an issue when allocating memory.

Logging

./kvs_gstreamer_sample test-stream
DEBUG] [03-06-2024 20:29:51:537.425 GMT] Refreshing credentials. Force refreshing: 1 Now time is: 1717446591537386739 Expiration: 1717450190
[INFO ] [03-06-2024 20:29:51:537.687 GMT] New credentials expiration is 1717450191
[INFO ] [03-06-2024 20:29:51:538.037 GMT] getStreamingTokenResultEvent(): Get streaming token result event.
[DEBUG] [03-06-2024 20:29:51:538.330 GMT] streamReadyHandler invoked
[DEBUG] [03-06-2024 20:29:51:539.233 GMT] Stream is ready
[INFO ] [03-06-2024 20:29:58:224.594 GMT] Streaming from live source
[DEBUG] [03-06-2024 20:29:58:225.491 GMT] Streaming with live source and width: 0, height: 0, fps: 25, bitrateInKBPS512
[DEBUG] [03-06-2024 20:29:58:252.608 GMT] Using x264enc
[DEBUG] [03-06-2024 20:29:58:332.131 GMT] Using v4l2src
[DEBUG] [03-06-2024 20:29:58:335.079 GMT] src supports raw
[DEBUG] [03-06-2024 20:18:55:082.211 GMT] Constructing pipeline with encoding element
Error received from element source: Failed to allocate required memory.
Debugging information: ../sys/v4l2/gstv4l2src.c(976): gst_v4l2src_decide_allocation (): /GstPipeline:live-kinesis-pipeline/GstV4l2Src:source:
Buffer pool activation failed
[INFO ] [03-06-2024 20:18:55:187.522 GMT] stopKinesisVideoStreamSync(): Synchronously stopping Kinesis Video Stream 0000000000de4a18.
[DEBUG] [03-06-2024 20:18:55:188.051 GMT] streamClosedHandler invoked for upload handle: 18446744073709551615
[INFO ] [03-06-2024 20:18:55:188.578 GMT] Freeing Kinesis Video Stream for test-stream
[INFO ] [03-06-2024 20:18:55:188.910 GMT] freeKinesisVideoStream(): Freeing Kinesis Video stream.
[DEBUG] [03-06-2024 20:18:55:189.213 GMT] freeStream(): [test-stream] Freeing stream
[DEBUG] [03-06-2024 20:18:55:189.497 GMT] curlApiCallbacksShutdownActiveRequests(): pActiveRequests hashtable is empty
[DEBUG] [03-06-2024 20:18:55:590.300 GMT] freeStream(): [test-stream] Completed freeing stream
[INFO ] [03-06-2024 20:18:55:590.758 GMT] Freeing Kinesis Video Stream for test-stream
[INFO ] [03-06-2024 20:18:55:591.028 GMT] freeKinesisVideoClient(): Freeing Kinesis Video Client
[DEBUG] [03-06-2024 20:18:55:591.178 GMT] curlApiCallbacksShutdownActiveRequests(): pActiveRequests hashtable is empty
[DEBUG] [03-06-2024 20:18:55:995.027 GMT] freeKinesisVideoClientInternal(): Total allocated memory 0
[INFO ] [03-06-2024 20:18:55:995.559 GMT] Completed freeing client
[WARN ] [03-06-2024 20:18:55:996.237 GMT] curlApiCallbacksShutdown(): curlApiCallbacksShutdown called when already in progress of shutting down
$ free
               total        used        free      shared  buff/cache   available
Mem:          943044      103580      766380        1012      122892      839464
Swap:         102396           0      102396

Any design considerations/constraints

I'm following this tutorial

What's confusing me is this line saying the source is 0w x 0h

Streaming with live source and width: 0, height: 0, fps: 25, bitrateInKBPS512
maximelebastard commented 3 months ago

I found a radical fix: I installed Raspbian Buster and now the script/instructions work perfectly. It seems a refresh of the instructions for the latest versions of Raspberry OS would be useful

niyatim23 commented 3 months ago

Hi @maximelebastard, thanks for your update. Would you like to share the updates here / open a PR to add these steps?

maximelebastard commented 3 months ago

Hi @niyatim23

Unfortunately I'm not able to contribute here as I don't have any skills about C++ and video streaming.

I'm pointing out that most documentation about using KVS with Raspberry OS are not relevant with Bookworm, but that's all the help I can bring on the topic sorry !