Closed vijayrakesh13 closed 3 years ago
There is no information in the issue to work with. Please include detailed information about your scenario and the results. Include verbose level logs, etc. in general, it’s expected that you debug your solution to exhaustion and ask targeted questions which the community could help you with. Also, search the existing open and resolved issues for more info
@MushMal I have uploaded a 20s video to KVS, but when I download video from AWS console and played. Video is playing in fast forward, looped, audio got clipped and I get some times variation in video length, please find the 20s video below. I had record the video at 25 fps, but logs shows fps as 120. How can I get audio and video smoothly in exact length without any looping?
Logs: heapInitialize(): Initializing native heap with limit size 134217728, spill ratio 0% and flags 0x00000001 stepStateMachine(): State Machine - Current state: 0x0000000000000001, Next state: 0x0000000000000002 stepStateMachine(): State Machine - Current state: 0x0000000000000002, Next state: 0x0000000000000010 stepStateMachine(): State Machine - Current state: 0x0000000000000010, Next state: 0x0000000000000040 logStreamInfo(): Streaming type: STREAMING_TYPE_REALTIME logStreamInfo(): Content type: video/h264,audio/aac logStreamInfo(): Max latency (100ns): 1020000000 logStreamInfo(): Fragment duration (100ns): 20000000 logStreamInfo(): Key frame fragmentation: Yes logStreamInfo(): Use frame timecode: Yes logStreamInfo(): Absolute frame timecode: No logStreamInfo(): Nal adaptation flags: 40 logStreamInfo(): Average bandwith (bps): 2097152 logStreamInfo(): Framerate: 120 putVideoFrameRoutine(): Start up latency: 3071.474700 ms // How to reduce start up latency? logStreamMetric(): Total streams frame rate (fps): 120 logStreamMetric(): Total streams transfer rate (bps): 16777216 (16384 Kbps) logStreamMetric(): Current frame rate (fps): 120.000000 logStreamMetric(): Current transfer rate (bps): 16777216 (16384 Kbps) logStreamMetric(): Stream uptime in (ms): 3079 logStreamMetric(): Total streams frame rate (fps): 32015 logStreamMetric(): Total streams transfer rate (bps): 16777216 (16384 Kbps) logStreamMetric(): Current view duration (ms): 1780 logStreamMetric(): Overall view duration (ms): 1780 logStreamMetric(): Current view byte size: 749271 logStreamMetric(): Overall view byte size: 749271 logStreamMetric(): Current frame rate (fps): 32015.761805 logStreamMetric(): Current transfer rate (bps): 16777216 (16384 Kbps) logStreamMetric(): Stream uptime in (ms): 4869
Again, you are not including any information on the assets you are using, any modifications to the samples you are making and whether the samples actually work for you or not.
If I were to guess, I am thinking that you've captured your own encoded frames and are attempting to use one of the samples to stream it? The samples are designed to be minimalistic and mock a media pipeline by loading from the files. They have a hard-coded value for fps, key-frame intervals and they simulate the timestamps.
I am not sure what you are attempting to do. But, if you simply want to upload previously captured files then you can use GStreamer plugin to combine a pipeline to do that. If you want to use C code still, you might want to modify the parameters in the sample to adapt for your frames.
Please debug your solution and ask targeted questions. More information is available in the dev docs: https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/tree/master/docs
@MushMal Yes, I had captured own encoded frames using webcam with ffmpeg and upload to KVS using KVS-C SDK.
I'm trying to live stream video(may with a few seconds delay), so I had modified threads in sample application such way that audio and video are loaded while uploading to KVS, and created one more thread for generating sample frames.
I had captured own encoded frames at 25fps so DEFAULT_FPS_VALUE was unchanged, but I'm not sure what value to set for DEFAULT_KEY_FRAME_INTERVAL for 80ms video samples, how to calculate it?
Is these two parameters are enough to play video smoothly in exact length without any looping?
Also, when I'm trying to upload audio samples generated using ffmpeg tool, I get codec errors, is this command I'm using below is correct? ffmpeg -f alsa -channels 1 -thread_queue_size 1024 -i hw:1 -c:a aac -ar 48k -t 0:30 -segment_time 00:00.08 -f stream_segment sample-%003d.aac
DEFAULT_FPS_VALUE is used to optimize the allocations in this case. DEFAULT_KEY_FRAME_INTERVAL is used to set the key-frame flags on captured I-frames.
These are very sample specific as I mentioned.
For live streaming perhaps you can look at the GStreamer integration that we provide. There is also ffmpeg plugins available for GStreamer.
This said, if you want to drive your own application using ffmpeg, you simply need to know the timestamps and the frame flags - which one is an I-frame and which one is a P-frame.
@MushMal I want to drive own application using ffmpeg, because Gstreamer plugins are not readily available for Yocto. Is there any documentation about timestamps and frame flags. So that I can can understand and configure in the code. As I'm new, still not sure what value to be set for DEFAULT_KEY_FRAME_INTERVAL.
The documentation is available https://github.com/awslabs/amazon-kinesis-video-streams-producer-sdk-cpp/tree/master/docs
The timestamp doc describes the usage and the meaning of the timestamps.
@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
This is a different issue than reported in the original issue. Check the region and the stream name. You have persisted acks.
Hi,
I had generated video samples of 80ms for 30s and combined audio samples which are provided in samples folder then uploaded to KVS. After downloading the video from KVS, video runs fast in loop for 2-3 times and audio gets clipped frequently. I guess I'm setting wrong KEY_FRAME_INTERVAL, how to calculate it?
define DEFAULT_KEY_FRAME_INTERVAL 90
define DEFAULT_FPS_VALUE 25
define DEFAULT_STREAM_DURATION 30 * HUNDREDS_OF_NANOS_IN_A_SECOND
define SAMPLE_AUDIO_FRAME_DURATION (20 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND)
define SAMPLE_VIDEO_FRAME_DURATION (HUNDREDS_OF_NANOS_IN_A_SECOND / DEFAULT_FPS_VALUE)
Thanks & Regards, VR