By using AWS re:Post, you agree to the AWS re:Post Terms of Use

suggest API or c code to change cpd in kinesis video stream media playback

0

i am using kinesis video stream producer to sending h264 stream to kinesis video stream i am able to see my video in media playback window. when resolution of my video changes i am getting error "Codec changed.", if i reload the web page it starts working again with new resolution. suggest some steps to resolve this issue. suggest API or c code to change cpd in kinesis video stream media playback.

asked a month ago38 views
1 Answer
0

To address the issue of changing resolutions in your Kinesis Video Stream and the resulting "Codec changed" error, there are a few steps you can take:

  1. Update codec private data (CPD): When the resolution changes, you need to update the codec private data in your stream. This can be done using the C producer library.

  2. Use FragmentMetadata: Include updated codec information in the FragmentMetadata when you send a new fragment with changed resolution.

  3. Implement adaptive bitrate streaming: Consider implementing adaptive bitrate streaming to handle resolution changes more smoothly.

Here's a general approach using the C producer library:

  1. When your video resolution changes, create a new track with the updated resolution information.

  2. Update the CPD for the new track:

STATUS updateCodecPrivateData(PKinesisVideoStream pKinesisVideoStream, PBYTE newCpd, UINT32 cpdSize)
{
    STATUS retStatus = STATUS_SUCCESS;
    Frame frame;

    // Create a codec private data frame
    frame.frameData = newCpd;
    frame.size = cpdSize;
    frame.flags = FRAME_FLAG_KEY_FRAME | FRAME_FLAG_CODEC_CONFIG;
    frame.trackId = DEFAULT_VIDEO_TRACK_ID;
    frame.duration = 0;
    frame.decodingTs = GETTIME(); // Get current timestamp
    frame.presentationTs = frame.decodingTs;

    // Send the frame to update codec private data
    retStatus = putKinesisVideoFrame(pKinesisVideoStream, &frame);

    return retStatus;
}
  1. After updating the CPD, send your new video frames with the updated resolution.

Remember to handle potential errors and implement proper error handling in your code. Also, ensure that your player is capable of handling resolution changes gracefully.

While this approach should help mitigate the issue, it's important to note that some players may still struggle with mid-stream resolution changes. In such cases, implementing server-side transcoding or using adaptive bitrate streaming might be necessary for a smoother viewing experience.

Sources
Use the C producer library - Amazon Kinesis Video Streams
PutMedia - Amazon Kinesis Video Streams

profile picture
answered a month ago
  • when i call above api on new sample codec change detect, it is giving error Fagment not able to decode in UI

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions