将视频中的帧转换成矩阵

I'm currently trying to implement a compression algorithm(frame prediction) for an assignment. I am not looking for thumbnail files, or even just a shell command to generate something for me. My problem is specifically integrating it with a golang program.

I just started and I'm already stuck. I'm supposed to get each frame out of a video,divide it into I P and B frames and perform inter-coding(compress the frame itself), then perform intra-coding(between the frames).

Right now I cannot even get started on the above problems, because I have no idea how to read the video as something I could use in code. Apparently, the only library I can think of is ffmpeg. FFMPEG can get separate frames, apparently even i p and b frames.

ffmpeg -i <inputfile> -vf '[in]select=eq(pict_type\,B)[out]' b.frames.mp4

But this is just another video output, that I do not know how to open. What I was thinking of was outputting frames into bitmaps(?), then reading each bitmap separately, to reconstruct three 3D matrixes, of i frames, p frames and b frames. However this seems like quite a feat. Someone, somewhere has definitely tried to parse a video into a 3D matrix and has found a better solution than what I'm thinking of.

To be concise, I have a video, I need a 3D matrix. The 3D matrix is a matrix of 2D matrixes, which represent a frame in the video. Each point in a 3D matrix is a pixel(or whatever the equivalent is in videos).

3D matrix

douduan6731
douduan6731 如下所述,一种选择是使ffmpeg输出YUV或RGB,这样您就可以通过管道传输输出并在您的应用程序中读取它。一些可能对您有帮助的资源:1、2、3。
一年多之前 回复
dongzhan5286
dongzhan5286 因此,理论上创建了X数量的jpeg,X数量的读者随后阅读了每个jpeg,然后将它们拼凑在一起。这听起来非常昂贵,但我会仔细研究,我在这里迫切希望。
一年多之前 回复
duanchao1002
duanchao1002 使用它可以将视频分解为图像:stackoverflow.com/questions/34786669/…,然后使用它来制作矩阵:stackoverflow.com/questions/33186783/…切一张矩阵,它应该是您想要的。
一年多之前 回复

1个回答



I / P / B帧仅存在于原始比特流中。 视频解码后,所有帧均为I帧。 您可能希望使用ffmprg解码为yuv4mpegpipe之类的内容,然后在golang程序中解析输出。 </ p>
</ div>

展开原文

原文

I/P/B frames only exist in the raw bitstream. Once the video is decoded, all frames are I frames. You probably want to use ffmprg to decode to something like yuv4mpegpipe then parse the output in your golang program.

dqsxsmi3704
dqsxsmi3704 这是一种将原始YUV数据编码为帧流的方法。 wiki.multimedia.cx/index.php/YUV4MPEG2
一年多之前 回复
doulao3905
doulao3905 介意解释yuv4mpegpipe的作用以及为什么对我有帮助? 我所发现的只是针对那些知道他们在寻找什么的人的文档。 提醒一下,实际上,我正在寻找的是一种无需处理元数据即可获取每个像素(亮度值,因为它是灰度视频)的方法。
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐