main.c
#include <libavcodec/avcodec.h>
#include <libavutil/pixfmt.h>
#include <libavutil/imgutils.h>
#include <libavutil/opt.h>
#include <stdio.h>
#include <stdlib.h>
void print_supported_pixel_formats(const AVCodec *codec) {
if (!codec) {
fprintf(stderr, "Codec is NULL\n");
return;
}
const enum AVPixelFormat *pix_fmts = codec->pix_fmts;
if (!pix_fmts) {
fprintf(stderr, "No pixel formats specified for this codec\n");
return;
}
printf("Supported pixel formats for codec '%s':\n", codec->name);
while (*pix_fmts != AV_PIX_FMT_NONE) {
printf(" %s\n", av_get_pix_fmt_name(*pix_fmts));
pix_fmts++;
}
}
int main() {
// 找到 MJPEG 编码器
const AVCodec *codec = avcodec_find_encoder_by_name("mjpeg_rkmpp");
if (!codec) {
fprintf(stderr, "Codec not found\n");
return -1;
}
// 打印支持的像素格式
print_supported_pixel_formats(codec);
return 0;
}
Makefile
C_COMPILER = aarch64-rockchip1031-linux-gnu-gcc
CFLAGS = -I/home/lingke/mnt/usr/include
LDFLAGS = -L/home/lingke/mnt/usr/lib \
-lrockchip_mpp -ldrm -lrga \
-lavcodec -lavformat -lavutil -lavfilter -lswscale -lswresample -lavdevice -lpostproc -lpthread -lm -lz
all: main.exe
main.exe: main.c
$(C_COMPILER) $(CFLAGS) -o $@ $^ $(LDFLAGS)
clean:
-rm -rf *.exe *.o
./main.exe
Supported pixel formats for codec 'mjpeg_rkmpp':
yuv420p
yuvj420p
yuv422p
yuvj422p
yuv444p
yuvj444p
nv12
nv21
nv16
nv24
yuyv422
uyvy422
yvyu422
rgb444be
bgr444be
rgb555be
bgr555be
rgb565be
bgr565be
rgba
rgb0
bgra
bgr0
argb
0rgb
abgr
0bgr
x2rgb10be
x2bgr10be
drm_prime