MM API and stream resize/scaling

hello,

i’m looking for a way to downscale a 1080p video using MM API and I am a bit confused about this.

Do i have to set output plane value according to desired target size or am i missing something?

any advice would be appreciated

Hi,
You can call NvBufferTransform() for downscaling. Please check samples in

/usr/src/jetson_multimedia_api

looks like it’s what i’m looking for (from 00_video_decode/video_decode_main.cpp)

            /* Clip & Stitch can be done by adjusting rectangle. */
            NvBufferRect src_rect, dest_rect;
            src_rect.top = 0;
            src_rect.left = 0;
            src_rect.width = ctx->display_width;
            src_rect.height = ctx->display_height;
            dest_rect.top = 0;
            dest_rect.left = 0;
            dest_rect.width = ctx->display_width;
            dest_rect.height = ctx->display_height;

            NvBufferTransformParams transform_params;
            memset(&transform_params,0,sizeof(transform_params));
            /* Indicates which of the transform parameters are valid. */
            transform_params.transform_flag = NVBUFFER_TRANSFORM_FILTER;
            transform_params.transform_flip = NvBufferTransform_None;
            transform_params.transform_filter = NvBufferTransform_Filter_Nearest;
            transform_params.src_rect = src_rect;
            transform_params.dst_rect = dest_rect;
            if(ctx->capture_plane_mem_type == V4L2_MEMORY_DMABUF)
                    dec_buffer->planes[0].fd = ctx->dmabuff_fd[v4l2_buf.index];
            /* Perform Blocklinear to PitchLinear conversion. */
            ret = NvBufferTransform(dec_buffer->planes[0].fd, ctx->dst_dma_fd, &transform_params);

is there any reason to do this while decoding instead of encoding? (the first thing that comes in my mind would be to reduce NVENC bandwidth usage, but if there’ something else it would be good to know)

thank you

Hi,

You can modify the two parameters to desired resolution, so that ctx->dst_dma_fd is the NvBuffer which is downscaled.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.