jocover / jetson-ffmpeg

ffmpeg support on jetson nano
Other
612 stars 196 forks source link

Allow NV12 choice #11

Open xsacha opened 4 years ago

xsacha commented 4 years ago

+ nvmpi_context->ctx=nvmpi_create_decoder(codectype,NV_PIX_YUV420); In the patch, it is hardcoded to use YUV420. Is there a reason why this is preferred over NV12?

Edit: I tried replacing YUV420 with NV12 and received this error: Assertion ((src_linesize) >= 0 ? (src_linesize) : (-(src_linesize))) >= bytewidth failed at libavutil/imgutils.c:314

jocover commented 4 years ago

ffmpeg tools decode video using yuv420,so I only did yuv420 support if you want to using nv12 please change https://github.com/jocover/jetson-ffmpeg/blob/master/ffmpeg_nvmpi.patch#L303 avctx->pix_fmt to AV_PIX_FMT_NV12 frame->format=AV_PIX_FMT_NV12; (not tested)

xsacha commented 4 years ago

This gives me: "NvMMLiteOpen : Block : BlockType = 261 NVMEDIA: Reading vendor.tegra.display-size : status: 6 NvMMLiteBlockCreate : Block : BlockType = 261 Assertion ((src_linesize) >= 0 ? (src_linesize) : (-(src_linesize))) >= bytewidth failed at libavutil/imgutils.c:314"

It seems like av_image_get_linesize(AV_PIX_FMT_NV12, 1280, 1) is returning 1280, correctly. But, linesize is 640.

Edit: I just read the source code and understand now that bytes per pixel is 2. https://github.com/jocover/jetson-ffmpeg/blob/master/common/NvBuffer.cpp#L372 I've made a pull request