c++ - 使用 libde265 直接显示过滤器

标签 c++ video directshow live-streaming decoder

嘿,我正在开发解码器 directshow 文件管理器。为此,我正在使用 libde265 库。但我面临一些问题:

HRESULT decoder::Transform(IMediaSample *pIn, IMediaSample *pOut)
{
    FILE * fh;

    tn++;
    long    sizein = 0;
    BYTE    *bufin;
    BYTE *bufout;
    BYTE *central_buffer;
    int counter_tobuff = 0;

    unsigned long   nSrcDataSize;
    unsigned long   nMaxDestSize;
    int totalbytes;
    totalbytes = 0;
    HRESULT         hr;
    // get the input and output buffers 
    pIn->GetPointer(&bufin);
    pOut->GetPointer(&bufout);
    nSrcDataSize = pIn->GetActualDataLength();



    /**************************************de265.cc******************************************************/
    de265_error err;





        /********Intilializing the decoder*******/
        if (tn == 1)
        {

            Init_decoder();

            //de265_start_worker_threads(ctx, 1);
            //de265_set_parameter_bool(ctx, DE265_DECODER_PARAM_DUMP_PPS_HEADERS, false);
        }
        /********Setting the parameters ********/


        /*de265_set_parameter_bool(ctx, DE265_DECODER_PARAM_DUMP_PPS_HEADERS, true);*/






        err = de265_push_data(ctx, bufin,nSrcDataSize, 1, NULL);



        pos += nSrcDataSize;
        if (!de265_isOK(err)) {

        }
        int more = 0;
        const de265_image * img;
        do {
            err = de265_decode(ctx, &more);
            if (err == DE265_OK)
            {
                img = de265_get_next_picture(ctx);

                if (img)
                {


                    set_output_filename("D:\\testnotcreated.yuv");
                    write_picture(img);
                    more = 0;
                }

            }
            else
            {
                memcpy(bufout, bufin, nSrcDataSize);
                more = 0;

            }


        } while (more);
        counter_tobuff = 0;


    /***************************************************************************************************/

        //nMaxDestSize = pOut->GetSize();
    hr = pOut->SetActualDataLength(nSrcDataSize);
    //free(bufin);
    if (FAILED(hr))
    {

        //m_pDbg->SendDbg(APP_ID_RGB2YUY2, DBG_ERROR, "CRGB2YUY2::Transform SetActualDataLength failed");
        return S_FALSE;
    }

    return S_OK;
}

我假设 bufin 不断接收样本,我必须将它传递给 push_data 函数,然后对其进行解码并写入文件。但事实并非如此。 它不是解码。有时它会解码一两帧。 虽然这段代码是在 exe 中测试的,但不同之处在于,在 exe 中我们从文件中读取数据,而这里我们在连续流上工作。 那么在处理数据时是否存在任何问题,因为它是连续的实时编码视频流。 那么我该怎么做才能解决这个问题,以便它能够很好地解码并将其写入文件。 任何帮助将不胜感激,因为我被困住了。

最佳答案

H.265 中图片的解码顺序与显示顺序不同。这意味着解码器有时必须延迟帧的输出,直到到达其显示位置。因此,对于某些帧,它不会输出任何内容,而对于其他帧,它会同时输出多个(缓冲的)帧。您可以使用用户数据来识别哪个帧来自哪个输入。

关于c++ - 使用 libde265 直接显示过滤器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31309367/

相关文章:

c++ - 使用其范围版本从容器中删除元素的最佳方法

php - 将 AS3 Flash (swf) 渲染到视频服务器端

iphone - 视频合并ios

c#-4.0 - 从图像和 mp3 文件创建 C# MP4 视频

c++ - 如何将 win32 应用程序迁移到 x64 应用程序?

c++ - 从映射中删除动态分配的内存

C++ 取消引用 void 指针,将 int ptr 转换为 void ptr

C++ 重载赋值运算符

swift - 将视频上传到 Firebase 存储错误 Swift

c++ - 使用 direct show 从 DVD 抓取图像