Эффективное получение пикселей из видео
Я ищу эффективный способ извлечь данные изображения из видеофайлов. Я сейчас тестируюFilgraphManagerClass.GetCurrentImage()
отInterop.QuartzTypeLib
библиотека. Это делает то, что мне нужно, но мучительно медленно. Мне нужно обработать все кадры каждого видео. Какие лучшие варианты у меня есть?
Требования
Must be frame accurate. <-- Very important! Gives me access to the decoded pixel buffer (array ofint
or byte[]
), ideally RGB24 or RGB32.
The buffer can be grabbed in realtime or faster. I do not need to display the video, I only need to analyze the pixels.
Handle mp4 files (h264/aac). I can rewrap or frame serve via AviSynth if needed but no retranscoding can be involved.
Любые предложения будут приветствоваться.
Некоторый код по запросу:
FilgraphManagerClass graphClass = new FilgraphManagerClass();
graphClass.RenderFile(@"C:\tmp\tmp.avs");
int sz = (graphClass.Width * graphClass.Height + 10) * 4;
int[] buffer = new int[sz - 1];
Затем я перехожу через каждый кадр. У меня есть что-то вроде этого в цикле:
graphClass.GetCurrentImage(ref sz, out buffer[0]);
//DoStuff(buffer);
graphClass.CurrentPosition += graphClass.AvgTimePerFrame;