![]() |
如何将文件保存到Matlab的y4m中?
因此,我有一部Matlab电影格式的电影(真的,只有几个RGB帧),我想将其另存为y4m文件。 (用于x.264)。我在一开始就已经具备了编写帧标题所需的所有信息,并且具有将RGB帧转换为YUV的函数,但是任何时候我尝试将其保存下来时,它都是横向的并且跟踪已关闭。我也在尝试将其转换为C420。这是我目前的功能:
function saveMovToY4m(mov, fileName, f, width, height, fpsNum, fpsDen, inter, ascNum, ascDen) fileId = fopen(fileName, 'w'); fprintf(fileId, 'YUV4MPEG2 W%d H%d F%d:%d I%c A%d:%d C420jpeg\n', width, height, fpsNum, fpsDen, inter, ascNum, ascDen); for frame = 1:f-1 frame imgRgb = frame2im(mov(frame)); imgYuv = (convertRgbToYuv(imgRgb, width, height)); fprintf(fileId,'FRAME\n'); % Print Y component buf = reshape(imgYuv(:,:,1),width*height,1); buf = buf; fwrite(fileId, buf, 'uint8'); % Print U component Cb = reshape(imgYuv(:,:,2),width*height,1); CBdown = downsample(Cb, 4); fwrite(fileId, CBdown, 'uint8'); % Print V component Cbr = reshape(imgYuv(:,:,3),width*height,1); CBrDown = downsample(Cbr, 4); fwrite(fileId, CBrDown, 'uint8'); end fclose(fileId); end [B]回答:[/B] 对于“横向”(我假设您是指旋转的),您只需要旋转数组(将列与行交换)。对于跟踪而言,如果偏离固定量,则似乎与您的重塑有关(尝试(宽度-1)*高度,然后查看结果并从那里开始) [url=https://stackoverflow.com/questions/4707565]更多&回答...[/url] |
所有时间均为北京时间。现在的时间是 20:35。 |
Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.