내용으로 건너뛰기

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.

질문됨 일 년 전83회 조회
1개 답변
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

답변함 일 년 전
  • when i call above api on new sample codec change detect, it is giving error Fagment not able to decode in UI

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠