您的位置:首页 > 其它

ODROID XU4 s5p-mfc H264 DECODER/ENCODER DEMO exynos5422

2018-01-13 14:48 239 查看
先下载最新的ODROID xu4 镜像。

https://wiki.odroid.com/odroid-xu4/os_images/linux/ubuntu_4.14/20171213

一定要下载最新的。旧版本会出现驱动不兼容,出现以下bug:

mfc.c:mfc_create:85: error: Cannot subscribe EOS event for MFC
14583.706270073:mfc.c:mfc_create:87: MFC device /dev/video7 opened with fd=3
mfc.c:mfc_set_rate:144: error: Cannot set rate on 3
This is apparently related to the kernel version being too old: https://patchwork.linuxtv.org/patch/21589/ According to the above post, the EOS error is fixed for kernel > 3.12


我用的img版本是:

ubuntu-16.04.3-4.14-minimal-odroid-xu4-20171213.img.xz

之后,下载测试源码。博主只对encodec做了验证。

git clone https://github.com/abhijeet-dev/public-apps

拷贝到板子后,运行一下命令:

./mfc-encode  -m /dev/video11 -o test.h264 -c h264 -d 1000 -r 25 -s 1280x720


以上命令没有指定输入的摄像头。因为手头的摄像头有点问题,运行不起来。

如果没有指定输入摄像头,则输入默认为一下函数:

static int in_demo_read(struct io_dev *dev, int nbufs, char **bufs, int *lens)
{
struct in_demo_priv *p;
int x, y;
int i, j;
int size;
double rx, ry;
int t;
p = dev->priv;
if (nbufs != 2)
return -1;
t = dev->io[DIR_OUT].counter;
size = p->width * p->height;
if (size > lens[0] || size > 2 * lens[1]) {
err("Size=%d len=%d,%d", size, lens[0], lens[1]);
return -1;
}
memset(bufs[0], 0, size);
memset(bufs[1], 128, size / 2);
rx = cos(7 * t / 3.14 / 25 * 100 / p->width);
ry = sin(6 * t / 3.14 / 25 * 100 / p->width);
x = (rx + 1) / 2 * (p->width - 2 * SQUARE_SIZE) + SQUARE_SIZE;
y = (ry + 1) / 2 * (p->height - 2 * SQUARE_SIZE) + SQUARE_SIZE;
for (i = MIN(SQUARE_SIZE, p->width) - 1; i >= 0; --i)
for (j = MIN(SQUARE_SIZE, p->height) - 1; j >= 0; --j)
bufs[0][x + i + (y + j) * p->width] = 128;//255;
return size;
}


最新的mfc驱动已经集成到v4l2驱动中。用以下命令可以看出decoder和encoder分别注册到那个v4l2驱动下。

[    3.373562] s5p-mfc 11000000.codec: decoder registered as /dev/video10
[    3.380006] s5p-mfc 11000000.codec: encoder registered as /dev/video11


Usage: ./mfc-encode [args]
-i <device>   - FIMC camera device (e.g. /dev/video1)
If not specified demo input device is used
-m <device>   - (required) MFC device (e.g. /dev/video8)
-o <file>     - Output file name
-c <codec>[,param[=val]]...
- The codec of the encoded stream optionally
followed by comma separated parameters.
Available codecs: mpeg4, h263, h264
-d <duration> - Number of frames to encode
-r <rate>     - Frame rate
-s <size>     - Size of frame in format WxH
Codec parameters:


生成的test.h264用vlc播放效果如下图:



博主的需求是编码外部YUV数据,只需将in_demod.c里面的函数改为我的yuv输入即可。

QQ:501930128


4000
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  HYT ODROID MFC H264