awslabs / amazon-kinesis-video-streams-producer-c

https://awslabs.github.io/amazon-kinesis-video-streams-producer-c/group__PublicMemberFunctions.html
Apache License 2.0
54 stars 72 forks source link

Custom Media Playback Failed #192

Closed vijayrakesh13 closed 3 years ago

vijayrakesh13 commented 3 years ago

@MushMal I tried to send custom generated video and audio to KVS, but I couldn't play/download from AWS Console (ResourceNotFoundException). Media player shows codec as avc1.64101e (H.264 High@3.0), mp4a.40.2 (AAC LC), Video resolution 640x480px, but bitrate & fragment duration are none. Please find the attached log Log.txt.

Recorded Video Parameters: Video Format: h264 Sample Video length: 80ms Resolution: 640x480p FPS = 25 Force Key Frames = 80ms Pixel format = YUV420p Total video length = 30s

Recorded Audio Parameters: Audio format: AAC Sample Rate; 48000 Sample Audio length: 80ms Total audio length = 30s Audio Type = Mono

Configured parameters in code

define DEFAULT_RETENTION_PERIOD 2 * HUNDREDS_OF_NANOS_IN_AN_HOUR

define DEFAULT_BUFFER_DURATION 120 * HUNDREDS_OF_NANOS_IN_A_SECOND

define DEFAULT_CALLBACK_CHAIN_COUNT 5

define DEFAULT_KEY_FRAME_INTERVAL 50

define DEFAULT_FPS_VALUE 25

define DEFAULT_STREAM_DURATION 20 * HUNDREDS_OF_NANOS_IN_A_SECOND

define SAMPLE_AUDIO_FRAME_DURATION (80 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND)

define SAMPLE_VIDEO_FRAME_DURATION (HUNDREDS_OF_NANOS_IN_A_SECOND / DEFAULT_FPS_VALUE)

define AUDIO_TRACK_SAMPLING_RATE 48000

define AUDIO_TRACK_CHANNEL_CONFIG 1

vijayrakesh13 commented 3 years ago

@MushMal I made sure that I'm streaming to correct region and the stream name. I also tried to upload samples provided in SDK and plays perfectly fine, but not custom generated samples.

MushMal commented 3 years ago

Try to start from the sample and then modify. It’s hard to tell what could be going wrong with your app. Try to debug the producer and ensure it streams out properly. The video only sample streams the pregenerated frames do you might need to modify to suit your key frame intervals, etc

vijayrakesh13 commented 3 years ago

@MushMal To debug the issue, I had just sent custom video and SDK audio samples, then I can see the video playback on AWS Console. But when I send both custom audio and video I face this issue. How to debug the producer? Logs seems fine.

vijayrakesh13 commented 3 years ago

@MushMal How to generate KVS debug dump video file in local directory? What parameter I have to set in code?

The downloaded video file from AWS console plays video on windows media player but no audio, and on VLC player audio plays but video doesn't. Can you please help me what I'm missing?

vijayrakesh13 commented 3 years ago

Hi @MushMal, any suggestions?

MushMal commented 3 years ago

Sorry for the delay but I have no idea. Try to dump your video frames into local directory and inspect them. It might give you some clues. Search the repository issues and the readme for more information on how to store the outgoing video as a file

vijayrakesh13 commented 3 years ago

@MushMal Thank you. I had generated mkv file in local directory, it generated & played with audio and video for 22s out of 25s. When download same from AWS console I get 5s video.

MushMal commented 3 years ago

Dump out the frames using media tools and see whether you have actually been producing the audio. As for the console download, try to check the producer verbose logs and see whether the logs indicate all of the frames are produced properly and whether they have been uploaded. Check the frame timestamps. Not much else I can think about to help you with your custom media pipeline.

vijayrakesh13 commented 3 years ago

@MushMal Audio is playing but not continues. it's like skipping a one second audio frequently (10 times).

I had ran producer logs and found that each frame difference is 40ms instead 80ms, my sample frames are 80ms each. Do I have to mention each frame time in code? I searched but couldn't find any. Also, I can see only timestamp up to 224400000 (22.4 sec). KVS_Producer_log.txt

vijayrakesh13 commented 3 years ago

@MushMal I guess above mentioned is the issue. where do I change video sample duration in code? I can find audio but not video. Is that the reason for producer generating 22.44s instead of 25s?

vijayrakesh13 commented 3 years ago

@MushMal Any suggestions?

MushMal commented 3 years ago

Sorry, nothing that comes to mind. Try to debug into it. The frame based sample is very specific to the frames we canned with it. Try a known media pipeline like the GStreamer based sample and adapt for your needs

vijayrakesh13 commented 3 years ago

@MushMal Using gstreamer would be time taking to me. I had generated samples using FFMPEG with all I frames with no p and b frames so, setting key frame interval to 0 is right?

MushMal commented 3 years ago

I am not super familiar with ffmpeg but I can’t imagine encoding I-frames with no p-frames you will get any real video compression, let alone the fact that if you cut a fragment per frame you will hit throttling. If you use frmpeg try to find settings that will produce 2-6 second GoP and mark your frames such that I-frames gets marked with key frame flag while others with no flag. Try to experiment as we won’t be able to help

vijayrakesh13 commented 3 years ago

@MushMal 2-6s GoP, means each h.264 segment, right? I had produced each video/audio frame with 2s and key frame interval as 45 and uploaded to KVS. Local generated file is not sync with audio and produced 11s out 20sec but downloaded file from AWS Console is only 1s.

vijayrakesh13 commented 3 years ago

Hi @MushMal, Can you please tell me what all parameters I have to consider while sending custom Audio and video? I'll close this issue.

As of my knowledge I know I have to change fps, keyframeinterval and sample audio duration values, anything apart from this?

vijayrakesh13 commented 3 years ago

@MushMal waiting for your reply.

MushMal commented 3 years ago

@vijayrakesh13 you are dealing with multiple issues. Let me give a few pointers for you to make progress. Please understand, debugging your solution is not something we can do.

Please ask targeted questions so we can help. Broad solution architecture questions are better asked to your AWS technical account management team,.