aws / amazon-kinesis-video-streams-parser-library

Amazon Kinesis Video Streams parser library is for developers to include in their applications that makes it easy to work with the output of video streams such as retrieving frame-level objects, metadata for fragments, and more.
Apache License 2.0
102 stars 52 forks source link

PutMedia on newly created stream adds nothing #103

Closed samjoshi26 closed 4 years ago

samjoshi26 commented 4 years ago

Hi. I am able to create a stream in AWS Kinesis using the following code.

AWSCredentials credentials = new BasicAWSCredentials("",""); // here, I have removed the sensitive details.

AmazonKinesisVideo client =AmazonKinesisVideoClientBuilder.standard().withCredentials(newAWSStaticCredentialsProvider(credentials)).withRegion(region).build(); region ...I specify as "us-east-1" ..the value is set without an issue

CreateStreamResult result = client.createStream(new CreateStreamRequest().withStreamName(streamName) .withDataRetentionInHours(120));

I am not specfiying any mediaType when I create the stream. Now, when I do putMedia ...nothing gets added ..

String endPoint = client.getDataEndpoint(new GetDataEndpointRequest().withStreamName(streamName).withAPIName(APIName.PUT_MEDIA)).getDataEndpoint();

endPoint comes out as https://s-1e415f8b.kinesisvideo.us-east-1.amazonaws.com/putMedia

putMedia.putMedia(new PutMediaRequest().withStreamName(streamName).withFragmentTimecodeType(FragmentTimecodeType.ABSOLUTE) .withProducerStartTimestamp(new Date()).withPayload(inputStream),new PutMediaAckResponseHandler() {

        @Override
        public void onFailure(Throwable t) {
             log.error("PutMedia for {} has suffered error {}", streamName, t);
        }

        @Override
        public void onComplete() {
            log.info("PutMedia for {} is complete ", streamName);
        }

        @Override
        public void onAckEvent(AckEvent event) {
             if (AckEventType.Values.PERSISTED.equals(event.getAckEventType().getEnumValue())) {
                    numFragmentsPersisted++;
                }
            log.info("numFragmentsPersisted is >> PutMedia Ack for stream {}: {} ", numFragmentsPersisted, streamName, event.toString());

        }
    });

I provide cluster.mkv file ...create an inputStream out of it and pass it. I do not know what I have missed. The data won't get written. I have debugged the code ..may be I am missing something ...Following is the output of debugging

POST https://s-1e415f8b.kinesisvideo.us-east-1.amazonaws.com/putMedia /putMedia Headers: (Content-Type: , transfer-encoding: chunked, User-Agent: aws-sdk-java/1.11.755 Windows_10/10.0 Java_HotSpot(TM)_64-Bit_Server_VM/25.201-b09 java/1.8.0_201 vendor/Oracle_Corporation NettyPutMedia/1.11.755, x-amzn-fragment-timecode-type: RELATIVE, x-amzn-producer-start-timestamp: 2020-06-25T03:52:08.339Z, x-amzn-stream-name: trialStream5, )

content-Type header gets no value on it's own and I have not set it. Is that the reason ? Any help would be greatly appreciated.

MushMal commented 4 years ago

Take a look at the demo in the Java producer SDK: https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-java/blob/5994c071f8d1ccef2152f9bc63fb23a87ba93b1b/src/main/demo/com/amazonaws/kinesisvideo/demoapp/PutMediaDemo.java#L115

samjoshi26 commented 4 years ago

Hello MushMal,

I have pasted the code I have written. I have create the PutMediaRequest , created the PutMediaAckResponseHandler ..tried both the values FragmentTimecodeType.RELATIVE and ABSOLUTE ..nothing has helped me

I have seen the code you mentioned ..also seen the code in parser library examples. That is how I learnt what to do...but somehow I am not able to write anything to the stream.

MushMal commented 4 years ago

@samjoshi26 I don't think your issue is related to fragment timecode type. I would recommend trying the sample first (Java demo). Ensure you are able to see the stream using PutMedia. Once this works, you can modify the code to your needs still ensuring the streaming works.

disa6302 commented 4 years ago

Closing based on tag. Feel free to reach out if you have any more questions.