Decoding h264 frames from RTP stream

前端 未结 2 1655
情书的邮戳
情书的邮戳 2021-02-04 21:46

I am using live555 and ffmpeg libraries to get and decode RTP H264 stream from server; Video stream was encoded by ffmpeg, using Baseline profile and

x264_param         


        
2条回答
  •  走了就别回头了
    2021-02-04 21:48

    I suspect the error is in the convert_yuv420p_to_rgb32() code. Try this:

    static SwsContext *m_swsCtx = NULL;
    QImage frame =  QImage ( m_picture->width, m_picture->height,
                             QImage::Format_RGB32 );
    m_swsCtx = sws_getCachedContext ( m_swsCtx, m_picture->width,
                                      m_picture->height, PIX_FMT_YUV420P,
                                      m_picture->width, m_picture->height,
                                      AV_PIX_FMT_RGB32, SWS_BICUBIC,
                                      NULL, NULL, NULL );
    uint8_t *dstSlice[] = { frame.bits() };
    int dstStride = frame.width() * 4;
    sws_scale ( m_swsCtx, &m_picture.data, &m_picture.linesize,
                0, m_picture->height, dstSlice, &dstStride );
    

    You will need to include/link swscale if you have not does so already.

    Note: you don't need SPS/PPS every frame (on keyframes is good enough). But it doesn't hurt either.

提交回复
热议问题