【问题标题】:sws_scale() does not convert image simply copying it from source to targetsws_scale() 不会简单地将图像从源复制到目标
【发布时间】:2020-03-14 19:58:45
【问题描述】:

尝试将任意视频读取为纯 RGB24 像素,因此使用 sws_scale() 以这种方式转换帧:

    //...
    AVFrame* pic_out = av_frame_alloc();
    pic_out->format = AV_PIX_FMT_RGB24;
    pic_out->width  = 1920;
    pic_out->height = 1080;
    av_frame_get_buffer( pic_out, 32 );

    struct SwsContext * img_convert_ctx = sws_getContext(
        1920, 1080, AV_PIX_FMT_YUV420P,
        1920, 1080, AV_PIX_FMT_RGB24,
        SWS_BICUBIC,
        NULL, NULL, NULL
    );
    //...
    sws_scale(
        img_convert_ctx,
        pic_src->data,     //pic_src is from avcodec_receive_frame()
        pic_src->linesize,
        0,
        1080,
        pic_out->data,
        pic_out->linesize
    );

一切正常,但pic_out 最终拥有与pic_src 相同的数据。 可能是什么问题?

完整的最小示例是here(假设是 RGB24 图像存在为 2.bmp 看起来实际上是 YUV-东西)

【问题讨论】:

    标签: ffmpeg libav swscale


    【解决方案1】:

    问题是我将pic_out->data 视为RGB24 图像数据,但它必须是pic_out->data[0]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-22
      • 1970-01-01
      • 2019-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多